diff --git a/apps/dashboard/package.json b/apps/dashboard/package.json index c81a153778..1f141c09c7 100644 --- a/apps/dashboard/package.json +++ b/apps/dashboard/package.json @@ -64,7 +64,7 @@ "react-zxing": "^2.1.0", "require-in-the-middle": "^8.0.1", "superjson": "^2.0.0", - "zod": "^3.25.47" + "zod": "^4.4.3" }, "devDependencies": { "@biomejs/biome": "2.4.16", diff --git a/apps/dashboard/src/app/(internal)/arrangementer/components/attendance-form.tsx b/apps/dashboard/src/app/(internal)/arrangementer/components/attendance-form.tsx index adcffa158f..2ce01a0c56 100644 --- a/apps/dashboard/src/app/(internal)/arrangementer/components/attendance-form.tsx +++ b/apps/dashboard/src/app/(internal)/arrangementer/components/attendance-form.tsx @@ -16,8 +16,6 @@ const AttendanceFormSchema = AttendanceWriteSchema.superRefine((val, ctx) => { const code = "custom" ctx.addIssue({ message, code, path: ["deregisterDeadline"] }) } - - return true }) interface AttendanceFormProps { diff --git a/apps/dashboard/src/app/(internal)/arrangementer/components/edit-form.tsx b/apps/dashboard/src/app/(internal)/arrangementer/components/edit-form.tsx index b33018d160..bab65a6c33 100644 --- a/apps/dashboard/src/app/(internal)/arrangementer/components/edit-form.tsx +++ b/apps/dashboard/src/app/(internal)/arrangementer/components/edit-form.tsx @@ -21,7 +21,7 @@ import { import { z } from "zod" import { validateEventWrite } from "../validation" -const EVENT_FORM_DATA_TYPE = Object.values(EventTypeSchema.Values).map((type) => ({ +const EVENT_FORM_DATA_TYPE = Object.values(EventTypeSchema.enum).map((type) => ({ value: type, label: mapEventTypeToLabel(type), })) @@ -37,7 +37,7 @@ const FormValidationSchema = EventSchema.extend({ }).superRefine((data, ctx) => { const issues = validateEventWrite(data) for (const issue of issues) { - ctx.addIssue(issue) + ctx.addIssue({ code: "custom", message: issue.message, path: issue.path }) } }) diff --git a/apps/dashboard/src/app/(internal)/arrangementer/components/feedback-form-edit-form.tsx b/apps/dashboard/src/app/(internal)/arrangementer/components/feedback-form-edit-form.tsx index ca5ac5f5b0..398c2a561c 100644 --- a/apps/dashboard/src/app/(internal)/arrangementer/components/feedback-form-edit-form.tsx +++ b/apps/dashboard/src/app/(internal)/arrangementer/components/feedback-form-edit-form.tsx @@ -47,7 +47,7 @@ import z from "zod" import { useDeleteFeedbackFormMutation } from "../mutations" import { useEventFeedbackPublicResultsTokenGetQuery, useFeedbackAnswersGetQuery } from "../queries" -const typeOptions = Object.values(FeedbackQuestionSchema.shape.type.Values).map((type) => ({ +const typeOptions = Object.values(FeedbackQuestionSchema.shape.type.enum).map((type) => ({ value: type, label: getFeedbackQuestionTypeName(type), })) @@ -63,8 +63,6 @@ const FormValuesSchema = z const code = "custom" ctx.addIssue({ message, code, path: ["feedbackForm.answerDeadline"] }) } - - return true }) export type FormValues = z.infer diff --git a/apps/dashboard/src/app/(internal)/arrangementer/components/pool-form.tsx b/apps/dashboard/src/app/(internal)/arrangementer/components/pool-form.tsx index 259b897672..7b6f0a52b9 100644 --- a/apps/dashboard/src/app/(internal)/arrangementer/components/pool-form.tsx +++ b/apps/dashboard/src/app/(internal)/arrangementer/components/pool-form.tsx @@ -41,7 +41,6 @@ export const PoolFormSchema = z.object({ } return null }, z - .number() .int() .min(0, "Utsettelse må være mellom 0 og 96 timer (4 dager).") .max(96, "Utsettelse må være mellom 0 og 96 timer (4 dager).") diff --git a/apps/dashboard/src/app/(internal)/arrangementer/components/qr-code-scanner.tsx b/apps/dashboard/src/app/(internal)/arrangementer/components/qr-code-scanner.tsx index 133f2450ed..f6000ed768 100644 --- a/apps/dashboard/src/app/(internal)/arrangementer/components/qr-code-scanner.tsx +++ b/apps/dashboard/src/app/(internal)/arrangementer/components/qr-code-scanner.tsx @@ -30,7 +30,7 @@ export const QrCodeScanner: FC = ({ attendance }) => { return } - const id = z.string().uuid().safeParse(result.getText()) + const id = z.guid().safeParse(result.getText()) if (id.success) { paused.current = true diff --git a/apps/dashboard/src/app/(internal)/arrangementer/components/write-form.tsx b/apps/dashboard/src/app/(internal)/arrangementer/components/write-form.tsx index b6c68885a3..df67ed4319 100644 --- a/apps/dashboard/src/app/(internal)/arrangementer/components/write-form.tsx +++ b/apps/dashboard/src/app/(internal)/arrangementer/components/write-form.tsx @@ -23,7 +23,7 @@ import { import { addHours, roundToNearestHours } from "date-fns" import { z } from "zod" -const EVENT_FORM_DATA_TYPE = Object.values(EventTypeSchema.Values).map((type) => ({ +const EVENT_FORM_DATA_TYPE = Object.values(EventTypeSchema.enum).map((type) => ({ value: type, label: mapEventTypeToLabel(type), })) @@ -40,7 +40,7 @@ const FormValidationSchema = EventWriteSchema.extend({ }).superRefine((data, ctx) => { const issues = validateEventWrite(data) for (const issue of issues) { - ctx.addIssue(issue) + ctx.addIssue({ code: "custom", message: issue.message, path: issue.path }) } }) diff --git a/apps/dashboard/src/app/(internal)/bedrifter/components/write-form.tsx b/apps/dashboard/src/app/(internal)/bedrifter/components/write-form.tsx index 2bdb99edd4..2c93996644 100644 --- a/apps/dashboard/src/app/(internal)/bedrifter/components/write-form.tsx +++ b/apps/dashboard/src/app/(internal)/bedrifter/components/write-form.tsx @@ -25,7 +25,7 @@ export const useCompanyWriteForm = ({ return useFormBuilder({ schema: CompanyWriteSchema.extend({ - website: z.string().url(), + website: z.url(), }), defaultValues, onSubmit, diff --git a/apps/dashboard/src/app/(internal)/brukere/components/membership-form.tsx b/apps/dashboard/src/app/(internal)/brukere/components/membership-form.tsx index 6b79b90303..15322f784f 100644 --- a/apps/dashboard/src/app/(internal)/brukere/components/membership-form.tsx +++ b/apps/dashboard/src/app/(internal)/brukere/components/membership-form.tsx @@ -134,7 +134,7 @@ export const useMembershipWriteForm = ({ label: "Type", required: true, placeholder: "Velg type", - data: Object.values(MembershipTypeSchema.Values).map((type) => ({ + data: Object.values(MembershipTypeSchema.enum).map((type) => ({ value: type, label: getMembershipTypeName(type) ?? type, })), @@ -144,7 +144,7 @@ export const useMembershipWriteForm = ({ required: false, clearable: true, placeholder: "Velg spesialisering", - data: Object.values(MembershipSpecializationSchema.Values) + data: Object.values(MembershipSpecializationSchema.enum) .filter((specialization) => specialization !== "UNKNOWN") .map((specialization) => ({ value: specialization, diff --git a/apps/dashboard/src/app/(internal)/grupper/all-groups-table.tsx b/apps/dashboard/src/app/(internal)/grupper/all-groups-table.tsx index a7b66ea0b3..783eccd2bb 100644 --- a/apps/dashboard/src/app/(internal)/grupper/all-groups-table.tsx +++ b/apps/dashboard/src/app/(internal)/grupper/all-groups-table.tsx @@ -99,7 +99,7 @@ export const AllGroupsTable = ({ groups }: Props) => { filters={[ { columnId: "status", label: "Aktiv", value: "Aktiv" }, { columnId: "status", label: "Inaktiv", value: "Inaktiv" }, - ...Object.values(GroupTypeSchema.Values).map((groupType) => { + ...Object.values(GroupTypeSchema.enum).map((groupType) => { const typeName = getGroupTypeName(groupType) return { diff --git a/apps/dashboard/src/app/(internal)/grupper/write-form.tsx b/apps/dashboard/src/app/(internal)/grupper/write-form.tsx index 7891a18212..02acc8787b 100644 --- a/apps/dashboard/src/app/(internal)/grupper/write-form.tsx +++ b/apps/dashboard/src/app/(internal)/grupper/write-form.tsx @@ -55,7 +55,7 @@ export const useGroupWriteForm = ({ FormSchema.superRefine((data, ctx) => { const issues = validateGroupWrite(data, existingGroupSlugs, defaultValues.slug) for (const issue of issues) { - ctx.addIssue(issue) + ctx.addIssue({ code: "custom", message: issue.message, path: issue.path }) } }), [existingGroupSlugs, defaultValues] @@ -108,7 +108,7 @@ export const useGroupWriteForm = ({ memberVisibility: createSelectInput({ label: "Hvilke medlemmer skal vises", placeholder: "Velg en", - data: Object.values(GroupMemberVisibilitySchema.Values).map((groupMemberVisibilityType) => ({ + data: Object.values(GroupMemberVisibilitySchema.enum).map((groupMemberVisibilityType) => ({ value: groupMemberVisibilityType, label: getGroupMemberVisibilityName(groupMemberVisibilityType), })), @@ -130,7 +130,7 @@ export const useGroupWriteForm = ({ placeholder: "Velg en", withAsterisk: true, required: true, - data: Object.values(GroupTypeSchema.Values).map((groupType) => ({ + data: Object.values(GroupTypeSchema.enum).map((groupType) => ({ value: groupType, label: getGroupTypeName(groupType), })), @@ -141,7 +141,7 @@ export const useGroupWriteForm = ({ placeholder: "Velg en", withAsterisk: true, required: true, - data: Object.values(GroupRecruitmentMethodSchema.Values).map((recruitmentMethod) => ({ + data: Object.values(GroupRecruitmentMethodSchema.enum).map((recruitmentMethod) => ({ value: recruitmentMethod, label: getGroupRecruitmentMethodName(recruitmentMethod), })), diff --git a/apps/dashboard/src/app/(internal)/karriere/write-form.tsx b/apps/dashboard/src/app/(internal)/karriere/write-form.tsx index a97aec54a2..7505ccab1c 100644 --- a/apps/dashboard/src/app/(internal)/karriere/write-form.tsx +++ b/apps/dashboard/src/app/(internal)/karriere/write-form.tsx @@ -88,7 +88,7 @@ export const useJobListingWriteForm = ({ employment: createSelectInput({ label: "Type", placeholder: "Velg type", - data: Object.values(JobListingSchema.shape.employment.Values).map((employment) => ({ + data: Object.values(JobListingSchema.shape.employment.enum).map((employment) => ({ value: employment, label: getJobListingEmploymentName(employment), })), diff --git a/apps/dashboard/src/app/(internal)/konkurranser/components/contest-write-form.tsx b/apps/dashboard/src/app/(internal)/konkurranser/components/contest-write-form.tsx index fc7a37f3d9..e1ad69b84a 100644 --- a/apps/dashboard/src/app/(internal)/konkurranser/components/contest-write-form.tsx +++ b/apps/dashboard/src/app/(internal)/konkurranser/components/contest-write-form.tsx @@ -23,7 +23,7 @@ const RESULT_ORDER_OPTIONS = [ const FormValidationSchema = ContestWriteSchema.superRefine((data, ctx) => { const issues = validateContestWrite(data) for (const issue of issues) { - ctx.addIssue(issue) + ctx.addIssue({ code: "custom", message: issue.message, path: issue.path }) } }) diff --git a/apps/dashboard/src/app/(internal)/prikker/write-form.tsx b/apps/dashboard/src/app/(internal)/prikker/write-form.tsx index d190416175..a044eab389 100644 --- a/apps/dashboard/src/app/(internal)/prikker/write-form.tsx +++ b/apps/dashboard/src/app/(internal)/prikker/write-form.tsx @@ -56,7 +56,7 @@ export const useMarkWriteForm = ({ return useFormBuilder({ schema: MarkFormSchema, - // @ts-expect-error: The default should be a string but is typed as a number + // @ts-expect-error: weight needs a string default for the text input but the schema output is number (handled by z.preprocess) defaultValues: { ...defaultValues, weight: defaultValues.weight?.toString() }, onSubmit, label, diff --git a/apps/dashboard/src/app/ApplicationShell.tsx b/apps/dashboard/src/app/ApplicationShell.tsx index f317998651..829e3e4265 100644 --- a/apps/dashboard/src/app/ApplicationShell.tsx +++ b/apps/dashboard/src/app/ApplicationShell.tsx @@ -253,7 +253,7 @@ export const ApplicationShell: FC = ({ isAdmin, children const decodedPart = decodeURIComponent(part) const isId = decodedPart.includes("|") - const isUuid = z.string().uuid().safeParse(decodedPart).success + const isUuid = z.uuid().safeParse(decodedPart).success // Ids should be lowercase const capitalizedPart = isId || isUuid ? decodedPart : capitalizeFirstLetter(decodedPart) diff --git a/apps/dashboard/src/components/ImageUploadModal.tsx b/apps/dashboard/src/components/ImageUploadModal.tsx index a6d5184643..147b5e4bc4 100644 --- a/apps/dashboard/src/components/ImageUploadModal.tsx +++ b/apps/dashboard/src/components/ImageUploadModal.tsx @@ -9,7 +9,7 @@ import { z } from "zod" const validationSchema = z.object({ title: z.string().max(255).optional(), alt: z.string().min(1).max(255), - imageUrl: z.string().url(), + imageUrl: z.url(), }) interface UploadImageModalProps { diff --git a/apps/dashboard/src/components/forms/CheckboxGroup.tsx b/apps/dashboard/src/components/forms/CheckboxGroup.tsx index 05e2cc7edb..5754371b92 100644 --- a/apps/dashboard/src/components/forms/CheckboxGroup.tsx +++ b/apps/dashboard/src/components/forms/CheckboxGroup.tsx @@ -1,7 +1,6 @@ -import { ErrorMessage } from "@hookform/error-message" import { Checkbox } from "@mantine/core" import { Controller, type FieldValues } from "react-hook-form" -import type { InputProducerResult } from "./types" +import { getErrorMessage, type InputProducerResult } from "./types" interface CheckboxGroupsProps { selected: number[] @@ -45,7 +44,7 @@ export function createLabelledCheckboxGroupInput({ return function LabelledCheckboxGroupInput({ name, state, control }) { return (
- {state.errors[name] && } + {getErrorMessage(state, name)} ({ ...props }: Omit): InputProducerResult { return function FormCheckboxInput({ name, state, register }) { - return ( - } - /> - ) + return } } diff --git a/apps/dashboard/src/components/forms/DateInput.tsx b/apps/dashboard/src/components/forms/DateInput.tsx index c75e916c5f..a44521e954 100644 --- a/apps/dashboard/src/components/forms/DateInput.tsx +++ b/apps/dashboard/src/components/forms/DateInput.tsx @@ -1,9 +1,8 @@ import { getCurrentUTC } from "@dotkomonline/utils" -import { ErrorMessage } from "@hookform/error-message" import { DatePickerInput, type DatePickerInputProps } from "@mantine/dates" import { roundToNearestHours } from "date-fns" import { Controller, type FieldValues } from "react-hook-form" -import type { InputProducerResult } from "./types" +import { getErrorMessage, type InputProducerResult } from "./types" import { ActionIcon, Stack } from "@mantine/core" import { IconX } from "@tabler/icons-react" @@ -24,7 +23,7 @@ export function createDateInput({ defaultValue={defaultValue ?? roundToNearestHours(getCurrentUTC(), { roundingMethod: "ceil" })} value={field.value} onChange={field.onChange} - error={state.errors[name] && } + error={getErrorMessage(state, name)} rightSection={ props.required !== true && ( field.onChange(null)}> diff --git a/apps/dashboard/src/components/forms/DateTimeInput.tsx b/apps/dashboard/src/components/forms/DateTimeInput.tsx index 2e3068ec1b..aa25135394 100644 --- a/apps/dashboard/src/components/forms/DateTimeInput.tsx +++ b/apps/dashboard/src/components/forms/DateTimeInput.tsx @@ -1,9 +1,8 @@ import { getCurrentUTC } from "@dotkomonline/utils" -import { ErrorMessage } from "@hookform/error-message" import { DateTimePicker, type DateTimePickerProps } from "@mantine/dates" import { roundToNearestHours } from "date-fns" import { Controller, type FieldValues } from "react-hook-form" -import type { InputProducerResult } from "./types" +import { getErrorMessage, type InputProducerResult } from "./types" import { IconX } from "@tabler/icons-react" import { ActionIcon } from "@mantine/core" @@ -24,7 +23,7 @@ export function createDateTimeInput({ defaultValue={defaultValue ?? roundToNearestHours(getCurrentUTC(), { roundingMethod: "ceil" })} value={field.value} onChange={field.onChange} - error={state.errors[name] && } + error={getErrorMessage(state, name)} rightSection={ props.required !== true && ( field.onChange(null)}> diff --git a/apps/dashboard/src/components/forms/EventSelectInput.tsx b/apps/dashboard/src/components/forms/EventSelectInput.tsx index d6541c7d41..636e85e86d 100644 --- a/apps/dashboard/src/components/forms/EventSelectInput.tsx +++ b/apps/dashboard/src/components/forms/EventSelectInput.tsx @@ -1,11 +1,10 @@ import { useEventAllQuery, useEventWithAttendancesGetQuery } from "@/app/(internal)/arrangementer/queries" import type { EventId } from "@dotkomonline/types" -import { ErrorMessage } from "@hookform/error-message" import { Select, type SelectProps } from "@mantine/core" import { useDebouncedValue } from "@mantine/hooks" import { useState } from "react" import { Controller, type FieldValues, useController } from "react-hook-form" -import type { InputProducerResult } from "./types" +import { getErrorMessage, type InputProducerResult } from "./types" interface Props extends Omit { excludeChildEvents?: boolean @@ -59,7 +58,7 @@ export function createEventSelectInput({ searchValue={searchQuery} onSearchChange={handleEventSearch} searchable={true} - error={state.errors[name] && } + error={getErrorMessage(state, name)} data={options} /> )} diff --git a/apps/dashboard/src/components/forms/Form.tsx b/apps/dashboard/src/components/forms/Form.tsx index fa80445ee7..20c2291c2c 100644 --- a/apps/dashboard/src/components/forms/Form.tsx +++ b/apps/dashboard/src/components/forms/Form.tsx @@ -1,6 +1,6 @@ import { zodResolver } from "@hookform/resolvers/zod" import { Button, Flex } from "@mantine/core" -import { type DefaultValues, type UseFormReturn, useForm } from "react-hook-form" +import { type DefaultValues, type FieldPath, type FieldValue, type UseFormReturn, useForm } from "react-hook-form" import type { z } from "zod" import type { InputProducerResult } from "./types" @@ -9,7 +9,7 @@ function entriesOf, K extends string & keyof T } interface FormBuilderOptions { - schema: z.ZodEffects> | z.ZodObject + schema: z.ZodObject fields: Partial<{ [K in keyof z.infer>]: InputProducerResult>> }> @@ -37,11 +37,15 @@ export function useFormBuilder({ throw new Error() } const Component: InputProducerResult>> = fc + // zod v4's $InferObjectOutput is opaque in generics. FieldPath cannot index DeepPartial without this cast + const defaultValue = (form.formState.defaultValues as Record)?.[name as string] as FieldValue< + z.infer> + > return ( >>} register={form.register} control={form.control} state={form.formState} diff --git a/apps/dashboard/src/components/forms/FormSelectInput.tsx b/apps/dashboard/src/components/forms/FormSelectInput.tsx index 3ec88727b8..10793b153e 100644 --- a/apps/dashboard/src/components/forms/FormSelectInput.tsx +++ b/apps/dashboard/src/components/forms/FormSelectInput.tsx @@ -1,7 +1,6 @@ -import { ErrorMessage } from "@hookform/error-message" import { Select, type SelectProps } from "@mantine/core" import { Controller, type FieldValues } from "react-hook-form" -import type { InputProducerResult } from "./types" +import { getErrorMessage, type InputProducerResult } from "./types" export function createIntegerSelectInput({ ...props @@ -22,7 +21,7 @@ export function createIntegerSelectInput({ }))} value={field.value?.toString() ?? ""} onChange={(value) => field.onChange(value !== null ? Number.parseInt(value, 10) : null)} - error={state.errors[name] && } + error={getErrorMessage(state, name)} /> )} /> diff --git a/apps/dashboard/src/components/forms/MultiSelectInput.tsx b/apps/dashboard/src/components/forms/MultiSelectInput.tsx index 74250cd85b..3aa3dcc2d9 100644 --- a/apps/dashboard/src/components/forms/MultiSelectInput.tsx +++ b/apps/dashboard/src/components/forms/MultiSelectInput.tsx @@ -1,7 +1,6 @@ -import { ErrorMessage } from "@hookform/error-message" import { MultiSelect, type MultiSelectProps } from "@mantine/core" import { Controller, type FieldValues } from "react-hook-form" -import type { InputProducerResult } from "./types" +import { getErrorMessage, type InputProducerResult } from "./types" export function createMultipleSelectInput({ ...props @@ -12,12 +11,7 @@ export function createMultipleSelectInput({ control={control} name={name} render={({ field }) => ( - } - onChange={field.onChange} - value={field.value} - /> + )} /> ) diff --git a/apps/dashboard/src/components/forms/NumberInput.tsx b/apps/dashboard/src/components/forms/NumberInput.tsx index cf6af8d2e0..8b2dc833be 100644 --- a/apps/dashboard/src/components/forms/NumberInput.tsx +++ b/apps/dashboard/src/components/forms/NumberInput.tsx @@ -1,7 +1,6 @@ -import { ErrorMessage } from "@hookform/error-message" import { NumberInput, type NumberInputProps } from "@mantine/core" import { Controller, type FieldValues } from "react-hook-form" -import type { InputProducerResult } from "./types" +import { getErrorMessage, type InputProducerResult } from "./types" export function createNumberInput({ ...props @@ -16,7 +15,7 @@ export function createNumberInput({ {...props} value={field.value} onChange={(value) => field.onChange({ target: { value } })} - error={state.errors[name] && } + error={getErrorMessage(state, name)} /> )} /> diff --git a/apps/dashboard/src/components/forms/RichTextInput/RichTextInput.tsx b/apps/dashboard/src/components/forms/RichTextInput/RichTextInput.tsx index 4dc170696f..ed71217ea7 100644 --- a/apps/dashboard/src/components/forms/RichTextInput/RichTextInput.tsx +++ b/apps/dashboard/src/components/forms/RichTextInput/RichTextInput.tsx @@ -14,7 +14,6 @@ import { ToggleHeaderColumn, ToggleHeaderRow, } from "@/components/forms/RichTextInput/TableActionButtons" -import { ErrorMessage } from "@hookform/error-message" import { Divider, Input } from "@mantine/core" import { RichTextEditor, type RichTextEditorProps } from "@mantine/tiptap" import Image from "@tiptap/extension-image" @@ -28,7 +27,7 @@ import { type Editor, useEditor } from "@tiptap/react" import StarterKit from "@tiptap/starter-kit" import { useRef } from "react" import { Controller, type FieldValues } from "react-hook-form" -import type { InputProducerResult } from "../types" +import { getErrorMessage, type InputProducerResult } from "../types" import "@mantine/tiptap/styles.css" import "./tiptap-table-styling.css" import "./tiptap-image-styling.css" @@ -69,7 +68,7 @@ export function createRichTextInput({ }) return ( - }> + {label} ({ ...props @@ -12,12 +11,7 @@ export function createSelectInput({ control={control} name={name} render={({ field }) => ( - )} /> ) diff --git a/apps/dashboard/src/components/forms/TagInput.tsx b/apps/dashboard/src/components/forms/TagInput.tsx index 69e9a62461..27f4419124 100644 --- a/apps/dashboard/src/components/forms/TagInput.tsx +++ b/apps/dashboard/src/components/forms/TagInput.tsx @@ -1,7 +1,6 @@ -import { ErrorMessage } from "@hookform/error-message" import { TagsInput, type TagsInputProps } from "@mantine/core" import { Controller, type FieldValues } from "react-hook-form" -import type { InputProducerResult } from "./types" +import { getErrorMessage, type InputProducerResult } from "./types" export function createTagInput({ ...props @@ -12,12 +11,7 @@ export function createTagInput({ control={control} name={name} render={({ field }) => ( - } - onChange={field.onChange} - value={field.value} - /> + )} /> ) diff --git a/apps/dashboard/src/components/forms/TextInput.tsx b/apps/dashboard/src/components/forms/TextInput.tsx index ecef0cfd06..68a866fbe5 100644 --- a/apps/dashboard/src/components/forms/TextInput.tsx +++ b/apps/dashboard/src/components/forms/TextInput.tsx @@ -1,18 +1,11 @@ -import { ErrorMessage } from "@hookform/error-message" import { TextInput, type TextInputProps } from "@mantine/core" import type { FieldValues } from "react-hook-form" -import type { InputProducerResult } from "./types" +import { getErrorMessage, type InputProducerResult } from "./types" export function createTextInput({ ...props }: Omit): InputProducerResult { return function FormTextInput({ name, state, register }) { - return ( - } - /> - ) + return } } diff --git a/apps/dashboard/src/components/forms/TextareaInput.tsx b/apps/dashboard/src/components/forms/TextareaInput.tsx index 33c380d8ce..aa3e18ad2d 100644 --- a/apps/dashboard/src/components/forms/TextareaInput.tsx +++ b/apps/dashboard/src/components/forms/TextareaInput.tsx @@ -1,18 +1,11 @@ -import { ErrorMessage } from "@hookform/error-message" import { Textarea, type TextareaProps } from "@mantine/core" import type { FieldValues } from "react-hook-form" -import type { InputProducerResult } from "./types" +import { getErrorMessage, type InputProducerResult } from "./types" export function createTextareaInput({ ...props }: Omit): InputProducerResult { return function TextareaInput({ name, state, register }) { - return ( -