import { useState } from "react"; import { toast } from "react-toastify"; import { exportRecipesPdf } from "./recipePdf"; /** Export receptů do PDF s příznakem probíhajícího exportu a hláškou při chybě. */ export const useRecipeExport = () => { const [exporting, setExporting] = useState(false); const exportRecipes = async (itemList: Parameters[0]) => { if (exporting || !itemList.length) return; setExporting(true); try { await exportRecipesPdf(itemList); } catch (error) { console.error('Export receptů do PDF selhal', error); toast.error('PDF se nepodařilo vytvořit.'); } finally { setExporting(false); } }; return { exporting, exportRecipes }; };