mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:31:12 -05:00
Refactor: Implement complete plan
This commit is contained in:
@@ -9,6 +9,7 @@ import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||
import { ArrowLeft, FerrisWheel, Building2, Edit } from 'lucide-react';
|
||||
import { RideModel, Ride, Company } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useTechnicalSpecifications } from '@/hooks/useTechnicalSpecifications';
|
||||
import { getCloudflareImageUrl } from '@/lib/cloudflareImageUtils';
|
||||
import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
@@ -29,6 +30,9 @@ export default function RideModelDetail() {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
||||
const [statistics, setStatistics] = useState({ rideCount: 0, photoCount: 0 });
|
||||
|
||||
// Fetch technical specifications from relational table
|
||||
const { data: technicalSpecs } = useTechnicalSpecifications('ride_model', model?.id);
|
||||
|
||||
const fetchData = useCallback(async () => {
|
||||
try {
|
||||
@@ -266,15 +270,19 @@ export default function RideModelDetail() {
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{model.technical_specs && typeof model.technical_specs === 'object' && Object.keys(model.technical_specs).length > 0 && (
|
||||
{technicalSpecs && technicalSpecs.length > 0 && (
|
||||
<Card>
|
||||
<CardContent className="pt-6">
|
||||
<h2 className="text-2xl font-semibold mb-4">Technical Specifications</h2>
|
||||
<div className="grid md:grid-cols-2 gap-4">
|
||||
{Object.entries(model.technical_specs as Record<string, any>).map(([key, value]) => (
|
||||
<div key={key} className="flex justify-between py-2 border-b">
|
||||
<span className="font-medium capitalize">{key.replace(/_/g, ' ')}</span>
|
||||
<span className="text-muted-foreground">{String(value)}</span>
|
||||
{technicalSpecs.map((spec) => (
|
||||
<div key={spec.id} className="flex justify-between py-2 border-b">
|
||||
<span className="font-medium capitalize">
|
||||
{spec.spec_name.replace(/_/g, ' ')}
|
||||
</span>
|
||||
<span className="text-muted-foreground">
|
||||
{spec.spec_value} {spec.spec_unit || ''}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user