reset add camera wizard when closing and saving

This commit is contained in:
Josh Hawkins 2025-12-24 08:10:45 -06:00
parent a2f57c81cb
commit 2361e4ed08

View File

@ -31,7 +31,8 @@ type WizardState = {
type WizardAction = type WizardAction =
| { type: "UPDATE_DATA"; payload: Partial<WizardFormData> } | { type: "UPDATE_DATA"; payload: Partial<WizardFormData> }
| { type: "UPDATE_AND_NEXT"; payload: Partial<WizardFormData> } | { type: "UPDATE_AND_NEXT"; payload: Partial<WizardFormData> }
| { type: "RESET_NAVIGATE" }; | { type: "RESET_NAVIGATE" }
| { type: "RESET_ALL" };
const wizardReducer = ( const wizardReducer = (
state: WizardState, state: WizardState,
@ -50,6 +51,11 @@ const wizardReducer = (
}; };
case "RESET_NAVIGATE": case "RESET_NAVIGATE":
return { ...state, shouldNavigateNext: false }; return { ...state, shouldNavigateNext: false };
case "RESET_ALL":
return {
wizardData: { streams: [] },
shouldNavigateNext: false,
};
default: default:
return state; return state;
} }
@ -84,13 +90,13 @@ export default function CameraWizardDialog({
useEffect(() => { useEffect(() => {
if (open) { if (open) {
setCurrentStep(0); setCurrentStep(0);
dispatch({ type: "UPDATE_DATA", payload: { streams: [] } }); dispatch({ type: "RESET_ALL" });
} }
}, [open]); }, [open]);
const handleClose = useCallback(() => { const handleClose = useCallback(() => {
setCurrentStep(0); setCurrentStep(0);
dispatch({ type: "UPDATE_DATA", payload: { streams: [] } }); dispatch({ type: "RESET_ALL" });
onClose(); onClose();
}, [onClose]); }, [onClose]);