Skip to content

Commit

Permalink
add gallery page
Browse files Browse the repository at this point in the history
  • Loading branch information
Firebird1029 committed Apr 6, 2024
1 parent 0765311 commit a8231e5
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/app/gallery/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import {
Button,
Container,
Heading,
Table,
TableContainer,
TableCaption,
Thead,
Tr,
Th,
Tbody,
Td,
Tfoot,
} from "@chakra-ui/react";
import createClient from "@/utils/supabase/server";

export default async function GalleryPage() {
const supabase = createClient();

// get all games from Supabase
// TODO move to Python API using api service
const { data: allGames, error } = await supabase
.from("games")
.select("*, profiles!inner(username)");

if (error) {
console.error(error); // TODO display error message in GUI
return <Container>Something went wrong!</Container>;
}

return (
<Container>
<Heading mt={4} mb={8}>
Gallery
</Heading>
<TableContainer>
<Table variant="simple">
<TableCaption>Browse user-created games!</TableCaption>
<Thead>
<Tr>
<Th>Game</Th>
<Th>Type</Th>
<Th>Created By</Th>
<Th />
</Tr>
</Thead>
<Tbody>
{allGames.map(({ id, name, type, profiles: { username } }) => (
<Tr key={id}>
<Td>{name}</Td>
<Td>{type}</Td>
<Td>{username}</Td>
<Td>
<Button colorScheme="green">Play</Button>
</Td>
</Tr>
))}
</Tbody>
<Tfoot>
<Tr>
<Th>Game</Th>
<Th>Type</Th>
<Th>Created By</Th>
<Th />
</Tr>
</Tfoot>
</Table>
</TableContainer>
</Container>
);
}
6 changes: 6 additions & 0 deletions src/app/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export default async function Home() {

{/* TODO move these links to navbar etc */}

<Box mb={12}>
<Link as={NextLink} href="/gallery">
<Button colorScheme="blue">Gallery</Button>
</Link>
</Box>

{user && (
<Box mb={16}>
<Link as={NextLink} href="/account">
Expand Down

0 comments on commit a8231e5

Please sign in to comment.