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