Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let newSchema = action.schema;
let newData = state.data;
const systems = action.systems || state.systems;
// For both systems and facilities, we want to put them in the form
// schema as radio options if we have more than one to choose from.
// If we only have one, then we want to just set the value in the
// form data and remove the schema for that field, so we don't
// show the question to the user
if (systems.length > 1) {
newSchema = set(
'properties.vaSystem.enum',
systems.map(sys => sys.institutionCode),
action.schema,
);
newSchema = set(
'properties.vaSystem.enumNames',
systems.map(sys => sys.authoritativeName),
newSchema,
);
} else {
newSchema = unset('properties.vaSystem', newSchema);
newData = {
...newData,
vaSystem: systems[0]?.institutionCode,
};
}
const facilities =
action.facilities ||
getFacilities(state, action.typeOfCareId, newData.vaSystem);
...state,
loadingSystems: true,
};
}
case FORM_PAGE_FACILITY_OPEN_SUCCEEDED: {
let newSchema = action.schema;
let newData = state.data;
const systems = action.systems || state.systems;
// For both systems and facilities, we want to put them in the form
// schema as radio options if we have more than one to choose from.
// If we only have one, then we want to just set the value in the
// form data and remove the schema for that field, so we don't
// show the question to the user
if (systems.length > 1) {
newSchema = set(
'properties.vaSystem.enum',
systems.map(sys => sys.institutionCode),
action.schema,
);
newSchema = set(
'properties.vaSystem.enumNames',
systems.map(sys => sys.authoritativeName),
newSchema,
);
} else {
newSchema = unset('properties.vaSystem', newSchema);
newData = {
...newData,
vaSystem: systems[0]?.institutionCode,
};
}
(city, addressSchema) => {
const schemaUpdate = {
properties: addressSchema.properties,
};
const stateList = usaStates;
const labelList = usaLabels;
// We constrain the state list when someone picks a city that’s a military base
if (
isMilitaryCity(city) &&
schemaUpdate.properties.state.enum !== militaryStates
) {
const withEnum = set(
'state.enum',
militaryStates,
schemaUpdate.properties,
);
schemaUpdate.properties = set(
'state.enumNames',
militaryLabels,
withEnum,
);
} else {
schemaUpdate.properties = set(
'state.enumNames',
labelList,
schemaUpdate.properties,
);
schemaUpdate.properties = set(
function ratedDisabilities(state = initialState, action) {
switch (action.type) {
case FETCH_RATED_DISABILITIES_SUCCESS:
return set('ratedDisabilities', action.response, state);
case FETCH_RATED_DISABILITIES_FAILED:
return set('ratedDisabilities', action.response, state);
default:
return state;
}
}
function vaProfile(state = initialState, action) {
switch (action.type) {
case FETCH_HERO_SUCCESS:
return set('hero', action.hero, state);
case FETCH_PERSONAL_INFORMATION_SUCCESS:
return set('personalInformation', action.personalInformation, state);
case FETCH_MILITARY_INFORMATION_SUCCESS:
return set('militaryInformation', action.militaryInformation, state);
case PAYMENT_INFORMATION_FETCH_SUCCEEDED:
case PAYMENT_INFORMATION_SAVE_SUCCEEDED: {
let newState = set('paymentInformation', action.response, state);
newState = set('paymentInformationUiState.isEditing', false, newState);
return set('paymentInformationUiState.isSaving', false, newState);
}
case PAYMENT_INFORMATION_EDIT_MODAL_TOGGLED: {
let newState = set(
'paymentInformationUiState.isEditing',
!state.paymentInformationUiState.isEditing,
state,
);
newState = set('paymentInformationUiState.responseError', null, newState);
return set(
'paymentInformationUiState.editModalForm',
editModalFormsInitialState,
function updateFacilitiesSchemaAndData(systems, facilities, schema, data) {
let newSchema = schema;
let newData = data;
const availableFacilities = getEligibleFacilities(facilities);
if (
availableFacilities.length > 1 ||
(availableFacilities.length === 1 && systems.length > 1)
) {
newSchema = unset('properties.vaFacilityMessage', newSchema);
newSchema = set(
'properties.vaFacility',
{
type: 'string',
enum: availableFacilities.map(
facility => facility.institution.institutionCode,
),
enumNames: availableFacilities.map(
facility =>
`${facility.institution.authoritativeName} (${
facility.institution.city
}, ${facility.institution.stateAbbrev})`,
),
},
newSchema,
);
} else if (newData.vaSystem) {
'state.enum',
militaryStates,
schemaUpdate.properties,
);
schemaUpdate.properties = set(
'state.enumNames',
militaryLabels,
withEnum,
);
} else {
schemaUpdate.properties = set(
'state.enumNames',
labelList,
schemaUpdate.properties,
);
schemaUpdate.properties = set(
'state.enum',
stateList,
schemaUpdate.properties,
);
}
return schemaUpdate;
},
);
case FETCH_PERSONAL_INFORMATION_SUCCESS:
return set('personalInformation', action.personalInformation, state);
case FETCH_MILITARY_INFORMATION_SUCCESS:
return set('militaryInformation', action.militaryInformation, state);
case PAYMENT_INFORMATION_FETCH_SUCCEEDED:
case PAYMENT_INFORMATION_SAVE_SUCCEEDED: {
let newState = set('paymentInformation', action.response, state);
newState = set('paymentInformationUiState.isEditing', false, newState);
return set('paymentInformationUiState.isSaving', false, newState);
}
case PAYMENT_INFORMATION_EDIT_MODAL_TOGGLED: {
let newState = set(
'paymentInformationUiState.isEditing',
!state.paymentInformationUiState.isEditing,
state,
);
newState = set('paymentInformationUiState.responseError', null, newState);
return set(
'paymentInformationUiState.editModalForm',
editModalFormsInitialState,
newState,
);
}
case PAYMENT_INFORMATION_EDIT_MODAL_FIELD_CHANGED:
return set(