Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function formStateReducer(
s = INITIAL_STATE,
a: CreateGroupElementAction | RemoveGroupElementAction,
) {
s = formGroupReducer(s, a);
switch (a.type) {
case CreateGroupElementAction.TYPE:
return updateGroup({
group: group => {
const newGroup = addGroupControl(group, a.name, false);
// alternatively we can also use setValue
// const newValue = { ...group.value, [a.name]: false };
// const newGroup = setValue(group, newValue);
return newGroup;
},
})(s);
case RemoveGroupElementAction.TYPE:
formState(s = INITIAL_STATE, a: Action) {
return formGroupReducer(s, a);
},
});
formState(fs = INITIAL_FORM_STATE, a: Action) {
return formGroupReducer(fs, a);
},
});
formState(s = INITIAL_STATE, a: Action) {
return formGroupReducer(s, a);
},
submittedValue(s: FormValue | undefined, a: SetSubmittedValueAction) {
formState(s = INITIAL_STATE, a: Action) {
return validateAndUpdateForm(formGroupReducer(s, a));
},
submittedValue(s: FormValue | undefined, a: SetSubmittedValueAction) {
export function formStateReducer(state = INITIAL_STATE, a: BlockUIAction | UnblockUIAction) {
state = formGroupReducer(state, a);
switch (a.type) {
case BlockUIAction.TYPE: {
state = updateRecursive(
state,
s => setUserDefinedProperty(s, 'wasDisabled', s.isDisabled),
);
return disable(state);
}
case UnblockUIAction.TYPE: {
state = enable(state);
return updateRecursive(
state,
s => s.userDefinedProperties.wasDisabled ? disable(s) : s,
);
formState(s = INITIAL_STATE, a: Action) {
return formGroupReducer(s, a);
},
});
export function reducer(fs: FormGroupState = INITIAL_FORM_STATE, a: Action) {
return formGroupReducer(fs, a);
}
formState(s = INITIAL_STATE, a: Action) {
return formGroupReducer(s, a);
},
});