add subscription to org

This commit is contained in:
2026-01-17 23:45:25 -03:00
parent d0a9998bf4
commit 3f0f7ec1e1
14 changed files with 550 additions and 367 deletions

View File

@@ -1,7 +1,7 @@
import type { Route } from './+types/route'
import { useEffect } from 'react'
import { zodResolver } from '@hookform/resolvers/zod'
import { useEffect } from 'react'
import { useForm } from 'react-hook-form'
import { PatternFormat } from 'react-number-format'
import { Link, useFetcher } from 'react-router'
@@ -37,6 +37,7 @@ import { Spinner } from '@repo/ui/components/ui/spinner'
import { HttpMethod, request as req } from '@repo/util/request'
import { useWorksapce } from '@/components/workspace-switcher'
import { FieldSet } from '@repo/ui/components/ui/field'
import { formSchema, type Schema } from './data'
export function meta({}: Route.MetaArgs) {
@@ -115,7 +116,7 @@ export default function Route({}: Route.ComponentProps) {
<div className="lg:max-w-2xl mx-auto">
<Form {...form}>
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
<form onSubmit={handleSubmit(onSubmit)}>
<Card>
<CardHeader>
<CardTitle className="text-2xl">
@@ -126,99 +127,99 @@ export default function Route({}: Route.ComponentProps) {
</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<FormField
control={control}
name="name"
defaultValue=""
render={({ field }) => (
<FormItem>
<FormLabel>Nome</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<div className="space-y-2.5">
<CardContent className="space-y-6">
<FieldSet>
<FormField
control={control}
name="email"
name="name"
defaultValue=""
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormLabel>Nome</FormLabel>
<FormControl>
<Input
{...field}
readOnly={givenEmail}
className="read-only:pointer-events-none read-only:opacity-50"
/>
<Input {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<div className="space-y-2.5">
<FormField
control={control}
name="email"
defaultValue=""
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input
{...field}
readOnly={givenEmail}
className="read-only:pointer-events-none read-only:opacity-50"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={control}
name="given_email"
defaultValue={false}
render={({ field: { value, onChange, ...field } }) => (
<FormItem className="flex items-center gap-2">
<FormControl>
<Checkbox
checked={Boolean(value)}
onCheckedChange={onChange}
tabIndex={-1}
{...field}
/>
</FormControl>
<FormLabel className="cursor-pointer">
Usar email gerado pela plataforma
</FormLabel>
</FormItem>
)}
/>
</div>
<FormField
control={control}
name="given_email"
defaultValue={false}
render={({ field: { value, onChange, ...field } }) => (
<FormItem className="flex items-center gap-2">
name="cpf"
defaultValue=""
render={({ field: { onChange, ref, ...props } }) => (
<FormItem>
<FormLabel>CPF</FormLabel>
<FormControl>
<Checkbox
checked={Boolean(value)}
onCheckedChange={onChange}
tabIndex={-1}
{...field}
<PatternFormat
format="###.###.###-##"
mask="_"
placeholder="___.___.___-__"
customInput={Input}
getInputRef={ref}
onValueChange={({ value }) => {
onChange(value)
}}
{...props}
/>
</FormControl>
<FormLabel className="cursor-pointer">
Usar email gerado pela plataforma
</FormLabel>
<FormMessage />
</FormItem>
)}
/>
</div>
</FieldSet>
<FormField
control={control}
name="cpf"
defaultValue=""
render={({ field: { onChange, ref, ...props } }) => (
<FormItem>
<FormLabel>CPF</FormLabel>
<FormControl>
<PatternFormat
format="###.###.###-##"
mask="_"
placeholder="___.___.___-__"
customInput={Input}
getInputRef={ref}
onValueChange={({ value }) => {
onChange(value)
}}
{...props}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<div className="flex justify-end">
<Button
type="submit"
className="cursor-pointer"
disabled={formState.isSubmitting}
>
{formState.isSubmitting && <Spinner />}
Adicionar
</Button>
</div>
<Button
type="submit"
className="cursor-pointer"
disabled={formState.isSubmitting}
>
{formState.isSubmitting && <Spinner />}
Adicionar usuário
</Button>
</CardContent>
</Card>
</form>