-
Notifications
You must be signed in to change notification settings - Fork 19
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
Hlm 6350 #1100
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8e109a4
timeline wip
Bhavya-egov 881259a
Merge branch 'campaign' into HLM-6350
Bhavya-egov 3ffb86e
added timeline from summary
Bhavya-egov fd00a28
Merge branch 'campaign' into HLM-6350
Bhavya-egov dda7094
removed log
Bhavya-egov 682f38d
integrated timeline with popup
Bhavya-egov 0b17108
Merge branch 'campaign' into HLM-6350
Bhavya-egov c485ed3
updated version
Bhavya-egov 7b3e48e
updated css version
Bhavya-egov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -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].59-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" /> --> | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@egovernments/digit-ui-css", | ||
"version": "1.0.59-campaign", | ||
"version": "1.0.61-campaign", | ||
"license": "MIT", | ||
"main": "dist/index.css", | ||
"author": "Jagankumar <[email protected]>", | ||
|
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
180 changes: 180 additions & 0 deletions
180
.../micro-ui-internals/packages/modules/campaign-manager/src/components/TimelineComponent.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,180 @@ | ||
import { Timeline, TimelineMolecule } from "@egovernments/digit-ui-components"; | ||
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"; | ||
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 [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: { | ||
campaignId: campaignId, | ||
}, | ||
}; | ||
// use refetch interval in this | ||
const { data: progessTrack , refetch} = Digit.Hooks.useCustomAPIHook(reqCriteria); | ||
useEffect(() => { | ||
const intervalId = setInterval(() => { | ||
refetch(); | ||
}, 60000); // 60000ms = 1 minute | ||
|
||
return () => clearInterval(intervalId); | ||
}, [refetch]); | ||
|
||
const lastCompletedProcess = progessTrack?.processTrack | ||
.filter((process) => process.status === "completed") | ||
.reduce((latestProcess, currentProcess) => { | ||
if (!latestProcess || currentProcess.lastModifiedTime > latestProcess.lastModifiedTime) { | ||
return currentProcess; | ||
} | ||
return latestProcess; | ||
}, null); | ||
|
||
const completedProcesses = progessTrack?.processTrack | ||
.filter(process => process.status === 'completed') | ||
.sort((a, b) => b.lastModifiedTime - a.lastModifiedTime) | ||
.map(process => ({ type: process.type, lastModifiedTime: process.lastModifiedTime })); | ||
|
||
const completedTimelines = completedProcesses?.map(process => ({ | ||
label: t(formatLabel(process.type)), | ||
subElements: [epochToDateTime(process.lastModifiedTime)], | ||
})); | ||
|
||
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))} , ${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))} , ${epochToDateTime(process.lastModifiedTime)}`) | ||
: []; | ||
|
||
|
||
|
||
return ( | ||
<React.Fragment> | ||
<div className="timeline-user"> | ||
{userCredential && ( | ||
<Button | ||
label={t("CAMPAIGN_DOWNLOAD_USER_CRED")} | ||
variation="secondary" | ||
icon={"DownloadIcon"} | ||
type="button" | ||
className="campaign-download-template-btn hover" | ||
onClick={downloadUserCred} | ||
/> | ||
)} | ||
{ | ||
(subElements.length > 0 || subElements2.length > 0) ? ( | ||
<TimelineMolecule > | ||
<Timeline label={t("HCM_UPCOMING")} | ||
variant="upcoming" | ||
subElements={subElements2} | ||
showConnector={true} /> | ||
<Timeline | ||
label={t("HCM_CURRENT")} | ||
subElements={subElements} | ||
variant="inprogress" | ||
showConnector={true} | ||
/> | ||
<Timeline | ||
label={ t(formatLabel(lastCompletedProcess?.type))} | ||
subElements={[epochToDateTime(lastCompletedProcess?.lastModifiedTime)]} | ||
variant="completed" | ||
showConnector={true} | ||
/> | ||
</TimelineMolecule> | ||
) : ( | ||
<TimelineMolecule initialVisibleCount={1} hideFutureLabel ={true}> | ||
{completedTimelines?.map((timeline, index) => ( | ||
<Timeline | ||
key={index} | ||
label={timeline?.label} | ||
subElements={timeline?.subElements} | ||
variant="completed" | ||
showConnector={true} | ||
/> | ||
))} | ||
</TimelineMolecule> | ||
) | ||
} | ||
</div> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default TimelineComponent; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.