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

HCMPRE 154 #1202

Merged
merged 13 commits into from
Jul 31, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ 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 @@ -260,7 +261,7 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => {
?.toISOString()
?.split("T")?.[0]
: today >= startDate
? today
? tomorrow
: startDate,
max: endDate,
},
Expand All @@ -278,17 +279,27 @@ const DateAndCycleUpdate = ({ onSelect, formData, ...props }) => {
withoutLabel={true}
type="date"
value={item?.endDate}
nonEditable={item?.endDate && item?.endDate?.length > 0 && today >= item?.endDate ? true : false}
nonEditable={
item?.endDate &&
item?.endDate?.length > 0 &&
today >= item?.endDate &&
(cycleDates?.[index + 1] ? today >= cycleDates?.[index + 1]?.startDate : true)
? true
: false
}
placeholder={t("HCM_END_DATE")}
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,
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,
},
}}
Expand Down
Loading