- Add DELETE /notifications/:id and POST /notifications/delete-in-app for owned in-app rows - Seed FAQ permissions for ADMIN/INSTRUCTOR, migration 000084, and improve RBAC sync - Document FAQ admin panel integration Co-authored-by: Cursor <cursoragent@cursor.com>
783 lines
19 KiB
Markdown
783 lines
19 KiB
Markdown
# FAQ Admin Panel — Integration Guide
|
|
|
|
This guide documents how to integrate the **FAQ management** feature into the Yimaru admin panel. It covers authentication, RBAC permissions, admin CRUD APIs, response shapes, validation, UI recommendations, and how admin content relates to the public help center.
|
|
|
|
---
|
|
|
|
## Table of contents
|
|
|
|
1. [Feature overview](#feature-overview)
|
|
2. [Architecture](#architecture)
|
|
3. [Authentication & permissions](#authentication--permissions)
|
|
4. [Data model](#data-model)
|
|
5. [Response envelopes](#response-envelopes)
|
|
6. [Admin API reference](#admin-api-reference)
|
|
7. [Public API reference (preview only)](#public-api-reference-preview-only)
|
|
8. [Publish workflow (ACTIVE / INACTIVE)](#publish-workflow-active--inactive)
|
|
9. [Categories & display order](#categories--display-order)
|
|
10. [Recommended admin UI screens](#recommended-admin-ui-screens)
|
|
11. [TypeScript types & API client](#typescript-types--api-client)
|
|
12. [Error handling](#error-handling)
|
|
13. [Integration checklist](#integration-checklist)
|
|
14. [Limitations & future work](#limitations--future-work)
|
|
15. [Quick reference](#quick-reference)
|
|
|
|
---
|
|
|
|
## Feature overview
|
|
|
|
The FAQ system is a simple **question / answer** help center:
|
|
|
|
| Capability | Admin panel | Mobile / web app |
|
|
|------------|-------------|------------------|
|
|
| List FAQs | All statuses (`ACTIVE`, `INACTIVE`) | `ACTIVE` only |
|
|
| Create / edit / delete | Yes | No |
|
|
| Filter by category | Yes | Yes (public) |
|
|
| Sort order | `display_order` field | Same order |
|
|
| Rich HTML answers | No (plain text) | Plain text |
|
|
|
|
**Admin panel uses only `/api/v1/admin/faqs*` routes** (authenticated + RBAC).
|
|
|
|
Public routes (`/api/v1/faqs`) are for learners and can be used in admin **preview** mode without auth.
|
|
|
|
---
|
|
|
|
## Architecture
|
|
|
|
```mermaid
|
|
flowchart LR
|
|
subgraph AdminPanel["Admin panel"]
|
|
ListPage[List / filter]
|
|
FormPage[Create / edit form]
|
|
Preview[Preview public view]
|
|
end
|
|
|
|
subgraph API["Yimaru API"]
|
|
AdminRoutes["/admin/faqs CRUD"]
|
|
PublicRoutes["/faqs read-only"]
|
|
end
|
|
|
|
subgraph DB["PostgreSQL"]
|
|
FAQsTable["faqs table"]
|
|
end
|
|
|
|
ListPage --> AdminRoutes
|
|
FormPage --> AdminRoutes
|
|
Preview --> PublicRoutes
|
|
AdminRoutes --> FAQsTable
|
|
PublicRoutes --> FAQsTable
|
|
```
|
|
|
|
- **Migration:** `000059_faqs`
|
|
- **Postman collection:** `postman/FAQ-Management.postman_collection.json`
|
|
|
|
---
|
|
|
|
## Authentication & permissions
|
|
|
|
All admin FAQ endpoints require:
|
|
|
|
```http
|
|
Authorization: Bearer <team_member_access_token>
|
|
Content-Type: application/json
|
|
```
|
|
|
|
### RBAC permission keys
|
|
|
|
| Action | Permission | HTTP |
|
|
|--------|------------|------|
|
|
| List FAQs (admin) | `faqs.list` | `GET /admin/faqs` |
|
|
| Get one FAQ (admin) | `faqs.get` | `GET /admin/faqs/:id` |
|
|
| Create FAQ | `faqs.create` | `POST /admin/faqs` |
|
|
| Update FAQ | `faqs.update` | `PUT /admin/faqs/:id` |
|
|
| Delete FAQ | `faqs.delete` | `DELETE /admin/faqs/:id` |
|
|
|
|
These permissions are included in the default **ADMIN** role bundle after RBAC seeding.
|
|
|
|
### UI gating
|
|
|
|
Hide or disable FAQ menu items / buttons when the logged-in team member lacks the corresponding permission. A `403` from the API means missing permission.
|
|
|
|
---
|
|
|
|
## Data model
|
|
|
|
### FAQ object (`data` in responses)
|
|
|
|
```json
|
|
{
|
|
"id": 1,
|
|
"question": "How do I reset my password?",
|
|
"answer": "Go to login and click 'Forgot Password'.",
|
|
"category": "Account",
|
|
"display_order": 1,
|
|
"status": "ACTIVE",
|
|
"created_at": "2026-04-30 08:45:15.961307 +0000 UTC",
|
|
"updated_at": "2026-04-30 09:10:00.123456 +0000 UTC"
|
|
}
|
|
```
|
|
|
|
| Field | Type | Description |
|
|
|-------|------|-------------|
|
|
| `id` | int64 | Primary key |
|
|
| `question` | string | FAQ question (required on create) |
|
|
| `answer` | string | FAQ answer, plain text (required on create) |
|
|
| `category` | string \| omitted | Optional grouping label (free text, max 100 chars in DB) |
|
|
| `display_order` | int32 | Sort order (ascending). Default `0` on create |
|
|
| `status` | string | `ACTIVE` (published) or `INACTIVE` (hidden from public) |
|
|
| `created_at` | string | Timestamp string from server |
|
|
| `updated_at` | string \| omitted | Set after first update |
|
|
|
|
### Status values
|
|
|
|
| Value | Meaning | Visible on public `/faqs`? |
|
|
|-------|---------|----------------------------|
|
|
| `ACTIVE` | Published | Yes |
|
|
| `INACTIVE` | Draft / hidden | No |
|
|
|
|
List order (admin and public): **`display_order ASC`, then `id ASC`**.
|
|
|
|
---
|
|
|
|
## Response envelopes
|
|
|
|
### Success (`domain.Response`)
|
|
|
|
```json
|
|
{
|
|
"message": "FAQs retrieved successfully",
|
|
"data": { },
|
|
"success": true,
|
|
"status_code": 200,
|
|
"metadata": null
|
|
}
|
|
```
|
|
|
|
Note: `success` and `status_code` in the JSON body may be `0` / `false` on some older responses; rely on **HTTP status code** as the source of truth.
|
|
|
|
### Error (`domain.ErrorResponse`)
|
|
|
|
```json
|
|
{
|
|
"message": "Validation failed",
|
|
"error": "question is required"
|
|
}
|
|
```
|
|
|
|
### List payload (`data`)
|
|
|
|
```json
|
|
{
|
|
"faqs": [ /* FAQ object[] */ ],
|
|
"total_count": 42
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Admin API reference
|
|
|
|
Base path: `{API_BASE_URL}/api/v1`
|
|
|
|
### 1. List FAQs (admin)
|
|
|
|
```
|
|
GET /admin/faqs
|
|
Permission: faqs.list
|
|
```
|
|
|
|
#### Query parameters
|
|
|
|
| Param | Type | Default | Description |
|
|
|-------|------|---------|-------------|
|
|
| `status` | string | — | `ACTIVE` or `INACTIVE` (case-insensitive) |
|
|
| `category` | string | — | Exact category match |
|
|
| `limit` | int | 20 | Page size (max 200 enforced server-side) |
|
|
| `offset` | int | 0 | Pagination offset |
|
|
|
|
Omit `status` to return **all** FAQs (active + inactive).
|
|
|
|
#### Example
|
|
|
|
```http
|
|
GET /api/v1/admin/faqs?status=ACTIVE&category=Account&limit=20&offset=0
|
|
Authorization: Bearer <token>
|
|
```
|
|
|
|
#### Response `200`
|
|
|
|
```json
|
|
{
|
|
"message": "FAQs retrieved successfully",
|
|
"data": {
|
|
"faqs": [
|
|
{
|
|
"id": 1,
|
|
"question": "How do I reset my password?",
|
|
"answer": "Go to login and click 'Forgot Password'.",
|
|
"category": "Account",
|
|
"display_order": 1,
|
|
"status": "ACTIVE",
|
|
"created_at": "2026-04-30 08:45:15.961307 +0000 UTC"
|
|
}
|
|
],
|
|
"total_count": 1
|
|
}
|
|
}
|
|
```
|
|
|
|
#### Pagination
|
|
|
|
```
|
|
page = 1-based page number
|
|
offset = (page - 1) * limit
|
|
total_pages = ceil(total_count / limit)
|
|
```
|
|
|
|
---
|
|
|
|
### 2. Get FAQ by ID (admin)
|
|
|
|
```
|
|
GET /admin/faqs/:id
|
|
Permission: faqs.get
|
|
```
|
|
|
|
Returns the FAQ **regardless of status** (unlike public GET).
|
|
|
|
#### Example
|
|
|
|
```http
|
|
GET /api/v1/admin/faqs/1
|
|
Authorization: Bearer <token>
|
|
```
|
|
|
|
#### Response `200`
|
|
|
|
```json
|
|
{
|
|
"message": "FAQ retrieved successfully",
|
|
"data": {
|
|
"id": 1,
|
|
"question": "How do I reset my password?",
|
|
"answer": "Go to login and click 'Forgot Password'.",
|
|
"category": "Account",
|
|
"display_order": 1,
|
|
"status": "INACTIVE",
|
|
"created_at": "2026-04-30 08:45:15.961307 +0000 UTC",
|
|
"updated_at": "2026-05-01 10:00:00 +0000 UTC"
|
|
}
|
|
}
|
|
```
|
|
|
|
#### Errors
|
|
|
|
| HTTP | When |
|
|
|------|------|
|
|
| `400` | Invalid ID |
|
|
| `404` | FAQ not found |
|
|
|
|
Use this endpoint to populate the **edit form**.
|
|
|
|
---
|
|
|
|
### 3. Create FAQ
|
|
|
|
```
|
|
POST /admin/faqs
|
|
Permission: faqs.create
|
|
```
|
|
|
|
#### Request body
|
|
|
|
| Field | Type | Required | Description |
|
|
|-------|------|----------|-------------|
|
|
| `question` | string | **Yes** | Non-empty after trim |
|
|
| `answer` | string | **Yes** | Non-empty after trim |
|
|
| `category` | string | No | Optional label; empty string → stored as null |
|
|
| `display_order` | int32 | No | Default `0` |
|
|
| `status` | string | No | Default `ACTIVE`. Must be `ACTIVE` or `INACTIVE` |
|
|
|
|
#### Example
|
|
|
|
```http
|
|
POST /api/v1/admin/faqs
|
|
Authorization: Bearer <token>
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"question": "How do I reset my password?",
|
|
"answer": "Go to login and click 'Forgot Password'.",
|
|
"category": "Account",
|
|
"display_order": 1,
|
|
"status": "ACTIVE"
|
|
}
|
|
```
|
|
|
|
#### Response `201`
|
|
|
|
```json
|
|
{
|
|
"message": "FAQ created successfully",
|
|
"data": {
|
|
"id": 5,
|
|
"question": "How do I reset my password?",
|
|
"answer": "Go to login and click 'Forgot Password'.",
|
|
"category": "Account",
|
|
"display_order": 1,
|
|
"status": "ACTIVE",
|
|
"created_at": "2026-06-10 12:00:00 +0000 UTC"
|
|
}
|
|
}
|
|
```
|
|
|
|
#### Validation errors `400`
|
|
|
|
| Error | Cause |
|
|
|-------|-------|
|
|
| `Validation failed` | Missing `question` or `answer` (validator) |
|
|
| `question is required` | Empty question after trim |
|
|
| `answer is required` | Empty answer after trim |
|
|
| `status must be one of ACTIVE, INACTIVE` | Invalid status |
|
|
|
|
---
|
|
|
|
### 4. Update FAQ
|
|
|
|
```
|
|
PUT /admin/faqs/:id
|
|
Permission: faqs.update
|
|
```
|
|
|
|
Partial update — send only fields you want to change.
|
|
|
|
#### Request body
|
|
|
|
| Field | Type | Required | Description |
|
|
|-------|------|----------|-------------|
|
|
| `question` | string | No | Must not be empty if sent |
|
|
| `answer` | string | No | Must not be empty if sent |
|
|
| `category` | string | No | Send `""` to clear category |
|
|
| `display_order` | int32 | No | New sort position |
|
|
| `status` | string | No | `ACTIVE` or `INACTIVE` |
|
|
|
|
#### Example — publish draft
|
|
|
|
```json
|
|
{
|
|
"status": "ACTIVE"
|
|
}
|
|
```
|
|
|
|
#### Example — full edit
|
|
|
|
```json
|
|
{
|
|
"question": "How can I reset my password?",
|
|
"answer": "Tap Forgot Password on the login screen and follow the email link.",
|
|
"category": "Account",
|
|
"display_order": 2,
|
|
"status": "ACTIVE"
|
|
}
|
|
```
|
|
|
|
#### Response `200`
|
|
|
|
```json
|
|
{
|
|
"message": "FAQ updated successfully",
|
|
"data": { /* updated FAQ object */ }
|
|
}
|
|
```
|
|
|
|
#### Errors
|
|
|
|
| HTTP | When |
|
|
|------|------|
|
|
| `400` | Validation / invalid status |
|
|
| `404` | FAQ not found |
|
|
|
|
---
|
|
|
|
### 5. Delete FAQ
|
|
|
|
```
|
|
DELETE /admin/faqs/:id
|
|
Permission: faqs.delete
|
|
```
|
|
|
|
Hard delete — row is removed from the database (not soft delete).
|
|
|
|
#### Example
|
|
|
|
```http
|
|
DELETE /api/v1/admin/faqs/5
|
|
Authorization: Bearer <token>
|
|
```
|
|
|
|
#### Response `200`
|
|
|
|
```json
|
|
{
|
|
"message": "FAQ deleted successfully",
|
|
"data": {
|
|
"id": 5
|
|
}
|
|
}
|
|
```
|
|
|
|
#### Errors
|
|
|
|
| HTTP | When |
|
|
|------|------|
|
|
| `404` | FAQ not found |
|
|
|
|
Show a confirmation dialog in the admin UI before calling delete.
|
|
|
|
---
|
|
|
|
## Public API reference (preview only)
|
|
|
|
Use these in admin **“Preview as learner”** or to verify published content. **No auth required.**
|
|
|
|
| Method | Path | Behavior |
|
|
|--------|------|----------|
|
|
| `GET` | `/api/v1/faqs` | List **ACTIVE** FAQs only |
|
|
| `GET` | `/api/v1/faqs/:id` | Get one **ACTIVE** FAQ |
|
|
|
|
Query params for list: `category`, `limit` (default 50), `offset` (default 0).
|
|
|
|
If `GET /faqs/:id` returns `404` but admin GET returns the FAQ, it is likely **`INACTIVE`** (not published).
|
|
|
|
---
|
|
|
|
## Publish workflow (ACTIVE / INACTIVE)
|
|
|
|
There is no separate publish endpoint. Publishing is done via `status`:
|
|
|
|
| Admin action | API call |
|
|
|--------------|----------|
|
|
| Save as draft | `POST` or `PUT` with `"status": "INACTIVE"` |
|
|
| Publish | `PUT` with `"status": "ACTIVE"` |
|
|
| Unpublish (hide) | `PUT` with `"status": "INACTIVE"` |
|
|
|
|
**Recommended UI:**
|
|
|
|
- Status toggle or dropdown: **Published** (`ACTIVE`) / **Draft** (`INACTIVE`)
|
|
- List filter tabs: All | Published | Draft
|
|
- Badge on list rows: green = Active, gray = Inactive
|
|
|
|
---
|
|
|
|
## Categories & display order
|
|
|
|
### Categories
|
|
|
|
- **Free-text** string on each FAQ (e.g. `"Account"`, `"Billing"`, `"General"`).
|
|
- No backend API to list distinct categories.
|
|
- **Admin panel pattern:** load all FAQs (or a large page), derive unique categories client-side for filter dropdowns and create-form suggestions.
|
|
|
|
```typescript
|
|
const categories = [...new Set(faqs.map(f => f.category).filter(Boolean))].sort();
|
|
```
|
|
|
|
Category filter on list uses **exact match** (case-sensitive in DB).
|
|
|
|
### Display order
|
|
|
|
- Lower numbers appear first.
|
|
- Default `0` for new FAQs if omitted.
|
|
- **No bulk reorder API** — set `display_order` on create/update per item.
|
|
|
|
**Admin panel patterns:**
|
|
|
|
1. **Numeric input** on create/edit form.
|
|
2. **Drag-and-drop reorder UI** → on drop, `PUT` each affected FAQ with new `display_order` values (e.g. 1, 2, 3…).
|
|
3. When creating, suggest `max(display_order) + 1` from current list.
|
|
|
|
---
|
|
|
|
## Recommended admin UI screens
|
|
|
|
### 1. FAQ list page
|
|
|
|
**Route example:** `/admin/help/faqs`
|
|
|
|
| UI element | API |
|
|
|------------|-----|
|
|
| Table/cards of FAQs | `GET /admin/faqs?limit=&offset=` |
|
|
| Status filter | `?status=ACTIVE` / `INACTIVE` |
|
|
| Category filter | `?category=Account` |
|
|
| Search (client-side) | Filter loaded rows by question/answer text |
|
|
| “Add FAQ” button | Navigate to create form (`faqs.create`) |
|
|
| Edit row | `GET /admin/faqs/:id` → edit form |
|
|
| Delete row | `DELETE /admin/faqs/:id` with confirm |
|
|
| Publish toggle | `PUT` with `status` |
|
|
|
|
**Columns:** Question, Category, Order, Status, Updated, Actions
|
|
|
|
### 2. Create / edit form
|
|
|
|
**Routes:** `/admin/help/faqs/new`, `/admin/help/faqs/:id/edit`
|
|
|
|
| Field | Control |
|
|
|-------|---------|
|
|
| Question | Text input / textarea |
|
|
| Answer | Textarea (plain text; no HTML editor unless you add sanitization client-side only for display) |
|
|
| Category | Text input with datalist from known categories |
|
|
| Display order | Number input |
|
|
| Status | Select: Published / Draft |
|
|
|
|
| Action | API |
|
|
|--------|-----|
|
|
| Save (create) | `POST /admin/faqs` |
|
|
| Save (update) | `PUT /admin/faqs/:id` |
|
|
| Cancel | Back to list |
|
|
|
|
### 3. Preview (optional)
|
|
|
|
- Open public URL or call `GET /api/v1/faqs` to show how learners see published FAQs.
|
|
- Preview single item: `GET /api/v1/faqs/:id` (only works when `ACTIVE`).
|
|
|
|
---
|
|
|
|
## TypeScript types & API client
|
|
|
|
### Types
|
|
|
|
```typescript
|
|
export type FAQStatus = "ACTIVE" | "INACTIVE";
|
|
|
|
export interface FAQ {
|
|
id: number;
|
|
question: string;
|
|
answer: string;
|
|
category?: string | null;
|
|
display_order: number;
|
|
status: FAQStatus;
|
|
created_at: string;
|
|
updated_at?: string | null;
|
|
}
|
|
|
|
export interface FAQListData {
|
|
faqs: FAQ[];
|
|
total_count: number;
|
|
}
|
|
|
|
export interface ApiResponse<T> {
|
|
message: string;
|
|
data: T;
|
|
success?: boolean;
|
|
status_code?: number;
|
|
metadata?: unknown;
|
|
}
|
|
|
|
export interface ApiError {
|
|
message: string;
|
|
error?: string;
|
|
}
|
|
|
|
export interface CreateFAQInput {
|
|
question: string;
|
|
answer: string;
|
|
category?: string | null;
|
|
display_order?: number;
|
|
status?: FAQStatus;
|
|
}
|
|
|
|
export interface UpdateFAQInput {
|
|
question?: string;
|
|
answer?: string;
|
|
category?: string | null;
|
|
display_order?: number;
|
|
status?: FAQStatus;
|
|
}
|
|
```
|
|
|
|
### Example client (fetch)
|
|
|
|
```typescript
|
|
const API_BASE = import.meta.env.VITE_API_BASE_URL; // e.g. https://api.yimaru.com
|
|
|
|
function authHeaders(token: string): HeadersInit {
|
|
return {
|
|
Authorization: `Bearer ${token}`,
|
|
"Content-Type": "application/json",
|
|
};
|
|
}
|
|
|
|
export async function listFAQsAdmin(
|
|
token: string,
|
|
params: { status?: FAQStatus; category?: string; limit?: number; offset?: number } = {}
|
|
): Promise<FAQListData> {
|
|
const qs = new URLSearchParams();
|
|
if (params.status) qs.set("status", params.status);
|
|
if (params.category) qs.set("category", params.category);
|
|
qs.set("limit", String(params.limit ?? 20));
|
|
qs.set("offset", String(params.offset ?? 0));
|
|
|
|
const res = await fetch(`${API_BASE}/api/v1/admin/faqs?${qs}`, {
|
|
headers: authHeaders(token),
|
|
});
|
|
if (!res.ok) throw await res.json();
|
|
const body: ApiResponse<FAQListData> = await res.json();
|
|
return body.data;
|
|
}
|
|
|
|
export async function getFAQAdmin(token: string, id: number): Promise<FAQ> {
|
|
const res = await fetch(`${API_BASE}/api/v1/admin/faqs/${id}`, {
|
|
headers: authHeaders(token),
|
|
});
|
|
if (!res.ok) throw await res.json();
|
|
const body: ApiResponse<FAQ> = await res.json();
|
|
return body.data;
|
|
}
|
|
|
|
export async function createFAQ(token: string, input: CreateFAQInput): Promise<FAQ> {
|
|
const res = await fetch(`${API_BASE}/api/v1/admin/faqs`, {
|
|
method: "POST",
|
|
headers: authHeaders(token),
|
|
body: JSON.stringify(input),
|
|
});
|
|
if (!res.ok) throw await res.json();
|
|
const body: ApiResponse<FAQ> = await res.json();
|
|
return body.data;
|
|
}
|
|
|
|
export async function updateFAQ(
|
|
token: string,
|
|
id: number,
|
|
input: UpdateFAQInput
|
|
): Promise<FAQ> {
|
|
const res = await fetch(`${API_BASE}/api/v1/admin/faqs/${id}`, {
|
|
method: "PUT",
|
|
headers: authHeaders(token),
|
|
body: JSON.stringify(input),
|
|
});
|
|
if (!res.ok) throw await res.json();
|
|
const body: ApiResponse<FAQ> = await res.json();
|
|
return body.data;
|
|
}
|
|
|
|
export async function deleteFAQ(token: string, id: number): Promise<void> {
|
|
const res = await fetch(`${API_BASE}/api/v1/admin/faqs/${id}`, {
|
|
method: "DELETE",
|
|
headers: authHeaders(token),
|
|
});
|
|
if (!res.ok) throw await res.json();
|
|
}
|
|
```
|
|
|
|
### React Query example (list + pagination)
|
|
|
|
```typescript
|
|
const page = 1;
|
|
const limit = 20;
|
|
|
|
const { data, isLoading, error } = useQuery({
|
|
queryKey: ["admin-faqs", statusFilter, categoryFilter, page],
|
|
queryFn: () =>
|
|
listFAQsAdmin(token, {
|
|
status: statusFilter,
|
|
category: categoryFilter,
|
|
limit,
|
|
offset: (page - 1) * limit,
|
|
}),
|
|
});
|
|
```
|
|
|
|
---
|
|
|
|
## Error handling
|
|
|
|
| HTTP | Typical `message` | Admin UI action |
|
|
|------|-------------------|-----------------|
|
|
| `400` | Validation failed / Failed to create FAQ | Show field errors from `error` |
|
|
| `401` | Unauthorized | Redirect to login |
|
|
| `403` | Forbidden | Show “No permission” |
|
|
| `404` | FAQ not found | Toast + redirect to list |
|
|
| `500` | Failed to list/get FAQ | Generic error + retry |
|
|
|
|
Always parse `error` field when present for detail.
|
|
|
|
---
|
|
|
|
## Integration checklist
|
|
|
|
### Backend / access
|
|
|
|
- [ ] Migration `000059_faqs` applied
|
|
- [ ] RBAC seeded; admin role has `faqs.*` permissions
|
|
- [ ] Team member can obtain Bearer token for admin API
|
|
|
|
### Admin panel — navigation
|
|
|
|
- [ ] Add “FAQs” or “Help center” menu item (gate on `faqs.list`)
|
|
|
|
### List page
|
|
|
|
- [ ] `GET /admin/faqs` with pagination
|
|
- [ ] Filters: status, category (optional)
|
|
- [ ] Status badges (ACTIVE / INACTIVE)
|
|
- [ ] Actions: Edit, Delete, quick publish/unpublish
|
|
|
|
### Create / edit
|
|
|
|
- [ ] Form validation (question + answer required)
|
|
- [ ] `POST /admin/faqs` on create
|
|
- [ ] `GET /admin/faqs/:id` on edit load
|
|
- [ ] `PUT /admin/faqs/:id` on save
|
|
|
|
### Delete
|
|
|
|
- [ ] Confirmation modal
|
|
- [ ] `DELETE /admin/faqs/:id`
|
|
- [ ] Refresh list after delete
|
|
|
|
### Optional enhancements
|
|
|
|
- [ ] Client-side search on question/answer
|
|
- [ ] Category datalist from existing FAQs
|
|
- [ ] Drag-and-drop reorder → multiple `PUT`s with `display_order`
|
|
- [ ] Preview link using public `GET /faqs`
|
|
|
|
### QA scenarios
|
|
|
|
- [ ] Create ACTIVE FAQ → appears on public `GET /faqs`
|
|
- [ ] Create INACTIVE FAQ → hidden from public, visible in admin list
|
|
- [ ] Update status INACTIVE → ACTIVE → public visibility
|
|
- [ ] Delete FAQ → gone from admin and public
|
|
- [ ] Invalid status → 400 error shown in UI
|
|
|
|
---
|
|
|
|
## Limitations & future work
|
|
|
|
| Topic | Current behavior |
|
|
|-------|------------------|
|
|
| Reorder API | None — update `display_order` per FAQ |
|
|
| Category API | No list endpoint; derive client-side |
|
|
| Search | No server-side search |
|
|
| Rich text | Plain text answers only |
|
|
| i18n | Single language |
|
|
| Soft delete | Hard delete |
|
|
| Audit log | Not FAQ-specific |
|
|
|
|
If product needs HTML answers, server-side search, or bulk reorder, those require backend changes.
|
|
|
|
---
|
|
|
|
## Quick reference
|
|
|
|
| Method | Path | Permission | Purpose |
|
|
|--------|------|------------|---------|
|
|
| `GET` | `/api/v1/admin/faqs` | `faqs.list` | List (all statuses) |
|
|
| `GET` | `/api/v1/admin/faqs/:id` | `faqs.get` | Get one for edit |
|
|
| `POST` | `/api/v1/admin/faqs` | `faqs.create` | Create |
|
|
| `PUT` | `/api/v1/admin/faqs/:id` | `faqs.update` | Update / publish |
|
|
| `DELETE` | `/api/v1/admin/faqs/:id` | `faqs.delete` | Delete |
|
|
| `GET` | `/api/v1/faqs` | — | Public list (preview) |
|
|
| `GET` | `/api/v1/faqs/:id` | — | Public detail (preview) |
|
|
|
|
**Postman:** Import `postman/FAQ-Management.postman_collection.json` for executable examples and test scripts.
|