forked from github/plane
chore: module date validation (#3565)
This commit is contained in:
parent
4041c5bc5b
commit
30aaec9097
@ -70,7 +70,7 @@ export const ModuleForm: React.FC<Props> = ({
|
||||
const startDate = watch("start_date");
|
||||
const targetDate = watch("target_date");
|
||||
|
||||
const minDate = startDate ? new Date(startDate) : new Date();
|
||||
const minDate = startDate ? new Date(startDate) : null;
|
||||
minDate?.setDate(minDate.getDate());
|
||||
|
||||
const maxDate = targetDate ? new Date(targetDate) : null;
|
||||
@ -159,7 +159,6 @@ export const ModuleForm: React.FC<Props> = ({
|
||||
onChange={(date) => onChange(date ? renderFormattedPayloadDate(date) : null)}
|
||||
buttonVariant="border-with-text"
|
||||
placeholder="Start date"
|
||||
minDate={new Date()}
|
||||
maxDate={maxDate ?? undefined}
|
||||
tabIndex={3}
|
||||
/>
|
||||
|
@ -168,18 +168,6 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {
|
||||
if (!watch("target_date") || watch("target_date") === "") endDateButtonRef.current?.click();
|
||||
|
||||
if (watch("start_date") && watch("target_date") && watch("start_date") !== "" && watch("start_date") !== "") {
|
||||
if (!isDateGreaterThanToday(`${watch("target_date")}`)) {
|
||||
setToastAlert({
|
||||
type: "error",
|
||||
title: "Error!",
|
||||
message: "Unable to create module in past date. Please enter a valid date.",
|
||||
});
|
||||
reset({
|
||||
...moduleDetails,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
submitChanges({
|
||||
start_date: renderFormattedPayloadDate(`${watch("start_date")}`),
|
||||
target_date: renderFormattedPayloadDate(`${watch("target_date")}`),
|
||||
@ -198,18 +186,6 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {
|
||||
if (!watch("start_date") || watch("start_date") === "") endDateButtonRef.current?.click();
|
||||
|
||||
if (watch("start_date") && watch("target_date") && watch("start_date") !== "" && watch("start_date") !== "") {
|
||||
if (!isDateGreaterThanToday(`${watch("target_date")}`)) {
|
||||
setToastAlert({
|
||||
type: "error",
|
||||
title: "Error!",
|
||||
message: "Unable to create module in past date. Please enter a valid date.",
|
||||
});
|
||||
reset({
|
||||
...moduleDetails,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
submitChanges({
|
||||
start_date: renderFormattedPayloadDate(`${watch("start_date")}`),
|
||||
target_date: renderFormattedPayloadDate(`${watch("target_date")}`),
|
||||
|
Loading…
Reference in New Issue
Block a user