-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/HCMPRE-1234: adding mapping screen for facility and user scre…
…en (#2012) * adding mapping screen for facility and user screen * Update health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadDataMappingWrapper.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: NabeelAyubee <nayubi7@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
4eea682
commit c35c899
Showing
15 changed files
with
1,804 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
health/micro-ui/web/micro-ui-internals/packages/css/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
.../micro-ui-internals/packages/modules/campaign-manager/src/components/DataUploadWrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { Card, Stepper, TextBlock } from "@egovernments/digit-ui-components"; | ||
import React, { Fragment, useEffect, useState } from "react"; | ||
import UploadData from "./UploadData"; | ||
import { useTranslation } from "react-i18next"; | ||
import UploadDataMappingWrapper from "./UploadDataMappingWrapper"; | ||
|
||
function DataUploadWrapper({ formData, props, onSelect }) { | ||
const { t } = useTranslation(); | ||
const { parentId, key: currentKey, ...queryParams } = Digit.Hooks.useQueryParams(); | ||
const categories = [ | ||
"HCM_UPLOAD_FACILITY", | ||
"HCM_UPLOAD_FACILITY_MAPPING", | ||
"HCM_UPLOAD_USER", | ||
"HCM_UPLOAD_USER_MAPPING", | ||
"HCM_UPLOAD_TARGET", | ||
"HCM_SUMMARY", | ||
]; | ||
const mappingCategories = ["HCM_UPLOAD_FACILITY_MAPPING", "HCM_UPLOAD_USER_MAPPING"]; | ||
const [currentStep, setCurrentStep] = useState(1); | ||
const currentCategories = categories?.[currentStep - 1]; | ||
const [key, setKey] = useState(() => { | ||
return currentKey ? parseInt(currentKey) : 1; | ||
}); | ||
const baseKey = 10; | ||
function updateUrlParams(params) { | ||
const url = new URL(window.location.href); | ||
Object.entries(params).forEach(([key, value]) => { | ||
url.searchParams.set(key, value); | ||
}); | ||
window.history.replaceState({}, "", url); | ||
} | ||
|
||
useEffect(() => { | ||
setKey(currentKey); | ||
setCurrentStep(currentKey - baseKey + 1); | ||
}, [currentKey]); | ||
|
||
useEffect(() => { | ||
updateUrlParams({ key: key }); | ||
window.dispatchEvent(new Event("checking")); | ||
}, [key]); | ||
|
||
const onStepClick = (currentStep) => { | ||
setCurrentStep(currentStep + 1); | ||
if (currentStep === 0) { | ||
setKey(10); | ||
} else if (currentStep === 1) { | ||
setKey(11); | ||
} else if (currentStep === 3) { | ||
setKey(13); | ||
} else if (currentStep === 4) { | ||
setKey(14); | ||
} else setKey(12); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className="container-full"> | ||
{!parentId && ( | ||
<div className="card-container"> | ||
<Card className="card-header-timeline"> | ||
<TextBlock subHeader={t("HCM_UPLOAD_DATA")} subHeaderClassName={"stepper-subheader"} wrapperClassName={"stepper-wrapper"} /> | ||
</Card> | ||
<Card className="stepper-card"> | ||
<Stepper customSteps={categories} currentStep={currentStep} onStepClick={onStepClick} direction={"vertical"} /> | ||
</Card> | ||
</div> | ||
)} | ||
{mappingCategories?.includes(currentCategories) ? ( | ||
<UploadDataMappingWrapper currentCategories={currentCategories} formData={formData} props={props} onSelect={onSelect} /> | ||
) : ( | ||
<UploadData formData={formData} props={props} onSelect={onSelect} /> | ||
)} | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default DataUploadWrapper; |
Oops, something went wrong.