diff --git a/components/forms/SettingsSubmit.tsx b/components/forms/SettingsSubmit.tsx index 4d38c012..b86b1c39 100644 --- a/components/forms/SettingsSubmit.tsx +++ b/components/forms/SettingsSubmit.tsx @@ -181,8 +181,6 @@ export default function SettingsSubmit({ mode = "create", submissionId, initialV handleSubmit, control, reset, - setValue, // <-- add - getValues, // <-- add formState: { isSubmitting }, } = useForm({ defaultValues: { @@ -256,61 +254,6 @@ export default function SettingsSubmit({ mode = "create", submissionId, initialV const apt = useOptions("laser_scan_lens_apt", initialValues?.lens_apt ?? null); const exp = useOptions("laser_scan_lens_exp", initialValues?.lens_exp ?? null); - // 🔧 Targeted fix: when options hydrate, re-apply current ids so selects adopt them. - useEffect(() => { - if (!initialValues) return; - - type Name = - | "mat" - | "mat_coat" - | "mat_color" - | "mat_opacity" - | "laser_soft" - | "source" - | "lens_conf" - | "lens_apt" - | "lens_exp" - | "lens"; - - const ensure = (name: Name, id?: string | null, opts?: Opt[]) => { - if (!id) return; - if (!opts || opts.length === 0) return; - const curr = getValues(name as any); - // Re-apply if blank OR already equal to the intended id (forces the select to adopt it) - if (curr == null || curr === "" || String(curr) === String(id)) { - setValue(name as any, String(id), { shouldDirty: false, shouldValidate: false }); - } - }; - - ensure("mat", initialValues.mat ?? null, mats.opts); - ensure("mat_coat", initialValues.mat_coat ?? null, coats.opts); - ensure("mat_color", initialValues.mat_color ?? null, colors.opts); - ensure("mat_opacity",initialValues.mat_opacity ?? null, opacs.opts); - - ensure("laser_soft", initialValues.laser_soft ?? null, soft.opts); - ensure("source", initialValues.source ?? null, srcs.opts); - - // Order: source → (conf/apt/exp) → lens - ensure("lens_conf", initialValues.lens_conf ?? null, conf.opts); - ensure("lens_apt", initialValues.lens_apt ?? null, apt.opts); - ensure("lens_exp", initialValues.lens_exp ?? null, exp.opts); - ensure("lens", initialValues.lens ?? null, lens.opts); - }, [ - initialValues, - mats.opts, - coats.opts, - colors.opts, - opacs.opts, - soft.opts, - srcs.opts, - lens.opts, - conf.opts, - apt.opts, - exp.opts, - getValues, - setValue, - ]); - // Image files const [photoFile, setPhotoFile] = useState(null); const [screenFile, setScreenFile] = useState(null); @@ -418,7 +361,7 @@ export default function SettingsSubmit({ mode = "create", submissionId, initialV - + {/* Suffixes after label */} +
@@ -454,24 +398,35 @@ export default function SettingsSubmit({ mode = "create", submissionId, initialV fields={fills.fields} onAdd={() => fills.append({ type: "" })} // default to "—" onRemove={(i) => fills.remove(i)} - render={(i) => ( -
- - + + + + + + + + {/* Only show when Auto Rotate = true; label + degree suffix */} + {autoRotate && ( + + )} + + + + +
+ ); + }} /> {/* Line */} @@ -480,23 +435,45 @@ export default function SettingsSubmit({ mode = "create", submissionId, initialV fields={lines.fields} onAdd={() => lines.append({})} onRemove={(i) => lines.remove(i)} - render={(i) => ( -
- - - - - - - - - - - - - -
- )} + render={(i) => { + const perf = !!useWatch({ control, name: `line_settings.${i}.perf` }); + const wobble = !!useWatch({ control, name: `line_settings.${i}.wobble` }); + return ( +
+ + + + + + + {/* Perforation mode toggle */} + + + {/* Cut/Skip are integers with mm suffix; only when perf=true */} + {perf && ( + <> + + + + )} + + + + {/* Wobble toggle */} + + + {/* Step/Size only when wobble=true; mm suffix */} + {wobble && ( + <> + + + + )} + + +
+ ); + }} /> {/* Raster */} @@ -520,15 +497,15 @@ export default function SettingsSubmit({ mode = "create", submissionId, initialV {isHalftone && ( <> - + )} - + - - - + + +
); }}