import { useDataContext } from "../../common/contexts/data_context";
import { useGet } from "../../common/hooks/useGet";
import { TravelDetails } from "../domain/entities/travel_details";

interface GetTravelDetailsProps {
    id: number;
}

export const useGetTravelDetails = ({ id }: GetTravelDetailsProps) => {
    const { travelRepository } = useDataContext();
    const callback = async () => {
        return await travelRepository!.getTravelDetails(id);
    }
    const { data, requestStatus } = useGet<TravelDetails>(callback);

    return {
        data,
        requestStatus
    }
}