@betterstart/cli 0.1.57 → 0.1.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +9 -4
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2664,7 +2664,6 @@ export function ${p7.pascal}Form() {
|
|
|
2664
2664
|
` : "";
|
|
2665
2665
|
return `'use client'
|
|
2666
2666
|
|
|
2667
|
-
import { zodResolver } from '@hookform/resolvers/zod'
|
|
2668
2667
|
import { ChevronLeft, ChevronRight${p7.hasListFields ? ", Trash2" : ""} } from 'lucide-react'
|
|
2669
2668
|
import { parseAsInteger, useQueryState } from 'nuqs'
|
|
2670
2669
|
import { useState } from 'react'
|
|
@@ -2708,8 +2707,6 @@ ${formComponentDecl}() {
|
|
|
2708
2707
|
const [submitting, setSubmitting] = useState(false)
|
|
2709
2708
|
|
|
2710
2709
|
const form = useForm<FormValues>({
|
|
2711
|
-
resolver: zodResolver(formSchema),
|
|
2712
|
-
mode: 'onTouched',
|
|
2713
2710
|
defaultValues: {
|
|
2714
2711
|
${p7.defaults}
|
|
2715
2712
|
},
|
|
@@ -2740,9 +2737,17 @@ ${p7.fieldArraySetup}${p7.watchSetup}
|
|
|
2740
2737
|
}
|
|
2741
2738
|
|
|
2742
2739
|
async function onSubmit(values: FormValues) {
|
|
2740
|
+
const validation = formSchema.safeParse(values)
|
|
2741
|
+
if (!validation.success) {
|
|
2742
|
+
for (const issue of validation.error.issues) {
|
|
2743
|
+
const fieldName = issue.path[0] as keyof FormValues
|
|
2744
|
+
form.setError(fieldName, { type: 'validate', message: issue.message })
|
|
2745
|
+
}
|
|
2746
|
+
return
|
|
2747
|
+
}
|
|
2743
2748
|
setSubmitting(true)
|
|
2744
2749
|
try {
|
|
2745
|
-
const result = await create${p7.pascal}Submission(
|
|
2750
|
+
const result = await create${p7.pascal}Submission(validation.data)
|
|
2746
2751
|
if (result.success) {
|
|
2747
2752
|
setSubmitted(true)
|
|
2748
2753
|
} else {
|