fix(SW-667): add ErrorMessage

This commit is contained in:
Chuma McPhoy
2024-10-29 10:32:47 +01:00
parent 33fd052c04
commit aa20c3569b

View File

@@ -10,6 +10,7 @@ import { dt } from "@/lib/dt"
import Select from "@/components/TempDesignSystem/Select" import Select from "@/components/TempDesignSystem/Select"
import { rangeArray } from "@/utils/rangeArray" import { rangeArray } from "@/utils/rangeArray"
import ErrorMessage from "../ErrorMessage"
import { DateName } from "./date" import { DateName } from "./date"
import styles from "./date.module.css" import styles from "./date.module.css"
@@ -21,7 +22,7 @@ import type { DateProps } from "./date"
export default function DateSelect({ name, registerOptions = {} }: DateProps) { export default function DateSelect({ name, registerOptions = {} }: DateProps) {
const intl = useIntl() const intl = useIntl()
const currentValue = useWatch({ name }) const currentValue = useWatch({ name })
const { control, setValue, trigger } = useFormContext() const { control, setValue, trigger, formState } = useFormContext()
const { field } = useController({ const { field } = useController({
control, control,
name, name,
@@ -204,6 +205,7 @@ export default function DateSelect({ name, registerOptions = {} }: DateProps) {
}} }}
</DateInput> </DateInput>
</Group> </Group>
<ErrorMessage errors={formState.errors} name={field.name} />
</DatePicker> </DatePicker>
) )
} }