Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/campaign' into campaign-for-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ashish-egov committed Jul 31, 2024
2 parents 12d05a1 + 7212232 commit 8b68a55
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 123 deletions.
4 changes: 2 additions & 2 deletions micro-ui/web/micro-ui-internals/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"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.18",
"@egovernments/digit-ui-module-core": "1.8.2-beta.7",
"@egovernments/digit-ui-components": "0.0.2-beta.19",
"@egovernments/digit-ui-module-core": "1.8.2-beta.9",
"@egovernments/digit-ui-module-utilities": "1.0.1-beta.30",
"@egovernments/digit-ui-react-components": "1.8.2-beta.11",
"@egovernments/digit-ui-module-hcmworkbench":"0.0.38",
Expand Down
4 changes: 2 additions & 2 deletions micro-ui/web/micro-ui-internals/example/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
rel="stylesheet"
href="https://unpkg.com/@egovernments/[email protected]/dist/index.css"
/> -->
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].6/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].7/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].62-campaign/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].65-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.18",
"@egovernments/digit-ui-components": "0.0.2-beta.19",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "6.15.8",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/micro-ui-internals/packages/css/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-css",
"version": "1.0.62-campaign",
"version": "1.0.65-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 @@ -121,3 +121,8 @@
display: flex;
justify-content: space-between;
}
.upcoming-timeline{
.timeline-label{
color: #b1b4b6;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -545,3 +545,11 @@ tbody {
bottom: 2.25rem;
}
}
.table.campaign-table {
.header-dropdown-menu.showBottom {
min-width: 8.6rem;
}
}
.digit-card-component.bannerCard.removeBottomMargin.languageSelection{
width: unset !important;
}
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.18",
"@egovernments/digit-ui-components": "0.0.2-beta.19",
"@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 @@ -10,6 +10,7 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
// const { t } = useTranslation();
const ONE_DAY_IN_MS = 24 * 60 * 60 * 1000;
const today = Digit.Utils.date.getDate(Date.now());
const tomorrow = Digit.Utils.date.getDate(new Date(today).getTime() + ONE_DAY_IN_MS);
const [startDate, setStartDate] = useState(project?.startDate ? Digit.Utils.date.getDate(project?.startDate) : ""); // Set default start date to today
const [endDate, setEndDate] = useState(project?.endDate ? Digit.Utils.date.getDate(project?.endDate) : ""); // Default end date
const [cycleDates, setCycleDates] = useState(null);
Expand All @@ -28,6 +29,9 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
}, [project]);

