Skip to content

Commit 9eb0db8

Browse files
committed
PM-1384 Fix date picker in copilot form
1 parent bc1f9b4 commit 9eb0db8

File tree

2 files changed

+5
-1
lines changed
  • src
    • apps/copilots/src/pages/copilot-request-form
    • libs/ui/lib/components/form/form-groups/form-input/input-date-picker

2 files changed

+5
-1
lines changed

src/apps/copilots/src/pages/copilot-request-form/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ const CopilotRequestForm: FC<{}> = () => {
376376
error={formErrors.startDate}
377377
dirty
378378
minDate={new Date()}
379+
maxDate={new Date(new Date().setFullYear(new Date().getFullYear() + 2))}
380+
minYear={new Date()}
379381
/>
380382
<p className={styles.formRow}>How many weeks will you need the copilot for?</p>
381383
<InputText

src/libs/ui/lib/components/form/form-groups/form-input/input-date-picker/InputDatePicker.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface InputDatePickerProps {
2626
readonly maxTime?: Date | undefined
2727
readonly minDate?: Date | null | undefined
2828
readonly minTime?: Date | undefined
29+
readonly minYear?: Date | null |undefined
2930
readonly placeholder?: string
3031
readonly showMonthPicker?: boolean
3132
readonly showYearPicker?: boolean
@@ -76,7 +77,8 @@ const InputDatePicker: FC<InputDatePickerProps> = (props: InputDatePickerProps)
7677
const datePickerRef = useRef<ReactDatePicker<never, undefined>>(null)
7778
const years = useMemo(() => {
7879
const maxYear = getYear(props.maxDate ? props.maxDate : new Date()) + 1
79-
return range(1979, maxYear, 1)
80+
const minYear = getYear(props.minYear ? props.minYear : 1979)
81+
return range(minYear, maxYear, 1)
8082
}, [props.maxDate])
8183

8284
const [stateHasFocus, setStateHasFocus] = useState(false)

0 commit comments

Comments
 (0)