Skip to content

feat(citations): inline "+" to add a cited domain as a competitor from the Domains table #301

Closed

Description

@gkhngyk

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 (category is news / 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.com as 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 (addCompetitor already strips http(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 to DomainsTable rows; a ConfirmAddCompetitorDialog (or inline Dialog) wired to addCompetitor; refresh after add.
  • Reuse addCompetitor from web/src/lib/actions/competitor.ts (no change expected) and Dialog from web/src/components/ui/dialog.tsx.

How to test

  1. Open Citations → Domains for a brand with at least one non-competitor domain and one tracked-competitor domain.
  2. A non-competitor third-party domain shows "+"; our own domain shows no action; an existing competitor shows no "+" (just its Competitor badge).
  3. 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.
  4. Add is disabled when the name field is cleared.
  5. Cancel closes the dialog without creating anything.

Activity

  1. added
    enhancement
    on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions