Skip to content

Ems 163 revisit modules#85

Merged
ashwin-athappan merged 24 commits intomainfrom
EMS-163-revisit-modules
Dec 1, 2025
Merged

Ems 163 revisit modules#85
ashwin-athappan merged 24 commits intomainfrom
EMS-163-revisit-modules

Conversation

@ashwin-athappan
Copy link
Copy Markdown
Collaborator

No description provided.

…arts

1. Created three new dedicated report pages:
    * `/dashboard/admin/reports/users`: Charts for monthly signups, total users, growth trend, and role distribution, plus a data table.
    * `/dashboard/admin/reports/events`: Charts for status distribution, status count, and top-performing events, plus data tables.
    * `/dashboard/admin/reports/registrations`: Charts for attendance overview, top events, attendance rates, and registrations vs. attendance, plus a data table.

2. Updated the main `/dashboard/admin/reports` page to be a simple navigation hub with buttons for the three new reports.

3. Created reusable chart components for consistency:
    * `ChartTooltip.tsx` (dark mode-aware)
    * `ChartCard.tsx` (wrapper)
    * `EmptyChartState.tsx`
    * All charts include loading, error, and responsive states.

4. Fixed two TypeScript build errors in the new chart components:
    * Added a null check `(percent || 0)` for a chart label function.
    * Transformed data for the Pie chart (from `{role, count}` to `{name, value}`) to match the Recharts API.
1. Updated the default `ADMIN_EMAIL` from `admin@eventmanagement.com` to `admin@ems.com`.
    * Modified in `scripts/modules/utils.py`.
    * Updated the corresponding error message in `scripts/seed.py`.

2. The seed script now uses `admin@ems.com` by default. This can still be overridden by the `ADMIN_EMAIL` environment variable.
… usage

1. Fixed a Next.js build error ("Expected 2-3 arguments") caused by passing too many arguments to `logger.error`.
    * Replaced instances of `logger.error` with `logger.errorWithContext` to allow for additional context objects.

2. Files updated:
    * ems-client/app/dashboard/admin/reports/users/page.tsx
    * ems-client/lib/api/admin.api.ts

3. The build should now succeed.
…no sessions

1. Fixed a bug where event-level speakers (at events with no sessions) would not load.
    * Root Cause: `loadAllSpeakers` was only triggered if `sessions.length > 0`. Events with no sessions relied on attendance data, but the effect would set `allSpeakers` to `[]` before attendance was available.

2. Fixes Implemented:
    * Removed the `sessions.length > 0` guard, ensuring `loadAllSpeakers` always runs when sessions or invitations change.
    * Added a new effect to serve as a fallback: it calls `loadAllSpeakers` when `sessions.length === 0` but speaker attendance data *does* exist.
    * Added a debug log to confirm when this fallback is used.

3. This ensures speakers are visible regardless of whether sessions exist, and the speaker list is no longer incorrectly cleared by the attendance logic.
…based dashboard redirect

1. Implemented role selection for new OAuth sign-ups across frontend and backend.
    * Backend Changes (auth-service):
        - `oauth.routes.ts` accepts `role` query parameter and passes it via the OAuth state.
        - `auth.service.ts`'s `findOrCreateGoogleUser` now accepts and validates the `role` (USER/SPEAKER) for new user creation.
        - Existing users linking accounts retain their current role.
    * Frontend Changes (ems-client):
        - `register/page.tsx` Google button now passes the selected role to the OAuth endpoint.

2. Refactored the post-OAuth flow for role-based dashboard redirection.
    * Backend Changes (auth-service):
        - `oauth.routes.ts` now redirects directly to the role-specific dashboard (`/dashboard/admin`, `/dashboard/speaker`, `/dashboard/attendee`) after successful authentication, passing the token in the URL query.
    * Frontend Refactor (HOC):
        - Updated `withAuth` HOC to handle token processing centrally:
            - Detects `token` and `oauth=true` in the URL query.
            - Stores the token via `tokenManager.setToken()`.
            - Calls `checkAuth()` to authenticate the user and load the profile.
            - Removes the query parameters from the URL.
            - Prevents the premature redirect to login while processing the token.
    * Removed duplicate token extraction and processing logic from individual dashboard pages (attendee, speaker, admin).

3. Configuration Update:
    * Updated the default `FRONTEND_URL` in `auth-service` from `http://localhost:3000` to `http://localhost` for the OAuth redirect.
1. Fixed a bug where new users signing up via OAuth with the SPEAKER role did not have a speaker profile created.
    * Problem: This resulted in the "Your speaker profile could not be loaded" error when accessing the speaker dashboard.

2. Solution: Updated `findOrCreateGoogleUser` in `auth.service.ts` to call `createSpeakerProfile()` when a new user is created with the SPEAKER role.

3. Flow: The speaker profile creation is now triggered asynchronously via a message sent to RabbitMQ, ensuring the speaker service creates the necessary profile for a successful dashboard load.
1. Implemented new functionality in the backend to unsuspend users.
    * Created POST endpoint `/admin/unsuspend-users` (auth-service).
    * Accepts an array of user emails and sets their `isActive` status to `true`.
    * **Crucially, this endpoint does not modify `emailVerified`** (unlike the `/admin/activate-users` route).
    * Includes backend protection to prevent unsuspending users with the ADMIN role.
    * Returns the count of successfully unsuspended and not-found users.

2. Implemented corresponding changes in the admin frontend (ems-client).
    * Added `unsuspendUsers()` method to `admin.api.ts` to call the new endpoint.
    * Updated `users/page.tsx` to display a new **"Unsuspend" button** (green styling) for inactive users.
    * Added a **confirmation dialog** before execution.
    * Automatically reloads the user list upon successful action.

3. The user management panel now fully supports toggling user status (suspend/unsuspend) with clear UI feedback.
…pension/unsuspension

1. Implemented cross-service type definitions for suspension notifications:
    * Added `ACCOUNT_SUSPENDED` and `ACCOUNT_UNSUSPENDED` to the `MESSAGE_TYPE` enum in both `auth-service` and `notification-service`.
    * Created `AccountSuspendedNotification` and `AccountUnsuspendedNotification` interfaces in the notification service.

2. Created new email templates in `notification-service`:
    * `generateAccountSuspendedEmail()`: Includes warning styling (red header) and support contact info.
    * `generateAccountUnsuspendedEmail()`: Includes success styling (green header) and a dashboard link.

3. Integrated email sending functionality into `auth-service` via RabbitMQ:
    * Added `sendAccountSuspendedEmail()` and `sendAccountUnsuspendedEmail()` methods to `AuthService` to publish notification messages.

4. Updated Admin Routes in `auth-service` for notification logic:
    * `/admin/suspend-users` now checks if the user is already suspended (skips if so) and sends the suspension email upon success.
    * `/admin/unsuspend-users` now checks if the user is already active (skips if so) and sends the unsuspension email upon success.
    * **Crucially, both routes handle email failures gracefully**, ensuring the suspend/unsuspend operation completes even if the notification fails.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 1, 2025

🧪 Test Results ❌

Check Status
Tests ❌ Failed
Coverage ✅ Passed

Summary: All automated checks have been completed for this PR.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 1, 2025

🧪 Test Results ❌

Check Status
Tests ❌ Failed
Coverage ✅ Passed

Summary: All automated checks have been completed for this PR.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 1, 2025

🧪 Test Results ❌

Check Status
Tests ❌ Failed
Coverage ✅ Passed

Summary: All automated checks have been completed for this PR.

@ashwin-athappan ashwin-athappan merged commit c522d08 into main Dec 1, 2025
2 of 7 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.

1 participant