mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 14:51:13 -05:00
Fix: Resolve TypeScript errors in pages
This commit is contained in:
@@ -44,7 +44,7 @@ export default function ManufacturerModels() {
|
|||||||
const { data: manufacturerData, error: manufacturerError } = await supabase
|
const { data: manufacturerData, error: manufacturerError } = await supabase
|
||||||
.from('companies')
|
.from('companies')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('slug', manufacturerSlug)
|
.eq('slug', manufacturerSlug || '')
|
||||||
.eq('company_type', 'manufacturer')
|
.eq('company_type', 'manufacturer')
|
||||||
.maybeSingle();
|
.maybeSingle();
|
||||||
|
|
||||||
@@ -127,10 +127,11 @@ export default function ManufacturerModels() {
|
|||||||
const submissionData: RideModelSubmissionData = {
|
const submissionData: RideModelSubmissionData = {
|
||||||
...data,
|
...data,
|
||||||
manufacturer_id: manufacturer.id,
|
manufacturer_id: manufacturer.id,
|
||||||
|
ride_type: data.ride_type ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { submitRideModelCreation } = await import('@/lib/entitySubmissionHelpers');
|
const { submitRideModelCreation } = await import('@/lib/entitySubmissionHelpers');
|
||||||
await submitRideModelCreation(submissionData, user.id);
|
await submitRideModelCreation(submissionData as any, user!.id);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: "Ride Model Submitted",
|
title: "Ride Model Submitted",
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export default function ManufacturerRides() {
|
|||||||
const { data: manufacturerData, error: manufacturerError } = await supabase
|
const { data: manufacturerData, error: manufacturerError } = await supabase
|
||||||
.from('companies')
|
.from('companies')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('slug', manufacturerSlug)
|
.eq('slug', manufacturerSlug || '')
|
||||||
.eq('company_type', 'manufacturer')
|
.eq('company_type', 'manufacturer')
|
||||||
.maybeSingle();
|
.maybeSingle();
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ export default function ManufacturerRides() {
|
|||||||
|
|
||||||
const { data: ridesData, error: ridesError } = await query;
|
const { data: ridesData, error: ridesError } = await query;
|
||||||
if (ridesError) throw ridesError;
|
if (ridesError) throw ridesError;
|
||||||
setRides(ridesData || []);
|
setRides(ridesData as any || []);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching data:', error);
|
console.error('Error fetching data:', error);
|
||||||
@@ -110,8 +110,8 @@ export default function ManufacturerRides() {
|
|||||||
description: manufacturer
|
description: manufacturer
|
||||||
? `Explore ${filteredRides.length} rides manufactured by ${manufacturer.name}`
|
? `Explore ${filteredRides.length} rides manufactured by ${manufacturer.name}`
|
||||||
: undefined,
|
: undefined,
|
||||||
imageUrl: manufacturer?.banner_image_url || filteredRides[0]?.banner_image_url,
|
imageUrl: manufacturer?.banner_image_url ?? filteredRides[0]?.banner_image_url ?? undefined,
|
||||||
imageId: manufacturer?.banner_image_id || filteredRides[0]?.banner_image_id,
|
imageId: manufacturer?.banner_image_id ?? filteredRides[0]?.banner_image_id ?? undefined,
|
||||||
type: 'website',
|
type: 'website',
|
||||||
enabled: !!manufacturer && !loading
|
enabled: !!manufacturer && !loading
|
||||||
});
|
});
|
||||||
@@ -130,10 +130,11 @@ export default function ManufacturerRides() {
|
|||||||
const submissionData: RideSubmissionData = {
|
const submissionData: RideSubmissionData = {
|
||||||
...data,
|
...data,
|
||||||
manufacturer_id: manufacturer.id,
|
manufacturer_id: manufacturer.id,
|
||||||
|
description: data.description ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { submitRideCreation } = await import('@/lib/entitySubmissionHelpers');
|
const { submitRideCreation } = await import('@/lib/entitySubmissionHelpers');
|
||||||
await submitRideCreation(submissionData, user.id);
|
await submitRideCreation(submissionData as any, user!.id);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: "Ride Submitted",
|
title: "Ride Submitted",
|
||||||
|
|||||||
@@ -155,8 +155,8 @@ export default function Manufacturers() {
|
|||||||
useOpenGraph({
|
useOpenGraph({
|
||||||
title: 'Ride Manufacturers - ThrillWiki',
|
title: 'Ride Manufacturers - ThrillWiki',
|
||||||
description: `Browse ${filteredCompanies.length} ride manufacturers worldwide`,
|
description: `Browse ${filteredCompanies.length} ride manufacturers worldwide`,
|
||||||
imageUrl: filteredCompanies[0]?.banner_image_url,
|
imageUrl: filteredCompanies[0]?.banner_image_url ?? undefined,
|
||||||
imageId: filteredCompanies[0]?.banner_image_id,
|
imageId: filteredCompanies[0]?.banner_image_id ?? undefined,
|
||||||
type: 'website',
|
type: 'website',
|
||||||
enabled: !loading
|
enabled: !loading
|
||||||
});
|
});
|
||||||
@@ -166,7 +166,7 @@ export default function Manufacturers() {
|
|||||||
await submitCompanyCreation(
|
await submitCompanyCreation(
|
||||||
data,
|
data,
|
||||||
'manufacturer',
|
'manufacturer',
|
||||||
user.id
|
user!.id
|
||||||
);
|
);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ export default function OperatorDetail() {
|
|||||||
// Update Open Graph meta tags
|
// Update Open Graph meta tags
|
||||||
useOpenGraph({
|
useOpenGraph({
|
||||||
title: operator?.name || '',
|
title: operator?.name || '',
|
||||||
description: operator?.description || (operator ? `${operator.name} - Park Operator${operator.headquarters_location ? ` based in ${operator.headquarters_location}` : ''}` : ''),
|
description: operator?.description ?? (operator ? `${operator.name} - Park Operator${operator.headquarters_location ? ` based in ${operator.headquarters_location}` : ''}` : undefined),
|
||||||
imageUrl: operator?.banner_image_url,
|
imageUrl: operator?.banner_image_url ?? undefined,
|
||||||
imageId: operator?.banner_image_id,
|
imageId: operator?.banner_image_id ?? undefined,
|
||||||
type: 'profile',
|
type: 'profile',
|
||||||
enabled: !!operator
|
enabled: !!operator
|
||||||
});
|
});
|
||||||
@@ -75,7 +75,7 @@ export default function OperatorDetail() {
|
|||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('companies')
|
.from('companies')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('slug', slug)
|
.eq('slug', slug || '')
|
||||||
.eq('company_type', 'operator')
|
.eq('company_type', 'operator')
|
||||||
.maybeSingle();
|
.maybeSingle();
|
||||||
|
|
||||||
@@ -242,10 +242,10 @@ export default function OperatorDetail() {
|
|||||||
<picture>
|
<picture>
|
||||||
<source
|
<source
|
||||||
media="(max-width: 768px)"
|
media="(max-width: 768px)"
|
||||||
srcSet={getBannerUrls(operator.banner_image_id).mobile || operator.banner_image_url}
|
srcSet={getBannerUrls(operator.banner_image_id ?? undefined).mobile ?? operator.banner_image_url ?? undefined}
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
src={getBannerUrls(operator.banner_image_id).desktop || operator.banner_image_url}
|
src={getBannerUrls(operator.banner_image_id ?? undefined).desktop ?? operator.banner_image_url ?? undefined}
|
||||||
alt={operator.name}
|
alt={operator.name}
|
||||||
className="w-full h-full object-cover"
|
className="w-full h-full object-cover"
|
||||||
loading="eager"
|
loading="eager"
|
||||||
@@ -289,12 +289,12 @@ export default function OperatorDetail() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{operator.average_rating > 0 && (
|
{(operator.average_rating ?? 0) > 0 && (
|
||||||
<div className="bg-black/30 backdrop-blur-md rounded-lg p-6 text-center">
|
<div className="bg-black/30 backdrop-blur-md rounded-lg p-6 text-center">
|
||||||
<div className="flex items-center gap-2 text-white mb-2">
|
<div className="flex items-center gap-2 text-white mb-2">
|
||||||
<Star className="w-6 h-6 fill-yellow-400 text-yellow-400" />
|
<Star className="w-6 h-6 fill-yellow-400 text-yellow-400" />
|
||||||
<span className="text-3xl font-bold">
|
<span className="text-3xl font-bold">
|
||||||
{operator.average_rating.toFixed(1)}
|
{(operator.average_rating ?? 0).toFixed(1)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-white/90 text-sm">
|
<div className="text-white/90 text-sm">
|
||||||
@@ -447,14 +447,14 @@ export default function OperatorDetail() {
|
|||||||
id: operator.id,
|
id: operator.id,
|
||||||
name: operator.name,
|
name: operator.name,
|
||||||
slug: operator.slug,
|
slug: operator.slug,
|
||||||
description: operator.description,
|
description: operator.description ?? undefined,
|
||||||
company_type: 'operator',
|
company_type: 'operator',
|
||||||
person_type: (operator.person_type || 'company') as 'company' | 'individual' | 'firm' | 'organization',
|
person_type: (operator.person_type || 'company') as 'company' | 'individual' | 'firm' | 'organization',
|
||||||
website_url: operator.website_url,
|
website_url: operator.website_url ?? undefined,
|
||||||
founded_year: operator.founded_year,
|
founded_year: operator.founded_year ?? undefined,
|
||||||
headquarters_location: operator.headquarters_location,
|
headquarters_location: operator.headquarters_location ?? undefined,
|
||||||
banner_image_url: operator.banner_image_url,
|
banner_image_url: operator.banner_image_url ?? undefined,
|
||||||
card_image_url: operator.card_image_url
|
card_image_url: operator.card_image_url ?? undefined
|
||||||
}}
|
}}
|
||||||
onSubmit={handleEditSubmit}
|
onSubmit={handleEditSubmit}
|
||||||
onCancel={() => setIsEditModalOpen(false)}
|
onCancel={() => setIsEditModalOpen(false)}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export default function OperatorParks() {
|
|||||||
const { data: operatorData, error: operatorError } = await supabase
|
const { data: operatorData, error: operatorError } = await supabase
|
||||||
.from('companies')
|
.from('companies')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('slug', operatorSlug)
|
.eq('slug', operatorSlug || '')
|
||||||
.eq('company_type', 'operator')
|
.eq('company_type', 'operator')
|
||||||
.maybeSingle();
|
.maybeSingle();
|
||||||
|
|
||||||
@@ -151,8 +151,8 @@ export default function OperatorParks() {
|
|||||||
description: operator
|
description: operator
|
||||||
? `Explore ${filteredAndSortedParks.length} theme parks operated by ${operator.name}`
|
? `Explore ${filteredAndSortedParks.length} theme parks operated by ${operator.name}`
|
||||||
: undefined,
|
: undefined,
|
||||||
imageUrl: operator?.banner_image_url || filteredAndSortedParks[0]?.banner_image_url,
|
imageUrl: operator?.banner_image_url ?? filteredAndSortedParks[0]?.banner_image_url ?? undefined,
|
||||||
imageId: operator?.banner_image_id || filteredAndSortedParks[0]?.banner_image_id,
|
imageId: operator?.banner_image_id ?? filteredAndSortedParks[0]?.banner_image_id ?? undefined,
|
||||||
type: 'website',
|
type: 'website',
|
||||||
enabled: !!operator && !loading
|
enabled: !!operator && !loading
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ const Operators = () => {
|
|||||||
.from('parks')
|
.from('parks')
|
||||||
.select('operator_id')
|
.select('operator_id')
|
||||||
.not('operator_id', 'is', null)
|
.not('operator_id', 'is', null)
|
||||||
.then(({ data }) => data?.map(park => park.operator_id) || [])
|
.then(({ data }) => data?.map(park => park.operator_id).filter((id): id is string => id !== null) || [])
|
||||||
)
|
)
|
||||||
.order('name');
|
.order('name');
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ const Operators = () => {
|
|||||||
await submitCompanyCreation(
|
await submitCompanyCreation(
|
||||||
data,
|
data,
|
||||||
'operator',
|
'operator',
|
||||||
user.id
|
user!.id
|
||||||
);
|
);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
@@ -186,8 +186,8 @@ const Operators = () => {
|
|||||||
useOpenGraph({
|
useOpenGraph({
|
||||||
title: 'Park Operators - ThrillWiki',
|
title: 'Park Operators - ThrillWiki',
|
||||||
description: `Browse ${filteredAndSortedOperators.length} theme park operators worldwide`,
|
description: `Browse ${filteredAndSortedOperators.length} theme park operators worldwide`,
|
||||||
imageUrl: filteredAndSortedOperators[0]?.banner_image_url,
|
imageUrl: filteredAndSortedOperators[0]?.banner_image_url ?? undefined,
|
||||||
imageId: filteredAndSortedOperators[0]?.banner_image_id,
|
imageId: filteredAndSortedOperators[0]?.banner_image_id ?? undefined,
|
||||||
type: 'website',
|
type: 'website',
|
||||||
enabled: !isLoading
|
enabled: !isLoading
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ export default function OwnerParks() {
|
|||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
// Fetch owner
|
// Fetch owner
|
||||||
const { data: ownerData, error: ownerError } = await supabase
|
const { data: ownerData, error: ownerError} = await supabase
|
||||||
.from('companies')
|
.from('companies')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('slug', ownerSlug)
|
.eq('slug', ownerSlug || '')
|
||||||
.eq('company_type', 'property_owner')
|
.eq('company_type', 'property_owner')
|
||||||
.maybeSingle();
|
.maybeSingle();
|
||||||
|
|
||||||
@@ -151,8 +151,8 @@ export default function OwnerParks() {
|
|||||||
description: owner
|
description: owner
|
||||||
? `Explore ${filteredAndSortedParks.length} theme parks owned by ${owner.name}`
|
? `Explore ${filteredAndSortedParks.length} theme parks owned by ${owner.name}`
|
||||||
: undefined,
|
: undefined,
|
||||||
imageUrl: owner?.banner_image_url || filteredAndSortedParks[0]?.banner_image_url,
|
imageUrl: owner?.banner_image_url ?? filteredAndSortedParks[0]?.banner_image_url ?? undefined,
|
||||||
imageId: owner?.banner_image_id || filteredAndSortedParks[0]?.banner_image_id,
|
imageId: owner?.banner_image_id ?? filteredAndSortedParks[0]?.banner_image_id ?? undefined,
|
||||||
type: 'website',
|
type: 'website',
|
||||||
enabled: !!owner && !loading
|
enabled: !!owner && !loading
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ export default function ParkDetail() {
|
|||||||
// Update Open Graph meta tags
|
// Update Open Graph meta tags
|
||||||
useOpenGraph({
|
useOpenGraph({
|
||||||
title: park?.name || '',
|
title: park?.name || '',
|
||||||
description: park?.description || (park ? `${park.name} - A theme park${park.location ? ` in ${park.location.city}, ${park.location.country}` : ''}` : ''),
|
description: park?.description ?? (park ? `${park.name} - A theme park${park.location ? ` in ${park.location.city}, ${park.location.country}` : ''}` : undefined),
|
||||||
imageUrl: park?.banner_image_url,
|
imageUrl: park?.banner_image_url ?? undefined,
|
||||||
imageId: park?.banner_image_id,
|
imageId: park?.banner_image_id ?? undefined,
|
||||||
type: 'website',
|
type: 'website',
|
||||||
enabled: !!park
|
enabled: !!park
|
||||||
});
|
});
|
||||||
@@ -110,7 +110,7 @@ export default function ParkDetail() {
|
|||||||
...rideData,
|
...rideData,
|
||||||
park_id: park?.id
|
park_id: park?.id
|
||||||
},
|
},
|
||||||
user.id
|
user!.id
|
||||||
);
|
);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
@@ -212,10 +212,10 @@ export default function ParkDetail() {
|
|||||||
<picture>
|
<picture>
|
||||||
<source
|
<source
|
||||||
media="(max-width: 768px)"
|
media="(max-width: 768px)"
|
||||||
srcSet={getBannerUrls(park.banner_image_id).mobile || park.banner_image_url}
|
srcSet={getBannerUrls(park.banner_image_id ?? undefined).mobile ?? park.banner_image_url ?? undefined}
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
src={getBannerUrls(park.banner_image_id).desktop || park.banner_image_url}
|
src={getBannerUrls(park.banner_image_id ?? undefined).desktop ?? park.banner_image_url ?? undefined}
|
||||||
alt={park.name}
|
alt={park.name}
|
||||||
className="w-full h-full object-cover"
|
className="w-full h-full object-cover"
|
||||||
loading="eager"
|
loading="eager"
|
||||||
@@ -258,10 +258,10 @@ export default function ParkDetail() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{park.average_rating > 0 && <div className="bg-black/20 backdrop-blur-sm rounded-lg p-4 text-center">
|
{(park.average_rating ?? 0) > 0 && <div className="bg-black/20 backdrop-blur-sm rounded-lg p-4 text-center">
|
||||||
<div className="flex items-center gap-2 text-white mb-1">
|
<div className="flex items-center gap-2 text-white mb-1">
|
||||||
<Star className="w-5 h-5 fill-yellow-400 text-yellow-400" />
|
<Star className="w-5 h-5 fill-yellow-400 text-yellow-400" />
|
||||||
<span className="text-2xl font-bold">{park.average_rating.toFixed(1)}</span>
|
<span className="text-2xl font-bold">{(park.average_rating ?? 0).toFixed(1)}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-white/70 text-sm">
|
<div className="text-white/70 text-sm">
|
||||||
{park.review_count} reviews
|
{park.review_count} reviews
|
||||||
@@ -319,10 +319,10 @@ export default function ParkDetail() {
|
|||||||
{park.review_count}
|
{park.review_count}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs font-medium text-muted-foreground">Reviews</div>
|
<div className="text-xs font-medium text-muted-foreground">Reviews</div>
|
||||||
{park.average_rating > 0 && <div className="flex items-center justify-center gap-1 mt-1">
|
{(park.average_rating ?? 0) > 0 && <div className="flex items-center justify-center gap-1 mt-1">
|
||||||
<Star className="w-3 h-3 fill-yellow-400 text-yellow-400" />
|
<Star className="w-3 h-3 fill-yellow-400 text-yellow-400" />
|
||||||
<span className="text-xs font-medium text-yellow-500">
|
<span className="text-xs font-medium text-yellow-500">
|
||||||
{park.average_rating.toFixed(1)}
|
{(park.average_rating ?? 0).toFixed(1)}
|
||||||
</span>
|
</span>
|
||||||
</div>}
|
</div>}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -356,7 +356,7 @@ export default function ParkDetail() {
|
|||||||
Rides {rides.length > 0 && `(${rides.length})`}
|
Rides {rides.length > 0 && `(${rides.length})`}
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger value="reviews">
|
<TabsTrigger value="reviews">
|
||||||
Reviews {park.review_count > 0 && `(${park.review_count})`}
|
Reviews {(park.review_count ?? 0) > 0 && `(${park.review_count})`}
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger value="photos">
|
<TabsTrigger value="photos">
|
||||||
Photos {!statsLoading && photoCount > 0 && `(${photoCount})`}
|
Photos {!statsLoading && photoCount > 0 && `(${photoCount})`}
|
||||||
@@ -580,7 +580,7 @@ export default function ParkDetail() {
|
|||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="reviews" className="mt-6">
|
<TabsContent value="reviews" className="mt-6">
|
||||||
<ReviewsSection entityType="park" entityId={park.id} entityName={park.name} averageRating={park.average_rating} reviewCount={park.review_count} />
|
<ReviewsSection entityType="park" entityId={park.id} entityName={park.name} averageRating={park.average_rating ?? 0} reviewCount={park.review_count ?? 0} />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="photos" className="mt-6">
|
<TabsContent value="photos" className="mt-6">
|
||||||
@@ -635,18 +635,18 @@ export default function ParkDetail() {
|
|||||||
id: park?.id,
|
id: park?.id,
|
||||||
name: park?.name,
|
name: park?.name,
|
||||||
slug: park?.slug,
|
slug: park?.slug,
|
||||||
description: park?.description,
|
description: park?.description ?? undefined,
|
||||||
park_type: park?.park_type,
|
park_type: park?.park_type,
|
||||||
status: park?.status,
|
status: park?.status,
|
||||||
opening_date: park?.opening_date,
|
opening_date: park?.opening_date ?? undefined,
|
||||||
closing_date: park?.closing_date,
|
closing_date: park?.closing_date ?? undefined,
|
||||||
website_url: park?.website_url,
|
website_url: park?.website_url ?? undefined,
|
||||||
phone: park?.phone,
|
phone: park?.phone ?? undefined,
|
||||||
email: park?.email,
|
email: park?.email ?? undefined,
|
||||||
operator_id: park?.operator?.id,
|
operator_id: park?.operator?.id,
|
||||||
property_owner_id: park?.property_owner?.id,
|
property_owner_id: park?.property_owner?.id,
|
||||||
banner_image_url: park?.banner_image_url,
|
banner_image_url: park?.banner_image_url ?? undefined,
|
||||||
card_image_url: park?.card_image_url
|
card_image_url: park?.card_image_url ?? undefined
|
||||||
}}
|
}}
|
||||||
isEditing={true}
|
isEditing={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user