disable form

This commit is contained in:
2025-12-16 14:57:51 -03:00
parent 2be277a42e
commit 086d3adcaf

View File

@@ -88,102 +88,104 @@ export default function Route({}: Route.ComponentProps) {
return ( return (
<Form {...form}> <Form {...form}>
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4"> <form onSubmit={handleSubmit(onSubmit)}>
{user?.rate_limit_exceeded && ( <fieldset disabled={!!user?.rate_limit_exceeded} className="space-y-4">
<Alert variant="destructive"> {user?.rate_limit_exceeded && (
<AlertCircleIcon /> <Alert variant="destructive">
<AlertTitle>Limite diário de atualizações atingido.</AlertTitle> <AlertCircleIcon />
<AlertDescription> <AlertTitle>Limite diário de atualizações atingido.</AlertTitle>
Tente novamente a partir de{' '} <AlertDescription>
{getDaysRemaining(user.rate_limit_exceeded.ttl)} Tente novamente a partir de{' '}
</AlertDescription> {getDaysRemaining(user.rate_limit_exceeded.ttl)}
</Alert> </AlertDescription>
)} </Alert>
)}
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle className="text-2xl">Editar colaborador</CardTitle> <CardTitle className="text-2xl">Editar colaborador</CardTitle>
<CardDescription> <CardDescription>
Configurar as informações gerais para este colaborador. Configurar as informações gerais para este colaborador.
</CardDescription> </CardDescription>
</CardHeader> </CardHeader>
<CardContent className="space-y-4"> <CardContent className="space-y-4">
<FormField <FormField
control={control} control={control}
name="name" name="name"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel>Nome</FormLabel> <FormLabel>Nome</FormLabel>
<FormControl> <FormControl>
<Input {...field} /> <Input {...field} />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
/> />
<FormField <FormField
control={control} control={control}
name="email" name="email"
disabled={true} disabled={true}
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel>Email</FormLabel> <FormLabel>Email</FormLabel>
<FormControl> <FormControl>
<Input {...field} /> <Input {...field} />
</FormControl> </FormControl>
<FormLabel className="text-sm font-normal text-muted-foreground"> <FormLabel className="text-sm font-normal text-muted-foreground">
<span> <span>
Para gerenciar os emails ou trocar o email principal, use Para gerenciar os emails ou trocar o email principal,
as{' '} use as{' '}
<Link <Link
to="emails" to="emails"
className="text-blue-400 underline hover:no-underline" className="text-blue-400 underline hover:no-underline"
> >
configurações de emails configurações de emails
</Link> </Link>
</span> </span>
</FormLabel> </FormLabel>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
/> />
<FormField <FormField
control={control} control={control}
name="cpf" name="cpf"
render={({ field: { onChange, ref, ...props } }) => ( render={({ field: { onChange, ref, ...props } }) => (
<FormItem> <FormItem>
<FormLabel>CPF</FormLabel> <FormLabel>CPF</FormLabel>
<FormControl> <FormControl>
<PatternFormat <PatternFormat
format="###.###.###-##" format="###.###.###-##"
mask="_" mask="_"
placeholder="___.___.___-__" placeholder="___.___.___-__"
customInput={Input} customInput={Input}
getInputRef={ref} getInputRef={ref}
onValueChange={({ value }) => { onValueChange={({ value }) => {
onChange(value) onChange(value)
}} }}
{...props} {...props}
/> />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
/> />
<Button <Button
type="submit" type="submit"
className="cursor-pointer" className="cursor-pointer"
disabled={formState.isSubmitting} disabled={formState.isSubmitting}
> >
{formState.isSubmitting && <Spinner />} {formState.isSubmitting && <Spinner />}
Editar Editar
</Button> </Button>
</CardContent> </CardContent>
</Card> </Card>
</fieldset>
</form> </form>
</Form> </Form>
) )