Files
playzer/apps/frontend/src/components/ui/date-picker.tsx
Jose Selesan 9ee98a4cb4 feat: add city/state/country to complex, new settings page with sidebar, and Biome linting
- Added city, state, and country optional fields to Complex model
- Updated onboarding to include optional location fields
- Created new settings page with sidebar navigation (Datos del Complejo, Canchas)
- Replaced ESLint with Biome for frontend and backend linting
- Added parallel dev script with concurrently
- Migrated register-routes to use direct app.route() pattern
2026-04-10 15:36:15 -03:00

72 lines
1.8 KiB
TypeScript

'use client';
import { format } from 'date-fns';
import { es } from 'date-fns/locale';
import { Calendar as CalendarIcon } from 'lucide-react';
import * as React from 'react';
import { Button } from '@/components/ui/button';
import { Calendar } from '@/components/ui/calendar';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { cn } from '@/lib/utils';
interface DatePickerProps {
value?: Date;
onChange?: (date: Date | undefined) => void;
disabled?: (date: Date) => boolean;
className?: string;
placeholder?: string;
minDate?: Date;
}
export function DatePicker({
value,
onChange,
disabled,
className,
placeholder = 'Selecciona una fecha',
minDate,
}: DatePickerProps) {
const [open, setOpen] = React.useState(false);
const isDateDisabled = React.useCallback(
(date: Date) => {
if (minDate && date < minDate) return true;
if (disabled) return disabled(date);
return false;
},
[minDate, disabled]
);
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<Button
variant="outline"
className={cn(
'w-full justify-start text-left font-normal',
!value && 'text-muted-foreground',
className
)}
data-empty={!value}
>
<CalendarIcon className="mr-2 h-4 w-4" />
{value ? format(value, 'PPP', { locale: es }) : <span>{placeholder}</span>}
</Button>
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="start">
<Calendar
mode="single"
selected={value}
onSelect={(date) => {
onChange?.(date);
setOpen(false);
}}
disabled={isDateDisabled}
initialFocus
/>
</PopoverContent>
</Popover>
);
}