2026-05-06 23:05:37 +03:30
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
2026-05-08 14:25:44 +03:30
|
|
|
import { addCalendarDays } from '@/lib/appointmentTime';
|
2026-05-06 23:05:37 +03:30
|
|
|
|
|
|
|
|
interface ScheduleDayPickerProps {
|
|
|
|
|
value: Date;
|
|
|
|
|
onChange: (day: Date) => void;
|
2026-05-08 14:25:44 +03:30
|
|
|
/** Optional lower bound; picker navigation is unrestricted for history browsing. */
|
|
|
|
|
minDate?: Date;
|
2026-05-06 23:05:37 +03:30
|
|
|
label?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 14:25:44 +03:30
|
|
|
export function ScheduleDayPicker({ value, onChange, label = 'Schedule date' }: ScheduleDayPickerProps) {
|
2026-05-06 23:05:37 +03:30
|
|
|
const labelText = value.toLocaleDateString(undefined, {
|
|
|
|
|
weekday: 'short',
|
|
|
|
|
month: 'short',
|
|
|
|
|
day: 'numeric',
|
|
|
|
|
year: 'numeric',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="w-full max-w-md">
|
|
|
|
|
<p className="text-sm font-medium text-text-secondary mb-2">{label}</p>
|
|
|
|
|
<div className="flex items-center gap-1 rounded-[var(--radius-md)] border border-border bg-background-secondary/90 px-1 py-1 shadow-[inset_0_1px_0_rgba(255,255,255,0.02)]">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => onChange(addCalendarDays(value, -1))}
|
2026-05-08 14:25:44 +03:30
|
|
|
className="shrink-0 rounded-[var(--radius-sm)] p-2 text-text-muted hover:text-text-primary hover:bg-background-card/80 focus:outline-none focus:ring-2 focus:ring-primary/35"
|
2026-05-06 23:05:37 +03:30
|
|
|
aria-label="Previous day"
|
|
|
|
|
>
|
|
|
|
|
<ChevronLeft className="h-4 w-4 icon-flat" />
|
|
|
|
|
</button>
|
|
|
|
|
<div className="flex-1 min-w-0 text-center text-sm font-medium text-text-primary tabular-nums px-2 py-1.5">
|
|
|
|
|
{labelText}
|
|
|
|
|
</div>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => onChange(addCalendarDays(value, 1))}
|
|
|
|
|
className="shrink-0 rounded-[var(--radius-sm)] p-2 text-text-muted hover:text-text-primary hover:bg-background-card/80 focus:outline-none focus:ring-2 focus:ring-primary/35"
|
|
|
|
|
aria-label="Next day"
|
|
|
|
|
>
|
|
|
|
|
<ChevronRight className="h-4 w-4 icon-flat" />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|