Skip to content

Commit

Permalink
Merge pull request #976 from egovernments/microplan-handling-same-she…
Browse files Browse the repository at this point in the history
…et-names
  • Loading branch information
nipunarora-eGov authored Jun 27, 2024
2 parents 5c97aff + 67e9619 commit 540ed7a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const HypothesisValues = memo(({ boundarySelections, hypothesisAssumption
setToast({ state: "error", message: t("ERROR_HYPOTHESIS_VALUE_SHOULD_NOT_BE_ZERO") });
return;
}
if (Object.keys(boundarySelections).length !== 0 && Object.values(boundarySelections)?.every((item) => item?.length !== 0))
if (Object.keys(boundarySelections).length !== 0 && Object.values(boundarySelections)?.some((item) => item?.length !== 0))
return setToast({ state: "error", message: t("HYPOTHESIS_CAN_BE_ONLY_APPLIED_ON_ADMIN_LEVEL_ZORO") });
setHypothesisAssumptionsList(tempHypothesisList);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,12 @@ const Upload = ({

const boundaryDataAgainstBoundaryCode = (await boundaryDataGeneration(schemaData, campaignData, t)) || {};
const mappedToList = resourceMappingData.map((item) => item.mappedTo);
if (hierarchy.every((item) => !mappedToList.includes(t(item)))) {
if (!schemaData.doHierarchyCheckInUploadedData && hierarchy.some((item) => !mappedToList.includes(t(item)))) {
data.features.forEach((feature) => {
const boundaryCode = feature.properties.boundaryCode;
const boundaryCode = feature?.properties?.boundaryCode;
const additionalDetails = {};
for (let i = 0; i < hierarchy.length; i++) {
if (boundaryDataAgainstBoundaryCode[boundaryCode]?.[i] || boundaryDataAgainstBoundaryCode[boundaryCode]?.[i] === "") {
if (boundaryDataAgainstBoundaryCode?.[boundaryCode]?.[i] || boundaryDataAgainstBoundaryCode?.[boundaryCode]?.[i] === "") {
additionalDetails[hierarchy[i]] = boundaryDataAgainstBoundaryCode[boundaryCode][i];
} else {
additionalDetails[hierarchy[i]] = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const useHypothesis = (tempHypothesisList, hypothesisAssumptionsList) =>
// Handles the change in hypothesis value
const valueChangeHandler = (e, setTempHypothesisList, boundarySelections, setToast, t) => {
// Checks it the boundary filters at at root level ( given constraints )
if (Object.keys(boundarySelections).length !== 0 && Object.values(boundarySelections)?.every((item) => item?.length !== 0))
if (Object.keys(boundarySelections).length !== 0 && Object.values(boundarySelections)?.some((item) => item?.length !== 0))
return setToast({ state: "error", message: t("HYPOTHESIS_CAN_BE_ONLY_APPLIED_ON_ADMIN_LEVEL_ZORO") });

// validating user input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,21 @@ export const colorHeaders = async (workbook, headerList1, headerList2, headerLis
}
};

const addUniqueWorksheet = (workbook, sheetName) => {
let uniqueSheetName = sheetName;
let counter = 1;
while (workbook.getWorksheet(uniqueSheetName)) {
uniqueSheetName = `${sheetName} (${counter})`;
counter++;
}
return workbook.addWorksheet(uniqueSheetName);
};

export const formatTemplate = (template, workbook, t) => {
template.forEach(({ sheetName, data }) => {
// Create a new worksheet with properties
const worksheet = workbook.addWorksheet(sheetName);
// Create a new worksheet with properties and unique name
const worksheet = addUniqueWorksheet(workbook, sheetName);

let commonColumnIndex = -1;
data?.forEach((row, index) => {
const worksheetRow = worksheet.addRow(row);
Expand Down

0 comments on commit 540ed7a

Please sign in to comment.