mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 12:32:34 +10:00
Compare commits
1 Commits
v1.9.0-rc.
...
fix/whites
| Author | SHA1 | Date | |
|---|---|---|---|
| f26ab295d2 |
@ -1,5 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
|
|
||||||
import type { Field, Recipient } from '@documenso/prisma/client';
|
import type { Field, Recipient } from '@documenso/prisma/client';
|
||||||
@ -9,6 +10,7 @@ import { FormErrorMessage } from '../form/form-error-message';
|
|||||||
import { Input } from '../input';
|
import { Input } from '../input';
|
||||||
import { Label } from '../label';
|
import { Label } from '../label';
|
||||||
import { useStep } from '../stepper';
|
import { useStep } from '../stepper';
|
||||||
|
import { ZAddTitleFormSchema } from './add-title.types';
|
||||||
import type { TAddTitleFormSchema } from './add-title.types';
|
import type { TAddTitleFormSchema } from './add-title.types';
|
||||||
import {
|
import {
|
||||||
DocumentFlowFormContainerActions,
|
DocumentFlowFormContainerActions,
|
||||||
@ -40,6 +42,7 @@ export const AddTitleFormPartial = ({
|
|||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors, isSubmitting },
|
formState: { errors, isSubmitting },
|
||||||
} = useForm<TAddTitleFormSchema>({
|
} = useForm<TAddTitleFormSchema>({
|
||||||
|
resolver: zodResolver(ZAddTitleFormSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
title: document.title,
|
title: document.title,
|
||||||
},
|
},
|
||||||
@ -71,7 +74,7 @@ export const AddTitleFormPartial = ({
|
|||||||
id="title"
|
id="title"
|
||||||
className="bg-background my-2"
|
className="bg-background my-2"
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
{...register('title', { required: "Title can't be empty" })}
|
{...register('title')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormErrorMessage className="mt-2" error={errors.title} />
|
<FormErrorMessage className="mt-2" error={errors.title} />
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
export const ZAddTitleFormSchema = z.object({
|
export const ZAddTitleFormSchema = z.object({
|
||||||
title: z.string().min(1),
|
title: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Title can't be empty" })
|
||||||
|
.trim()
|
||||||
|
.refine((value) => value.length > 0, {
|
||||||
|
message: "Title can't be empty",
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TAddTitleFormSchema = z.infer<typeof ZAddTitleFormSchema>;
|
export type TAddTitleFormSchema = z.infer<typeof ZAddTitleFormSchema>;
|
||||||
|
|||||||
Reference in New Issue
Block a user