Skip to content

Commit

Permalink
🐛 Add range styles and remove initial validation for end date (#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 authored Jan 3, 2024
1 parent 0f64970 commit 34ffd17
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,13 @@ export const WaveForm: React.FC<WaveFormProps> = ({
});

const startDateStr = watch("startDateStr");
const endDateStr = watch("endDateStr");
const startDate = dateStrFormatValidator(startDateStr)
? dayjs(startDateStr).toDate()
: null;
const endDate = dateStrFormatValidator(endDateStr)
? dayjs(endDateStr).toDate()
: null;

const onSubmit = (formValues: WaveFormValues) => {
const stakeholders =
Expand Down Expand Up @@ -315,7 +319,7 @@ export const WaveForm: React.FC<WaveFormProps> = ({
aria-label={name}
onChange={(e, val) => {
onChange(val);
trigger("endDateStr");
if (endDate) trigger("endDateStr");
}}
placeholder="MM/DD/YYYY"
value={value}
Expand Down Expand Up @@ -356,6 +360,7 @@ export const WaveForm: React.FC<WaveFormProps> = ({
dateFormat={(val) => dayjs(val).format("MM/DD/YYYY")}
dateParse={(val) => dayjs(val).toDate()}
validators={[endDateRangeValidator]}
rangeStart={startDate ? startDate : undefined}
appendTo={() => endDateRef.current || document.body}
/>
)}
Expand Down

0 comments on commit 34ffd17

Please sign in to comment.