Skip to content

Commit

Permalink
Revert "HCMPRE 154 (#1191)" (#1203)
Browse files Browse the repository at this point in the history
This reverts commit 59ec953.

Co-authored-by: nabeelmd-eGov <[email protected]>
  • Loading branch information
2 people authored and Bhavya-egov committed Aug 12, 2024
1 parent f8e9599 commit 1fd4a5d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ 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 Down Expand Up @@ -153,7 +152,7 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
?.toISOString()
?.split("T")?.[0]
: today >= startDate
? tomorrow
? today
: startDate,
max: endDate,
},
Expand All @@ -170,26 +169,17 @@ const BoundaryWithDate = ({ project, props, onSelect, dateReducerDispatch, canDe
withoutLabel={true}
type="date"
value={item?.endDate}
nonEditable={
item?.endDate?.length > 0 &&
today >= item?.endDate &&
(cycleDates?.[index + 1] ? today >= cycleDates?.[index + 1]?.startDate : true)
? 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:
!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,
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,
},
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => {
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 tenantId = Digit.ULBService.getCurrentTenantId();
const { state } = useLocation();
const historyState = window.history.state;
Expand Down Expand Up @@ -261,7 +260,7 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => {
?.toISOString()
?.split("T")?.[0]
: today >= startDate
? tomorrow
? today
: startDate,
max: endDate,
},
Expand All @@ -279,27 +278,17 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => {
withoutLabel={true}
type="date"
value={item?.endDate}
nonEditable={
item?.endDate &&
item?.endDate?.length > 0 &&
today >= item?.endDate &&
(cycleDates?.[index + 1] ? today >= cycleDates?.[index + 1]?.startDate : true)
? true
: false
}
nonEditable={item?.endDate && item?.endDate?.length > 0 && today >= item?.endDate ? true : false}
placeholder={t("HCM_END_DATE")}
populators={{
validation: {
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,
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,
},
}}
Expand Down

0 comments on commit 1fd4a5d

Please sign in to comment.