# Admin · Support content (FAQ / questions) — Logic & Flows

Canonical target: React demo `portals/admin/SupportContent.tsx` (dev branch).
Our impl: Yii2 admin (`backend/`), shared models (`common/`).

## 1. What the demo actually is

`AdminSupportContent` (`/private/tmp/Navagoo_MI_dev/navagoo-app/src/portals/admin/SupportContent.tsx`)
is a **single admin screen with two segmented tabs** — `FAQs` and `Contact Us` — routed at
`admin/content` (`App.tsx:99`, imported `App.tsx:45`). It is intentionally tiny and
**100% local component state** — there is no Zustand store, no `lib/*` logic, no `types.ts`
entry, and no persistence:

- `view: 'faqs' | 'contact'` — active tab (`SupportContent.tsx:31`).
- `faqs` — seeded from the hard-coded `SEED_FAQS` array of 4 `{q, a}` objects
  (`SupportContent.tsx:11-29`, state `:32`).
- `openIdx` — which accordion row is expanded (default `0`) (`:33`).
- `adding` — Add-FAQ modal open flag (`:34`).
- `q`, `a` — the new-FAQ form fields (`:35-36`).

### 1.1 FAQ flows (demo)
- **List/read**: render `faqs.map`, each row is an accordion button toggling `openIdx`
  (`SupportContent.tsx:71-90`). Only one row open at a time; clicking the open row closes it
  (`openIdx === i ? null : i`, `:74`).
- **Add**: header "Add FAQ" button opens the modal (`:46-50`). Modal has Question + Answer
  inputs; the Add button is `disabled={!q || !a}` (`:117`) and on click pushes
  `{q, a}` onto local `faqs`, fires `toast.success('FAQ added')`, closes the modal and clears
  the fields (`:118-126`). **Nothing is sent to a server; refresh loses it.**
- **No edit, no delete, no reorder, no status, no category** in the demo.

### 1.2 Contact Us flow (demo)
- Pure display. Three hard-coded `ContactCard`s: Email `support@navagoo.sa`,
  Phone `+966 11 200 0000`, WhatsApp `+966 55 000 0000` (`SupportContent.tsx:93-106`).
- **No editing.** These are constants in the JSX; the admin cannot change them in the demo.
- Subtitle states FAQs are "Shown in the customer & shop help centres" (`:64`) — i.e. the
  FAQ list is meant to feed the public/shop help centre. Contact values are the same channels
  the help centres would surface.

## 2. How ours computes the same (or not)

Our app splits this one demo screen across **four separate admin CRUDs plus a shop form**,
and the data shapes diverge.

### 2.1 FAQ (relational) — `Faq`
- Controller `backend/controllers/FaqController.php` — full CRUD: `actionIndex` (`:67`),
  `actionView` (`:89`), `actionCreate` (`:106`), `actionUpdate` (`:145`), `actionDelete`
  (`:185`), plus `change-sort` drag-reorder action (`:56-59`).
- Model `common/models/base/Faq.php`: fields `question`, `answer`, `sort`, `status`,
  `category_id` (`:21-30`); validation `[['question','answer'],'required']` (`:63`);
  `demi\sort\SortBehavior` for ordering (`:109`).
- List view `backend/views/faq/index.php` is a Tailwind table (#, Question, truncated Answer
  80 chars `:102`, Status chip `:34-40`, up/down sort `:104-128`, edit/delete `:130-152`,
  status GET filter `:56-77`, LinkPager `:164`).
- **Verdict:** ours is a *superset* of the demo FAQ feature (adds status, category, sort,
  pagination, delete, edit, persistence) but the **UX is a different paradigm** — a CRUD
  grid + separate full-page create/update forms, not an inline accordion + modal. There is no
  combined "Support & content" screen and no segmented tabs.

### 2.2 Questions (Elasticsearch) — `Questions`
- Controller `backend/controllers/QuestionsController.php`, same CRUD shape, but model is
  `yii\elasticsearch\ActiveRecord` (`common/models/base/Questions.php:31`), looked up via
  `Questions::get($id)` (`QuestionsController.php:221`). Same `question/answer/sort/status`
  shape (`common/models/base/Questions.php:20-23`).
- Index degrades gracefully if ES is down (`QuestionsController.php:86-92`).
- **Verdict:** a near-duplicate of FAQ on a different store. The demo has no Questions/FAQ
  split — this is purely ours. Likely legacy; not represented in the demo at all.

### 2.3 Contact channels (Email / Phone / WhatsApp) — MISSING as config
- The demo's "Contact Us" tab = **editable-looking contact-channel cards** (read-only in
  demo, but conceptually the admin's contact info shown in help centres).
- Ours has **no admin-managed contact-channel config**. `backend/controllers/ContactUsController.php`
  + `backend/models/ContactUs.php` are an **inbound message inbox** (`name/phone/email/title/message/type`,
  `backend/models/ContactUs.php:17-25`) — i.e. messages *from* users, the inverse of the demo.
  The demo has no inbound-message inbox at all.
- No `support@navagoo.sa` / phone / WhatsApp constants are surfaced as an admin screen; grep
  found them only scattered in `settings`/`referral`/`managers` views, not a contact-channel
  editor.
- **Verdict:** the demo "Contact Us" tab is **MISSING** on our side. Our same-named controller
  is a different feature.

### 2.4 Technical Support — adjacent, not in demo
- `backend/controllers/TechnicalSupportController.php` (admin inbox of tickets) +
  `frontend/controllers/TechnicalSupportController.php` (shop submits ticket, `:51-80`).
  This support-ticket flow has **no counterpart in the demo SupportContent screen**.

## 3. Persistence / state model contrast
- Demo: ephemeral component state, seed data, no API. Adds vanish on reload.
- Ours: DB-backed (`faq` table) + ES index (`questions`), real CRUD, audit columns
  (`created_at/by`, `updated_at/by` in `Faq.php:65`), drag-sort persistence.
- Net: ours is materially more capable for FAQ, but does NOT replicate the demo's unified
  screen, accordion read UX, or the Contact-Us channel display.