const handleDateChange = ({ date, endDate = false, cycleDate = false, cycleIndex }) => {
if (typeof date === "undefined") {
return null;
}
if (!endDate) {
dateReducerDispatch({
type: "START_DATE",
Expand All @@ -44,6 +48,9 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
};

const handleCycleDateChange = ({ date, endDate = false, cycleIndex }) => {
if (typeof date === "undefined") {
return null;
}
if (!endDate) {
dateReducerDispatch({
type: "CYCLE_START_DATE",
Expand All @@ -54,7 +61,7 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
});
} else {
dateReducerDispatch({
type: "CYCYLE_END_DATE",
type: "CYCLE_END_DATE",
date: date,
item: project,
cycleIndex: cycleIndex,
Expand Down Expand Up @@ -83,7 +90,7 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
withoutLabel={true}
type="date"
value={startDate}
nonEditable={startDate?.length > 0 && today > startDate ? true : false}
nonEditable={startDate?.length > 0 && today >= startDate ? true : false}
placeholder={t("HCM_START_DATE")}
populators={
today >= startDate
Expand All @@ -96,15 +103,15 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
}
onChange={(d) => {
handleDateChange({
date: d,
date: d?.target?.value,
});
}}
/>
<FieldV1
withoutLabel={true}
type="date"
value={endDate}
nonEditable={endDate?.length > 0 && today > endDate ? true : false}
nonEditable={endDate?.length > 0 && today >= endDate ? true : false}
placeholder={t("HCM_END_DATE")}
populators={{
validation: {
Expand All @@ -116,7 +123,7 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
}}
onChange={(d) => {
handleDateChange({
date: d,
date: d?.target?.value,
endDate: true,
});
}}
Expand All @@ -135,29 +142,26 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
<FieldV1
withoutLabel={true}
type="date"
nonEditable={item?.startDate?.length > 0 && today > item?.startDate ? true : false}
nonEditable={item?.startDate?.length > 0 && today >= item?.startDate ? true : false}
value={item?.startDate}
placeholder={t("HCM_START_DATE")}
populators={
today >= item?.startDate
? {}
: {
validation: {
min:
index > 0
? cycleDates?.find((j) => j.cycleIndex == index)?.endDate &&
new Date(new Date(cycleDates?.find((j) => j.cycleIndex == index)?.endDate)?.getTime() + 86400000)
?.toISOString()
?.split("T")?.[0]
: startDate,
max: endDate,
},
}
}
populators={{
validation: {
min:
index > 0 && !isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index)?.endDate)?.getTime())
? new Date(new Date(cycleDates?.find((j) => j.cycleIndex == index)?.endDate)?.getTime() + ONE_DAY_IN_MS)
?.toISOString()
?.split("T")?.[0]
: today >= startDate
? tomorrow
: startDate,
max: endDate,
},
}}
onChange={(d) => {
// setStartValidation(true);
handleCycleDateChange({
date: d,
date: d?.target?.value,
cycleIndex: item?.cycleIndex,
});
}}
Expand All @@ -166,21 +170,26 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
withoutLabel={true}
type="date"
value={item?.endDate}
nonEditable={item?.endDate?.length > 0 && today > item?.endDate && today > cycleDates?.[index + 1]?.startDate ? true : false}
nonEditable={item?.endDate?.length > 0 && today >= item?.endDate && today >= cycleDates?.[index + 1]?.startDate ? true : false}
placeholder={t("HCM_END_DATE")}
populators={{
validation: {
min: cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate
? new Date(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime() + 86400000)
?.toISOString()
?.split("T")?.[0]
: null,
min:
!isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime()) &&
Digit.Utils.date.getDate(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime() + ONE_DAY_IN_MS) >
today
? new Date(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime() + ONE_DAY_IN_MS)
?.toISOString()
?.split("T")?.[0]
: today >= startDate
? tomorrow
: startDate,
max: endDate,
},
}}
onChange={(d) => {
handleCycleDateChange({
date: d,
date: d?.target?.value,
endDate: true,
cycleIndex: item?.cycleIndex,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const CampaignSummary = (props) => {
const cycleData = reverseDeliveryRemap(target, t);
return {
cards: [
isPreview
isPreview === "true"
? {
name: "timeline",
sections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const reducer = (state, action) => {
return item;
});
break;
case "CYCYLE_END_DATE":
case "CYCLE_END_DATE":
const cycleEndRemap = action?.cycles?.map((item, index) => {
if (item?.id === action?.cycleIndex) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const TimelineComponent = ({campaignId, resourceId}) => {
const { data: baseTimeOut } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "baseTimeOut" }]);

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

Expand Down Expand Up @@ -83,7 +84,7 @@ const TimelineComponent = ({campaignId, resourceId}) => {
const { data: progessTrack , refetch} = Digit.Hooks.useCustomAPIHook(reqCriteria);

const lastCompletedProcess = progessTrack?.processTrack
.filter((process) => process.status === "completed")
.filter((process) => process.status === "completed" && process.showInUi === true)
.reduce((latestProcess, currentProcess) => {
if (!latestProcess || currentProcess.lastModifiedTime > latestProcess.lastModifiedTime) {
return currentProcess;
Expand All @@ -109,29 +110,29 @@ const TimelineComponent = ({campaignId, resourceId}) => {


const completedProcesses = progessTrack?.processTrack
.filter(process => process.status === 'completed')
.filter(process => process.status === 'completed' && process.showInUi === true)
.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)),
label: t(formatLabel(process?.type)),
subElements: [epochToDateTime(process.lastModifiedTime)],
}));

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

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

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

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

// useEffect(()=>{
Expand Down Expand Up @@ -183,19 +184,30 @@ const TimelineComponent = ({campaignId, resourceId}) => {
<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}
/>
<Timeline
{/* <Timeline
label={ t(formatLabel(lastCompletedProcess?.type))}
subElements={[epochToDateTime(lastCompletedProcess?.lastModifiedTime)]}
variant="completed"
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}>
Expand All @@ -211,7 +223,7 @@ const TimelineComponent = ({campaignId, resourceId}) => {
</TimelineMolecule>
)
}
{userCredential && (
{userCredential && lastCompletedProcess?.type === "campaign-creation" && (
<Button
label={t("CAMPAIGN_DOWNLOAD_USER_CRED")}
variation="primary"
Expand Down
Loading

0 comments on commit 8b68a55

Please sign in to comment.