From f3e95a7bc796ea21a643d26ed56869743ede13e2 Mon Sep 17 00:00:00 2001 From: Rachel Liang Date: Sat, 4 May 2024 21:52:23 -0400 Subject: [PATCH 1/2] Adding carousel --- src/app/user/user-page.jsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/app/user/user-page.jsx b/src/app/user/user-page.jsx index b237132..34003e3 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); } @@ -75,14 +77,17 @@ export default function AccountForm() { const { data, error, status } = await supabase .from("games") .select(`name, type, url_tag, description, created_at`) - .eq("owner", userid) - .maybeSingle(); + .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 - + From 4176b9fc159472074e6f80c0fa8182c66064184a Mon Sep 17 00:00:00 2001 From: rrliang Date: Sat, 4 May 2024 22:00:49 -0400 Subject: [PATCH 2/2] OOP carousel --- src/app/carousel/index.jsx | 42 +++++++++++++++++++------------------- src/app/page.jsx | 2 +- src/app/user/user-page.jsx | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) 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 34003e3..910a4c5 100644 --- a/src/app/user/user-page.jsx +++ b/src/app/user/user-page.jsx @@ -76,7 +76,7 @@ export default function AccountForm() { try { const { data, error, status } = await supabase .from("games") - .select(`name, type, url_tag, description, created_at`) + .select("*, profiles!inner(username)") .eq("owner", userid); // .maybeSingle();