diff --git a/src/components/admin/ManufacturerForm.tsx b/src/components/admin/ManufacturerForm.tsx index 740ee918..0ffe469f 100644 --- a/src/components/admin/ManufacturerForm.tsx +++ b/src/components/admin/ManufacturerForm.tsx @@ -163,7 +163,11 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur {/* Additional Details */}
{ + const dateValue = watch('founded_date'); + if (!dateValue) return undefined; + return parseDateOnly(dateValue); + })()} precision={(watch('founded_date_precision') as DatePrecision) || 'year'} onChange={(date, precision) => { setValue('founded_date', date ? toDateOnly(date) : undefined); diff --git a/src/components/admin/NotificationDebugPanel.tsx b/src/components/admin/NotificationDebugPanel.tsx index b03879a4..e02e6c03 100644 --- a/src/components/admin/NotificationDebugPanel.tsx +++ b/src/components/admin/NotificationDebugPanel.tsx @@ -9,10 +9,10 @@ import { supabase } from '@/integrations/supabase/client'; import { format } from 'date-fns'; interface DuplicateStats { - date: string; - total_attempts: number; - duplicates_prevented: number; - prevention_rate: number; + date: string | null; + total_attempts: number | null; + duplicates_prevented: number | null; + prevention_rate: number | null; health_status: 'healthy' | 'warning' | 'critical'; } @@ -20,11 +20,11 @@ interface RecentDuplicate { id: string; user_id: string; channel: string; - idempotency_key: string; + idempotency_key: string | null; created_at: string; profiles?: { username: string; - display_name: string; + display_name: string | null; }; } @@ -165,11 +165,11 @@ export function NotificationDebugPanel() { {stats.map((stat) => ( - - {format(new Date(stat.date), 'MMM d, yyyy')} - {stat.total_attempts} - {stat.duplicates_prevented} - {stat.prevention_rate.toFixed(1)}% + + {stat.date ? format(new Date(stat.date), 'MMM d, yyyy') : 'N/A'} + {stat.total_attempts ?? 0} + {stat.duplicates_prevented ?? 0} + {stat.prevention_rate !== null ? stat.prevention_rate.toFixed(1) : 'N/A'}% {getHealthBadge(stat.health_status)} ))} diff --git a/src/components/admin/ParkForm.tsx b/src/components/admin/ParkForm.tsx index 5893893d..fd9c4b7c 100644 --- a/src/components/admin/ParkForm.tsx +++ b/src/components/admin/ParkForm.tsx @@ -375,7 +375,7 @@ export function ParkForm({ onSubmit, onCancel, initialData, isEditing = false }: {/* Dates */}
{ setValue('opening_date', date ? toDateOnly(date) : undefined); @@ -388,7 +388,7 @@ export function ParkForm({ onSubmit, onCancel, initialData, isEditing = false }: /> { setValue('closing_date', date ? toDateOnly(date) : undefined); @@ -632,7 +632,7 @@ export function ParkForm({ onSubmit, onCancel, initialData, isEditing = false }: {/* Images */} setValue('images', images)} entityType="park" entityId={isEditing ? initialData?.id : undefined} @@ -663,7 +663,7 @@ export function ParkForm({ onSubmit, onCancel, initialData, isEditing = false }: { setTempNewOperator(data); setIsOperatorModalOpen(false); @@ -678,7 +678,7 @@ export function ParkForm({ onSubmit, onCancel, initialData, isEditing = false }: { setTempNewPropertyOwner(data); setIsPropertyOwnerModalOpen(false); diff --git a/src/components/admin/RideForm.tsx b/src/components/admin/RideForm.tsx index 083792dc..3c91d114 100644 --- a/src/components/admin/RideForm.tsx +++ b/src/components/admin/RideForm.tsx @@ -326,10 +326,10 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }: _technical_specifications: technicalSpecs, _coaster_statistics: coasterStats, _name_history: formerNames, - _tempNewPark: tempNewPark, - _tempNewManufacturer: tempNewManufacturer, - _tempNewDesigner: tempNewDesigner, - _tempNewRideModel: tempNewRideModel + _tempNewPark: tempNewPark || undefined, + _tempNewManufacturer: tempNewManufacturer || undefined, + _tempNewDesigner: tempNewDesigner || undefined, + _tempNewRideModel: tempNewRideModel || undefined }; // Pass clean data to parent with extended fields @@ -492,7 +492,7 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }: // Show combobox for existing manufacturers { setValue('manufacturer_id', value); setSelectedManufacturerId(value); @@ -557,7 +557,7 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }: <> setValue('ride_model_id', value)} placeholder="Select model" searchPlaceholder="Search models..." @@ -595,7 +595,7 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }: {/* Dates */}
{ setValue('opening_date', date ? toDateOnly(date) : undefined); @@ -608,7 +608,7 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }: /> { setValue('closing_date', date ? toDateOnly(date) : undefined); @@ -1390,7 +1390,7 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }: Create New Designer { setTempNewDesigner(data); setIsDesignerModalOpen(false); @@ -1413,7 +1413,7 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }: { setTempNewManufacturer(data); setSelectedManufacturerName(data.name); @@ -1442,9 +1442,9 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }: { setTempNewRideModel(data); setIsModelModalOpen(false); diff --git a/src/components/admin/SystemActivityLog.tsx b/src/components/admin/SystemActivityLog.tsx index ff191dfe..df4f490d 100644 --- a/src/components/admin/SystemActivityLog.tsx +++ b/src/components/admin/SystemActivityLog.tsx @@ -730,7 +730,7 @@ export const SystemActivityLog = forwardRefUnknown activity type; } }; diff --git a/src/components/auth/AuthModal.tsx b/src/components/auth/AuthModal.tsx index 3f416c66..5601fb05 100644 --- a/src/components/auth/AuthModal.tsx +++ b/src/components/auth/AuthModal.tsx @@ -126,7 +126,7 @@ export function AuthModal({ open, onOpenChange, defaultTab = 'signin' }: AuthMod const { handlePostAuthFlow } = await import('@/lib/authService'); const postAuthResult = await handlePostAuthFlow(data.session, 'password'); - if (postAuthResult.success && postAuthResult.data.shouldRedirect) { + if (postAuthResult.success && postAuthResult.data?.shouldRedirect) { // Get the TOTP factor ID const { data: factors } = await supabase.auth.mfa.listFactors(); const totpFactor = factors?.totp?.find(f => f.status === 'verified'); diff --git a/src/types/database.ts b/src/types/database.ts index a0a49ef8..332505a9 100644 --- a/src/types/database.ts +++ b/src/types/database.ts @@ -35,13 +35,13 @@ export interface Park { id: string; name: string; slug: string; - description?: string; + description?: string | null; status: string; // Allow any string from database park_type: string; // Allow any string from database - opening_date?: string; - opening_date_precision?: string; - closing_date?: string; - closing_date_precision?: string; + opening_date?: string | null; + opening_date_precision?: string | null; + closing_date?: string | null; + closing_date_precision?: string | null; website_url?: string; phone?: string; email?: string; @@ -132,7 +132,7 @@ export interface Ride { id: string; name: string; slug: string; - description?: string; + description?: string | null; park?: Park | { name: string; slug: string; location?: Location }; // Allow partial park data ride_model?: RideModel; manufacturer?: Company; @@ -140,10 +140,10 @@ export interface Ride { category: string; // Allow any string from database ride_sub_type?: string; // Sub-category like "Flying Coaster", "Inverted Coaster", etc. status: string; // Allow any string from database - opening_date?: string; - opening_date_precision?: string; - closing_date?: string; - closing_date_precision?: string; + opening_date?: string | null; + opening_date_precision?: string | null; + closing_date?: string | null; + closing_date_precision?: string | null; height_requirement?: number; age_requirement?: number; capacity_per_hour?: number;