-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0765311
commit a8231e5
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters