Skip to content

Commit

Permalink
Updated the checklist manage screens
Browse files Browse the repository at this point in the history
  • Loading branch information
jagankumar-egov committed Oct 9, 2024
1 parent b47d9ed commit d11c006
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const enabledModules = [
"DSS",
"HRMS",
"Workbench",
"HCMWORKBENCH",
// "HCMWORKBENCH",
"Campaign",
// "Engagement", "NDSS","QuickPayLinks", "Payment",
"Utilities",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const UICustomizations = {
projectId: row?.projectId,
},
"",
`/${window.contextPath}/employee/campaign/checklist/search?name=${row?.campaignName}`
`/${window.contextPath}/employee/campaign/checklist/search?name=${row?.campaignName}&campaignId=${row?.id}`
);
const navEvent1 = new PopStateEvent("popstate");
window.dispatchEvent(navEvent1);
Expand Down Expand Up @@ -477,7 +477,7 @@ export const UICustomizations = {
campaignType: row?.projectType
},
"",
`/${window.contextPath}/employee/campaign/checklist/search?name=${row?.campaignName}`
`/${window.contextPath}/employee/campaign/checklist/search?name=${row?.campaignName}&campaignId=${row?.id}`
);
const navEvent1 = new PopStateEvent("popstate");
window.dispatchEvent(navEvent1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,65 +1,45 @@
import {
Header,
InboxSearchComposer,

} from "@egovernments/digit-ui-react-components";
import { Dropdown, ViewCardFieldPair,Toast, Card, TextBlock, Button, PopUp, CardText} from "@egovernments/digit-ui-components";
import { Header, InboxSearchComposer } from "@egovernments/digit-ui-react-components";
import { Dropdown, ViewCardFieldPair, Toast, Card, TextBlock, Button, PopUp, CardText, Stepper } from "@egovernments/digit-ui-components";
import React, { useState, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { useHistory } from 'react-router-dom';
import { useHistory } from "react-router-dom";
import { checklistSearchConfig } from "../../configs/checklistSearchConfig";
import useCreateChecklist from "../../hooks/useCreateChecklist";

const defaultSearchValues = {
// Field: { label: "Name", opt: "name" },
// Value: "",
};

const SearchChecklist = () => {
const { t } = useTranslation();
const history = useHistory(); // Get history object for navigation
const [defaultValues, setDefaultValues] = useState(defaultSearchValues); // State to hold default values for search fields
const indConfigs = checklistSearchConfig;
const [showPopUp, setShowPopUp] = useState(false);
const tenantId = Digit.ULBService.getCurrentTenantId();

const [types, setTypes] = useState([]);
const [error, setError] = useState(null);
const searchParams = new URLSearchParams(location.search);
const id = searchParams.get("campaignId");

const { mutate, data } = Digit.Hooks.campaign.useTypeOfChecklist(tenantId);
const stateData = window.history.state;

// TODO.. CHANGE WHAT HAPPENS ON CLICING SEARCH RESULT ROW
const onClickRow = (row) =>{
// add code here
}
const onClickRow = (row) => {
// add code here
};

const makeNewChecklist = ()=> {
setShowPopUp(true);
const makeNewChecklist = () => {
setShowPopUp(true);
};

const createNewChecklist = ()=>{
window.history.pushState(
{
},
"",
const createNewChecklist = () => {
history.push(
`/${window.contextPath}/employee/campaign/checklist/create?checklistType=${list?.list}&campaignName=${stateData?.name}&role=${code?.code}&campaignType=${stateData?.campaignType}`
);
const navEvent1 = new PopStateEvent("popstate");
window.dispatchEvent(navEvent1);


}
};

const userinfo = Digit.UserService.getUser();
const [codesopt, setCodesOpt] = useState([]);
const { data: dataBT } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "rolesForChecklist" }]);
useEffect(()=>{
if(dataBT) setCodesOpt(dataBT["HCM-ADMIN-CONSOLE"]?.rolesForChecklist?.map(item => ({ code: t(`ACCESSCONTROL_ROLES_ROLES_${item.code}`)})));
useEffect(() => {
if (dataBT) setCodesOpt(dataBT["HCM-ADMIN-CONSOLE"]?.rolesForChecklist?.map((item) => ({ code: t(`ACCESSCONTROL_ROLES_ROLES_${item.code}`) })));
}, [dataBT]);

// const codesopt = userinfo?.info?.roles?.map(item => ({ code: t(`ACCESSCONTROL_ROLES_ROLES_${item.code}`)}));
// const codesopt = dataBT?.HCM-ADMIN-CONSOLE?.rolesForChecklist?.map(item => ({ code: t(`ACCESSCONTROL_ROLES_ROLES_${item.code}`)}));
const [listsopt, setListsOpt] = useState([]);
const reqCriteriaResource = {
url: `/mdms-v2/v1/_search`,
Expand All @@ -71,12 +51,12 @@ const SearchChecklist = () => {
moduleName: "HCM",
masterDetails: [
{
name: "CHECKLIST_TYPES"
}
]
}
]
}
name: "CHECKLIST_TYPES",
},
],
},
],
},
},
config: {
enabled: true,
Expand All @@ -86,51 +66,62 @@ const SearchChecklist = () => {
},
};
const { isLoading, data: HCM, isFetching } = Digit.Hooks.useCustomAPIHook(reqCriteriaResource);

