import React from 'react';
import { useGetGuestsQuery } from '../slices/apiSlice';

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

  let content;

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

  return (
    <>
      <p>Admin</p>
      {content}
    </>
  );
}

export default Admin;
