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;
