"use client"; import { createClient } from "@/utils/supabase/client"; import { redirect } from "next/navigation"; import { Vortex } from "@/components/ui/vortex"; import GalleryThumbnail from "@/components/ui/gallery_thumbnail"; import React, { useState, useEffect } from 'react'; import { User } from "@supabase/supabase-js"; import Gallery from "@/components/ui/gallery"; function PageComponent() { const supabase = createClient(); const [isOpen, setIsOpen] = useState(false); const [galleries, setGalleries] = useState([]); // replace any with your gallery type const [user, setUser] = useState(null); const [loading, setLoading] = useState(true); const [selectedGallery, setSelectedGallery] = useState(null); const selectGallery = (gallery:number) => { setSelectedGallery(gallery); setIsOpen(true); }; const getData = async () => { const galleriesResponse = await fetch('/api/galleries'); const galleriesData = await galleriesResponse.json(); let { data: { user } } = await supabase.auth.getUser(); setGalleries(galleriesData); setUser(user); setLoading(false); } useEffect(() => { getData(); }, [selectedGallery,isOpen]); return ( ( user ? (
Background
{galleries.map((gallery, index) => ( selectGallery(gallery.id)}> ))}
{(isOpen ? ( <> ): null)}
) : (

loading

))); } export default PageComponent;