diff --git a/src/app/carousel/index.jsx b/src/app/carousel/index.jsx index 1be9982..15577da 100644 --- a/src/app/carousel/index.jsx +++ b/src/app/carousel/index.jsx @@ -22,30 +22,30 @@ import { import ChakraCarousel from "./ChakraCarousel"; -export default function App() { - const supabase = createClient(); - const [data, setData] = useState([]); +export default function App({data}) { + // const supabase = createClient(); + // const [data, setData] = useState([]); - const allGames = useCallback(async () => { - try { - const { data: allGameData, error, status} = await supabase.from("games").select("*, profiles!inner(username)"); + // const allGames = useCallback(async () => { + // try { + // const { data: allGameData, error, status} = await supabase.from("games").select("*, profiles!inner(username)"); - if (error && status !== 406) { - throw error; - } + // if (error && status !== 406) { + // throw error; + // } - if (data) { - setData(allGameData); - } - } catch (error) { - alert("Error loading games!"); - console.log(error); - } - }, [supabase]); + // if (data) { + // setData(allGameData); + // } + // } catch (error) { + // alert("Error loading games!"); + // console.log(error); + // } + // }, [supabase]); - useEffect(() => { - allGames(); - }, [allGames]); + // useEffect(() => { + // allGames(); + // }, [allGames]); return ( @@ -64,7 +64,7 @@ export default function App() { > {/* TODO: instead of just limiting data from query, try to sort by rating for featured games */} - {data.slice(1, 10).map(({id, description, name, type, url_tag: url, profiles: { username }}) => ( + {data.map(({id, description, name, type, url_tag: url, profiles: { username }}) => ( { try { - const { - data: allGameData, - error, - status, - } = await supabase.from("games").select("*, profiles!inner(username)"); + const { data: allGameData, error, status} = await supabase.from("games").select("*, profiles!inner(username)").limit(10); if (error && status !== 406) { throw error; diff --git a/src/app/user/user-page.jsx b/src/app/user/user-page.jsx index b237132..910a4c5 100644 --- a/src/app/user/user-page.jsx +++ b/src/app/user/user-page.jsx @@ -27,6 +27,7 @@ import { Input, WrapItem, IconButton, Alert, AlertIcon, Spinner, AlertTitle, AlertDescription, CloseButton } from "@chakra-ui/react"; import createClient from "@/utils/supabase/client"; import React, { useRef } from 'react'; +import Carousel from "../carousel/index" // import {useParams} from 'react-router-dom'; @@ -67,6 +68,7 @@ export default function AccountForm() { } } catch (error) { alert("Error loading user data!"); + console.log("GOT HERE 1"); console.log(error); } @@ -74,15 +76,18 @@ export default function AccountForm() { try { const { data, error, status } = await supabase .from("games") - .select(`name, type, url_tag, description, created_at`) - .eq("owner", userid) - .maybeSingle(); + .select("*, profiles!inner(username)") + .eq("owner", userid); + // .maybeSingle(); + if (error && status !== 406) { throw error; } if (data) { + console.log("GOT HERE 2"); + console.log("CREATED GAMES: ", data) setCreatedGames(data); } } catch (error) { @@ -95,14 +100,16 @@ export default function AccountForm() { const { data, error, status } = await supabase .from("ratings") .select(`game_id, rating, comment, created_at`) - .eq("user_id", userid) - .maybeSingle(); + .eq("user_id", userid); + // .maybeSingle(); if (error && status !== 406) { throw error; } if (data) { + + console.log("GOT HERE 3"); setReviews(data); } } catch (error) { @@ -127,6 +134,8 @@ export default function AccountForm() { } } catch (error) { + + console.log("GOT HERE 4"); alert("Error loading user data!"); console.log(error); } @@ -169,7 +178,7 @@ export default function AccountForm() { Created Games - +