Skip to content

Intersection API Email Subscription Management Frontend#323

Open
jacob6838 wants to merge 40 commits into
developfrom
iapi-email-unsubscription-frontend
Open

Intersection API Email Subscription Management Frontend#323
jacob6838 wants to merge 40 commits into
developfrom
iapi-email-unsubscription-frontend

Conversation

@jacob6838

Copy link
Copy Markdown
Collaborator

PR Details

Description

This PR updates the webapp to point to the new Intersection API endpoints in #322. This also includes re-working the email subscription management pages as well as adding a new token authenticated unsubscribe page.

image

How Has This Been Tested?

2026-04-21.13-21-11.mp4
  1. Startup the cvmanager and make sure to include the "intersection" profile, which now includes smtp4dev
  2. Generate an email notification from the Intersection API. Without the contact-support endpoint added in 259, this is difficult. I have been grabbing the user's keycloak token from the webapp dev console network tab, and then making a Postman POST request to the IAPI /emails/send-intersection-notification-summary endpoint, with some fake notification data
  3. Navigate to smtp4dev (localhost:5000), and navigate to the unsubscribe link
  4. This should bring you to the notification management page. You should not be prompted to log into the cvmanager.
  5. Change your email notifications and hit save. Refresh the page to conform the changes took effect

Types of changes

  • Defect fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that cause existing functionality to change)

Checklist:

  • My changes require new environment variables:
    • I have updated the docker-compose, K8s YAML, and all dependent deployment configuration files.
  • My changes require updates to the documentation:
    • I have updated the documentation accordingly.
  • My changes require updates and/or additions to the unit tests:
    • I have modified/added tests to cover my changes.
  • All existing tests pass.

Copilot AI review requested due to automatic review settings May 8, 2026 22:18
@jacob6838 jacob6838 changed the base branch from develop to iapi-email-unsubscription-backend May 8, 2026 22:25

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

Updates the webapp’s email subscription management UI to use the new Intersection API endpoints and adds a public, token-authenticated unsubscribe page, while removing the legacy Python API admin-notification functionality.

Changes:

  • Added /unsubscribe?token=... public route and UI for managing email subscriptions without logging in.
  • Replaced the previous “settings” notification management UI with an RTK Query–backed subscription management page calling Intersection API subscription endpoints.
  • Removed legacy Python API admin notification endpoints and corresponding webapp Redux slices/components/tests.

