mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-25 18:31:12 -05:00
feat: Lazy load admin forms
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useState, useEffect, lazy, Suspense } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { Header } from '@/components/layout/Header';
|
||||
import { trackPageView } from '@/lib/viewTracking';
|
||||
@@ -8,12 +8,15 @@ import { Badge } from '@/components/ui/badge';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||
import { AdminFormSkeleton } from '@/components/loading/PageSkeletons';
|
||||
import { ArrowLeft, MapPin, Star, Globe, Calendar, Edit, Building2, Gauge } from 'lucide-react';
|
||||
import { Company, Park } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { PropertyOwnerForm } from '@/components/admin/PropertyOwnerForm';
|
||||
import { PropertyOwnerPhotoGallery } from '@/components/companies/PropertyOwnerPhotoGallery';
|
||||
import { ParkCard } from '@/components/parks/ParkCard';
|
||||
|
||||
// Lazy load admin form
|
||||
const PropertyOwnerForm = lazy(() => import('@/components/admin/PropertyOwnerForm').then(m => ({ default: m.PropertyOwnerForm })));
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
@@ -423,23 +426,25 @@ export default function PropertyOwnerDetail() {
|
||||
{/* Edit Modal */}
|
||||
<Dialog open={isEditModalOpen} onOpenChange={setIsEditModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<PropertyOwnerForm
|
||||
initialData={{
|
||||
id: owner.id,
|
||||
name: owner.name,
|
||||
slug: owner.slug,
|
||||
description: owner.description,
|
||||
company_type: 'property_owner',
|
||||
person_type: (owner.person_type || 'company') as 'company' | 'individual' | 'firm' | 'organization',
|
||||
website_url: owner.website_url,
|
||||
founded_year: owner.founded_year,
|
||||
headquarters_location: owner.headquarters_location,
|
||||
banner_image_url: owner.banner_image_url,
|
||||
card_image_url: owner.card_image_url
|
||||
}}
|
||||
onSubmit={handleEditSubmit}
|
||||
onCancel={() => setIsEditModalOpen(false)}
|
||||
/>
|
||||
<Suspense fallback={<AdminFormSkeleton />}>
|
||||
<PropertyOwnerForm
|
||||
initialData={{
|
||||
id: owner.id,
|
||||
name: owner.name,
|
||||
slug: owner.slug,
|
||||
description: owner.description,
|
||||
company_type: 'property_owner',
|
||||
person_type: (owner.person_type || 'company') as 'company' | 'individual' | 'firm' | 'organization',
|
||||
website_url: owner.website_url,
|
||||
founded_year: owner.founded_year,
|
||||
headquarters_location: owner.headquarters_location,
|
||||
banner_image_url: owner.banner_image_url,
|
||||
card_image_url: owner.card_image_url
|
||||
}}
|
||||
onSubmit={handleEditSubmit}
|
||||
onCancel={() => setIsEditModalOpen(false)}
|
||||
/>
|
||||
</Suspense>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user