import { getTrip } from '@/services/controller/TripController';
import { useCallback, useState } from 'react';

export default function useGetTripModel() {
  const [data, setData] = useState<API.Trip | null>(null);
  const [loading, setLoading] = useState(false);
  const getApi = useCallback(async () => {
    setLoading(true);
    try {
      const res = await getTrip(); // đổi URL cho phù hợp
      setData(res || []);
    } catch (err) {
      console.error('Fetch data failed', err);
    } finally {
      setLoading(false);
    }
  }, []);
  return {
    data,
    loading,
    getApi,
  };
}
