Skip to content

feat: add share-by-URL for search parameters#11

Open
Idrhas wants to merge 3 commits into
ShippedLabs:mainfrom
Idrhas:feat/share-by-url
Open

feat: add share-by-URL for search parameters#11
Idrhas wants to merge 3 commits into
ShippedLabs:mainfrom
Idrhas:feat/share-by-url

Conversation

@Idrhas

@Idrhas Idrhas commented Jun 18, 2026

Copy link
Copy Markdown

Summary

Closes #6

Encodes the current search inputs (source, destination, amount, direction, and network) as URL query parameters so a user can copy the URL and share it. Opening the URL pre-fills the form and runs the search automatically.

Changes

src/app/page.tsx

  • Added useRouter and useSearchParams from next/navigation
  • encodeAsset / decodeAsset helpers serialise AssetRef to/from ?src=XLM or ?src=CODE:ISSUER - malformed params return undefined (no crash)
  • Bootstrap useEffect fires once after network hydration, reads URL params, and calls search() only when all params are valid
  • handleSearch pushes a history entry via router.push() before calling search() so the back button works correctly
  • Polling re-fetches go through refresh() and never touch the router

src/components/path-form.tsx

  • Added four optional props: initialSource, initialDestination, initialAmount, initialDirection
  • All props default to the same values previously hardcoded - fully backwards compatible
  • useState initialisers use the URL-seeded values when provided

src/hooks/use-paths.ts

  • Added refresh() alongside search() - both share the same internal logic
  • refresh() signals to callers (polling) that no history entry should be pushed

Acceptance Criteria

  • After a search, the URL contains ?src=&dst=&amount=&dir=&net= params
  • Pasting the URL into a new tab pre-fills the form and runs the search automatically
  • Malformed query parameters do not crash the app (graceful fallback to defaults)
  • The browser back button navigates to the previous search state
  • Polling re-fetches do not push a new history entry

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

@Idrhas is attempting to deploy a commit to the raymondabiola's projects Team on Vercel.

A member of the Team first needs to authorize it.

@RaymondAbiola

Copy link
Copy Markdown
Contributor

@Idrhas please resolve conflicts, thank you.

@RaymondAbiola

Copy link
Copy Markdown
Contributor

@Idrhas Kindly resolve pr conflicts

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 share-by-URL for search parameters

2 participants