@@ -38,6 +38,14 @@ const generateOptionsFromObject = (bodyshop, path, labelPath, valuePath) => {
|
||||
})), 'value');
|
||||
}
|
||||
|
||||
const generateOptionsFromArray = (bodyshop, path) => {
|
||||
const options = getValueFromPath(bodyshop, path);
|
||||
return uniqBy(options.map((value) => ({
|
||||
label: value,
|
||||
value: value,
|
||||
})), 'value');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate special reflections
|
||||
* @param bodyshop
|
||||
@@ -46,15 +54,15 @@ const generateOptionsFromObject = (bodyshop, path, labelPath, valuePath) => {
|
||||
*/
|
||||
const generateSpecialReflections = (bodyshop, finalPath) => {
|
||||
switch (finalPath) {
|
||||
// Special case because Referral Sources is an Array, not an Object.
|
||||
case 'referral_source':
|
||||
return generateOptionsFromArray(bodyshop, 'md_referral_sources');
|
||||
case 'class':
|
||||
return generateOptionsFromArray(bodyshop, 'md_classes');
|
||||
case 'cost_centers':
|
||||
return generateOptionsFromObject(bodyshop, 'md_responsibility_centers.costs', 'name', 'name');
|
||||
// Special case because Categories is an Array, not an Object.
|
||||
case 'categories':
|
||||
const catOptions = getValueFromPath(bodyshop, 'md_categories');
|
||||
return uniqBy(catOptions.map((value) => ({
|
||||
label: value,
|
||||
value: value,
|
||||
})), 'value');
|
||||
return generateOptionsFromArray(bodyshop, 'md_categories');
|
||||
case 'insurance_companies':
|
||||
return generateOptionsFromObject(bodyshop, 'md_ins_cos', 'name', 'name');
|
||||
case 'employee_teams':
|
||||
@@ -118,4 +126,4 @@ const generateInternalReflections = ({bodyshop, upperPath, finalPath}) => {
|
||||
}
|
||||
};
|
||||
|
||||
export {generateInternalReflections,}
|
||||
export {generateInternalReflections,}
|
||||
|
||||
Reference in New Issue
Block a user