Skip to content

Commit

Permalink
fixes based on Brendan's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ailZhou committed Oct 7, 2024
1 parent e56f1d0 commit 2fb78c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,9 @@ export const omsLocationDictionary = (

return (labels: string[]) =>
labels.reduce((prevValue, currentValue, index) => {
if (index === 0) {
if (index === 0 || prevValue === "") {
return dictionary[currentValue] ?? currentValue;
}
if (prevValue === "") {
return `${dictionary[currentValue] ?? currentValue}`;
}
if (dictionary[currentValue] === "") {
return prevValue;
}
Expand Down
41 changes: 20 additions & 21 deletions services/ui-src/src/shared/globalValidations/omsValidator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,28 @@ const getOMSRates = (

//if user choose to [+Add Another Classification]
if (topLevel.additionalSelections) {
const additional = topLevel.additionalSelections?.map((selection) => ({
key: `${locationDictionary([topLevelKey])} - ${selection.description}`,
rateData: selection.rateData,
}));
if (additional) {
omsRates.push(...additional);
}
omsRates.push(
...topLevel.additionalSelections?.map((selection) => ({
key: `${locationDictionary([topLevelKey])} - ${
selection.description
}`,
rateData: selection.rateData,
}))
);

//if user choose to [+Add Another Sub-Category] after adding a new Classification
const additionalSubCategories = topLevel.additionalSelections
.filter((additional) => additional.additionalSubCategories)
.flatMap((additional) =>
additional.additionalSubCategories?.map((subCat) => ({
key: `${locationDictionary([topLevelKey])} - ${
additional.description
} - ${subCat.description}`,
rateData: subCat.rateData,
}))
);

if (additionalSubCategories) {
omsRates.push(...additionalSubCategories);
}
omsRates.push(
...topLevel.additionalSelections
.filter((additional) => additional.additionalSubCategories)
.flatMap((additional) =>
additional.additionalSubCategories?.map((subCat) => ({
key: `${locationDictionary([topLevelKey])} - ${
additional.description
} - ${subCat.description}`,
rateData: subCat.rateData,
}))
)
);
}
}
return omsRates;
Expand Down

0 comments on commit 2fb78c3

Please sign in to comment.