"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; const RESULT_LIMIT = 10; const RESULT_OPTIONS = [10, 25, 50, 100]; export function ApifyEmptySearch({ query, country, mediaType, matchMode, status, planLimit }: { query: string; country: string; mediaType: string; matchMode: "ALL_WORDS" | "EXACT_PHRASE"; status: "ACTIVE" | "INACTIVE" | "ALL"; planLimit: number }) { const router = useRouter(); const [maxResults, setMaxResults] = useState(RESULT_LIMIT); const [busy, setBusy] = useState(false); const [message, setMessage] = useState(""); const [error, setError] = useState(false); async function importFromApify() { setBusy(true); setMessage(""); try { const response = await fetch("/api/ads/import-apify", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ searchTerm: query, country, mediaType, matchMode, status, maxResults }) }); const data = await response.json().catch(() => ({})); if (!response.ok) throw new Error(data.error || "APIFY_INGEST_FAILED"); setError(false); setMessage(`${data.received} aday tarandı, ${data.relevant} ilgili reklam bulundu. Sonuçlar yenileniyor…`); router.refresh(); } catch (caught) { setError(true); setMessage(caught instanceof Error ? caught.message : "Apify içe aktarması başarısız oldu."); } finally { setBusy(false); } } return (
Bu arama önce AdSeeQ veritabanını kontrol eder. Yeni Meta reklamlarını seçtiğiniz ülke ve medya türüyle Apify üzerinden getirip aynı aramaya ekleyebilirsiniz.
Apify · {country === "ALL" ? "Tüm dünya" : country} · {mediaType === "ALL" ? "Tüm medya" : mediaType} · {matchMode === "EXACT_PHRASE" ? "Tam ifade" : "Tüm kelimeler"} · Plan limiti: {planLimit || "erişim yok"} reklam
{message &&{message}
}