import { useState } from 'react';
import { getGuest } from '../services/guestService';
import type { Guest } from '../types/guest';

export function useGuest(guestId: number | null) {
  const [guest, setGuest] = useState<Guest | null>(() =>
    guestId ? (getGuest(guestId) ?? null) : null
  );

  const refresh = () => {
    if (!guestId) return;
    setGuest(getGuest(guestId) ?? null);
  };

  return { guest, loading: false, refresh };
}
