Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeline update #1286

Open
wants to merge 2 commits into
base: IRS
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion micro-ui/web/micro-ui-internals/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"devDependencies": {
"@egovernments/digit-ui-libraries": "1.8.2-beta.6",
"@egovernments/digit-ui-module-workbench": "1.0.2-beta.7",
"@egovernments/digit-ui-components": "0.0.2-beta.19",
"@egovernments/digit-ui-components": "0.0.2-beta.25",
"@egovernments/digit-ui-module-core": "1.8.2-beta.12",
"@egovernments/digit-ui-module-utilities": "1.0.1-beta.30",
"@egovernments/digit-ui-react-components": "1.8.2-beta.11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/> -->
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].13/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].24/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<!-- added below css for hcm-workbench module inclusion-->
<!-- <link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" /> -->
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/micro-ui-internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"lodash": "4.17.21",
"microbundle-crl": "0.13.11",
"@egovernments/digit-ui-react-components": "1.8.2-beta.11",
"@egovernments/digit-ui-components": "0.0.2-beta.19",
"@egovernments/digit-ui-components": "0.0.2-beta.25",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "6.15.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.2-beta.11",
"@egovernments/digit-ui-components": "0.0.2-beta.19",
"@egovernments/digit-ui-components": "0.0.2-beta.25",
"@rjsf/core": "5.10.0",
"@rjsf/utils": "5.10.0",
"@rjsf/validator-ajv8": "5.10.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ const TimelineComponent = ({ campaignId, resourceId }) => {
};
}, [lastCompletedProcess]);

useEffect(() => {
if (lastCompletedProcess?.type === "campaign-creation") {
fetchUser(); // Fetch the user credentials again after the campaign is created
}
}, [lastCompletedProcess]);

