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

Hlm 6350 #1100

Merged
merged 9 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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]/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].60-campaign/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].61-campaign/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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-css",
"version": "1.0.60-campaign",
"version": "1.0.61-campaign",
"license": "MIT",
"main": "dist/index.css",
"author": "Jagankumar <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@
.headerWrapperClassName {
display: none;
}
.popup-close-svg {
display: none;
}
.whoLogo {
margin-top: -1rem;
margin-bottom: -1rem;
Expand Down Expand Up @@ -120,3 +117,8 @@
.digit-error{
z-index: 900;
}
.timeline-user{
display: flex;
flex-direction: row-reverse;
justify-content: space-between;
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ const CampaignSummary = (props) => {
component: "TimelineComponent",
props: {
campaignId: data?.[0]?.id,
resourceId: resourceIdArr
},
cardHeader: { value: t("TIMELINE"), inlineStyles: { marginTop: 0, fontSize: "1.5rem" } },
cardHeader: { value: t("HCM_TIMELINE"), inlineStyles: { marginTop: 0, fontSize: "1.5rem" } },
},
],
}: {},
Expand Down Expand Up @@ -491,7 +492,7 @@ const CampaignSummary = (props) => {
<>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<Header className="summary-header">{t("ES_TQM_SUMMARY_HEADING")}</Header>
{userCredential && (
{/* {userCredential && (
<Button
label={t("CAMPAIGN_DOWNLOAD_USER_CRED")}
variation="secondary"
Expand All @@ -500,7 +501,7 @@ const CampaignSummary = (props) => {
className="campaign-download-template-btn hover"
onButtonClick={downloadUserCred}
/>
)}
)} */}
</div>
<div className="campaign-summary-container">
<ViewComposer data={data} cardErrors={summaryErrors} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,75 @@ import React, { useState, useEffect, Fragment } from "react";
import { useTranslation } from "react-i18next";
import { Button } from "@egovernments/digit-ui-components";
import { LabelFieldPair } from "@egovernments/digit-ui-components";

const TimelineComponent = ({}) => {
import { downloadExcelWithCustomName } from "../utils";

function epochToDateTime(epoch) {
// Create a new Date object using the epoch time
const date = new Date(epoch );
// Extract the date components
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-based, so add 1
const day = String(date.getDate()).padStart(2, '0');

// Extract the time components
let hours = date.getHours();
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');

// Determine AM/PM and convert to 12-hour format
const ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
const formattedHours = String(hours).padStart(2, '0');

// Format the date and time
const formattedDate = `${day}/${month}/${year}`;
const formattedTime = `${formattedHours}:${minutes}:${seconds} ${ampm}`;

// Return the formatted date and time
return `${formattedDate} ${formattedTime}`;
}

const TimelineComponent = ({campaignId, resourceId}) => {
const { t } = useTranslation();
const tenantId = Digit.ULBService.getCurrentTenantId();
const searchParams = new URLSearchParams(location.search);
const isPreview = searchParams.get("preview");
const [showTimeLineButton, setShowTimelineButton] = useState(isPreview);
const [showTimeLine, setShowTimeline] = useState(!isPreview);
const campaignId = searchParams.get("id");
const [userCredential , setUserCredential] = useState(null);

const formatLabel = (label) => {
return `HCM_${label.replace(/-/g, "_").toUpperCase()}`;
};


const fetchUser = async () => {
const responseTemp = await Digit.CustomService.getResponse({
url: `/project-factory/v1/data/_search`,
body: {
SearchCriteria: {
tenantId: tenantId,
id: resourceId,
},
},
});

const response = responseTemp?.ResourceDetails?.map((i) => i?.processedFilestoreId);

if (response?.[0]) {
setUserCredential({ fileStoreId: response?.[0], customName: "userCredential" });
}
};

useEffect(()=>{
if(resourceId?.length>0){
fetchUser();
}
},[resourceId])

const downloadUserCred = async () => {
downloadExcelWithCustomName(userCredential);
};


const reqCriteria = {
url: `/project-factory/v1/project-type/getProcessTrack`,
params: {
Expand Down Expand Up @@ -49,45 +104,41 @@ const TimelineComponent = ({}) => {

const completedTimelines = completedProcesses?.map(process => ({
label: t(formatLabel(process.type)),
subElements: [Digit.Utils.date.convertEpochToDate(process.lastModifiedTime)],
subElements: [epochToDateTime(process.lastModifiedTime)],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep both date and time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function is taking both date and time.

}));

const inprogressProcesses = progessTrack?.processTrack
.filter(process => process.status === 'inprogress')
.map(process => ({ type: process.type, lastModifiedTime: process.lastModifiedTime }));

const subElements = inprogressProcesses?.length > 0
? inprogressProcesses.map(process => `${t(formatLabel(process.type))} , ${Digit.Utils.date.convertEpochToDate(process.lastModifiedTime)}`)
? inprogressProcesses.map(process => `${t(formatLabel(process.type))} , ${epochToDateTime(process.lastModifiedTime)}`)
: [];

const upcomingProcesses = progessTrack?.processTrack
.filter(process => process.status === "toBeCompleted")
.map(process => ({ type: process.type, lastModifiedTime: process.lastModifiedTime }));

const subElements2 = upcomingProcesses?.length > 0
? upcomingProcesses.map(process => `${t(formatLabel(process.type))} , ${Digit.Utils.date.convertEpochToDate(process.lastModifiedTime)}`)
? upcomingProcesses.map(process => `${t(formatLabel(process.type))} , ${epochToDateTime(process.lastModifiedTime)}`)
: [];



return (
<React.Fragment>
{showTimeLineButton && (
<div className="timeline-div">
<div className="timeline-button">{`${t("HCM_CAMPAIGN_CREATION_PROGRESS")}`}</div>
<div className="timeline-user">
{userCredential && (
<Button
type={"button"}
size={"large"}
variation={"secondary"}
label={t("HCM_VIEW_PROGRESS")}
onClick={() => {
setShowTimeline(true);
setShowTimelineButton(false);
}}
label={t("CAMPAIGN_DOWNLOAD_USER_CRED")}
variation="secondary"
icon={"DownloadIcon"}
type="button"
className="campaign-download-template-btn hover"
onClick={downloadUserCred}
/>
</div>
)}
{showTimeLine && (
)}
{
(subElements.length > 0 || subElements2.length > 0) ? (
<TimelineMolecule >
<Timeline label={t("HCM_UPCOMING")}
Expand All @@ -102,7 +153,7 @@ const TimelineComponent = ({}) => {
/>
<Timeline
label={ t(formatLabel(lastCompletedProcess?.type))}
subElements={[Digit.Utils.date.convertEpochToDate(lastCompletedProcess?.lastModifiedTime)]}
subElements={[epochToDateTime(lastCompletedProcess?.lastModifiedTime)]}
variant="completed"
showConnector={true}
/>
Expand All @@ -120,7 +171,8 @@ const TimelineComponent = ({}) => {
))}
</TimelineMolecule>
)
)}
}
</div>
</React.Fragment>
);
};
Expand Down
Loading
Loading