diff --git a/src/App.tsx b/src/App.tsx index e9277e18..97054260 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -52,12 +52,7 @@ function AppContent() { return ( - +
diff --git a/src/components/admin/DesignerForm.tsx b/src/components/admin/DesignerForm.tsx index 99e97281..09f71f88 100644 --- a/src/components/admin/DesignerForm.tsx +++ b/src/components/admin/DesignerForm.tsx @@ -23,28 +23,6 @@ import { useNavigate } from 'react-router-dom'; type DesignerFormData = z.infer; -// Input type for the form (before transformation) -type DesignerFormInput = { - name: string; - slug: string; - description?: string; - person_type: 'company' | 'individual' | 'firm' | 'organization'; - website_url?: string; - founded_year?: string; - headquarters_location?: string; - images?: { - uploaded: Array<{ - url: string; - cloudflare_id?: string; - file?: any; - isLocal?: boolean; - caption?: string; - }>; - banner_assignment?: number | null; - card_assignment?: number | null; - }; -}; - interface DesignerFormProps { onSubmit: (data: DesignerFormData) => void; onCancel: () => void; @@ -68,7 +46,7 @@ export function DesignerForm({ onSubmit, onCancel, initialData }: DesignerFormPr setValue, watch, formState: { errors } - } = useForm({ + } = useForm({ resolver: zodResolver(entitySchemas.designer), defaultValues: { name: initialData?.name || '', diff --git a/src/components/admin/ManufacturerForm.tsx b/src/components/admin/ManufacturerForm.tsx index 845312cd..b6813bcf 100644 --- a/src/components/admin/ManufacturerForm.tsx +++ b/src/components/admin/ManufacturerForm.tsx @@ -23,30 +23,6 @@ import { useNavigate } from 'react-router-dom'; type ManufacturerFormData = z.infer; -// Input type for the form (before transformation) -type ManufacturerFormInput = { - name: string; - slug: string; - description?: string; - person_type: 'company' | 'individual' | 'firm' | 'organization'; - website_url?: string; - founded_year?: string; // Legacy support - founded_date?: string; - founded_date_precision?: string; - headquarters_location?: string; - images?: { - uploaded: Array<{ - url: string; - cloudflare_id?: string; - file?: any; - isLocal?: boolean; - caption?: string; - }>; - banner_assignment?: number | null; - card_assignment?: number | null; - }; -}; - interface ManufacturerFormProps { onSubmit: (data: ManufacturerFormData) => void; onCancel: () => void; @@ -70,7 +46,7 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur setValue, watch, formState: { errors } - } = useForm({ + } = useForm({ resolver: zodResolver(entitySchemas.manufacturer), defaultValues: { name: initialData?.name || '', diff --git a/src/components/admin/OperatorForm.tsx b/src/components/admin/OperatorForm.tsx index c000b992..4f83e6b6 100644 --- a/src/components/admin/OperatorForm.tsx +++ b/src/components/admin/OperatorForm.tsx @@ -23,30 +23,6 @@ import { useNavigate } from 'react-router-dom'; type OperatorFormData = z.infer; -// Input type for the form (before transformation) -type OperatorFormInput = { - name: string; - slug: string; - description?: string; - person_type: 'company' | 'individual' | 'firm' | 'organization'; - website_url?: string; - founded_year?: string; - founded_date?: string; - founded_date_precision?: string; - headquarters_location?: string; - images?: { - uploaded: Array<{ - url: string; - cloudflare_id?: string; - file?: any; - isLocal?: boolean; - caption?: string; - }>; - banner_assignment?: number | null; - card_assignment?: number | null; - }; -}; - interface OperatorFormProps { onSubmit: (data: OperatorFormData) => void; onCancel: () => void; @@ -70,7 +46,7 @@ export function OperatorForm({ onSubmit, onCancel, initialData }: OperatorFormPr setValue, watch, formState: { errors } - } = useForm({ + } = useForm({ resolver: zodResolver(entitySchemas.operator), defaultValues: { name: initialData?.name || '', diff --git a/src/components/admin/PropertyOwnerForm.tsx b/src/components/admin/PropertyOwnerForm.tsx index b9d27f0d..6218245a 100644 --- a/src/components/admin/PropertyOwnerForm.tsx +++ b/src/components/admin/PropertyOwnerForm.tsx @@ -52,28 +52,6 @@ const propertyOwnerSchema = z.object({ type PropertyOwnerFormData = z.infer; -// Input type for the form (before transformation) -type PropertyOwnerFormInput = { - name: string; - slug: string; - description?: string; - person_type: 'company' | 'individual' | 'firm' | 'organization'; - website_url?: string; - founded_year?: string; - headquarters_location?: string; - images?: { - uploaded: Array<{ - url: string; - cloudflare_id?: string; - file?: any; - isLocal?: boolean; - caption?: string; - }>; - banner_assignment?: number | null; - card_assignment?: number | null; - }; -}; - interface PropertyOwnerFormProps { onSubmit: (data: PropertyOwnerFormData) => void; onCancel: () => void; @@ -97,7 +75,7 @@ export function PropertyOwnerForm({ onSubmit, onCancel, initialData }: PropertyO setValue, watch, formState: { errors } - } = useForm({ + } = useForm({ resolver: zodResolver(propertyOwnerSchema), defaultValues: { name: initialData?.name || '', diff --git a/src/components/blog/MarkdownRenderer.tsx b/src/components/blog/MarkdownRenderer.tsx index 85b92770..622d54d6 100644 --- a/src/components/blog/MarkdownRenderer.tsx +++ b/src/components/blog/MarkdownRenderer.tsx @@ -8,7 +8,7 @@ interface MarkdownRendererProps { export function MarkdownRenderer({ content, className }: MarkdownRendererProps) { return ( - - {content} - + + {content} + +
); } diff --git a/src/components/reviews/ReviewForm.tsx b/src/components/reviews/ReviewForm.tsx index c89592e5..a44a40fc 100644 --- a/src/components/reviews/ReviewForm.tsx +++ b/src/components/reviews/ReviewForm.tsx @@ -19,14 +19,7 @@ const reviewSchema = z.object({ title: z.string().optional(), content: z.string().min(10, 'Review must be at least 10 characters long'), visit_date: z.string().optional(), - wait_time_minutes: z.preprocess( - (val) => { - if (val === '' || val === null || val === undefined) return undefined; - const num = Number(val); - return isNaN(num) ? undefined : num; - }, - z.number().positive().optional() - ), + wait_time_minutes: z.number().positive().optional(), photos: z.array(z.string()).optional() }); type ReviewFormData = z.infer; diff --git a/src/components/ui/calendar.tsx b/src/components/ui/calendar.tsx index 1943803a..36246f0a 100644 --- a/src/components/ui/calendar.tsx +++ b/src/components/ui/calendar.tsx @@ -55,9 +55,13 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }: C ...classNames, }} components={{ - IconLeft: ({ ..._props }) => , - IconRight: ({ ..._props }) => , - }} + Chevron: ({ orientation, ...props }: any) => { + if (orientation === 'left') { + return ; + } + return ; + }, + } as any} {...props} /> ); diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsx index 08d40d90..e3d621b9 100644 --- a/src/components/ui/chart.tsx +++ b/src/components/ui/chart.tsx @@ -101,21 +101,21 @@ const ChartTooltipContent = React.forwardRef< } >( ( - { - active, - payload, - className, - indicator = "dot", - hideLabel = false, - hideIndicator = false, - label, - labelFormatter, - labelClassName, - formatter, - color, - nameKey, - labelKey, - }, + { + active, + payload, + className, + indicator = "dot", + hideLabel = false, + hideIndicator = false, + label, + labelFormatter, + labelClassName, + formatter, + color, + nameKey, + labelKey, + }: any, ref, ) => { const { config } = useChart(); @@ -229,11 +229,12 @@ const ChartLegend = RechartsPrimitive.Legend; const ChartLegendContent = React.forwardRef< HTMLDivElement, - React.ComponentProps<"div"> & - Pick & { - hideIcon?: boolean; - nameKey?: string; - } + React.ComponentProps<"div"> & { + hideIcon?: boolean; + nameKey?: string; + payload?: any[]; + verticalAlign?: "top" | "bottom"; + } >(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => { const { config } = useChart(); @@ -246,7 +247,7 @@ const ChartLegendContent = React.forwardRef< ref={ref} className={cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className)} > - {payload.map((item) => { + {payload.map((item: any) => { const key = `${nameKey || item.dataKey || "value"}`; const itemConfig = getPayloadConfigFromPayload(config, item, key); diff --git a/src/components/ui/date-picker.tsx b/src/components/ui/date-picker.tsx index 6acf2e76..84381610 100644 --- a/src/components/ui/date-picker.tsx +++ b/src/components/ui/date-picker.tsx @@ -71,7 +71,7 @@ export function DatePicker({ onSelect={handleSelect} disabled={getDisabledDates} initialFocus - captionLayout="dropdown-buttons" + captionLayout="dropdown" fromYear={fromYear} toYear={toYear} /> diff --git a/src/hooks/useModerationQueue.ts b/src/hooks/useModerationQueue.ts index 26a25b5d..629847e9 100644 --- a/src/hooks/useModerationQueue.ts +++ b/src/hooks/useModerationQueue.ts @@ -25,7 +25,7 @@ export const useModerationQueue = () => { const [currentLock, setCurrentLock] = useState(null); const [queueStats, setQueueStats] = useState(null); const [isLoading, setIsLoading] = useState(false); - const lockTimerRef = useRef(); + const lockTimerRef = useRef(null); const { user } = useAuth(); const { toast } = useToast(); diff --git a/src/lib/entityValidationSchemas.ts b/src/lib/entityValidationSchemas.ts index 4079241f..a9b4fd8d 100644 --- a/src/lib/entityValidationSchemas.ts +++ b/src/lib/entityValidationSchemas.ts @@ -101,7 +101,16 @@ export const companyValidationSchema = z.object({ company_type: z.enum(['manufacturer', 'designer', 'operator', 'property_owner']), description: z.string().max(2000, 'Description must be less than 2000 characters').optional(), person_type: z.enum(['company', 'individual', 'firm', 'organization']), - founded_year: z.number().min(1800, 'Founded year must be after 1800').max(currentYear, `Founded year cannot be in the future`).optional(), + founded_year: z.string() + .optional() + .transform(val => { + if (!val || val.trim() === '') return undefined; + const num = Number(val); + return isNaN(num) ? undefined : num; + }) + .refine(val => val === undefined || (typeof val === 'number' && val >= 1800 && val <= currentYear), { + message: `Founded year must be between 1800 and ${currentYear}` + }), founded_date: z.string().optional(), founded_date_precision: z.enum(['day', 'month', 'year']).optional(), headquarters_location: z.string().max(200, 'Location must be less than 200 characters').optional(),