Skip to content

Commit

Permalink
Merge pull request #2409 from tom0827/TRACK-185
Browse files Browse the repository at this point in the history
TRACK-185: event actual date restrict putting in future dates
  • Loading branch information
tom0827 authored Sep 28, 2024
2 parents abcea80 + c4533f9 commit 70091cc
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions epictrack-web/src/components/workPlan/event/EventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ const EventForm = ({
: selectedWorkPhase?.work_phase.start_date;
}, [event, selectedWorkPhase]);

const acutalReferenceDate = useMemo(() => {
const actualReferenceDate = useMemo(() => {
return event ? event.anticipated_date : anticipatedDefaultValue;
}, [event, anticipatedDefaultValue]);
const anticipatedMinDate = useMemo(
Expand All @@ -288,15 +288,6 @@ const EventForm = ({
: dayjs(selectedWorkPhase?.work_phase.start_date),
[selectedWorkPhase, isStartEvent, isStartPhase]
);
const actualDateMax = useMemo(() => {
if (
selectedWorkPhase?.work_phase.legislated &&
selectedConfiguration?.event_category_id !== EventCategory.EXTENSION
) {
return dayjs(selectedWorkPhase.work_phase.end_date);
}
return dayjs(new Date());
}, [selectedWorkPhase?.work_phase, selectedConfiguration]);
const methods = useForm({
resolver: yupResolver(schema),
defaultValues: event,
Expand Down Expand Up @@ -411,7 +402,7 @@ const EventForm = ({

/**
* Check if the selected event configuration cause date to exceed the phase
* or push susequent events
* or push subsequent events
*/
const eventDateCheck = async () => {
try {
Expand Down Expand Up @@ -565,7 +556,7 @@ const EventForm = ({

/**
* Unregister various fields which might have already loaded
* based on diffrent milestone type. This is required or else
* based on different milestone type. This is required or else
* such hidden fields would be submitted to the server
*/
const unregisterOptionalFields = () => {
Expand Down Expand Up @@ -737,9 +728,9 @@ const EventForm = ({
event?.actual_date ? dayjs(event?.actual_date).format() : ""
}
datePickerProps={{
referenceDate: dayjs(acutalReferenceDate),
referenceDate: dayjs(actualReferenceDate),
minDate: actualDateMin,
maxDate: actualDateMax,
maxDate: dayjs(new Date()),
onDateChange: (event: any, defaultOnChange: any) => {
const d = event ? event["$d"] : null;
defaultOnChange(d);
Expand Down

0 comments on commit 70091cc

Please sign in to comment.