Skip to content

Commit 8bb8aba

Browse files
authored
Merge pull request #1144 from topcoder-platform/PM-1384
PM-1384 Fix date picker in copilot form
2 parents cfc2d1e + 8184aab commit 8bb8aba

File tree

2 files changed

+7
-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

+7
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ const CopilotRequestForm: FC<{}> = () => {
394394
error={formErrors.startDate}
395395
dirty
396396
minDate={new Date()}
397+
maxDate={new Date(new Date()
398+
.setFullYear(new Date()
399+
.getFullYear() + 2))}
400+
minYear={new Date()}
397401
/>
398402
<p className={styles.formRow}>How many weeks will you need the copilot for?</p>
399403
<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)