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 6 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.5",
"@egovernments/digit-ui-module-workbench": "1.0.2-beta.3",
"@egovernments/digit-ui-components": "0.0.2-beta.13",
"@egovernments/digit-ui-components": "0.0.2-beta.14",
"@egovernments/digit-ui-module-core": "1.8.2-beta.6",
"@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 @@ -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" /> -->

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.13",
"@egovernments/digit-ui-components": "0.0.2-beta.14",
"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
@@ -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]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,36 +77,39 @@
gap: 0.5rem;
margin-bottom: 0.5rem;
}
.infoClass{
margin-bottom: 1.5rem
.infoClass {
margin-bottom: 1.5rem;
}
.headerWrapperClassName{
display: none
}
.popup-close-svg{
.headerWrapperClassName {
display: none;
}
.whoLogo{

.whoLogo {
margin-top: -1rem;
margin-bottom: -1rem;
}

.digit-popup-wrapper{
&.popUpClass{
width:45rem;
.digit-popup-wrapper {
&.popUpClass {
width: 45rem;

.popUpFooter{
.digit-popup-footer-buttons{
.popUpFooter {
.digit-popup-footer-buttons {
margin-left: 0px;
width: 100%;

button{
flex:1;
button {
flex: 1;
}
}
}
}
}
.timeline-div {
display: flex;
justify-content: space-between;
align-items: center;
}
.setup-campaign{
.digit-success{
z-index: 1000;
Expand All @@ -115,3 +118,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 @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.2-beta.11",
"@egovernments/digit-ui-components": "0.0.2-beta.13",
"@egovernments/digit-ui-components": "0.0.2-beta.14",
"@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 @@ -27,6 +27,7 @@ import CampaignResourceDocuments from "./components/CampaignResourceDocuments";
import ConfigureApp from "./pages/employee/ConfigureApp";
import SideEffects from "./components/ConfigureApp/SideEffect";
import SideEffectType from "./components/ConfigureApp/SideEffectType";
import TimelineComponent from "./components/TimelineComponent";
import { DSSCard } from "./components/DSSCard";
import UpdateDatesWithBoundaries from "./pages/employee/UpdateDatesWithBoundaries";
import DateWithBoundary from "./components/DateWithBoundary";
Expand Down Expand Up @@ -97,7 +98,8 @@ const componentsToRegister = {
UpdateDatesWithBoundaries,
DateWithBoundary,
BoundaryWithDate,
DateAndCycleUpdate
DateAndCycleUpdate,
TimelineComponent
};

const overrideHooks = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const CampaignSummary = (props) => {
const [userErrors, setUserErrors] = useState(null);
const [cycleDatesError, setCycleDatesError] = useState(null);
const [summaryErrors, setSummaryErrors] = useState(null);
const isPreview = searchParams.get("preview");
const handleRedirect = (step, activeCycle) => {
const urlParams = new URLSearchParams(window.location.search);
const id = urlParams.get("id");
Expand Down Expand Up @@ -221,6 +222,23 @@ const CampaignSummary = (props) => {
const cycleData = reverseDeliveryRemap(target, t);
return {
cards: [
isPreview
?
{
name: "timeline",
sections: [
{
name: "timeline",
type: "COMPONENT",
component: "TimelineComponent",
props: {
campaignId: data?.[0]?.id,
resourceId: resourceIdArr
},
cardHeader: { value: t("HCM_TIMELINE"), inlineStyles: { marginTop: 0, fontSize: "1.5rem" } },
},
],
}: {},
{
sections: [
{
Expand Down Expand Up @@ -474,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 @@ -483,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
@@ -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)],
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))} , ${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;
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ const UploadData = ({ formData, onSelect, ...props }) => {
// { name: "Boundary" },
// ]);

const { data: Schemas, isLoading: isThisLoading } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "adminSchema" }] , {} ,{schemaCode: "HCM-ADMIN-CONSOLE.adminSchema"});
const { data: Schemas, isLoading: isThisLoading } = Digit.Hooks.useCustomMDMS(
tenantId,
"HCM-ADMIN-CONSOLE",
[{ name: "adminSchema" }],
{},
{ schemaCode: "HCM-ADMIN-CONSOLE.adminSchema" }
);

const { data: readMe } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "ReadMeConfig" }]);
const { data: baseTimeOut } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "baseTimeout" }]);
Expand Down Expand Up @@ -178,13 +184,17 @@ const UploadData = ({ formData, onSelect, ...props }) => {

useEffect(async () => {
if (Schemas?.MdmsRes?.["HCM-ADMIN-CONSOLE"]?.adminSchema) {
const facility = await convertIntoSchema(Schemas?.MdmsRes?.["HCM-ADMIN-CONSOLE"]?.adminSchema?.filter((item) => item.title === "facility" && item.campaignType === "all")?.[0]);
const facility = await convertIntoSchema(
Schemas?.MdmsRes?.["HCM-ADMIN-CONSOLE"]?.adminSchema?.filter((item) => item.title === "facility" && item.campaignType === "all")?.[0]
);
const boundary = await convertIntoSchema(
Schemas?.MdmsRes?.["HCM-ADMIN-CONSOLE"]?.adminSchema?.filter(
(item) => item.title === "boundaryWithTarget" && item.campaignType === totalData?.HCM_CAMPAIGN_TYPE?.projectType?.code
)?.[0]
);
const user = await convertIntoSchema(Schemas?.MdmsRes?.["HCM-ADMIN-CONSOLE"]?.adminSchema?.filter((item) => item.title === "user" && item.campaignType === "all")?.[0]);
const user = await convertIntoSchema(
Schemas?.MdmsRes?.["HCM-ADMIN-CONSOLE"]?.adminSchema?.filter((item) => item.title === "user" && item.campaignType === "all")?.[0]
);
const schema = {
boundary: boundary,
facilityWithBoundary: facility,
Expand Down
Loading