Fix null/undefined type mismatches

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 01:35:07 +00:00
parent 2ce837f376
commit c4b1339f0d
4 changed files with 39 additions and 35 deletions

View File

@@ -170,7 +170,11 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur
})()}
precision={(watch('founded_date_precision') as DatePrecision) || 'year'}
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);
}}
label="Founded Date"

View File

@@ -116,7 +116,7 @@ export function RecentChangeCard({
{changedByUsername && (
<div className="flex items-center gap-1">
<Avatar className="h-4 w-4">
<AvatarImage src={changedByAvatar} />
<AvatarImage src={changedByAvatar || undefined} />
<AvatarFallback>
<User className="h-2 w-2" />
</AvatarFallback>

View File

@@ -39,7 +39,7 @@ export function ListDisplay({ list }: ListDisplayProps) {
// Then, fetch the entities for each item
const enrichedItems = await Promise.all(
(itemsData as UserTopListItem[]).map(async (item) => {
let entity = null;
let entity: Park | Ride | Company | null = null;
if (item.entity_type === "park") {
const { data } = await supabase
@@ -47,28 +47,28 @@ export function ListDisplay({ list }: ListDisplayProps) {
.select("id, name, slug, park_type, location_id")
.eq("id", item.entity_id)
.single();
entity = data;
entity = data as Park | null;
} else if (item.entity_type === "ride") {
const { data } = await supabase
.from("rides")
.select("id, name, slug, category, park_id")
.eq("id", item.entity_id)
.single();
entity = data;
entity = data as Ride | null;
} else if (item.entity_type === "company") {
const { data } = await supabase
.from("companies")
.select("id, name, slug, company_type")
.eq("id", item.entity_id)
.single();
entity = data;
entity = data as Company | null;
}
return { ...item, entity };
})
);
setItems(enrichedItems);
setItems(enrichedItems as EnrichedListItem[]);
setLoading(false);
};