feat: Centralize Auth Modal and require auth for actions

This commit is contained in:
gpt-engineer-app[bot]
2025-10-16 12:59:20 +00:00
parent e340f1c489
commit 6819682ace
14 changed files with 138 additions and 125 deletions

View File

@@ -14,11 +14,13 @@ import { RideSubmissionData } from '@/types/submission-data';
import { supabase } from '@/integrations/supabase/client';
import { useAuth } from '@/hooks/useAuth';
import { toast } from '@/hooks/use-toast';
import { useAuthModal } from '@/hooks/useAuthModal';
export default function ParkRides() {
const { parkSlug } = useParams<{ parkSlug: string }>();
const navigate = useNavigate();
const { user } = useAuth();
const { requireAuth } = useAuthModal();
const [park, setPark] = useState<Park | null>(null);
const [rides, setRides] = useState<Ride[]>([]);
const [loading, setLoading] = useState(true);
@@ -223,13 +225,7 @@ export default function ParkRides() {
<div className="flex items-center gap-2">
<Button
onClick={() => {
if (!user) {
navigate('/auth');
} else {
setIsCreateModalOpen(true);
}
}}
onClick={() => requireAuth(() => setIsCreateModalOpen(true), "Sign in to add a new ride")}
className="gap-2"
>
<Plus className="w-4 h-4" />