Skip to content

Commit

Permalink
Update genericUtils.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ashish-egov authored Aug 27, 2024
1 parent 65f8883 commit ecd5fce
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions utilities/project-factory/src/server/utils/genericUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,9 @@ function setHiddenColumns(request: any, schema: any, localizationMap?: { [key: s
request.body.hiddenColumns = hiddenColumns;
}

async function createFacilitySheet(request: any, allFacilities: any[], localizationMap?: { [key: string]: string }) {
async function getSchemaBasedOnSource(request: any, isSourceMicroplan: boolean, resourceDistributionStrategy: string) {
const tenantId = request?.query?.tenantId;
const responseFromCampaignSearch = await getCampaignSearchResponse(request);
const isSourceMicroplan = checkIfSourceIsMicroplan(responseFromCampaignSearch?.CampaignDetails?.[0]);
const resourceDistributionStrategy = responseFromCampaignSearch?.CampaignDetails?.[0]?.additionalDetails?.resourceDistributionStrategy;
let schema;
let schema: any;
if (isSourceMicroplan) {
if (resourceDistributionStrategyTypes.includes(resourceDistributionStrategy)) {
schema = await callMdmsTypeSchema(request, tenantId, "facility", `MP-FACILITY-${resourceDistributionStrategy}`);
Expand All @@ -485,6 +482,13 @@ async function createFacilitySheet(request: any, allFacilities: any[], localizat
} else {
schema = await callMdmsTypeSchema(request, tenantId, "facility", "all");
}
return schema;
}

async function createFacilitySheet(request: any, allFacilities: any[], localizationMap?: { [key: string]: string }) {
const responseFromCampaignSearch = await getCampaignSearchResponse(request);
const isSourceMicroplan = checkIfSourceIsMicroplan(responseFromCampaignSearch?.CampaignDetails?.[0]);
let schema: any = await getSchemaBasedOnSource(request, isSourceMicroplan, responseFromCampaignSearch?.CampaignDetails?.[0]?.additionalDetails?.resourceDistributionStrategy);
const keys = schema?.columns;
setDropdownFromSchema(request, schema, localizationMap);
setHiddenColumns(request, schema, localizationMap);
Expand Down

0 comments on commit ecd5fce

Please sign in to comment.