diff --git a/micro-ui/web/micro-ui-internals/example/package.json b/micro-ui/web/micro-ui-internals/example/package.json index 50ad45ff778..e706f047a47 100644 --- a/micro-ui/web/micro-ui-internals/example/package.json +++ b/micro-ui/web/micro-ui-internals/example/package.json @@ -12,7 +12,7 @@ "@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.19", - "@egovernments/digit-ui-module-core": "1.8.2-beta.8", + "@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", diff --git a/micro-ui/web/micro-ui-internals/example/public/index.html b/micro-ui/web/micro-ui-internals/example/public/index.html index a69003b67f2..49e6287a4ab 100644 --- a/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/micro-ui/web/micro-ui-internals/example/public/index.html @@ -14,7 +14,7 @@ rel="stylesheet" href="https://unpkg.com/@egovernments/digit-ui-css@1.8.0-alpha.6/dist/index.css" /> --> - + diff --git a/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss b/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss index db6f6a1d271..9e9cf52f732 100644 --- a/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss +++ b/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss @@ -550,3 +550,6 @@ tbody { min-width: 8.6rem; } } +.digit-card-component.bannerCard.removeBottomMargin.languageSelection{ + width: unset; +} \ No newline at end of file diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundaryWithDate.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundaryWithDate.js index ed0dc797b8f..9191c5c352b 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundaryWithDate.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundaryWithDate.js @@ -28,6 +28,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", @@ -44,6 +47,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", @@ -54,7 +60,7 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe }); } else { dateReducerDispatch({ - type: "CYCYLE_END_DATE", + type: "CYCLE_END_DATE", date: date, item: project, cycleIndex: cycleIndex, @@ -96,7 +102,7 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe } onChange={(d) => { handleDateChange({ - date: d, + date: d?.target?.value, }); }} /> @@ -116,7 +122,7 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe }} onChange={(d) => { handleDateChange({ - date: d, + date: d?.target?.value, endDate: true, }); }} @@ -138,26 +144,23 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe 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 + ? today + : startDate, + max: endDate, + }, + }} onChange={(d) => { // setStartValidation(true); handleCycleDateChange({ - date: d, + date: d?.target?.value, cycleIndex: item?.cycleIndex, }); }} @@ -170,17 +173,19 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe 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) + min: !isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime()) + ? new Date(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime() + ONE_DAY_IN_MS) ?.toISOString() ?.split("T")?.[0] - : null, + : today >= startDate + ? today + : startDate, max: endDate, }, }} onChange={(d) => { handleCycleDateChange({ - date: d, + date: d?.target?.value, endDate: true, cycleIndex: item?.cycleIndex, }); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DateWithBoundary.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DateWithBoundary.js index 5c2ba3d6379..49bd71a2e76 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DateWithBoundary.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DateWithBoundary.js @@ -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 { diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/DateAndCycleUpdate.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/DateAndCycleUpdate.js index 61245b4f406..093e201d774 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/DateAndCycleUpdate.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/DateAndCycleUpdate.js @@ -30,7 +30,7 @@ const reducer = (state, action) => { if (item?.id === action?.cycleIndex) { return { ...item, - startDate: Digit.Utils.pt.convertDateToEpoch(action?.date, "dayStart"), + startDate: Digit.Utils.pt.convertDateToEpoch(typeof action?.date === "string" ? action?.date : null, "dayStart"), }; } return item; @@ -46,7 +46,7 @@ const reducer = (state, action) => { }, }; break; - case "CYCYLE_END_DATE": + case "CYCLE_END_DATE": const cycleEndRemap = action?.cycles?.map((item, index) => { if (item?.id === action?.cycleIndex) { return { @@ -116,14 +116,16 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => { useEffect(() => { if (dateReducer) { - setStartDate(Digit.Utils.date.getDate(dateReducer?.startDate)); - setEndDate(Digit.Utils.date.getDate(dateReducer?.endDate)); + setStartDate(dateReducer?.startDate ? Digit.Utils.date.getDate(dateReducer?.startDate) : ""); + setEndDate(dateReducer?.endDate ? Digit.Utils.date.getDate(dateReducer?.endDate) : ""); if (dateReducer?.additionalDetails?.projectType?.cycles?.length > 0) { - const cycleDateData = dateReducer?.additionalDetails?.projectType?.cycles?.map((cycle) => ({ - cycleIndex: cycle.id, - startDate: Digit.Utils.date.getDate(cycle.startDate), - endDate: Digit.Utils.date.getDate(cycle.endDate), - })); + const cycleDateData = dateReducer?.additionalDetails?.projectType?.cycles?.map((cycle) => { + return { + cycleIndex: cycle.id, + startDate: cycle.startDate ? Digit.Utils.date.getDate(cycle.startDate) : "", + endDate: cycle.endDate ? Digit.Utils.date.getDate(cycle.endDate) : "", + }; + }); setCycleDates(cycleDateData); } } @@ -139,7 +141,7 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => { }, [isLoading, projectData]); const handleDateChange = ({ date, endDate = false, cycleDate = false, cycleIndex }) => { - if (!date || date <= today) { + if (typeof date === "undefined") { return null; } if (!endDate) { @@ -158,7 +160,7 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => { }; const handleCycleDateChange = ({ date, endDate = false, cycleIndex }) => { - if (!date || date <= today) { + if (typeof date === "undefined") { return null; } if (!endDate) { @@ -171,7 +173,7 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => { }); } else { dateReducerDispatch({ - type: "CYCYLE_END_DATE", + type: "CYCLE_END_DATE", date: date, item: dateReducer, cycleIndex: cycleIndex, @@ -182,17 +184,18 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => { return ( {t(`UPDATE_DATE_AND_CYCLE_HEADER`)} - + {t(`HCM_CAMPAIGN_DATES`)} * = startDate ? true : false} + nonEditable={startDate && startDate?.length > 0 && today >= startDate ? true : false} placeholder={t("HCM_START_DATE")} populators={ today >= startDate @@ -205,31 +208,28 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => { } onChange={(d) => { handleDateChange({ - date: d, + date: d?.target?.value, }); }} /> = endDate ? true : false} + nonEditable={endDate && endDate?.length > 0 && today >= endDate ? true : false} placeholder={t("HCM_END_DATE")} - populators={ - today >= endDate - ? {} - : { - validation: { - min: - startDate && startDate > today - ? Digit.Utils.date.getDate(new Date(startDate).getTime() + 2 * ONE_DAY_IN_MS) - : Digit.Utils.date.getDate(Date.now() + 2 * ONE_DAY_IN_MS), - }, - } - } + populators={{ + validation: { + min: + startDate && startDate > today + ? Digit.Utils.date.getDate(new Date(startDate).getTime() + 2 * ONE_DAY_IN_MS) + : Digit.Utils.date.getDate(Date.now() + 2 * ONE_DAY_IN_MS), + }, + }} onChange={(d) => { handleDateChange({ - date: d, + date: d?.target?.value, endDate: true, }); }} @@ -246,57 +246,55 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => { = item?.startDate ? true : false} + nonEditable={item?.startDate && item?.startDate?.length > 0 && today >= item?.startDate ? true : false} placeholder={t("HCM_START_DATE")} - populators={ - today >= item?.startDate - ? {} - : { - validation: { - min: - index > 0 - ? 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 + ? today + : startDate, + max: endDate, + }, + }} onChange={(d) => { // setStartValidation(true); handleCycleDateChange({ - date: d, + date: d?.target?.value, cycleIndex: item?.cycleIndex, }); }} /> = item?.endDate ? true : false} + nonEditable={item?.endDate && item?.endDate?.length > 0 && today >= item?.endDate ? true : false} placeholder={t("HCM_END_DATE")} - populators={ - today >= item?.endDate - ? {} - : { - 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, - max: endDate, - }, - } - } + populators={{ + validation: { + min: !isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime()) + ? new Date(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime() + ONE_DAY_IN_MS) + ?.toISOString() + ?.split("T")?.[0] + : today >= startDate + ? today + : startDate, + max: endDate, + }, + }} onChange={(d) => { handleCycleDateChange({ - date: d, + date: d?.target?.value, endDate: true, cycleIndex: item?.cycleIndex, }); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateDatesWithBoundaries.js b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateDatesWithBoundaries.js index 07ae457fe7f..07a67e84f4d 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateDatesWithBoundaries.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateDatesWithBoundaries.js @@ -32,9 +32,41 @@ function UpdateDatesWithBoundaries() { } }, [showToast]); + const checkValid = (data) => { + if (DateWithBoundary) { + const temp = data?.dateWithBoundary; + const allCycleDateValid = temp + .map((i) => i.additionalDetails.projectType.cycles.every((j) => j.startDate && j.endDate)) + .every((k) => k === true); + const allDateValid = temp.every((i) => i.startDate && i.endDate); + + if (allCycleDateValid && allDateValid) { + return true; + } + return false; + } else if (!DateWithBoundary) { + const cycleDateValid = data?.dateAndCycle?.additionalDetails?.projectType?.cycles?.every((item) => item?.startDate && item?.endDate); + if (data?.dateAndCycle?.startDate && data?.dateAndCycle?.endDate && cycleDateValid) { + return true; + } + return false; + } + }; const onSubmit = async (formData) => { - if (!formData?.dateWithBoundary || formData?.dateWithBoundary?.length === 0) { - setShowToast({ isError: true, label: "SELECT_BOUNDARY_LEVEL_ERROR" }); + if (DateWithBoundary) { + if (!formData?.dateWithBoundary || !Array.isArray(formData?.dateWithBoundary) || formData?.dateWithBoundary?.length === 0) { + setShowToast({ isError: true, label: "SELECT_BOUNDARY_LEVEL_ERROR" }); + return; + } + } else if (!DateWithBoundary) { + if (!formData?.dateAndCycle) { + setShowToast({ isError: true, label: "SELECT_DATE_CHANGE_MANDATORY_ERROR" }); + return; + } + } + let isValid = checkValid(formData); + if (!isValid) { + setShowToast({ isError: true, label: "UPDATE_DATE_MANDATORY_FIELDS_MISSING" }); return; } setShowPopUp(formData); @@ -44,7 +76,24 @@ function UpdateDatesWithBoundaries() { setShowPopUp(null); try { if (DateWithBoundary) { - const temp = await Digit.Hooks.campaign.useProjectUpdateWithBoundary({ formData: formData?.dateWithBoundary }); + // updating the endDate by +1 sec and -1 sec so that backend logic for ancestor update work + const payload = formData?.dateWithBoundary?.map((item) => { + 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, + }; + } + }); + const temp = await Digit.Hooks.campaign.useProjectUpdateWithBoundary({ formData: payload }); // 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"), diff --git a/micro-ui/web/package.json b/micro-ui/web/package.json index 5575c91b0d4..8e13578379b 100644 --- a/micro-ui/web/package.json +++ b/micro-ui/web/package.json @@ -16,7 +16,7 @@ "dependencies": { "@egovernments/digit-ui-libraries": "1.8.2-beta.5", "@egovernments/digit-ui-module-workbench": "1.0.1-beta.16", - "@egovernments/digit-ui-module-core": "1.8.2-beta.8", + "@egovernments/digit-ui-module-core": "1.8.2-beta.9", "@egovernments/digit-ui-module-hrms": "1.8.0-beta.2", "@egovernments/digit-ui-react-components": "1.8.2-beta.11", "@egovernments/digit-ui-components": "0.0.2-beta.19", diff --git a/micro-ui/web/public/index.html b/micro-ui/web/public/index.html index 507bad88398..d7ae529c30f 100644 --- a/micro-ui/web/public/index.html +++ b/micro-ui/web/public/index.html @@ -8,7 +8,7 @@ href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@400;500;700&family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" type="text/css" /> - + diff --git a/micro-ui/web/workbench/package.json b/micro-ui/web/workbench/package.json index 9c97bbcdd33..dde9d61650c 100644 --- a/micro-ui/web/workbench/package.json +++ b/micro-ui/web/workbench/package.json @@ -15,7 +15,7 @@ "@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.19", - "@egovernments/digit-ui-module-core": "1.8.2-beta.8", + "@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",
{t(`HCM_CAMPAIGN_DATES`)}