mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:11:12 -05:00
feat: Centralize Auth Modal and require auth for actions
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user