Skip to content

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

Merged
gkhngyk merged 1 commit into
mainfrom
feature/citations-add-competitor
Jul 2, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/citations-add-competitor

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

On the Citations page Domains tab, each row now has an inline "+" to turn a cited domain into a tracked competitor without leaving for the Competitors page.

Per-row behavior (uses the category the row already carries — no extra fetch):

  • Third-party domain (news / review / forum / social / editorial / institutional / other) → shows "+".
  • Our own domain (category === 'you') → no action.
  • Already a competitor (category === 'competitor') → no action; the row already renders the Competitor badge.

Add flow: the "+" opens a confirm dialog — title "Add caranddriver.com as competitor?", an editable Name input pre-filled from the domain (caranddriver.com → "Caranddriver"), Cancel / Add (Add disabled while the name is empty, spinner while saving). It calls the existing addCompetitor(brandId, { name, domain }) (which already strips http(s):// + trailing slashes). On success: toast + refresh the citations data, so the row flips from "+" to the Competitor badge.

No new server code, endpoints, or migrations — reuses addCompetitor and the Dialog primitive.

Related issue

Closes #301

Type of change

  • feat — New feature

How to test

  1. Citations → Domains for a brand with a non-competitor third-party domain and a tracked-competitor domain.
  2. Third-party domain shows "+"; our own domain shows no action; an existing competitor shows no "+" (just its Competitor badge).
  3. Click "+" → dialog with an editable, pre-filled name → Add → competitor is created (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; Cancel closes without creating anything.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an inline per-domain action on the Citations → Domains table so users can promote a cited third‑party domain into a tracked competitor without navigating away, reusing the existing addCompetitor action and Dialog UI primitive.

Changes:

  • Added a per-row “+” action (hidden for you and competitor categories) that opens a confirmation dialog and calls addCompetitor.
  • Implemented a small name-derivation helper to prefill the competitor name from the domain.
  • Refreshes citations data after a successful add so the row updates from “+” to the Competitor badge.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +740 to +743
<Label htmlFor="add-competitor-name">Name</Label>
<Input
id="add-competitor-name"
value={name}
<TableHead className="text-xs">Platforms</TableHead>
<TableHead className="text-xs">Usage</TableHead>
<TableHead className="text-right text-xs">Avg Citations</TableHead>
<TableHead className="w-[44px]" />
Comment on lines +708 to +710
} catch (err) {
toast.error(err instanceof Error ? err.message : 'Failed to add competitor');
} finally {
…m the Domains table

Each Domains-table row for a third-party domain (news / review / forum /
social / editorial / institutional / other) now shows a "+" that opens a
confirm dialog to track it as a competitor. Our own domain (category
'you') and already-tracked competitors show no action — the latter already
render the Competitor badge.

The dialog pre-fills an editable name derived from the domain
(caranddriver.com -> "Caranddriver") and calls the existing addCompetitor
action; on success it refreshes the citations data so the row flips from
"+" to the Competitor badge. No new server code or endpoints.
@gkhngyk
gkhngyk force-pushed the feature/citations-add-competitor branch from dc71ece to 51e1560 Compare July 2, 2026 14:14
@gkhngyk
gkhngyk merged commit 0d06a02 into main Jul 2, 2026
3 checks passed
@gkhngyk
gkhngyk deleted the feature/citations-add-competitor branch July 2, 2026 15:04
@gkhngyk gkhngyk mentioned this pull request Jul 6, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants