|
1 |
| -import StrippedTable from "@component/StrippedTable"; |
2 | 1 | import Head from "@layout/Head";
|
3 | 2 | import Label from "@component/Label";
|
4 | 3 | import { trpc } from "@util/trpc";
|
5 |
| -import { VStack } from "@chakra-ui/react"; |
| 4 | +import { Table, TableContainer, Thead, Tr, Th, Tbody, Td } from "@chakra-ui/react"; |
6 | 5 | import { getVocationNameById } from "@shared/enums/Vocation";
|
7 | 6 | import { Content } from "@component/Content";
|
8 | 7 |
|
9 | 8 | export default function WhoIsOnline() {
|
10 | 9 | const players = trpc.player.online.useQuery();
|
11 | 10 | const status = trpc.status.status.useQuery();
|
| 11 | + const onlinePlayers = players.data; |
12 | 12 |
|
13 | 13 | return (
|
14 | 14 | <>
|
15 | 15 | <Head title="Who is online" />
|
16 | 16 | <Content>
|
17 |
| - <Content.Header>Server Info</Content.Header> |
18 |
| - <Content.Body> |
19 |
| - <VStack w="40rem" maxW="40rem"> |
20 |
| - <Label colorScheme="violet" fontSize="sm"> |
21 |
| - Overall Maximum: {status.data?.maxOnlineCount ?? 0} players. There are currently {players.data?.length ?? 0} players online on |
22 |
| - {status.data?.name ?? "..."} |
23 |
| - </Label> |
24 |
| - {players.data && ( |
25 |
| - <StrippedTable |
26 |
| - isLoading={players.isLoading} |
27 |
| - head={[{ text: "Name" }, { text: "Level" }, { text: "Vocation" }]} |
28 |
| - body={players.data?.map((player) => [ |
29 |
| - { href: `/character/${player.name}`, text: player.name }, |
30 |
| - { text: player.level }, |
31 |
| - { text: getVocationNameById(player.vocation) }, |
32 |
| - ])} |
33 |
| - /> |
34 |
| - )} |
35 |
| - </VStack> |
| 17 | + <Content.Header>Who Is Online</Content.Header> |
| 18 | + <Content.Body w="100%" gap={5}> |
| 19 | + <Label colorScheme="violet" fontSize="sm"> |
| 20 | + Overall Maximum: {status.data?.maxOnlineCount ?? 0} players. There are currently {onlinePlayers?.length ?? 0} players online on{" "} |
| 21 | + {status.data?.name ? status.data.name : "unknown"} |
| 22 | + </Label> |
| 23 | + {onlinePlayers && ( |
| 24 | + <TableContainer> |
| 25 | + <Table variant="striped" colorScheme="purple"> |
| 26 | + <Thead> |
| 27 | + <Tr> |
| 28 | + <Th>Name</Th> |
| 29 | + <Th isNumeric>Level</Th> |
| 30 | + <Th>Vocation</Th> |
| 31 | + </Tr> |
| 32 | + </Thead> |
| 33 | + <Tbody> |
| 34 | + {onlinePlayers?.map((player) => ( |
| 35 | + <Tr key={player.name}> |
| 36 | + <Td>{player.name}</Td> |
| 37 | + <Td isNumeric>{player.level}</Td> |
| 38 | + <Td>{getVocationNameById(player.vocation)}</Td> |
| 39 | + </Tr> |
| 40 | + ))} |
| 41 | + </Tbody> |
| 42 | + </Table> |
| 43 | + </TableContainer> |
| 44 | + )} |
36 | 45 | </Content.Body>
|
37 | 46 | </Content>
|
38 | 47 | </>
|
|
0 commit comments