const completedProcesses = progessTrack?.processTrack
.filter((process) => process.status === "completed" && process.showInUi === true)
.sort((a, b) => b.lastModifiedTime - a.lastModifiedTime)
Expand Down Expand Up @@ -245,51 +251,121 @@ const TimelineComponent = ({ campaignId, resourceId }) => {

// }, [progessTrack])

// return (
// <React.Fragment>
// <div className="timeline-user">
// {upcomingTimelines?.length > 0 || inProgressTimelines?.length > 0 ? (
// <TimelineMolecule>
// {/* <Timeline label={t("HCM_UPCOMING")} variant="upcoming" subElements={subElements2} className={"upcoming-timeline"} showConnector={true} /> */}

// {/* <Timeline
// label={t("HCM_CURRENT")}
// subElements={subElements}
// variant="inprogress"
// showConnector={true}
// /> */}
// {/* {subElements.length > 0 && <Timeline label={t("HCM_CURRENT")} subElements={subElements} variant="inprogress" showConnector={true} />} */}

// {upcomingTimelines?.map((timeline, index) => (
// <Timeline
// key={index}
// label={timeline?.label}
// subElements={timeline?.subElements}
// variant="upcoming"
// showConnector={true}
// className={"upcoming-timeline"}
// />
// ))}

// {inProgressTimelines?.map((timeline, index) => (
// <Timeline key={index} label={timeline?.label} subElements={timeline?.subElements} variant="inprogress" showConnector={true} />
// ))}

// {completedTimelines?.map((timeline, index) => (
// <Timeline key={index} label={timeline?.label} subElements={timeline?.subElements} variant="completed" showConnector={true} />
// ))}
// </TimelineMolecule>
// ) : (
// <TimelineMolecule
// initialVisibleCount={1}
// hideFutureLabel={true}
// viewLessLabelForPast={t("HCM_SHOW_LESS")}
// viewMoreLabelForPast={t("HCM_SHOW_MORE")}
// >
// {completedTimelines?.map((timeline, index) => (
// <Timeline key={index} label={timeline?.label} subElements={timeline?.subElements} variant="completed" showConnector={true} />
// ))}
// </TimelineMolecule>
// )}
// {userCredential && lastCompletedProcess?.type === "campaign-creation" && (
// <Button
// label={t("CAMPAIGN_DOWNLOAD_USER_CRED")}
// variation="primary"
// icon={"DownloadIcon"}
// type="button"
// className="campaign-download-template-btn hover"
// onClick={downloadUserCred}
// />
// )}
// </div>
// </React.Fragment>
// );

return (
<React.Fragment>
<div className="timeline-user">
{upcomingTimelines?.length > 0 || inProgressTimelines?.length > 0 ? (
<TimelineMolecule>
{/* <Timeline label={t("HCM_UPCOMING")} variant="upcoming" subElements={subElements2} className={"upcoming-timeline"} showConnector={true} /> */}

{/* <Timeline
label={t("HCM_CURRENT")}
subElements={subElements}
variant="inprogress"
showConnector={true}
/> */}
{/* {subElements.length > 0 && <Timeline label={t("HCM_CURRENT")} subElements={subElements} variant="inprogress" showConnector={true} />} */}

{upcomingTimelines?.map((timeline, index) => (
<Timeline
key={index}
label={timeline?.label}
subElements={timeline?.subElements}
variant="upcoming"
showConnector={true}
className={"upcoming-timeline"}
/>
))}

{inProgressTimelines?.map((timeline, index) => (
<Timeline key={index} label={timeline?.label} subElements={timeline?.subElements} variant="inprogress" showConnector={true} />
))}

{completedTimelines?.map((timeline, index) => (
<Timeline key={index} label={timeline?.label} subElements={timeline?.subElements} variant="completed" showConnector={true} />
))}
</TimelineMolecule>
) : (
{progessTrack ? (
<TimelineMolecule
initialVisibleCount={1}
hideFutureLabel={true}
viewLessLabelForPast={t("HCM_SHOW_LESS")}
viewMoreLabelForPast={t("HCM_SHOW_MORE")}
>
{completedTimelines?.map((timeline, index) => (
<Timeline key={index} label={timeline?.label} subElements={timeline?.subElements} variant="completed" showConnector={true} />
))}
{(() => {
const processesToRender = [];
let foundFirstFailed = false;

for (let i = 0; i < progessTrack?.processTrack?.length; i++) {
const process = progessTrack?.processTrack[i];
if (process.status === "failed") {
processesToRender.push(
<Timeline
key={i}
isError
label={t(formatLabel(process?.type))}
showDefaultValueForDate
subElements={[epochToDateTime(process.lastModifiedTime)]}
variant="completed"
/>
);
foundFirstFailed = true;
break;
} else {
if (process.showInUi) {
let variant = "completed";
if (process.status === "inprogress") {
variant = "inprogress";
} else if (process.status === "toBeCompleted") {
variant = "upcoming";
}

processesToRender.push(
<Timeline
key={i}
label={t(formatLabel(process?.type))}
subElements={[epochToDateTime(process.lastModifiedTime)]}
variant={variant}
showConnector={true}
/>
);
}
}
}
return processesToRender.reverse();
})()}
</TimelineMolecule>
) : (
<p></p> // You can replace this with a loading spinner or any other indicator
)}
{userCredential && lastCompletedProcess?.type === "campaign-creation" && (
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const useProjectUpdateWithBoundary = async ({ formData }) => {
const requests = formData.map((item) => {
return Digit.CustomService.getResponse({
url: "/health-project/v1/_update",
// url: "/health-project/v1/_update",
url: "/health-project/v1/_update", // todo should be picked up from globalconfig
body: {
Projects: [item],
isCascadingProjectDateUpdate: true,
},
}).then((res) => {
return res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,20 @@ function UpdateDatesWithBoundaries() {
let itemEndDate = item?.endDate;
let endDate = new Date(item?.endDate);
let endSecond = endDate?.getSeconds();
if (endSecond < 59) {
return {
...item,
endDate: itemEndDate + 1000,
};
} else {
return {
...item,
endDate: itemEndDate - 1000,
};
}
// if (endSecond < 59) {
// return {
// ...item,
// endDate: itemEndDate + 1000,
// };
// } else {
// return {
// ...item,
// endDate: itemEndDate - 1000,
// };
// }
});
const temp = await Digit.Hooks.campaign.useProjectUpdateWithBoundary({ formData: payload });
// const temp = await Digit.Hooks.campaign.useProjectUpdateWithBoundary({ formData: payload });
const temp = await Digit.Hooks.campaign.useProjectUpdateWithBoundary({ formData: formData?.dateWithBoundary });
// setShowToast({ isError: false, label: "DATE_UPDATED_SUCCESSFULLY" });
history.push(`/${window.contextPath}/employee/campaign/response?isSuccess=${true}`, {
message: t("ES_CAMPAIGN_DATE_CHANGE_WITH_BOUNDARY_SUCCESS"),
Expand All @@ -118,6 +119,7 @@ function UpdateDatesWithBoundaries() {
url: "/health-project/v1/_update",
body: {
Projects: [formData?.dateAndCycle],
isCascadingProjectDateUpdate: true,
},
});
// setShowToast({ isError: false, label: "DATE_UPDATED_SUCCESSFULLY" });
Expand Down
Loading