From ecd5fce6efa8b852dd5ae3f0e58ed4e542c752f3 Mon Sep 17 00:00:00 2001 From: ashish-egov <137176738+ashish-egov@users.noreply.github.com> Date: Tue, 27 Aug 2024 11:38:38 +0530 Subject: [PATCH] Update genericUtils.ts --- .../src/server/utils/genericUtils.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/utilities/project-factory/src/server/utils/genericUtils.ts b/utilities/project-factory/src/server/utils/genericUtils.ts index cdae44a85e1..a1b3beb6887 100644 --- a/utilities/project-factory/src/server/utils/genericUtils.ts +++ b/utilities/project-factory/src/server/utils/genericUtils.ts @@ -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}`); @@ -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);