import config from "../../../config";
import useApiFetchLocations from "../../api/useApiFetchLocations"

const useGetFuneralLocations = () => {
    const locationsResponse = useApiFetchLocations()

    const excludedTypes = ["mosque"];
    const locationTypesValues = config.locationTypes.map((locationType: any) => locationType.value);

    const funeralLocations = locationsResponse?.data?.filter(
        (location: any) =>
            locationTypesValues.includes(location.type) && !excludedTypes.includes(location.type)
    );

    return {
        funeralLocations,
        isLoading: locationsResponse.isLoading,
        error: locationsResponse.error,
        manualRefetch: locationsResponse.manualRefetch
    }
}

export default useGetFuneralLocations