mirror of
https://github.com/d0zingcat/alert-message-center.git
synced 2026-05-13 15:09:19 +00:00
2.6 KiB
2.6 KiB
description
| description |
|---|
| Topic Request Lifecycle and User Feedback |
Topic Request Workflow
This workflow describes the lifecycle of a Topic creation request, from submission by a normal user to approval/rejection by an admin, and how users track their requests.
Architecture
-
Backend API:
- Submission:
POST /api/topics(Authenticated users).- If
isAdmin, status isapproved. - If normal user, status is
pending.
- If
- Global Admin View:
GET /api/topics/requests(Admin only). - User Personal View:
GET /api/topics/my-requests(Authenticated users).- Retrieves all topics where
createdBymatches the current session user ID.
- Retrieves all topics where
- Approval:
POST /api/topics/:id/approve(Admin only). - Rejection:
POST /api/topics/:id/reject(Admin only).
- Submission:
-
Frontend Implementation:
- File:
apps/web/src/views/TopicsView.tsx - Submission Modal:
- Uses
submitStatusstate to provide immediate success/error feedback. - Automatically closes and refreshes after 1.5s on success.
- Uses
- My Requests Table:
- Rendered below the main topic list.
- Uses color-coded badges for status:
Approved: Green.Rejected: Red.Pending: Yellow.
- File:
Common Maintenance Tasks
1. Adding/Removing Request Fields
If a new field is needed (e.g., "Justification"):
- Update
topicstable inapps/server/src/db/schema.ts. - Update
topicSchemainapps/server/src/api.ts. - Update the form in
TopicsView.tsx. - Ensure the field is displayed in both
AdminViewandTopicsView(personal requests).
2. Customizing Feedback Messages
Feedback messages are managed in the handleSubmit function in TopicsView.tsx. Update the message property in setSubmitStatus to change the user-facing wording.
3. Handling Rejection Comments (Future)
To add a reason for rejection:
- Add a
rejectionReasoncolumn to thetopicstable. - Modify the
AdminView.tsxto prompt for a reason during rejection. - Update
POST /api/topics/:id/rejectto accept this reason. - Display the reason in the
My Requestssection ofTopicsView.tsx.
Design Decisions
- Separate Personal Requests: We show personal requests in a dedicated section to avoid cluttering the primary Topic list, which only shows
approvedtopics that can actually be subscribed to. - Optimistic UI vs. Simple Refresh: Currently, we use a full refresh (
fetchTopics,fetchMyRequests) for simplicity and data consistency.