Skip to content

feat: feat: sync selected campaign to URL query param - #49

Merged
ritik4ever merged 2 commits into
ritik4ever:mainfrom
simplicityf:feat/share-campaign
Mar 27, 2026
Merged

feat: feat: sync selected campaign to URL query param #49
ritik4ever merged 2 commits into
ritik4ever:mainfrom
simplicityf:feat/share-campaign

Conversation

@simplicityf

Copy link
Copy Markdown
Contributor

Add URL-based campaign selection

Selected campaigns are now reflected in the URL as ?campaign=<id>, enabling direct links to any campaign on the board.

Changes

App.tsx

  • Added getCampaignIdFromUrl() to read ?campaign= from window.location.search on mount
  • Added setCampaignIdInUrl() using history.replaceState to keep the URL in sync without polluting browser history
  • Bootstrap effect now validates the URL param against the fetched campaign list — restores a valid ID, falls back to the first campaign and shows a warning banner for an invalid one, or defaults to existing behaviour when no param is present
  • Added invalidUrlCampaignId state and a dismissible amber warning banner rendered above the metric grid with role="alert"
  • Replaced direct setSelectedCampaignId in onSelect with a handleSelect wrapper that also clears the invalid-link banner on intentional navigation

invalid-campaign-banner.css (new)

  • Amber warning banner styles; add to your main stylesheet

Behaviour

Scenario Result
?campaign=42 — valid ID Campaign 42 selected and detail panel loaded
?campaign=99 — unknown ID Warning banner shown, falls back to first campaign
No param Default behaviour unchanged (first campaign selected)
User selects a campaign URL updated in place; banner dismissed if visible

Notes

  • Uses replaceState not pushState — selecting campaigns doesn't pollute browser history, but the param is visible in the address bar for copying/sharing
  • No router library added; plain URLSearchParams + history.replaceState covers the requirement with zero new dependencies

Related Issue

Closes #8

@drips-wave

drips-wave Bot commented Mar 26, 2026

Copy link
Copy Markdown

@simplicityf Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Mar 26, 2026

Copy link
Copy Markdown

@simplicityf is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@ritik4ever
ritik4ever merged commit e2b8fec into ritik4ever:main Mar 27, 2026
0 of 2 checks passed
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.

Add Shareable Campaign Links

2 participants