@betterstart/cli 0.1.58 → 0.1.60

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 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: 'onSubmit',
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(values)
2750
+ const result = await create${p7.pascal}Submission(validation.data)
2746
2751
  if (result.success) {
2747
2752
  setSubmitted(true)
2748
2753
  } else {
@@ -2766,7 +2771,7 @@ ${p7.fieldArraySetup}${p7.watchSetup}
2766
2771
 
2767
2772
  return (
2768
2773
  <Form {...form}>
2769
- <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
2774
+ <form onSubmit={(e) => e.preventDefault()} className="space-y-8">
2770
2775
  {/* Step header */}
2771
2776
  <div>
2772
2777
  <h3 className="text-lg font-semibold">{STEPS[currentStep].label}</h3>
@@ -2801,7 +2806,7 @@ ${p7.stepContentBlocks}
2801
2806
  <ChevronRight className="ml-2 h-4 w-4" />
2802
2807
  </Button>
2803
2808
  ) : (
2804
- <Button type="submit" disabled={submitting}>
2809
+ <Button type="button" disabled={submitting} onClick={() => onSubmit(form.getValues())}>
2805
2810
  {submitting ? 'Submitting...' : '${p7.submitText}'}
2806
2811
  </Button>
2807
2812
  )}