useEffect(()=>{
setListsOpt(HCM?.HCM?.CHECKLIST_TYPES?.map(item => ({list:t(`HCM_CHECKLIST_TYPE_${item.code}`)})));
const onStepClick = (step) => {
history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${id}&preview=true&action=false&actionBar=true&key=13&summary=true`);
};
useEffect(() => {
setListsOpt(HCM?.HCM?.CHECKLIST_TYPES?.map((item) => ({ list: t(`HCM_CHECKLIST_TYPE_${item.code}`) })));
}, [HCM]);

const [code, setCode] = useState(null);
const [list, setList] = useState(null)
const [list, setList] = useState(null);
const handleUpdateCode = (data) => {
setCode(data);
};
const handleUpdateList = (data)=>{
const handleUpdateList = (data) => {
setList(data);
}
checklistSearchConfig[0].sections.search.uiConfig.fields[0].populators.options=codesopt;
checklistSearchConfig[0].sections.search.uiConfig.fields[1].populators.options=listsopt;
};

checklistSearchConfig[0].sections.search.uiConfig.fields[0].populators.options = codesopt;
checklistSearchConfig[0].sections.search.uiConfig.fields[1].populators.options = listsopt;

if(isFetching)
return (<div></div>)
else
{
if (isFetching) return <div></div>;
else {
return (
<React.Fragment>
<div style={{display:"flex", justifyContent:"space-between"}}>
<Header styles={{ fontSize: "32px", marginBottom:"2rem", marginTop:"2rem"}}>{"Manage Checklist for your campaign"}</Header>
<Stepper
customSteps={[
"HCM_CAMPAIGN_SETUP_DETAILS",
"HCM_BOUNDARY_DETAILS",
"HCM_DELIVERY_DETAILS",
"HCM_UPLOAD_DATA",
"HCM_REVIEW_DETAILS",
"ACTION_LABEL_CONFIGURE_APP",
]}
currentStep={6}
onStepClick={onStepClick}
activeSteps={6}
/>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<Header styles={{ fontSize: "32px", marginBottom: "2rem", marginTop: "2rem" }}>{"ACTION_LABEL_CONFIGURE_APP"}</Header>
<Button
variation="secondary"
label={t("ADD_NEW_CHECKLIST")}
className={"hover"}
style={{marginTop:"2rem", marginBottom:"2rem"}}
// icon={<AddIcon style={{ height: "1.5rem", width: "1.5rem" }} fill={PRIMARY_COLOR} />}
style={{ marginTop: "2rem", marginBottom: "2rem" }}
onClick={makeNewChecklist}
/>
/>
{showPopUp && (
<PopUp
className={"boundaries-pop-module"}
type={"default"}
heading={t("CREATE_CHECKLIST")}
children={[
// <div>
// <CardText style={{ margin: 0 }}>{"testing" + " "}</CardText>
// </div>,
]}
children={
[
]
}
style={{
height:"30rem"
height: "30rem",
}}
onOverlayClick={() => {
setShowPopUp(false);
Expand All @@ -154,58 +145,66 @@ const SearchChecklist = () => {
variation={"primary"}
label={t("CREATE_CHECKLIST")}
onClick={() => {
// onSubmit(null, 1, tempFormData);
createNewChecklist();
}}
/>,
]}
sortFooterChildren={true}
>
<div>
<div style={{display:"flex", justifyContent:"space-between"}}>
<span>{"Select Role"}</span>
<Dropdown
style={{ width: "50%" }}
option={codesopt}
optionKey={"code"}
select={(value) => {
handleUpdateCode(value,)
}}
placeholder="Type"
/>
</div>
<div style={{height:"1rem"}}></div>
<div style={{display:"flex", justifyContent:"space-between"}}>
<span>{t("SELECT_CHECKLIST_TYPE")}</span>
<Dropdown
style={{ width: "50%" }}
option={listsopt}
optionKey={"list"}
select={(value) => {
handleUpdateList(value,)
}}
placeholder="Type"
/>
</div>
</div>
<div>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<span>{t("HCM_CHECKLIST_ROLE")}</span>
<Dropdown
style={{ width: "50%" }}
option={codesopt}
optionKey={"code"}
select={(value) => {
handleUpdateCode(value);
}}
placeholder="Type"
/>
</div>
<div style={{ height: "1rem" }}></div>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<span>{t("SELECT_CHECKLIST_TYPE")}</span>
<Dropdown
style={{ width: "50%" }}
option={listsopt}
optionKey={"list"}
select={(value) => {
handleUpdateList(value);
}}
placeholder="Type"
/>
</div>
</div>
</PopUp>
)}
</div>

<div className="inbox-search-wrapper">
{/* Pass defaultValues as props to InboxSearchComposer */}
<InboxSearchComposer configs={checklistSearchConfig?.[0]}
// defaultValues={defaultValues}
additionalConfig={{
resultsTable: {
onClickRow,
},
}}
>
</InboxSearchComposer>
</div>
<div className="container">
<div className="card-container">
<Card className="card-header-timeline">
<TextBlock subHeader={t("ACTION_LABEL_CONFIGURE_APP")} subHeaderClasName={"stepper-subheader"} wrapperClassName={"stepper-wrapper"} />
</Card>
<Card className="stepper-card">
<Stepper customSteps={["HCM_MANAGE_CHECKLIST"]} currentStep={1} onStepClick={() => {}} direction={"vertical"} />
</Card>
</div>
<div className="inbox-search-wrapper" style={{ width: "100%" }}>
{/* Pass defaultValues as props to InboxSearchComposer */}
<InboxSearchComposer
configs={checklistSearchConfig?.[0]}
// defaultValues={defaultValues}
additionalConfig={{
resultsTable: {
onClickRow,
},
}}
></InboxSearchComposer>
</div>
</div>
</React.Fragment>
);
};
}
};
export default SearchChecklist;
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,23 @@ const CampaignBreadCrumb = ({ location, defaultPath }) => {
{
path: pathVar === "my-campaign" ? "" : `/${window?.contextPath}/employee/campaign/my-campaign`,
content: t("MY_CAMPAIGN"),
show: pathVar === "my-campaign" ? true : false,
show: pathVar === "my-campaign" || pathVar === "checklist/search" ? true : false,
},
{
path: pathVar === "setup-campaign" ? "" : `/${window?.contextPath}/employee/campaign/setup-campaign`,
content: t("CREATE_NEW_CAMPAIGN"),
show: pathVar === "setup-campaign" ? true : false,
show: pathVar === "setup-campaign" ? true : false,
},
{
path: pathVar === "update-dates-boundary" ? "" : `/${window?.contextPath}/employee/campaign/my-campaign`,
content: t("UPDATE_DATE_CHANGE"),
show: pathVar === "update-dates-boundary" ? true: false,
},
{
path: "",
content: t("ACTION_LABEL_CONFIGURE_APP"),
show:pathVar === "checklist/search" ? true : false,
}
];

return <BreadCrumb className="campaign-breadcrumb" crumbs={crumbs} spanStyle={{ maxWidth: "min-content" }} />;
Expand Down

0 comments on commit d11c006

Please sign in to comment.