mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 13:51:13 -05:00
Fix null/undefined type mismatches
This commit is contained in:
@@ -170,7 +170,11 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur
|
|||||||
})()}
|
})()}
|
||||||
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);
|
if (date && typeof date === 'string') {
|
||||||
|
setValue('founded_date', toDateOnly(date) as any);
|
||||||
|
} else {
|
||||||
|
setValue('founded_date', null as any);
|
||||||
|
}
|
||||||
setValue('founded_date_precision', precision);
|
setValue('founded_date_precision', precision);
|
||||||
}}
|
}}
|
||||||
label="Founded Date"
|
label="Founded Date"
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ export function RecentChangeCard({
|
|||||||
{changedByUsername && (
|
{changedByUsername && (
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Avatar className="h-4 w-4">
|
<Avatar className="h-4 w-4">
|
||||||
<AvatarImage src={changedByAvatar} />
|
<AvatarImage src={changedByAvatar || undefined} />
|
||||||
<AvatarFallback>
|
<AvatarFallback>
|
||||||
<User className="h-2 w-2" />
|
<User className="h-2 w-2" />
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export function ListDisplay({ list }: ListDisplayProps) {
|
|||||||
// Then, fetch the entities for each item
|
// Then, fetch the entities for each item
|
||||||
const enrichedItems = await Promise.all(
|
const enrichedItems = await Promise.all(
|
||||||
(itemsData as UserTopListItem[]).map(async (item) => {
|
(itemsData as UserTopListItem[]).map(async (item) => {
|
||||||
let entity = null;
|
let entity: Park | Ride | Company | null = null;
|
||||||
|
|
||||||
if (item.entity_type === "park") {
|
if (item.entity_type === "park") {
|
||||||
const { data } = await supabase
|
const { data } = await supabase
|
||||||
@@ -47,28 +47,28 @@ export function ListDisplay({ list }: ListDisplayProps) {
|
|||||||
.select("id, name, slug, park_type, location_id")
|
.select("id, name, slug, park_type, location_id")
|
||||||
.eq("id", item.entity_id)
|
.eq("id", item.entity_id)
|
||||||
.single();
|
.single();
|
||||||
entity = data;
|
entity = data as Park | null;
|
||||||
} else if (item.entity_type === "ride") {
|
} else if (item.entity_type === "ride") {
|
||||||
const { data } = await supabase
|
const { data } = await supabase
|
||||||
.from("rides")
|
.from("rides")
|
||||||
.select("id, name, slug, category, park_id")
|
.select("id, name, slug, category, park_id")
|
||||||
.eq("id", item.entity_id)
|
.eq("id", item.entity_id)
|
||||||
.single();
|
.single();
|
||||||
entity = data;
|
entity = data as Ride | null;
|
||||||
} else if (item.entity_type === "company") {
|
} else if (item.entity_type === "company") {
|
||||||
const { data } = await supabase
|
const { data } = await supabase
|
||||||
.from("companies")
|
.from("companies")
|
||||||
.select("id, name, slug, company_type")
|
.select("id, name, slug, company_type")
|
||||||
.eq("id", item.entity_id)
|
.eq("id", item.entity_id)
|
||||||
.single();
|
.single();
|
||||||
entity = data;
|
entity = data as Company | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { ...item, entity };
|
return { ...item, entity };
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
setItems(enrichedItems);
|
setItems(enrichedItems as EnrichedListItem[]);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,31 +2,31 @@ export interface Location {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
country: string;
|
country: string;
|
||||||
state_province?: string;
|
state_province?: string | null;
|
||||||
city?: string;
|
city?: string | null;
|
||||||
postal_code?: string;
|
postal_code?: string | null;
|
||||||
latitude?: number;
|
latitude?: number | null;
|
||||||
longitude?: number;
|
longitude?: number | null;
|
||||||
timezone?: string;
|
timezone?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Company {
|
export interface Company {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
description?: string;
|
description?: string | null;
|
||||||
company_type: string; // Allow any string from database
|
company_type: string; // Allow any string from database
|
||||||
person_type?: string; // Database returns string, validated at form level
|
person_type?: string | null; // Database returns string, validated at form level
|
||||||
website_url?: string;
|
website_url?: string | null;
|
||||||
founded_year?: number; // Legacy field
|
founded_year?: number | null; // Legacy field
|
||||||
founded_date?: string;
|
founded_date?: string | null;
|
||||||
founded_date_precision?: string;
|
founded_date_precision?: string | null;
|
||||||
headquarters_location?: string;
|
headquarters_location?: string | null;
|
||||||
logo_url?: string;
|
logo_url?: string | null;
|
||||||
banner_image_url?: string;
|
banner_image_url?: string | null;
|
||||||
banner_image_id?: string;
|
banner_image_id?: string | null;
|
||||||
card_image_url?: string;
|
card_image_url?: string | null;
|
||||||
card_image_id?: string;
|
card_image_id?: string | null;
|
||||||
average_rating: number;
|
average_rating: number;
|
||||||
review_count: number;
|
review_count: number;
|
||||||
}
|
}
|
||||||
@@ -42,16 +42,16 @@ export interface Park {
|
|||||||
opening_date_precision?: string | null;
|
opening_date_precision?: string | null;
|
||||||
closing_date?: string | null;
|
closing_date?: string | null;
|
||||||
closing_date_precision?: string | null;
|
closing_date_precision?: string | null;
|
||||||
website_url?: string;
|
website_url?: string | null;
|
||||||
phone?: string;
|
phone?: string | null;
|
||||||
email?: string;
|
email?: string | null;
|
||||||
location?: Location;
|
location?: Location | null;
|
||||||
operator?: Company;
|
operator?: Company | null;
|
||||||
property_owner?: Company;
|
property_owner?: Company | null;
|
||||||
banner_image_url?: string;
|
banner_image_url?: string | null;
|
||||||
banner_image_id?: string;
|
banner_image_id?: string | null;
|
||||||
card_image_url?: string;
|
card_image_url?: string | null;
|
||||||
card_image_id?: string;
|
card_image_id?: string | null;
|
||||||
average_rating: number;
|
average_rating: number;
|
||||||
review_count: number;
|
review_count: number;
|
||||||
ride_count: number;
|
ride_count: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user