Add NotificationDeepLinkHandler and related tests for handling deep l…#268
Open
Chrisbankz0 wants to merge 3 commits intoamina69:mainfrom
Open
Add NotificationDeepLinkHandler and related tests for handling deep l…#268Chrisbankz0 wants to merge 3 commits intoamina69:mainfrom
Chrisbankz0 wants to merge 3 commits intoamina69:mainfrom
Conversation
|
@Chrisbankz0 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! 🚀 |
Owner
|
@Chrisbankz0 you have lint error |
…r unread notifications
Owner
|
@Chrisbankz0 lint erorrs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

#closes #234
PR Summary
Adds a notification deep-link handler for the PetAd frontend application. On app startup, the handler checks for a
notificationIdquery parameter, fetches the associated notification, marks it as read, navigates to the correct route usingnotificationRouter(), and removes the query parameter from the URL.What changed
Added
src/lib/NotificationDeepLinkHandler.tsx?notificationId=from the current URL on app mount./api/notifications/:idto retrieve the notification payload.PATCH /api/notifications/:id/read.notificationRouter()to determine the destination route.notificationIdfrom the URL after handling.Updated
src/App.tsx<NotificationDeepLinkHandler />globally so deep links are processed as soon as the app renders.Updated
src/mocks/handlers/notify.tsGET /api/notifications/:idin the development/test mock server.Added tests
src/lib/__tests__/NotificationDeepLinkHandler.test.tsxsrc/lib/__tests__/notificationRouter.test.ts.Why this matters
This change enables notification deep-linking for the app, allowing users to open a URL with
?notificationId=and be routed directly to the relevant page while still marking the notification as read. It also removes the query parameter after processing so the URL remains clean.Testing instructions
Install dependencies if needed:
npm installRun the focused tests:
node_modules/.bin/vitest run src/lib/__tests__/NotificationDeepLinkHandler.test.tsx src/lib/__tests__/notificationRouter.test.tsRun the app:
npm run devValidate deep-link behavior in the browser:
http://localhost:5173/?notificationId=notif-001/adoption/adoption-001/settlementnotificationIdValidate 404 handling:
http://localhost:5173/?notificationId=missing-idNotes
apiClientfor API calls.#closes