Skip to content

Commit

Permalink
Add disabled feature in DatePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Jan 19, 2025
1 parent cdc745e commit b4a49ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/ui/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import {
interface DatePickerProps {
date?: Date;
onChange?: (date?: Date) => void;
disabled?: (date: Date) => boolean;
}

export function DatePicker({ date, onChange }: DatePickerProps) {
export function DatePicker({ date, onChange, disabled }: DatePickerProps) {
const [open, setOpen] = useState(false);

return (
Expand All @@ -44,6 +45,7 @@ export function DatePicker({ date, onChange }: DatePickerProps) {
setOpen(false);
}}
initialFocus
disabled={disabled}
/>
</PopoverContent>
</Popover>
Expand Down
4 changes: 4 additions & 0 deletions src/pages/PublicAppointments/PatientRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ export function PatientRegistration(props: PatientRegistrationProps) {
field.value ? new Date(field.value) : undefined
}
onChange={(date) => field.onChange(date)}
disabled={(date) =>
date <= new Date("1900-01-01") ||
date >= new Date()
}
/>
</FormControl>
<FormMessage />
Expand Down

0 comments on commit b4a49ef

Please sign in to comment.