diff --git a/src/app/dashboard/ads/page.tsx b/src/app/dashboard/ads/page.tsx index 9434e8f..97fe278 100644 --- a/src/app/dashboard/ads/page.tsx +++ b/src/app/dashboard/ads/page.tsx @@ -6,6 +6,7 @@ import { maskAdForPlan } from "@/lib/locked-response"; import { planFromUser } from "@/lib/plans"; import { Card } from "@/components/ui/card"; import { AdCreativeMedia } from "@/components/ad-creative-media"; +import { ApifyEmptySearch } from "@/components/ads/apify-empty-search"; export default async function AdsPage({ searchParams }: { searchParams: Promise> }) { const user = await requireUser(); @@ -45,6 +46,13 @@ export default async function AdsPage({ searchParams }: { searchParams: Promise< {["Week's biggest winners", "US winners", "Dropship Ads", "Supplements", "Top Branded"].map((x) => {x})}
+ {q && masked.length === 0 && isAdmin && } + {q && masked.length === 0 && !isAdmin && ( +
+

“{q}” için sonuç bulunamadı

+

Yeni reklamların içe aktarılması için yöneticinizle iletişime geçin.

+
+ )} {masked.map((ad: any) => ( {ad.isLocked &&
Start now — Unlock winners
} diff --git a/src/components/ads/apify-empty-search.tsx b/src/components/ads/apify-empty-search.tsx new file mode 100644 index 0000000..f9d1416 --- /dev/null +++ b/src/components/ads/apify-empty-search.tsx @@ -0,0 +1,67 @@ +"use client"; + +import { useState } from "react"; +import { useRouter } from "next/navigation"; + +const RESULT_LIMIT = 10; +const MAX_COST_USD = 0.1; + +export function ApifyEmptySearch({ query }: { query: string }) { + const router = useRouter(); + const [busy, setBusy] = useState(false); + const [message, setMessage] = useState(""); + const [error, setError] = useState(false); + + async function importFromApify() { + if (!window.confirm(`“${query}” için Apify'dan en fazla ${RESULT_LIMIT} reklam getirilsin mi? Harcama üst sınırı $${MAX_COST_USD.toFixed(2)}.`)) return; + + setBusy(true); + setMessage(""); + try { + const response = await fetch("/api/admin/ingest/apify", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ + searchTerms: [query], + country: "ALL", + adActiveStatus: "ACTIVE", + mediaType: "ALL", + maxResults: RESULT_LIMIT, + maxCostUsd: MAX_COST_USD, + scrapeAdDetails: true, + includeAboutPage: false + }) + }); + const data = await response.json().catch(() => ({})); + if (!response.ok) throw new Error(data.error || "APIFY_INGEST_FAILED"); + + setError(false); + setMessage(`${data.imported} reklam işlendi. 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 ( +
+

“{query}” için kayıtlı reklam bulunamadı

+

+ Bu arama önce WinningHunter veritabanını kontrol eder. Yeni Meta reklamlarını Apify üzerinden getirip aynı aramaya ekleyebilirsiniz. +

+ +

Harcama üst sınırı: $0.10 · Yalnızca yöneticiler

+ {message &&

{message}

} +
+ ); +}