@betterstart/cli 0.1.55 → 0.1.56
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 +10 -4
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2667,7 +2667,7 @@ export function ${p7.pascal}Form() {
|
|
|
2667
2667
|
import { zodResolver } from '@hookform/resolvers/zod'
|
|
2668
2668
|
import { ChevronLeft, ChevronRight${p7.hasListFields ? ", Trash2" : ""} } from 'lucide-react'
|
|
2669
2669
|
import { parseAsInteger, useQueryState } from 'nuqs'
|
|
2670
|
-
import { useState } from 'react'
|
|
2670
|
+
import { useEffect, useRef, useState } from 'react'
|
|
2671
2671
|
${p7.rhfImport}
|
|
2672
2672
|
import { z } from 'zod/v3'${queryClientImport}
|
|
2673
2673
|
import { create${p7.pascal}Submission } from '@cms/actions/${p7.kebab}-form'
|
|
@@ -2714,15 +2714,21 @@ ${formComponentDecl}() {
|
|
|
2714
2714
|
${p7.defaults}
|
|
2715
2715
|
},
|
|
2716
2716
|
})
|
|
2717
|
+
|
|
2718
|
+
const prevStep = useRef(currentStep)
|
|
2719
|
+
useEffect(() => {
|
|
2720
|
+
if (currentStep !== prevStep.current) {
|
|
2721
|
+
form.clearErrors(STEPS[currentStep].fields as (keyof FormValues)[])
|
|
2722
|
+
prevStep.current = currentStep
|
|
2723
|
+
}
|
|
2724
|
+
}, [currentStep, form])
|
|
2717
2725
|
${p7.fieldArraySetup}${p7.watchSetup}
|
|
2718
2726
|
async function handleNext() {
|
|
2719
2727
|
const isValid = await form.trigger(
|
|
2720
2728
|
STEPS[currentStep].fields as (keyof FormValues)[]
|
|
2721
2729
|
)
|
|
2722
2730
|
if (isValid) {
|
|
2723
|
-
|
|
2724
|
-
form.clearErrors(STEPS[next].fields as (keyof FormValues)[])
|
|
2725
|
-
setCurrentStep(next)
|
|
2731
|
+
setCurrentStep(currentStep + 1)
|
|
2726
2732
|
}
|
|
2727
2733
|
}
|
|
2728
2734
|
|