mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 12:51:14 -05:00
feat: Implement company management plan
This commit is contained in:
277
src/pages/DesignerDetail.tsx
Normal file
277
src/pages/DesignerDetail.tsx
Normal file
@@ -0,0 +1,277 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { Header } from '@/components/layout/Header';
|
||||
import { Button } from '@/components/ui/button';
|
||||
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 { ArrowLeft, MapPin, Star, Globe, Calendar, Edit, Ruler } from 'lucide-react';
|
||||
import { Company } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { DesignerForm } from '@/components/admin/DesignerForm';
|
||||
import { DesignerPhotoGallery } from '@/components/companies/DesignerPhotoGallery';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { submitCompanyUpdate } from '@/lib/companyHelpers';
|
||||
|
||||
export default function DesignerDetail() {
|
||||
const { slug } = useParams<{ slug: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [designer, setDesigner] = useState<Company | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
||||
const { user } = useAuth();
|
||||
const { isModerator } = useUserRole();
|
||||
|
||||
useEffect(() => {
|
||||
if (slug) {
|
||||
fetchDesignerData();
|
||||
}
|
||||
}, [slug]);
|
||||
|
||||
const fetchDesignerData = async () => {
|
||||
try {
|
||||
const { data, error } = await supabase
|
||||
.from('companies')
|
||||
.select('*')
|
||||
.eq('slug', slug)
|
||||
.eq('company_type', 'designer')
|
||||
.maybeSingle();
|
||||
|
||||
if (error) throw error;
|
||||
setDesigner(data);
|
||||
} catch (error) {
|
||||
console.error('Error fetching designer:', error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleEditSubmit = async (data: any) => {
|
||||
try {
|
||||
const result = await submitCompanyUpdate(
|
||||
designer!.id,
|
||||
data,
|
||||
user!.id,
|
||||
isModerator()
|
||||
);
|
||||
|
||||
toast({
|
||||
title: result.submitted ? "Edit Submitted" : "Designer Updated",
|
||||
description: result.submitted
|
||||
? "Your edit has been submitted for review."
|
||||
: "The designer has been updated successfully."
|
||||
});
|
||||
|
||||
setIsEditModalOpen(false);
|
||||
if (!result.submitted) {
|
||||
fetchDesignerData();
|
||||
}
|
||||
} catch (error: any) {
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message || "Failed to submit edit.",
|
||||
variant: "destructive"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="animate-pulse space-y-6">
|
||||
<div className="h-64 bg-muted rounded-lg"></div>
|
||||
<div className="h-8 bg-muted rounded w-1/2"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!designer) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="text-center py-12">
|
||||
<h1 className="text-2xl font-bold mb-4">Designer Not Found</h1>
|
||||
<Button onClick={() => navigate('/designers')}>
|
||||
<ArrowLeft className="w-4 h-4 mr-2" />
|
||||
Back to Designers
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
|
||||
<main className="container mx-auto px-4 py-8">
|
||||
{/* Back Button and Edit Button */}
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<Button variant="ghost" onClick={() => navigate('/designers')}>
|
||||
<ArrowLeft className="w-4 h-4 mr-2" />
|
||||
Back to Designers
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
if (!user) {
|
||||
navigate('/auth');
|
||||
} else {
|
||||
setIsEditModalOpen(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Edit className="w-4 h-4 mr-2" />
|
||||
Edit Designer
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Hero Section */}
|
||||
<div className="relative mb-8">
|
||||
<div className="aspect-[21/9] bg-gradient-to-br from-primary/20 via-secondary/20 to-accent/20 rounded-lg overflow-hidden relative">
|
||||
{designer.logo_url ? (
|
||||
<div className="flex items-center justify-center h-full bg-background/90">
|
||||
<img
|
||||
src={designer.logo_url}
|
||||
alt={designer.name}
|
||||
className="max-h-48 object-contain"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full">
|
||||
<Ruler className="w-24 h-24 opacity-50" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="absolute bottom-0 left-0 right-0 p-8 bg-gradient-to-t from-black/60 to-transparent">
|
||||
<div className="flex items-end justify-between">
|
||||
<div>
|
||||
<Badge variant="outline" className="bg-black/20 text-white border-white/20 mb-2">
|
||||
Designer
|
||||
</Badge>
|
||||
<h1 className="text-4xl md:text-6xl font-bold text-white mb-2">
|
||||
{designer.name}
|
||||
</h1>
|
||||
{designer.headquarters_location && (
|
||||
<div className="flex items-center text-white/90 text-lg">
|
||||
<MapPin className="w-5 h-5 mr-2" />
|
||||
{designer.headquarters_location}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{designer.average_rating > 0 && (
|
||||
<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">
|
||||
<Star className="w-6 h-6 fill-yellow-400 text-yellow-400" />
|
||||
<span className="text-3xl font-bold">
|
||||
{designer.average_rating.toFixed(1)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-white/90 text-sm">
|
||||
{designer.review_count} {designer.review_count === 1 ? "review" : "reviews"}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Company Info */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-8">
|
||||
{designer.founded_year && (
|
||||
<Card>
|
||||
<CardContent className="p-4 text-center">
|
||||
<Calendar className="w-6 h-6 text-primary mx-auto mb-2" />
|
||||
<div className="text-2xl font-bold">{designer.founded_year}</div>
|
||||
<div className="text-sm text-muted-foreground">Founded</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
{designer.website_url && (
|
||||
<Card>
|
||||
<CardContent className="p-4 text-center">
|
||||
<Globe className="w-6 h-6 text-primary mx-auto mb-2" />
|
||||
<a
|
||||
href={designer.website_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-sm text-primary hover:underline break-all"
|
||||
>
|
||||
Visit Website
|
||||
</a>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Tabs */}
|
||||
<Tabs defaultValue="overview" className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-3">
|
||||
<TabsTrigger value="overview">Overview</TabsTrigger>
|
||||
<TabsTrigger value="rides">Rides</TabsTrigger>
|
||||
<TabsTrigger value="photos">Photos</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="overview" className="space-y-6">
|
||||
{designer.description && (
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<h2 className="text-2xl font-bold mb-4">About</h2>
|
||||
<p className="text-muted-foreground whitespace-pre-wrap">
|
||||
{designer.description}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="rides">
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<p className="text-muted-foreground">Rides designed by {designer.name} will be displayed here.</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="photos">
|
||||
<DesignerPhotoGallery
|
||||
designerId={designer.id}
|
||||
designerName={designer.name}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</main>
|
||||
|
||||
{/* Edit Modal */}
|
||||
<Dialog open={isEditModalOpen} onOpenChange={setIsEditModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<DesignerForm
|
||||
initialData={{
|
||||
name: designer.name,
|
||||
slug: designer.slug,
|
||||
description: designer.description,
|
||||
person_type: designer.person_type as any,
|
||||
website_url: designer.website_url,
|
||||
founded_year: designer.founded_year,
|
||||
headquarters_location: designer.headquarters_location
|
||||
}}
|
||||
onSubmit={handleEditSubmit}
|
||||
onCancel={() => setIsEditModalOpen(false)}
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,18 +1,48 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Header } from '@/components/layout/Header';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Search, SlidersHorizontal, Palette } from 'lucide-react';
|
||||
import { Search, SlidersHorizontal, Ruler, Plus } from 'lucide-react';
|
||||
import { Company } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { DesignerCard } from '@/components/designers/DesignerCard';
|
||||
import { DesignerForm } from '@/components/admin/DesignerForm';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { submitCompanyCreation } from '@/lib/companyHelpers';
|
||||
|
||||
export default function Designers() {
|
||||
const navigate = useNavigate();
|
||||
const { user } = useAuth();
|
||||
const { isModerator } = useUserRole();
|
||||
const [companies, setCompanies] = useState<Company[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [sortBy, setSortBy] = useState('name');
|
||||
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
||||
|
||||
const handleCreateSubmit = async (data: any) => {
|
||||
try {
|
||||
if (!user) {
|
||||
navigate('/auth');
|
||||
return;
|
||||
}
|
||||
const result = await submitCompanyCreation(data, 'designer', user.id, isModerator());
|
||||
toast({
|
||||
title: result.submitted ? "Designer Submitted" : "Designer Created",
|
||||
description: result.submitted ? "Your submission has been sent for review." : "The designer has been created successfully."
|
||||
});
|
||||
setIsCreateModalOpen(false);
|
||||
if (!result.submitted) fetchCompanies();
|
||||
} catch (error: any) {
|
||||
toast({ title: "Error", description: error.message || "Failed to create designer.", variant: "destructive" });
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchCompanies();
|
||||
@@ -76,9 +106,16 @@ export default function Designers() {
|
||||
<main className="container mx-auto px-4 py-8">
|
||||
{/* Page Header */}
|
||||
<div className="mb-8">
|
||||
<div className="flex items-center gap-3 mb-4">
|
||||
<Palette className="w-10 h-10 text-primary" />
|
||||
<h1 className="text-4xl font-bold">Designers</h1>
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<Ruler className="w-10 h-10 text-primary" />
|
||||
<h1 className="text-4xl font-bold">Designers</h1>
|
||||
</div>
|
||||
{(user && isModerator()) && (
|
||||
<Button onClick={() => setIsCreateModalOpen(true)}>
|
||||
<Plus className="w-4 h-4 mr-2" />Create Designer
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-lg text-muted-foreground">
|
||||
Explore the designers behind your favorite rides and attractions
|
||||
@@ -124,7 +161,7 @@ export default function Designers() {
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-center py-12">
|
||||
<Palette className="w-16 h-16 mb-4 mx-auto text-muted-foreground" />
|
||||
<Ruler className="w-16 h-16 mb-4 mx-auto text-muted-foreground" />
|
||||
<h3 className="text-xl font-semibold mb-2">No designers found</h3>
|
||||
<p className="text-muted-foreground">
|
||||
Try adjusting your search criteria
|
||||
@@ -132,6 +169,11 @@ export default function Designers() {
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<DesignerForm onSubmit={handleCreateSubmit} onCancel={() => setIsCreateModalOpen(false)} />
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
277
src/pages/ManufacturerDetail.tsx
Normal file
277
src/pages/ManufacturerDetail.tsx
Normal file
@@ -0,0 +1,277 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { Header } from '@/components/layout/Header';
|
||||
import { Button } from '@/components/ui/button';
|
||||
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 { ArrowLeft, MapPin, Star, Globe, Calendar, Edit, Factory, FerrisWheel } from 'lucide-react';
|
||||
import { Company } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { ManufacturerForm } from '@/components/admin/ManufacturerForm';
|
||||
import { ManufacturerPhotoGallery } from '@/components/companies/ManufacturerPhotoGallery';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { submitCompanyUpdate } from '@/lib/companyHelpers';
|
||||
|
||||
export default function ManufacturerDetail() {
|
||||
const { slug } = useParams<{ slug: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [manufacturer, setManufacturer] = useState<Company | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
||||
const { user } = useAuth();
|
||||
const { isModerator } = useUserRole();
|
||||
|
||||
useEffect(() => {
|
||||
if (slug) {
|
||||
fetchManufacturerData();
|
||||
}
|
||||
}, [slug]);
|
||||
|
||||
const fetchManufacturerData = async () => {
|
||||
try {
|
||||
const { data, error } = await supabase
|
||||
.from('companies')
|
||||
.select('*')
|
||||
.eq('slug', slug)
|
||||
.eq('company_type', 'manufacturer')
|
||||
.maybeSingle();
|
||||
|
||||
if (error) throw error;
|
||||
setManufacturer(data);
|
||||
} catch (error) {
|
||||
console.error('Error fetching manufacturer:', error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleEditSubmit = async (data: any) => {
|
||||
try {
|
||||
const result = await submitCompanyUpdate(
|
||||
manufacturer!.id,
|
||||
data,
|
||||
user!.id,
|
||||
isModerator()
|
||||
);
|
||||
|
||||
toast({
|
||||
title: result.submitted ? "Edit Submitted" : "Manufacturer Updated",
|
||||
description: result.submitted
|
||||
? "Your edit has been submitted for review."
|
||||
: "The manufacturer has been updated successfully."
|
||||
});
|
||||
|
||||
setIsEditModalOpen(false);
|
||||
if (!result.submitted) {
|
||||
fetchManufacturerData();
|
||||
}
|
||||
} catch (error: any) {
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message || "Failed to submit edit.",
|
||||
variant: "destructive"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="animate-pulse space-y-6">
|
||||
<div className="h-64 bg-muted rounded-lg"></div>
|
||||
<div className="h-8 bg-muted rounded w-1/2"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!manufacturer) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="text-center py-12">
|
||||
<h1 className="text-2xl font-bold mb-4">Manufacturer Not Found</h1>
|
||||
<Button onClick={() => navigate('/manufacturers')}>
|
||||
<ArrowLeft className="w-4 h-4 mr-2" />
|
||||
Back to Manufacturers
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
|
||||
<main className="container mx-auto px-4 py-8">
|
||||
{/* Back Button and Edit Button */}
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<Button variant="ghost" onClick={() => navigate('/manufacturers')}>
|
||||
<ArrowLeft className="w-4 h-4 mr-2" />
|
||||
Back to Manufacturers
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
if (!user) {
|
||||
navigate('/auth');
|
||||
} else {
|
||||
setIsEditModalOpen(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Edit className="w-4 h-4 mr-2" />
|
||||
Edit Manufacturer
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Hero Section */}
|
||||
<div className="relative mb-8">
|
||||
<div className="aspect-[21/9] bg-gradient-to-br from-primary/20 via-secondary/20 to-accent/20 rounded-lg overflow-hidden relative">
|
||||
{manufacturer.logo_url ? (
|
||||
<div className="flex items-center justify-center h-full bg-background/90">
|
||||
<img
|
||||
src={manufacturer.logo_url}
|
||||
alt={manufacturer.name}
|
||||
className="max-h-48 object-contain"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full">
|
||||
<Factory className="w-24 h-24 opacity-50" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="absolute bottom-0 left-0 right-0 p-8 bg-gradient-to-t from-black/60 to-transparent">
|
||||
<div className="flex items-end justify-between">
|
||||
<div>
|
||||
<Badge variant="outline" className="bg-black/20 text-white border-white/20 mb-2">
|
||||
Manufacturer
|
||||
</Badge>
|
||||
<h1 className="text-4xl md:text-6xl font-bold text-white mb-2">
|
||||
{manufacturer.name}
|
||||
</h1>
|
||||
{manufacturer.headquarters_location && (
|
||||
<div className="flex items-center text-white/90 text-lg">
|
||||
<MapPin className="w-5 h-5 mr-2" />
|
||||
{manufacturer.headquarters_location}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{manufacturer.average_rating > 0 && (
|
||||
<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">
|
||||
<Star className="w-6 h-6 fill-yellow-400 text-yellow-400" />
|
||||
<span className="text-3xl font-bold">
|
||||
{manufacturer.average_rating.toFixed(1)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-white/90 text-sm">
|
||||
{manufacturer.review_count} {manufacturer.review_count === 1 ? "review" : "reviews"}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Company Info */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-8">
|
||||
{manufacturer.founded_year && (
|
||||
<Card>
|
||||
<CardContent className="p-4 text-center">
|
||||
<Calendar className="w-6 h-6 text-primary mx-auto mb-2" />
|
||||
<div className="text-2xl font-bold">{manufacturer.founded_year}</div>
|
||||
<div className="text-sm text-muted-foreground">Founded</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
{manufacturer.website_url && (
|
||||
<Card>
|
||||
<CardContent className="p-4 text-center">
|
||||
<Globe className="w-6 h-6 text-primary mx-auto mb-2" />
|
||||
<a
|
||||
href={manufacturer.website_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-sm text-primary hover:underline break-all"
|
||||
>
|
||||
Visit Website
|
||||
</a>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Tabs */}
|
||||
<Tabs defaultValue="overview" className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-3">
|
||||
<TabsTrigger value="overview">Overview</TabsTrigger>
|
||||
<TabsTrigger value="rides">Rides</TabsTrigger>
|
||||
<TabsTrigger value="photos">Photos</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="overview" className="space-y-6">
|
||||
{manufacturer.description && (
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<h2 className="text-2xl font-bold mb-4">About</h2>
|
||||
<p className="text-muted-foreground whitespace-pre-wrap">
|
||||
{manufacturer.description}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="rides">
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<p className="text-muted-foreground">Rides manufactured by {manufacturer.name} will be displayed here.</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="photos">
|
||||
<ManufacturerPhotoGallery
|
||||
manufacturerId={manufacturer.id}
|
||||
manufacturerName={manufacturer.name}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</main>
|
||||
|
||||
{/* Edit Modal */}
|
||||
<Dialog open={isEditModalOpen} onOpenChange={setIsEditModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<ManufacturerForm
|
||||
initialData={{
|
||||
name: manufacturer.name,
|
||||
slug: manufacturer.slug,
|
||||
description: manufacturer.description,
|
||||
person_type: manufacturer.person_type as any,
|
||||
website_url: manufacturer.website_url,
|
||||
founded_year: manufacturer.founded_year,
|
||||
headquarters_location: manufacturer.headquarters_location
|
||||
}}
|
||||
onSubmit={handleEditSubmit}
|
||||
onCancel={() => setIsEditModalOpen(false)}
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,18 +1,30 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Header } from '@/components/layout/Header';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Search, SlidersHorizontal, Factory } from 'lucide-react';
|
||||
import { Search, SlidersHorizontal, Factory, Plus } from 'lucide-react';
|
||||
import { Company } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { ManufacturerCard } from '@/components/manufacturers/ManufacturerCard';
|
||||
import { ManufacturerForm } from '@/components/admin/ManufacturerForm';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { submitCompanyCreation } from '@/lib/companyHelpers';
|
||||
|
||||
export default function Manufacturers() {
|
||||
const navigate = useNavigate();
|
||||
const { user } = useAuth();
|
||||
const { isModerator } = useUserRole();
|
||||
const [companies, setCompanies] = useState<Company[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [sortBy, setSortBy] = useState('name');
|
||||
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@@ -52,6 +64,40 @@ export default function Manufacturers() {
|
||||
company.description?.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
);
|
||||
|
||||
const handleCreateSubmit = async (data: any) => {
|
||||
try {
|
||||
if (!user) {
|
||||
navigate('/auth');
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await submitCompanyCreation(
|
||||
data,
|
||||
'manufacturer',
|
||||
user.id,
|
||||
isModerator()
|
||||
);
|
||||
|
||||
toast({
|
||||
title: result.submitted ? "Manufacturer Submitted" : "Manufacturer Created",
|
||||
description: result.submitted
|
||||
? "Your submission has been sent for review."
|
||||
: "The manufacturer has been created successfully."
|
||||
});
|
||||
|
||||
setIsCreateModalOpen(false);
|
||||
if (!result.submitted) {
|
||||
fetchCompanies();
|
||||
}
|
||||
} catch (error: any) {
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message || "Failed to create manufacturer.",
|
||||
variant: "destructive"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
if (loading) {
|
||||
@@ -79,9 +125,17 @@ export default function Manufacturers() {
|
||||
<main className="container mx-auto px-4 py-8">
|
||||
{/* Page Header */}
|
||||
<div className="mb-8">
|
||||
<div className="flex items-center gap-3 mb-4">
|
||||
<Factory className="w-10 h-10 text-primary" />
|
||||
<h1 className="text-4xl font-bold">Manufacturers</h1>
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<Factory className="w-10 h-10 text-primary" />
|
||||
<h1 className="text-4xl font-bold">Manufacturers</h1>
|
||||
</div>
|
||||
{(user && isModerator()) && (
|
||||
<Button onClick={() => setIsCreateModalOpen(true)}>
|
||||
<Plus className="w-4 h-4 mr-2" />
|
||||
Create Manufacturer
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-lg text-muted-foreground">
|
||||
Explore the manufacturers behind your favorite rides and attractions
|
||||
@@ -136,6 +190,16 @@ export default function Manufacturers() {
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
|
||||
{/* Create Modal */}
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<ManufacturerForm
|
||||
onSubmit={handleCreateSubmit}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
277
src/pages/OperatorDetail.tsx
Normal file
277
src/pages/OperatorDetail.tsx
Normal file
@@ -0,0 +1,277 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { Header } from '@/components/layout/Header';
|
||||
import { Button } from '@/components/ui/button';
|
||||
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 { ArrowLeft, MapPin, Star, Globe, Calendar, Edit, FerrisWheel } from 'lucide-react';
|
||||
import { Company } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { OperatorForm } from '@/components/admin/OperatorForm';
|
||||
import { OperatorPhotoGallery } from '@/components/companies/OperatorPhotoGallery';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { submitCompanyUpdate } from '@/lib/companyHelpers';
|
||||
|
||||
export default function OperatorDetail() {
|
||||
const { slug } = useParams<{ slug: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [operator, setOperator] = useState<Company | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
||||
const { user } = useAuth();
|
||||
const { isModerator } = useUserRole();
|
||||
|
||||
useEffect(() => {
|
||||
if (slug) {
|
||||
fetchOperatorData();
|
||||
}
|
||||
}, [slug]);
|
||||
|
||||
const fetchOperatorData = async () => {
|
||||
try {
|
||||
const { data, error } = await supabase
|
||||
.from('companies')
|
||||
.select('*')
|
||||
.eq('slug', slug)
|
||||
.eq('company_type', 'operator')
|
||||
.maybeSingle();
|
||||
|
||||
if (error) throw error;
|
||||
setOperator(data);
|
||||
} catch (error) {
|
||||
console.error('Error fetching operator:', error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleEditSubmit = async (data: any) => {
|
||||
try {
|
||||
const result = await submitCompanyUpdate(
|
||||
operator!.id,
|
||||
data,
|
||||
user!.id,
|
||||
isModerator()
|
||||
);
|
||||
|
||||
toast({
|
||||
title: result.submitted ? "Edit Submitted" : "Operator Updated",
|
||||
description: result.submitted
|
||||
? "Your edit has been submitted for review."
|
||||
: "The operator has been updated successfully."
|
||||
});
|
||||
|
||||
setIsEditModalOpen(false);
|
||||
if (!result.submitted) {
|
||||
fetchOperatorData();
|
||||
}
|
||||
} catch (error: any) {
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message || "Failed to submit edit.",
|
||||
variant: "destructive"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="animate-pulse space-y-6">
|
||||
<div className="h-64 bg-muted rounded-lg"></div>
|
||||
<div className="h-8 bg-muted rounded w-1/2"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!operator) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="text-center py-12">
|
||||
<h1 className="text-2xl font-bold mb-4">Operator Not Found</h1>
|
||||
<Button onClick={() => navigate('/operators')}>
|
||||
<ArrowLeft className="w-4 h-4 mr-2" />
|
||||
Back to Operators
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
|
||||
<main className="container mx-auto px-4 py-8">
|
||||
{/* Back Button and Edit Button */}
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<Button variant="ghost" onClick={() => navigate('/operators')}>
|
||||
<ArrowLeft className="w-4 h-4 mr-2" />
|
||||
Back to Operators
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
if (!user) {
|
||||
navigate('/auth');
|
||||
} else {
|
||||
setIsEditModalOpen(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Edit className="w-4 h-4 mr-2" />
|
||||
Edit Operator
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Hero Section */}
|
||||
<div className="relative mb-8">
|
||||
<div className="aspect-[21/9] bg-gradient-to-br from-primary/20 via-secondary/20 to-accent/20 rounded-lg overflow-hidden relative">
|
||||
{operator.logo_url ? (
|
||||
<div className="flex items-center justify-center h-full bg-background/90">
|
||||
<img
|
||||
src={operator.logo_url}
|
||||
alt={operator.name}
|
||||
className="max-h-48 object-contain"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full">
|
||||
<FerrisWheel className="w-24 h-24 opacity-50" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="absolute bottom-0 left-0 right-0 p-8 bg-gradient-to-t from-black/60 to-transparent">
|
||||
<div className="flex items-end justify-between">
|
||||
<div>
|
||||
<Badge variant="outline" className="bg-black/20 text-white border-white/20 mb-2">
|
||||
Operator
|
||||
</Badge>
|
||||
<h1 className="text-4xl md:text-6xl font-bold text-white mb-2">
|
||||
{operator.name}
|
||||
</h1>
|
||||
{operator.headquarters_location && (
|
||||
<div className="flex items-center text-white/90 text-lg">
|
||||
<MapPin className="w-5 h-5 mr-2" />
|
||||
{operator.headquarters_location}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{operator.average_rating > 0 && (
|
||||
<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">
|
||||
<Star className="w-6 h-6 fill-yellow-400 text-yellow-400" />
|
||||
<span className="text-3xl font-bold">
|
||||
{operator.average_rating.toFixed(1)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-white/90 text-sm">
|
||||
{operator.review_count} {operator.review_count === 1 ? "review" : "reviews"}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Company Info */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-8">
|
||||
{operator.founded_year && (
|
||||
<Card>
|
||||
<CardContent className="p-4 text-center">
|
||||
<Calendar className="w-6 h-6 text-primary mx-auto mb-2" />
|
||||
<div className="text-2xl font-bold">{operator.founded_year}</div>
|
||||
<div className="text-sm text-muted-foreground">Founded</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
{operator.website_url && (
|
||||
<Card>
|
||||
<CardContent className="p-4 text-center">
|
||||
<Globe className="w-6 h-6 text-primary mx-auto mb-2" />
|
||||
<a
|
||||
href={operator.website_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-sm text-primary hover:underline break-all"
|
||||
>
|
||||
Visit Website
|
||||
</a>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Tabs */}
|
||||
<Tabs defaultValue="overview" className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-3">
|
||||
<TabsTrigger value="overview">Overview</TabsTrigger>
|
||||
<TabsTrigger value="parks">Parks</TabsTrigger>
|
||||
<TabsTrigger value="photos">Photos</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="overview" className="space-y-6">
|
||||
{operator.description && (
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<h2 className="text-2xl font-bold mb-4">About</h2>
|
||||
<p className="text-muted-foreground whitespace-pre-wrap">
|
||||
{operator.description}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="parks">
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<p className="text-muted-foreground">Parks operated by {operator.name} will be displayed here.</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="photos">
|
||||
<OperatorPhotoGallery
|
||||
operatorId={operator.id}
|
||||
operatorName={operator.name}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</main>
|
||||
|
||||
{/* Edit Modal */}
|
||||
<Dialog open={isEditModalOpen} onOpenChange={setIsEditModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<OperatorForm
|
||||
initialData={{
|
||||
name: operator.name,
|
||||
slug: operator.slug,
|
||||
description: operator.description,
|
||||
person_type: operator.person_type as any,
|
||||
website_url: operator.website_url,
|
||||
founded_year: operator.founded_year,
|
||||
headquarters_location: operator.headquarters_location
|
||||
}}
|
||||
onSubmit={handleEditSubmit}
|
||||
onCancel={() => setIsEditModalOpen(false)}
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
277
src/pages/PropertyOwnerDetail.tsx
Normal file
277
src/pages/PropertyOwnerDetail.tsx
Normal file
@@ -0,0 +1,277 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { Header } from '@/components/layout/Header';
|
||||
import { Button } from '@/components/ui/button';
|
||||
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 { ArrowLeft, MapPin, Star, Globe, Calendar, Edit, Building2 } from 'lucide-react';
|
||||
import { Company } from '@/types/database';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { PropertyOwnerForm } from '@/components/admin/PropertyOwnerForm';
|
||||
import { PropertyOwnerPhotoGallery } from '@/components/companies/PropertyOwnerPhotoGallery';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { submitCompanyUpdate } from '@/lib/companyHelpers';
|
||||
|
||||
export default function PropertyOwnerDetail() {
|
||||
const { slug } = useParams<{ slug: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [owner, setOwner] = useState<Company | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
||||
const { user } = useAuth();
|
||||
const { isModerator } = useUserRole();
|
||||
|
||||
useEffect(() => {
|
||||
if (slug) {
|
||||
fetchOwnerData();
|
||||
}
|
||||
}, [slug]);
|
||||
|
||||
const fetchOwnerData = async () => {
|
||||
try {
|
||||
const { data, error } = await supabase
|
||||
.from('companies')
|
||||
.select('*')
|
||||
.eq('slug', slug)
|
||||
.eq('company_type', 'property_owner')
|
||||
.maybeSingle();
|
||||
|
||||
if (error) throw error;
|
||||
setOwner(data);
|
||||
} catch (error) {
|
||||
console.error('Error fetching property owner:', error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleEditSubmit = async (data: any) => {
|
||||
try {
|
||||
const result = await submitCompanyUpdate(
|
||||
owner!.id,
|
||||
data,
|
||||
user!.id,
|
||||
isModerator()
|
||||
);
|
||||
|
||||
toast({
|
||||
title: result.submitted ? "Edit Submitted" : "Property Owner Updated",
|
||||
description: result.submitted
|
||||
? "Your edit has been submitted for review."
|
||||
: "The property owner has been updated successfully."
|
||||
});
|
||||
|
||||
setIsEditModalOpen(false);
|
||||
if (!result.submitted) {
|
||||
fetchOwnerData();
|
||||
}
|
||||
} catch (error: any) {
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message || "Failed to submit edit.",
|
||||
variant: "destructive"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="animate-pulse space-y-6">
|
||||
<div className="h-64 bg-muted rounded-lg"></div>
|
||||
<div className="h-8 bg-muted rounded w-1/2"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!owner) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="text-center py-12">
|
||||
<h1 className="text-2xl font-bold mb-4">Property Owner Not Found</h1>
|
||||
<Button onClick={() => navigate('/owners')}>
|
||||
<ArrowLeft className="w-4 h-4 mr-2" />
|
||||
Back to Property Owners
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<Header />
|
||||
|
||||
<main className="container mx-auto px-4 py-8">
|
||||
{/* Back Button and Edit Button */}
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<Button variant="ghost" onClick={() => navigate('/owners')}>
|
||||
<ArrowLeft className="w-4 h-4 mr-2" />
|
||||
Back to Property Owners
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
if (!user) {
|
||||
navigate('/auth');
|
||||
} else {
|
||||
setIsEditModalOpen(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Edit className="w-4 h-4 mr-2" />
|
||||
Edit Property Owner
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Hero Section */}
|
||||
<div className="relative mb-8">
|
||||
<div className="aspect-[21/9] bg-gradient-to-br from-primary/20 via-secondary/20 to-accent/20 rounded-lg overflow-hidden relative">
|
||||
{owner.logo_url ? (
|
||||
<div className="flex items-center justify-center h-full bg-background/90">
|
||||
<img
|
||||
src={owner.logo_url}
|
||||
alt={owner.name}
|
||||
className="max-h-48 object-contain"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full">
|
||||
<Building2 className="w-24 h-24 opacity-50" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="absolute bottom-0 left-0 right-0 p-8 bg-gradient-to-t from-black/60 to-transparent">
|
||||
<div className="flex items-end justify-between">
|
||||
<div>
|
||||
<Badge variant="outline" className="bg-black/20 text-white border-white/20 mb-2">
|
||||
Property Owner
|
||||
</Badge>
|
||||
<h1 className="text-4xl md:text-6xl font-bold text-white mb-2">
|
||||
{owner.name}
|
||||
</h1>
|
||||
{owner.headquarters_location && (
|
||||
<div className="flex items-center text-white/90 text-lg">
|
||||
<MapPin className="w-5 h-5 mr-2" />
|
||||
{owner.headquarters_location}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{owner.average_rating > 0 && (
|
||||
<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">
|
||||
<Star className="w-6 h-6 fill-yellow-400 text-yellow-400" />
|
||||
<span className="text-3xl font-bold">
|
||||
{owner.average_rating.toFixed(1)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-white/90 text-sm">
|
||||
{owner.review_count} {owner.review_count === 1 ? "review" : "reviews"}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Company Info */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-8">
|
||||
{owner.founded_year && (
|
||||
<Card>
|
||||
<CardContent className="p-4 text-center">
|
||||
<Calendar className="w-6 h-6 text-primary mx-auto mb-2" />
|
||||
<div className="text-2xl font-bold">{owner.founded_year}</div>
|
||||
<div className="text-sm text-muted-foreground">Founded</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
{owner.website_url && (
|
||||
<Card>
|
||||
<CardContent className="p-4 text-center">
|
||||
<Globe className="w-6 h-6 text-primary mx-auto mb-2" />
|
||||
<a
|
||||
href={owner.website_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-sm text-primary hover:underline break-all"
|
||||
>
|
||||
Visit Website
|
||||
</a>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Tabs */}
|
||||
<Tabs defaultValue="overview" className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-3">
|
||||
<TabsTrigger value="overview">Overview</TabsTrigger>
|
||||
<TabsTrigger value="parks">Parks</TabsTrigger>
|
||||
<TabsTrigger value="photos">Photos</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="overview" className="space-y-6">
|
||||
{owner.description && (
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<h2 className="text-2xl font-bold mb-4">About</h2>
|
||||
<p className="text-muted-foreground whitespace-pre-wrap">
|
||||
{owner.description}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="parks">
|
||||
<Card>
|
||||
<CardContent className="p-6">
|
||||
<p className="text-muted-foreground">Parks owned by {owner.name} will be displayed here.</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="photos">
|
||||
<PropertyOwnerPhotoGallery
|
||||
propertyOwnerId={owner.id}
|
||||
propertyOwnerName={owner.name}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</main>
|
||||
|
||||
{/* Edit Modal */}
|
||||
<Dialog open={isEditModalOpen} onOpenChange={setIsEditModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<PropertyOwnerForm
|
||||
initialData={{
|
||||
name: owner.name,
|
||||
slug: owner.slug,
|
||||
description: owner.description,
|
||||
person_type: owner.person_type as any,
|
||||
website_url: owner.website_url,
|
||||
founded_year: owner.founded_year,
|
||||
headquarters_location: owner.headquarters_location
|
||||
}}
|
||||
onSubmit={handleEditSubmit}
|
||||
onCancel={() => setIsEditModalOpen(false)}
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user