mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 12:31:13 -05:00
feat: Implement type-safe company rides lists
This commit is contained in:
@@ -4,21 +4,28 @@ import { Header } from '@/components/layout/Header';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { ArrowLeft, Filter, SlidersHorizontal, FerrisWheel } from 'lucide-react';
|
||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||
import { ArrowLeft, Filter, SlidersHorizontal, FerrisWheel, Plus } from 'lucide-react';
|
||||
import { RideModel, Company } from '@/types/database';
|
||||
import { RideModelSubmissionData } from '@/types/submission-data';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { RideModelCard } from '@/components/rides/RideModelCard';
|
||||
import { RideModelForm } from '@/components/admin/RideModelForm';
|
||||
import { AutocompleteSearch } from '@/components/search/AutocompleteSearch';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
|
||||
export default function ManufacturerModels() {
|
||||
const { manufacturerSlug } = useParams<{ manufacturerSlug: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { user } = useAuth();
|
||||
const [manufacturer, setManufacturer] = useState<Company | null>(null);
|
||||
const [models, setModels] = useState<RideModel[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [sortBy, setSortBy] = useState('name');
|
||||
const [filterCategory, setFilterCategory] = useState('all');
|
||||
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
||||
|
||||
const fetchData = useCallback(async () => {
|
||||
try {
|
||||
@@ -84,6 +91,36 @@ export default function ManufacturerModels() {
|
||||
model.description?.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
);
|
||||
|
||||
const handleCreateSubmit = async (data: any) => {
|
||||
try {
|
||||
if (!user) {
|
||||
navigate('/auth');
|
||||
return;
|
||||
}
|
||||
|
||||
// For now, just show a toast since ride model submission isn't implemented yet
|
||||
toast({
|
||||
title: "Coming Soon",
|
||||
description: "Ride model submission is not yet available.",
|
||||
});
|
||||
return;
|
||||
|
||||
toast({
|
||||
title: "Ride Model Submitted",
|
||||
description: "Your ride model submission has been sent for review."
|
||||
});
|
||||
|
||||
setIsCreateModalOpen(false);
|
||||
fetchData();
|
||||
} catch (error: any) {
|
||||
toast({
|
||||
title: "Error",
|
||||
description: error.message || "Failed to submit ride model.",
|
||||
variant: "destructive"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const categories = [
|
||||
{ value: 'all', label: 'All Categories' },
|
||||
{ value: 'roller_coaster', label: 'Roller Coasters' },
|
||||
@@ -142,9 +179,15 @@ export default function ManufacturerModels() {
|
||||
</div>
|
||||
|
||||
<div className="mb-8">
|
||||
<div className="flex items-center gap-3 mb-4">
|
||||
<FerrisWheel className="w-8 h-8 text-primary" />
|
||||
<h1 className="text-4xl font-bold">Models by {manufacturer.name}</h1>
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<FerrisWheel className="w-8 h-8 text-primary" />
|
||||
<h1 className="text-4xl font-bold">Models by {manufacturer.name}</h1>
|
||||
</div>
|
||||
<Button onClick={() => setIsCreateModalOpen(true)}>
|
||||
<Plus className="w-4 h-4 mr-2" />
|
||||
Add Ride Model
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-lg text-muted-foreground mb-4">
|
||||
Explore all ride models manufactured by {manufacturer.name}
|
||||
@@ -214,6 +257,16 @@ export default function ManufacturerModels() {
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<RideModelForm
|
||||
manufacturerName={manufacturer.name}
|
||||
onSubmit={handleCreateSubmit}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user