[Fullstack] Volunteer Approved Screens + Auto-Redirection
Closed this issue · 0 comments
Context
We want to enable BEI admins to approve/deny volunteers who sign up with the admin dashboard. Currently, after the volunteer fills out their signup information on the /auth/information
page, the app redirects them to the /patient/search
page. However, we want to prevent volunteers from accessing the /patient/search
and related pages until the volunteer has been approved.
Requirements
The volunteer has a field approved: AdminApprovalStatus
in the IUser
type. The AdminApprovalStatus
enum has 3 values APPROVED
, REJECTED
, and PENDING
to mark the approval status of the volunteer. Also, the user record for the logged-in user is cached in the authUser
cookie.
Your task for this sprint includes:
Create /auth/admin-approval
Page
-
This page is similar in design to the
/auth/email-verification/[token]
page (so you copy most of the components from there) -
Access the
approved
field of theauthUser
cookie to determine one of the following:- if
AdminApprovalStatus.PENDING
, display the following:
- if
AdminApprovalStatus.REJECTED
, display the following:
- if
AdminApprovalStatus.APPROVED
, redirect to/patient/search
- if
-
You do not have to implement any approval API route
Note: The designs can be accessed in the following Figma link: https://www.figma.com/file/hPK3RX40paMClQQPhJB5lR/Brain-Exercise-Initiative-SPRING24-new?type=design&node-id=4039-28202&mode=design&t=GDAK5Nf5DuK2a5WS-0
Modify middleware.ts
- This will be used to add auto-redirection for the admin approval page based on the session cookie.
- Understand the
middleware.ts
code. Your code should check the approval status only if the user has verified their email and filled in their signup information - You will have to implement the following steps
- If the user is already approved, redirect them to
/patient/search
- If the user is not approved, refresh the cookie and perform the previous step again
- If the user is still not approved, then redirect them
/auth/admin-approval
if they aren't already there
- If the user is already approved, redirect them to
- Note that cookie refreshing has already been implemented
Acceptance Criteria
- Create
/auth/admin-approval
page - Modify
middleware.ts
to support auto-redirection based on the admin approval status