Reviewed changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
webapp/src/Unsubscribe.tsx New public unsubscribe page that loads/saves subscriptions using a token query param.
webapp/src/Unsubscribe.test.tsx Updated snapshot test intended to cover the unsubscribe page.
webapp/src/store.tsx Removed legacy notification reducers; registered new RTK Query slices/middleware.
webapp/src/pages/Admin.tsx Removed notification-fetch side effects tied to the deleted admin notification feature.
webapp/src/models/email-subscriptions.d.ts Added TypeScript types for email subscription data exchanged with Intersection API.
webapp/src/features/api/unsubscribeApiSlice.ts New RTK Query API slice for token-authenticated unsubscribe endpoints.
webapp/src/features/api/subscriptionManagementApiSlice.ts New RTK Query API slice for authenticated subscription management endpoints.
webapp/src/features/adminNotificationTab/adminNotificationTabSlice.tsx Deleted legacy notification slice (Python API–backed).
webapp/src/features/adminNotificationTab/adminNotificationTabSlice.test.ts Deleted tests for removed legacy notification slice.
webapp/src/features/adminNotificationTab/AdminNotificationTab.tsx Deleted legacy admin notification UI.
webapp/src/features/adminEditNotification/adminEditNotificationSlice.tsx Deleted legacy edit-notification slice.
webapp/src/features/adminEditNotification/adminEditNotificationSlice.test.ts Deleted tests for removed edit-notification slice.
webapp/src/features/adminEditNotification/AdminEditNotification.tsx Deleted legacy edit-notification UI.
webapp/src/features/adminAddNotification/adminAddNotificationSlice.tsx Deleted legacy add-notification slice.
webapp/src/features/adminAddNotification/adminAddNotificationSlice.test.ts Deleted tests for removed add-notification slice.
webapp/src/features/adminAddNotification/AdminAddNotification.tsx Deleted legacy add-notification UI.
webapp/src/features/adminAddNotification/AdminAddNotification.test.tsx Deleted snapshot test for removed add-notification UI.
webapp/src/EnvironmentVars.tsx Removed environment variables for deleted legacy notification endpoints.
webapp/src/Dashboard.tsx Routed settings/* to the new subscription management component.
webapp/src/components/SubscriptionManagement.tsx New authenticated subscription management page using RTK Query.
webapp/src/components/SubscriptionManagement.test.tsx Updated snapshot test for the new subscription management page.
webapp/src/components/SubscriptionForm.tsx New reusable form component for editing subscription frequencies and saving.
webapp/src/components/SubscriptionForm.test.tsx Added snapshot test for the new subscription form component.
webapp/src/App.tsx Added a public /unsubscribe route outside Keycloak-protected routing.
services/api/src/middleware.py Removed legacy Python API endpoint mappings for admin notification routes.
services/api/src/main.py Removed legacy Python API resources for admin notification routes.
services/api/src/admin_new_email_notification.py Deleted legacy Python API endpoint for adding notifications.
services/api/src/admin_email_notification.py Deleted legacy Python API endpoint for listing/modifying/deleting notifications.
Comments suppressed due to low confidence (2)

webapp/src/Unsubscribe.test.tsx:16

  • This test is rendering Unsubscribe from @mui/icons-material (an icon), not the Unsubscribe page component in ./Unsubscribe. As written it won’t validate the unsubscribe page at all; import the page component instead (and consider setting a token search param for the router if you want meaningful coverage).
    webapp/src/components/SubscriptionManagement.test.tsx:22
  • Rendering SubscriptionManagement triggers an RTK Query request on mount. This snapshot test doesn’t mock fetch, so it will attempt a real network request during the test run (and the snapshot will likely just capture the loading spinner). Mock the endpoint response (e.g., with fetchMock.mockResponseOnce(...)) and/or wait for the loaded UI before snapshotting to keep the test deterministic.

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

Comment thread webapp/src/Unsubscribe.tsx Outdated
Comment thread webapp/src/Unsubscribe.tsx Outdated
@jacob6838 jacob6838 mentioned this pull request May 11, 2026
10 tasks
Comment thread webapp/src/Unsubscribe.tsx Outdated
Comment thread webapp/src/components/SubscriptionManagement.tsx
Comment thread webapp/src/components/SubscriptionForm.tsx
Comment thread webapp/src/features/api/unsubscribeApiSlice.ts Outdated
@jacob6838 jacob6838 requested review from Michael7371 and mcook42 May 20, 2026 13:50
Base automatically changed from iapi-email-unsubscription-backend to develop June 4, 2026 19:36
@jacob6838 jacob6838 requested review from Russ-Garrett-Trihydro and removed request for mcook42 June 19, 2026 19:23

@Michael7371 Michael7371 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good end-to-end migration to IAPI subscription management and token-based unsubscribe. Follow-ups on error UX and additional unit tests, but otherwise LGTM.

const Unsubscribe = () => {
const [searchParams] = useSearchParams()
const token = searchParams.get('token')
const { data, isLoading, isFetching } = useGetEmailSubscriptionsQuery(token ?? '', { skip: !token })

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(question): have you considered including the isError RTK query to be able to display error status to the user (403, 401, or 500)? Expired token vs network error shouldn’t both show “invalid unsubscribe link”.

@@ -1,19 +1,19 @@
import { render } from '@testing-library/react'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

chore: new tests are snapshot-only (loading/empty). Can we add at least one interaction test (toggle + save) and an error-state test for invalid token?

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.

4 participants