const { useState: useStateSR } = React; const ALL_COMPETITORS_ID = '__all_competitors__'; window.SearchRow = function SearchRow({ row, onChange, onRemove, canRemove, competitors }) { const filters = row.filters || {}; const togglePlatform = (p) => { const next = { ...row.platforms, [p]: !row.platforms[p] }; onChange({ ...row, platforms: next }); }; const setFilter = (key, value) => { onChange({ ...row, filters: { ...filters, [key]: value } }); }; const onCompetitor = (e) => { const competitorId = e.target.value || null; onChange({ ...row, competitorId }); }; const allCompetitorsSet = row.competitorId === ALL_COMPETITORS_ID; const competitorSet = !!row.competitorId; const foreplayEnabled = !!row.platforms?.foreplay; const adspyEnabled = !!row.platforms?.adspy; const brandsearchEnabled = !!row.platforms?.brandsearch; return (
onChange({ ...row, query: e.target.value })} placeholder={allCompetitorsSet ? 'Optional keyword across competitor ads' : competitorSet ? 'Optional keyword within competitor' : 'Brand or keyword (e.g. mushroom coffee)'} /> onChange({ ...row, count: +e.target.value })} />
{Object.entries(PLATFORMS).map(([key, p]) => { const on = row.platforms[key]; const live = key === 'foreplay' || key === 'adspy' || key === 'brandsearch'; return ( ); })}
{adspyEnabled && (
)} {brandsearchEnabled && (
)} {(foreplayEnabled || brandsearchEnabled) && (
{foreplayEnabled && ( setFilter('foreplayUrl', e.target.value)} placeholder="Foreplay ad URL" title="Fetch only this Foreplay ad" /> )} {brandsearchEnabled && ( setFilter('brandsearchUrl', e.target.value)} placeholder="BrandSearch ad URL" title="Fetch only this BrandSearch ad" /> )}
)}
); };