mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:31:13 -05:00
Fix date parsing bug
This commit is contained in:
@@ -18,7 +18,7 @@ import { FlexibleDateInput, type DatePrecision } from '@/components/ui/flexible-
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { toast } from 'sonner';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { toDateOnly } from '@/lib/dateUtils';
|
||||
import { toDateOnly, parseDateOnly } from '@/lib/dateUtils';
|
||||
import type { UploadedImage } from '@/types/company';
|
||||
|
||||
// Zod output type (after transformation)
|
||||
@@ -163,7 +163,7 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur
|
||||
{/* Additional Details */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<FlexibleDateInput
|
||||
value={watch('founded_date') ? new Date(watch('founded_date')) : undefined}
|
||||
value={watch('founded_date') ? parseDateOnly(watch('founded_date')) : undefined}
|
||||
precision={(watch('founded_date_precision') as DatePrecision) || 'year'}
|
||||
onChange={(date, precision) => {
|
||||
setValue('founded_date', date ? toDateOnly(date) : undefined);
|
||||
|
||||
@@ -18,7 +18,7 @@ import { SlugField } from '@/components/ui/slug-field';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { MapPin, Save, X, Plus } from 'lucide-react';
|
||||
import { toDateOnly } from '@/lib/dateUtils';
|
||||
import { toDateOnly, parseDateOnly } from '@/lib/dateUtils';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Combobox } from '@/components/ui/combobox';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
@@ -343,7 +343,7 @@ export function ParkForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
{/* Dates */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<FlexibleDateInput
|
||||
value={watch('opening_date') ? new Date(watch('opening_date')) : undefined}
|
||||
value={watch('opening_date') ? parseDateOnly(watch('opening_date')) : undefined}
|
||||
precision={(watch('opening_date_precision') as DatePrecision) || 'day'}
|
||||
onChange={(date, precision) => {
|
||||
setValue('opening_date', date ? toDateOnly(date) : undefined);
|
||||
@@ -356,7 +356,7 @@ export function ParkForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
/>
|
||||
|
||||
<FlexibleDateInput
|
||||
value={watch('closing_date') ? new Date(watch('closing_date')) : undefined}
|
||||
value={watch('closing_date') ? parseDateOnly(watch('closing_date')) : undefined}
|
||||
precision={(watch('closing_date_precision') as DatePrecision) || 'day'}
|
||||
onChange={(date, precision) => {
|
||||
setValue('closing_date', date ? toDateOnly(date) : undefined);
|
||||
|
||||
@@ -24,7 +24,7 @@ import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { Plus, Zap, Save, X } from 'lucide-react';
|
||||
import { toDateOnly } from '@/lib/dateUtils';
|
||||
import { toDateOnly, parseDateOnly } from '@/lib/dateUtils';
|
||||
import { useUnitPreferences } from '@/hooks/useUnitPreferences';
|
||||
import { useManufacturers, useRideModels } from '@/hooks/useAutocompleteData';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
@@ -566,7 +566,7 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
{/* Dates */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<FlexibleDateInput
|
||||
value={watch('opening_date') ? new Date(watch('opening_date')) : undefined}
|
||||
value={watch('opening_date') ? parseDateOnly(watch('opening_date')) : undefined}
|
||||
precision={(watch('opening_date_precision') as DatePrecision) || 'day'}
|
||||
onChange={(date, precision) => {
|
||||
setValue('opening_date', date ? toDateOnly(date) : undefined);
|
||||
@@ -579,7 +579,7 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
/>
|
||||
|
||||
<FlexibleDateInput
|
||||
value={watch('closing_date') ? new Date(watch('closing_date')) : undefined}
|
||||
value={watch('closing_date') ? parseDateOnly(watch('closing_date')) : undefined}
|
||||
precision={(watch('closing_date_precision') as DatePrecision) || 'day'}
|
||||
onChange={(date, precision) => {
|
||||
setValue('closing_date', date ? toDateOnly(date) : undefined);
|
||||
|
||||
@@ -14,7 +14,7 @@ import { supabase } from '@/integrations/supabase/client';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { PhotoUpload } from '@/components/upload/PhotoUpload';
|
||||
import { StarRating } from './StarRating';
|
||||
import { toDateOnly } from '@/lib/dateUtils';
|
||||
import { toDateOnly, parseDateOnly } from '@/lib/dateUtils';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
const reviewSchema = z.object({
|
||||
@@ -176,7 +176,7 @@ export function ReviewForm({
|
||||
<div className="space-y-2">
|
||||
<Label>Visit Date</Label>
|
||||
<DatePicker
|
||||
date={watch('visit_date') ? new Date(watch('visit_date')) : undefined}
|
||||
date={watch('visit_date') ? parseDateOnly(watch('visit_date')) : undefined}
|
||||
onSelect={(date) => setValue('visit_date', date ? toDateOnly(date) : undefined)}
|
||||
placeholder="When did you visit?"
|
||||
disableFuture={true}
|
||||
|
||||
Reference in New Issue
Block a user