summaryrefslogtreecommitdiff
path: root/src/components/Admin.tsx
blob: 11fbc2244ad7c8bf43e31dbbe34fb900504349d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Paper, Typography } from '@mui/material';
import { useGetGuestsQuery } from '../apiSlice';

function Admin() {
  const {
    data: guests,
    isLoading,
    isSuccess,
    isError,
    error
  } = useGetGuestsQuery();

  let content;

  if (isLoading) {
    content = <Typography>Loading...</Typography>
  } else if (isSuccess) {
    content = JSON.stringify(guests);
  } else if (isError) {
    content = <>{error.toString()}</>
  }

  return (
    <Paper>
      <Typography variant="h6">
        Admin
      </Typography>
      {content}
    </Paper>
  );
}

export default Admin;