diff --git a/skill/erika/SKILL.md b/skill/erika/SKILL.md index 1a19875..fc10c28 100644 --- a/skill/erika/SKILL.md +++ b/skill/erika/SKILL.md @@ -204,17 +204,33 @@ Erika is a Next.js website for the content creator "Erika!". It has two main fea | `app/form/[id]/page.tsx` | Individual form submission page where users answer questions | | `app/form/[id]/layout.tsx` | Layout for individual form pages | -#### `/admin/form` — Admin Form Management (admin-only) +#### `/admin` — Admin Panel (admin-only) | File | Purpose | |---|---| -| `app/admin/form/page.tsx` | **Admin form list.** Shows all forms (open and closed) with create/edit/delete actions. Protected by admin auth check — redirects non-admins to `/`. | -| `app/admin/form/[id]/layout.tsx` | **Admin form editor layout.** Contains the admin auth guard (checks `getServerSession` against `ADMIN_DISCORD_IDS`). Redirects non-admins to `/form`. Includes sidebar navigation. | +| `app/admin/layout.tsx` | **Centralized admin auth guard.** Checks `getServerSession` against `ADMIN_DISCORD_IDS` env var for ALL `/admin/*` routes. Redirects non-admins to `/`. | +| `app/admin/page.tsx` | **Admin dashboard homepage (`/admin`).** Overview cards linking to Form and Backend sections. Wrapped with `AdminShell` sidebar. | + +#### `/admin/form` — Admin Form Management + +| File | Purpose | +|---|---| +| `app/admin/form/page.tsx` | **Admin form list.** Shows all forms (open and closed) with create/edit/delete actions. Wrapped with `AdminShell` sidebar. | +| `app/admin/form/actions.ts` | Server actions for form CRUD (create, update settings, delete). All protected by admin auth check. | +| `app/admin/form/[id]/layout.tsx` | **Admin form editor layout.** Has its own form-specific sidebar (Editor/Responses/Extra). The admin-level sidebar is NOT shown here. | | `app/admin/form/[id]/page.tsx` | Admin form editor page | | `app/admin/form/[id]/client.tsx` | Client-side admin form editor components (question builder, drag-and-drop, settings) | | `app/admin/form/[id]/result/` | Admin view of form submission results | | `app/admin/form/[id]/extra/` | Additional admin form settings | +#### `/admin/backend` — Backend Settings + +| File | Purpose | +|---|---| +| `app/admin/backend/page.tsx` | **Backend settings page (`/admin/backend`).** Auto-discovers platform files from `lib/followers/` using `fs.readdir`. Reads cached counts from Redis. Wrapped with `AdminShell` sidebar. | +| `app/admin/backend/client.tsx` | Client component rendering platform cards with cached counts and individual refetch buttons. | +| `app/admin/backend/actions.ts` | Server action `refetchPlatform()` — dynamically imports the platform module, calls the fetcher, and updates Redis cache per-platform. Adding a new `.ts` file to `lib/followers/` auto-registers it here. | + #### `/discord` — Discord Redirect | File | Purpose | @@ -234,7 +250,6 @@ Erika is a Next.js website for the content creator "Erika!". It has two main fea | File | Purpose | |---|---| -| `app/actions/form.ts` | Server actions for form CRUD (create, update settings, delete). All protected by admin auth check. | | `app/actions/questions.ts` | Server actions for question CRUD within a form. Admin-protected. | | `app/actions/submissions.ts` | Server actions for form submissions (submit, edit, view results). | @@ -242,8 +257,10 @@ Erika is a Next.js website for the content creator "Erika!". It has two main fea | File | Purpose | |---|---| +| `components/admin-shell.tsx` | **Shared admin sidebar layout.** Client component with `SidebarProvider` + `Sidebar` (Dashboard, Form, Backend links). Used by `/admin`, `/admin/form`, `/admin/backend`. NOT used by `/admin/form/[id]` which has its own form-specific sidebar. | | `components/LinkCard.tsx` | Social link card component with follower count badges | | `components/ShaderBackground.tsx` | WebGL shader background effect | +| `components/delete-buttons.tsx` | Delete confirmation dialogs for forms, submissions, and bulk delete. Uses AlertDialog/Dialog from ShadCN. | | `components/login-dialog.tsx` | Discord OAuth login dialog | | `components/rich-text-editor.tsx` | Rich text editor for form descriptions | | `components/page-progress.tsx` | Page navigation progress bar | @@ -267,10 +284,8 @@ Erika is a Next.js website for the content creator "Erika!". It has two main fea ## Auth Model 1. **User login**: Discord OAuth via NextAuth.js. Users log in at `/form` to submit forms. -2. **Admin check**: Server-side only. Compares the logged-in user's `discordId` (from session) against the comma-separated `ADMIN_DISCORD_IDS` env var. This pattern is repeated in: - - `app/admin/form/page.tsx` (form list) - - `app/admin/form/[id]/layout.tsx` (form editor) - - `app/actions/form.ts` (form CRUD actions) +2. **Admin check**: Server-side only. Compares the logged-in user's `discordId` (from session) against the comma-separated `ADMIN_DISCORD_IDS` env var. The primary guard is **centralized** in `app/admin/layout.tsx` which protects all `/admin/*` routes. Additional per-action checks exist in: + - `app/admin/form/actions.ts` (form CRUD actions) - `app/actions/questions.ts` (question CRUD actions) - `app/api/upload/route.ts` (file uploads) 3. **No middleware.ts**: Modern Next.js replaces `middleware.ts` with `proxy.ts`. The project has a `proxy.ts` that matches `/form/:path*` but currently just passes through. Auth checks are done per-page/per-action in server components and server actions.