feat: set default maxDate in DatePicker component

This commit is contained in:
Yoga Pangestu 2026-09-02 11:56:00 +07:00
parent 692b84cc1b
commit 0327b07669

View File

@ -19,13 +19,17 @@ type DatePickerProps = {
maxDate?: Date;
};
const defaultMaxDate = new Date(
new Date().setFullYear(new Date().getFullYear() + 5),
);
export function DatePicker({
value,
onChange,
placeholder = 'Pilih tanggal',
className,
disabled,
maxDate,
maxDate = defaultMaxDate,
}: DatePickerProps) {
return (
<Popover>
@ -50,6 +54,7 @@ export function DatePicker({
defaultMonth={value ?? undefined}
captionLayout="dropdown"
onSelect={onChange}
endMonth={maxDate}
disabled={maxDate ? { after: maxDate } : undefined}
/>
</PopoverContent>