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 { RideForm } from '@/components/admin/RideForm';
import { AutocompleteSearch } from '@/components/search/AutocompleteSearch';
import { useAuth } from '@/hooks/useAuth';
import { toast } from '@/hooks/use-toast';
import { useAuthModal } from '@/hooks/useAuthModal';
export default function DesignerRides() {
const { designerSlug } = useParams<{ designerSlug: string }>();
const navigate = useNavigate();
const { user } = useAuth();
const { requireAuth } = useAuthModal();
const [designer, setDesigner] = useState<Company | null>(null);
const [rides, setRides] = useState<Ride[]>([]);
const [loading, setLoading] = useState(true);
@@ -100,8 +102,7 @@ export default function DesignerRides() {
const handleCreateSubmit = async (data: any) => {
try {
if (!user) {
navigate('/auth');
if (!user || !designer) {
return;
}
@@ -209,12 +210,12 @@ export default function DesignerRides() {
<FerrisWheel className="w-8 h-8 text-primary" />
<h1 className="text-4xl font-bold">Rides by {designer.name}</h1>
</div>
{user && (
<Button onClick={() => setIsCreateModalOpen(true)}>
<Plus className="w-4 h-4 mr-2" />
Add Ride
</Button>
)}
<Button
onClick={() => requireAuth(() => setIsCreateModalOpen(true), "Sign in to add a new ride")}
>
<Plus className="w-4 h-4 mr-2" />
Add Ride
</Button>
</div>
<p className="text-lg text-muted-foreground mb-4">
Explore all rides designed by {designer.name}