Skip to content

Commit

Permalink
Merge branch 'beta' into yaara_and_brice
Browse files Browse the repository at this point in the history
  • Loading branch information
rrliang authored May 5, 2024
2 parents 36bb583 + 4176b9f commit 49a511e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 32 deletions.
42 changes: 21 additions & 21 deletions src/app/carousel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (

Expand All @@ -64,7 +64,7 @@ export default function App() {
>
<ChakraCarousel gap={32}>
{/* 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 }}) => (
<Flex
key={id}
boxShadow="rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px"
Expand Down
6 changes: 1 addition & 5 deletions src/app/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ export default function Home() {

const allGames = useCallback(async () => {
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;
Expand Down
21 changes: 15 additions & 6 deletions src/app/user/user-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -67,22 +68,26 @@ export default function AccountForm() {
}
} catch (error) {
alert("Error loading user data!");
console.log("GOT HERE 1");
console.log(error);
}

//SET CREATED GAMES
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) {
Expand All @@ -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) {
Expand All @@ -127,6 +134,8 @@ export default function AccountForm() {
}

} catch (error) {

console.log("GOT HERE 4");
alert("Error loading user data!");
console.log(error);
}
Expand Down Expand Up @@ -169,7 +178,7 @@ export default function AccountForm() {
<CardBody>
<Box>
<Heading>Created Games</Heading>

<Carousel data={createdGames}/>
</Box>
</CardBody>

Expand Down

0 comments on commit 49a511e

Please sign in to comment.