diff --git a/app/components/DateInput.tsx b/app/components/DateInput.tsx
index f7d9d386c..dfc42a542 100644
--- a/app/components/DateInput.tsx
+++ b/app/components/DateInput.tsx
@@ -1,5 +1,6 @@
import { useIsMounted } from "~/hooks/useIsMounted";
import { dateToYearMonthDayHourMinuteString } from "~/utils/dates";
+import * as React from "react";
export function DateInput({
id,
@@ -18,6 +19,7 @@ export function DateInput({
"data-cy": string;
required?: boolean;
}) {
+ const [date, setDate] = React.useState(defaultValue ?? new Date());
const isMounted = useIsMounted();
if (!isMounted) {
@@ -33,19 +35,18 @@ export function DateInput({
}
return (
-
+ <>
+ {date && }
+ setDate(new Date(e.target.value))}
+ data-cy={dataCy}
+ required={required}
+ />
+ >
);
}
diff --git a/app/utils/zod.ts b/app/utils/zod.ts
index 2913b0792..b0ac43bd2 100644
--- a/app/utils/zod.ts
+++ b/app/utils/zod.ts
@@ -40,7 +40,9 @@ export function actualNumber(value: unknown) {
export function date(value: unknown) {
if (typeof value === "string" || typeof value === "number") {
- return new Date(value);
+ const valueAsNumber = Number(value);
+
+ return new Date(Number.isNaN(valueAsNumber) ? value : valueAsNumber);
}
return value;