Skip to content

Commit

Permalink
adding callbacks back in
Browse files Browse the repository at this point in the history
  • Loading branch information
ailZhou committed Sep 20, 2024
1 parent 4e6fe49 commit 359572c
Showing 1 changed file with 57 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ const getOMSRates = (
}
}
}
//if no options are selected, we want to generate a warning for that too
else if (!topLevel.options || topLevel.options.length === 0) {
omsRates.push({ key: locationDictionary([topLevelKey]), ...topLevel });
}

//if user choose to [+Add Another Classification]
if (topLevel.additionalSelections) {
Expand Down Expand Up @@ -247,43 +251,75 @@ const validateNDRs = (
let errorArray: FormError[] = [];
const omsRates = getOMSRates(data, locationDictionary);

//validation when only the top node is selected
//error for OPM

//running callbacks

const errorsNDR = omsRates.map((data) => {
const label = data?.key!;
const rateData = data?.rateData as AnyObject;
const errorLogs = [];
if (data) {
if ((data?.rateData as AnyObject)?.["aifhh-rate"]) {

if (rateData) {
if (rateData?.["aifhh-rate"]) {
errorLogs.push(
...validateFields(
(data.rateData as AnyObject)?.["aifhh-rate"],
data.key,
locationDictionary
)
...validateFields(rateData?.["aifhh-rate"], label, locationDictionary)
);
} else if ((data?.rateData as AnyObject)?.["iuhh-rate"]) {
} else if (rateData?.["iuhh-rate"]) {
errorLogs.push(
...validateFields(
(data.rateData as AnyObject)?.["iuhh-rate"],
data.key,
(rateData as AnyObject)?.["iuhh-rate"],
label,
locationDictionary
)
);
} else if ((data?.rateData as AnyObject)?.["pcr-rate"]) {
} else if (rateData?.["pcr-rate"]) {
errorLogs.push(
...validateValues(
(data.rateData as AnyObject)?.["pcr-rate"],
data.key
)
...validateValues((rateData as AnyObject)?.["pcr-rate"], label)
);
} else if (data?.rateData?.rates) {
} else if (rateData?.rates) {
errorLogs.push(
...validateNDR(data.rateData?.rates, data.key, locationDictionary)
...validateNDR(rateData?.rates, label, locationDictionary)
);
} else {
errorLogs.push(errorForNDRSelection(data!.key));
errorLogs.push(errorForNDRSelection(label));
}

//running any callback functions
for (const callback of callbackArr) {
errorLogs.push(
...callback({
rateData,
categories,
qualifiers,
label: [label],
locationDictionary,
isOPM,
customTotalLabel,
dataSource,
})
);
}

//validate partial rates
if (!rateData?.["pcr-rate"]) {
// check for complex rate type and assign appropriate tag
const rateType = !!rateData?.["iuhh-rate"]
? "iuhh-rate"
: !!rateData?.["aifhh-rate"]
? "aifhh-rate"
: undefined;

errorLogs.push(
...validatePartialRateCompletionOMS(rateType)({
rateData,
categories,
qualifiers,
label: [label],
locationDictionary,
isOPM,
customTotalLabel,
dataSource,
})
);
}
}
return errorLogs;
Expand Down

0 comments on commit 359572c

Please sign in to comment.