import { useState } from 'react';
import RsvpForm from './RsvpForm';
import GuestLogin from './GuestLogin';
import { useGetGuestsQuery } from '../apiSlice'

function Rsvp() {
  // Enter your name to RSVP; query the database
  const [loggedIn, setLoggedIn] = useState(false);

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

  return (
    <>
      {loggedIn ? (
        <RsvpForm />
      ) : (
        <GuestLogin loggedIn={loggedIn} setLoggedIn={setLoggedIn} />
      )}
    </>
  )
}

export default Rsvp;
