import {useQuery} from "@tanstack/react-query";
import {BarcodeService} from "../../client";

const useGetAllBarcodeTemplates = () => {
    const {data, error, isLoading, refetch} = useQuery({
        queryKey: ['getAllBarcodeTemplates'],
        queryFn: () => BarcodeService.getAllBarcodeTemplates(),
        select: (data) => data.templates
    });
    const barcodeTemplates = isLoading || error || !data ? [] : data;
    return {barcodeTemplates, refetch}
}

export default useGetAllBarcodeTemplates;