Skip to content

Commit

Permalink
Milestones - disabled anticipated date picker on phase end milestone (#…
Browse files Browse the repository at this point in the history
…2199)

* disabled anticipated date picker after milestone creation

* disabled only on phase end

* add legislated
  • Loading branch information
djnunez-aot authored May 6, 2024
1 parent a91b711 commit d261ac6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import TrackDatePicker from "../DatePicker";
type ControlledDatePickerProps = {
name: string;
defaultValue?: any;
disabled?: boolean;
datePickerProps?: {
placeholder?: string;
referenceDate?: dayjs.Dayjs;
Expand All @@ -29,6 +30,7 @@ const ControlledDatePicker: React.FC<ControlledDatePickerProps> = ({
datePickerProps,
datePickerSlotProps,
defaultValue,
disabled,
}) => {
const { control, register } = useFormContext();
return (
Expand Down Expand Up @@ -57,6 +59,7 @@ const ControlledDatePicker: React.FC<ControlledDatePickerProps> = ({
onChange(event?.format() || "");
}
}}
disabled={disabled}
/>
)}
/>
Expand Down
7 changes: 6 additions & 1 deletion epictrack-web/src/components/workPlan/event/EventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ const EventForm = ({
const [showEventPushConfirmation, setShowEventPushConfirmation] =
useState(false);
const [pushEvents, setPushEvents] = useState<boolean>(false);

const initialNotes = useMemo(() => event?.notes, [event?.id]);
const { handleHighlightRows } = useContext(EventContext);
const [dateCheckStatus, setDateCheckStatus] =
Expand Down Expand Up @@ -144,6 +143,11 @@ const EventForm = ({
}),
[selectedConfiguration, actualAdded]
);
const disableAnticipatedDate = Boolean(
selectedConfiguration?.id &&
selectedWorkPhase?.work_phase.legislated &&
selectedConfiguration?.event_position === EventPosition.END
);
const isHighPriorityActive = useMemo(() => {
if (event) {
return event.high_priority;
Expand Down Expand Up @@ -679,6 +683,7 @@ const EventForm = ({
<ETFormLabel required>{anticipatedLabel}</ETFormLabel>
<ControlledDatePicker
name="anticipated_date"
disabled={disableAnticipatedDate}
defaultValue={dayjs(anticipatedDefaultValue).format()}
datePickerProps={{
referenceDate: dayjs(
Expand Down

0 comments on commit d261ac6

Please sign in to comment.