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