) {
// Do something with the form values.
// ✅ This will be type-safe and validated.
+ toast({
+ title: "You submitted the following values:",
+ description: (
+
+ {JSON.stringify(values, null, 2)}
+
+ ),
+ })
console.log(values)
}
+
+
+ function onErrors(errors) {
+ toast({
+ title: "You have errors",
+ description: (
+
+ {JSON.stringify(errors, null, 2)}
+
+ ),
+ })
+ console.log(JSON.stringify(errors))
+ }
+
return (
diff --git a/src/app/ui/forms/sub.tsx b/src/app/ui/forms/sub.tsx
index 8c574f9..5e8a415 100644
--- a/src/app/ui/forms/sub.tsx
+++ b/src/app/ui/forms/sub.tsx
@@ -31,21 +31,26 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
-import { ItemText, SelectItemIndicator, SelectItemText } from "@radix-ui/react-select"
+import { useState } from "react"
const FormSchema = z.object({
- storyId: z.string(),
- pubId: z.string(),
+ storyId: z.coerce.number(),
+ pubId: z.coerce.number(),
submitted: z.date(),
- // responded: z.date(),
- // responseId: z.string()
+ responded: z.date().optional(),
+ responseId: z.number()
})
export default function SubmissionForm({ stories, pubs, responses }) {
const form = useForm>({
resolver: zodResolver(FormSchema),
+ defaultValues: {
+ responseId: responses[0].id
+ }
})
+ const [isSubCalendarOpen, setIsSubCalendarOpen] = useState(false);
+ const [isRespCalendarOpen, setIsRespCalendarOpen] = useState(false);
const storiesSelectItems = stories.map(e => (
{e.title}
@@ -146,8 +151,8 @@ export default function SubmissionForm({ stories, pubs, responses }) {
name="submitted"
render={({ field }) => (
- Date of birth
-
+ Date of submission
+