const { useState, useEffect } = React; function DownloadModal({ hook, onClose }) { const [count, setCount] = useState(5); const [downloading, setDownloading] = useState(false); useEffect(() => { let timer; if (count > 0 && !downloading) { timer = setTimeout(() => setCount(c => c - 1), 1000); } else if (count === 0 && !downloading) { setDownloading(true); const formData = new FormData(); formData.append('action', 'incress_views'); formData.append('file_hash', hook.file_hash); fetch('ajax.php?action=incress_views', { method: 'POST', body: formData }).then(r => r.json()).then(res => { if (res.status === 'success') { let url = `ajax.php?action=download&file_hash=${res.new_hash}`; let a = document.createElement('a'); a.href = url; a.download = res.filename; document.body.appendChild(a); a.click(); a.remove(); setTimeout(() => { onClose(); }, 500); } }).catch(e => { console.error("Error during download trigger:", e); onClose(); }); } return () => clearTimeout(timer); }, [count, downloading, hook, onClose]); return (

تحميل الهاك

لحظات وسوف يتم تحميل الهاك تلقائياً

{hook.name}
الإصدار: {hook.version}
{count}
); }