Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-05-07 13:32:35 +03:00
co-authored by Copilot
parent 4faafe6667
commit c7eb23dd3f
17 changed files with 668 additions and 120 deletions
@@ -11,7 +11,7 @@ import { toast } from "sonner"
import { useAuthApi } from "@/shared/useApi"
const schema = z.object({
title: z.string().min(1, "Title is required"),
name: z.string().min(1, "Name is required"),
})
type FormValues = z.infer<typeof schema>
@@ -21,16 +21,16 @@ export function DocumentTypeInlineForm({ onSuccess }: InlineCreateFormProps) {
const form = useForm<FormValues>({
resolver: zodResolver(schema),
defaultValues: { title: "" },
defaultValues: { name: "" },
})
const handleSubmit = async (values: FormValues) => {
try {
const result = await api.vehicleDocuments.createDocumentType({ title: values.title } as any)
const result = await api.vehicleDocuments.createDocumentType({ name: values.name } as any)
toast.success("Document type created")
form.reset()
const item = (result as any)?.data ?? result
onSuccess({ value: String(item.id), label: item.title ?? item.name ?? String(item.id) })
onSuccess({ value: String(item.id), label: item.name ?? String(item.id) })
} catch {
toast.error("Failed to create document type")
}
@@ -40,8 +40,8 @@ export function DocumentTypeInlineForm({ onSuccess }: InlineCreateFormProps) {
<Rhform form={form} onSubmit={handleSubmit}>
<FieldGroup>
<RhfTextField
name="title"
label="Title"
name="name"
label="Name"
placeholder="e.g. Registration Certificate"
required
/>