Repository navigation
Description
Summary
On the Citations page Domains tab, add a per-row action that lets a user turn any cited domain into a tracked competitor in one click. When scanning which domains AI engines cite, you often spot a competitor that isn't tracked yet — today you'd have to leave for the Competitors page and re-type it. This adds an inline "+" to add it on the spot.
Behaviour
For each row in the Domains table:
- Not a competitor and not our own domain (
categoryisnews/review/forum/social/editorial/institutional/other): show a "+" action. Clicking it opens a small confirmation dialog to add the domain as a competitor. - Already a competitor (
category === 'competitor'): show no add action. Don't add a separate "−"/remove marker — the row already renders a Competitor badge (CategoryBadge), which is enough to signal "already tracked." (Removing a competitor stays on the Competitors page.) - Our own domain (
category === 'you'): show nothing (you can't add yourself as a competitor).
The row already carries category (set by getCitationsOverview in web/src/lib/actions/citations.ts), so the page knows the competitor state with no extra fetch.
Add flow (the "+")
addCompetitor(brandId, { name, domain }) already exists (web/src/lib/actions/competitor.ts), but name is required and we only have a domain from the table. So the "+" opens a confirmation dialog:
- Title: "Add
caranddriver.comas competitor?" - A Name input, pre-filled with a name derived from the domain (e.g.
caranddriver.com→ "Caranddriver"), editable so the user can correct it. - Buttons: Cancel / Add (Add disabled while name is empty, spinner while saving).
- The domain is passed straight through (
addCompetitoralready stripshttp(s)://and trailing slashes).
On success: toast + refresh the citations data so the row's "+" disappears and it shows the Competitor badge instead. Reuse the existing Dialog primitive (web/src/components/ui/dialog.tsx) and mirror the confirm-dialog pattern already used on the Competitors page.
Files to touch
web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx— add the "+" action toDomainsTablerows; aConfirmAddCompetitorDialog(or inline Dialog) wired toaddCompetitor; refresh after add.- Reuse
addCompetitorfromweb/src/lib/actions/competitor.ts(no change expected) andDialogfromweb/src/components/ui/dialog.tsx.
How to test
- Open Citations → Domains for a brand with at least one non-competitor domain and one tracked-competitor domain.
- A non-competitor third-party domain shows "+"; our own domain shows no action; an existing competitor shows no "+" (just its Competitor badge).
- Click "+" on a non-competitor domain → dialog opens with an editable, pre-filled name → Add → competitor is created (verify it appears on the Competitors page) and the row's "+" is replaced by the Competitor badge.
- Add is disabled when the name field is cleared.
- Cancel closes the dialog without creating anything.
Activity