Swing gate changes: LA500 1 op + secondary arm, CSW24UL optional second operator

This commit is contained in:
Todd
2026-05-25 21:59:15 -04:00
parent da5323776e
commit 5ce5f6ddee
4 changed files with 122 additions and 9 deletions

View File

@ -7,6 +7,7 @@ import QuoteSummary from './QuoteSummary';
const initialState = {
step: 1,
operator: null,
optionalParts: [],
groundLoops: {
needed: false,
style: null,
@ -21,7 +22,17 @@ const initialState = {
function reducer(state, action) {
switch (action.type) {
case 'SELECT_OPERATOR':
return { ...state, operator: action.payload, step: 2 };
return { ...state, operator: action.payload, optionalParts: [], step: 2 };
case 'TOGGLE_OPTIONAL_PART': {
const id = action.payload;
const exists = state.optionalParts.includes(id);
return {
...state,
optionalParts: exists
? state.optionalParts.filter((p) => p !== id)
: [...state.optionalParts, id],
};
}
case 'SET_GROUND_LOOPS_NEEDED':
return {
...state,
@ -94,7 +105,7 @@ function reducer(state, action) {
export default function Wizard({ pricing, onLogout }) {
const [state, dispatch] = useReducer(reducer, initialState);
const { step, operator, groundLoops, accessControl, remoteButtons, remoteQuantity } = state;
const { step, operator, optionalParts, groundLoops, accessControl, remoteButtons, remoteQuantity } = state;
const steps = [
{ num: 1, label: 'Operator' },
@ -171,7 +182,10 @@ export default function Wizard({ pricing, onLogout }) {
<StepOperator
operators={pricing.operators}
selected={operator}
optionalParts={optionalParts}
onSelect={(id) => dispatch({ type: 'SELECT_OPERATOR', payload: id })}
onToggleOptionalPart={(id) => dispatch({ type: 'TOGGLE_OPTIONAL_PART', payload: id })}
onNext={() => dispatch({ type: 'NEXT_STEP' })}
/>
)}
@ -209,7 +223,7 @@ export default function Wizard({ pricing, onLogout }) {
{step === 4 && (
<QuoteSummary
pricing={pricing}
selections={{ operator, groundLoops, accessControl, remoteButtons, remoteQuantity }}
selections={{ operator, optionalParts, groundLoops, accessControl, remoteButtons, remoteQuantity }}
onBack={() => dispatch({ type: 'PREV_STEP' })}
onNew={() => dispatch({ type: 'RESET' })}
/>