A4: app shell (layout, nav, tokens, error/empty states, /api/health)
Fixes the A4 blocker: /api/dev/complete now establishes the Auth.js session. Root cause was UntrustedHost (trustHost defaulted false in pnpm start / production because setEnvDefaults derives it from AUTH_URL, not NEXTAUTH_URL, and assertConfig checks it before that default applies). Added trustHost: true to the auth config; rebuilt. Complete response now sets authjs.session-token, /schedule returns 200, and all 4 e2e shell tests pass. Also ignores test-results/ artifacts.
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
/coverage
|
||||||
|
/test-results
|
||||||
|
|
||||||
# next.js
|
# next.js
|
||||||
/.next/
|
/.next/
|
||||||
|
|||||||
+126
@@ -0,0 +1,126 @@
|
|||||||
|
# A4 Handoff — App Shell
|
||||||
|
|
||||||
|
**Status:** In progress. A1, A2, A3 committed. A4 work is uncommitted.
|
||||||
|
|
||||||
|
**Resolved:** The `/api/dev/complete` session bug (see below). With it fixed, all 4 e2e shell tests pass, plus typecheck/lint/17 unit tests. Next session: commit A4 (instructions at the bottom of this file).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## What's Done
|
||||||
|
|
||||||
|
- **A1** (commit `9cdf8be`): Foundation scaffold — Next.js 15, shadcn/Radix, Drizzle+Postgres, Vitest, Docker.
|
||||||
|
- **A2** (commit `d133aff`): Schema core — 6 tables, migration, idempotent seed.
|
||||||
|
- **A3** (commit `c0e73e2`): Auth — magic-link sign-in, `requirePermission()` chokepoint, role enum.
|
||||||
|
|
||||||
|
## A4 Work (Uncommitted)
|
||||||
|
|
||||||
|
Built for the app shell:
|
||||||
|
|
||||||
|
- `src/components/app/nav.tsx` — Nav (5 tabs mobile / rail desktop). Uses lucide-react icons.
|
||||||
|
- `src/components/app/state-message.tsx` — Error + empty states.
|
||||||
|
- `src/components/app/app-layout.tsx` — Shell layout (header, nav, main, footer).
|
||||||
|
- `src/app/(app)/layout.tsx` — Authenticated route group (redirects to /login if no session).
|
||||||
|
- `src/app/(app)/schedule/page.tsx` — `src/app/(app)/roster/page.tsx` — `src/app/(app)/training/page.tsx` — `src/app/(app)/announcements/page.tsx` — `src/app/(app)/settings/page.tsx` — 5 shell pages.
|
||||||
|
- `src/app/api/health/route.ts` — Health check endpoint.
|
||||||
|
- `e2e/shell.spec.ts` — Playwright e2e test (5 nav tabs at 360px viewport).
|
||||||
|
- `playwright.config.ts` — Playwright config.
|
||||||
|
- `package.json` — Added `test:e2e` script.
|
||||||
|
- `src/app/api/dev/complete/route.ts` — Added try/catch + logging around `signIn`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## The Blocker (RESOLVED): `/api/dev/complete` never set a session cookie
|
||||||
|
|
||||||
|
**Original report:** `GET /api/dev/complete?token=...` appeared to return HTTP 000 / connection
|
||||||
|
reset. That was a **test-harness artifact** (curl URL parsing/quoting in the handoff's shell
|
||||||
|
script), not an app bug — the endpoint returns `200 {"ok":true}`.
|
||||||
|
|
||||||
|
**Real symptom:** The complete response carried **no `Set-Cookie` header**, so no session cookie
|
||||||
|
was established. Every subsequent navigation to `/schedule` (etc.) then 307-redirected to
|
||||||
|
`/login`, and the two shell e2e tests failed (nav tabs never rendered). The route reported
|
||||||
|
`{"ok":true}` because `signIn` returned the error-page URL rather than throwing.
|
||||||
|
|
||||||
|
**Root cause:** `[auth][error] UntrustedHost: Host must be trusted.`
|
||||||
|
- Auth.js v5's `assertConfig()` checks `config.trustHost` **before** `setEnvDefaults()` applies
|
||||||
|
its env-based default (the code comment says so explicitly).
|
||||||
|
- `setEnvDefaults()` only derives `trustHost` from `AUTH_URL` / `AUTH_TRUST_HOST` / `VERCEL` /
|
||||||
|
`CF_PAGES` / `NODE_ENV !== "production"` — **not** from `NEXTAUTH_URL`.
|
||||||
|
- In `pnpm start` (production, `NODE_ENV=production`) with no `AUTH_URL`, `trustHost` stayed
|
||||||
|
`false`, so the magic-link callback was rejected and no session cookie was written.
|
||||||
|
- `pnpm dev` worked (dev mode) and Docker set `NEXTAUTH_URL` — but that var does not set
|
||||||
|
`trustHost`, so Docker had the same latent bug.
|
||||||
|
|
||||||
|
**Fix:** `src/auth/config.ts` now sets `trustHost: true` explicitly (the documented fix for
|
||||||
|
`UntrustedHost`; this is a localhost app behind a reverse proxy). Rebuild required for
|
||||||
|
`pnpm start`. Verified: complete response now sets `authjs.session-token`, `/schedule` returns
|
||||||
|
200, and all 4 e2e shell tests pass.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## How to Test (for next session)
|
||||||
|
|
||||||
|
Start the app and test the complete flow:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/bhursey/code/glenlochmedia
|
||||||
|
|
||||||
|
# Start app (detached, kills itself on exit)
|
||||||
|
env DATABASE_URL="postgres://media:media@localhost:5433/media" \
|
||||||
|
NEXTAUTH_SECRET="e2e-secret-for-shell-tests" \
|
||||||
|
AUTO_ACTIVATE_NEW_USERS="true" \
|
||||||
|
PORT=3000 \
|
||||||
|
pnpm start >/tmp/app.log 2>&1 &
|
||||||
|
APP_PID=$!
|
||||||
|
|
||||||
|
# Wait for ready
|
||||||
|
for i in $(seq 1 30); do grep -qiE "Ready" /tmp/app.log && break; sleep 1; done
|
||||||
|
|
||||||
|
# Get a token
|
||||||
|
TOKEN_URL=$(curl -s -X POST localhost:3000/api/dev/magic-link \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{"email":"e2e-test@example.com"}' \
|
||||||
|
| python3 -c "import sys,json; print(json.load(sys.stdin)['url'])")
|
||||||
|
|
||||||
|
# Complete sign-in (this is where HTTP 000 happens)
|
||||||
|
curl -sv "http://localhost:3000$TOKEN_URL" 2>&1 | grep -iE "set-cookie|HTTP/|error"
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
kill $APP_PID
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Use valid emails (with a TLD). Zod's `.email()` rejects `@localhost`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## E2E Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/bhursey/code/glenlochmedia
|
||||||
|
pnpm test:e2e --grep shell
|
||||||
|
```
|
||||||
|
|
||||||
|
The webServer runs `pnpm db:migrate && pnpm build && pnpm start` on port 3000.
|
||||||
|
|
||||||
|
**Current e2e status:** Both shell tests fail because `signInAs` doesn't establish a session (the complete endpoint resets the connection). Once the complete endpoint works, the e2e tests should pass.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Known Good Commands
|
||||||
|
|
||||||
|
- Typecheck: `pnpm typecheck` (exit 0)
|
||||||
|
- Lint: `pnpm lint` (exit 0)
|
||||||
|
- Unit tests: `pnpm test` (17 tests, exit 0)
|
||||||
|
- Build: `pnpm build` (exit 0)
|
||||||
|
- DB migrate: `pnpm db:migrate` (needs Postgres on :5433)
|
||||||
|
- DB seed: `pnpm db:seed`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## To Commit A4 (once complete)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/bhursey/code/glenlochmedia
|
||||||
|
rm -f src/app/api/dev/magic-debug.log # debug file, don't commit
|
||||||
|
git add -A
|
||||||
|
git commit -m "A4: app shell (layout, nav, tokens, error/empty states, /api/health)"
|
||||||
|
```
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { test, expect, type Page } from "@playwright/test";
|
||||||
|
|
||||||
|
const BASE = "http://localhost:3000";
|
||||||
|
const TAB_LABELS = ["Schedule", "Roster", "Training", "Announcements", "Settings"];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dev console transport: request a magic link, then complete it in the browser
|
||||||
|
* context so the Auth.js session cookie is set for the navigation under test.
|
||||||
|
*/
|
||||||
|
async function signInAs(page: Page, email: string) {
|
||||||
|
const res = await page.request.post(`${BASE}/api/dev/magic-link`, {
|
||||||
|
data: { email },
|
||||||
|
});
|
||||||
|
expect(res.ok(), "magic-link request should succeed").toBe(true);
|
||||||
|
const body = (await res.json()) as { url?: string };
|
||||||
|
expect(body.url, "magic-link should return a sign-in url").toBeTruthy();
|
||||||
|
await page.goto(body.url!);
|
||||||
|
await expect(page).toHaveURL(/complete/);
|
||||||
|
}
|
||||||
|
|
||||||
|
test.describe("app shell", () => {
|
||||||
|
test("renders the shell with 5 nav tabs at a 360px viewport", async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 360, height: 780 });
|
||||||
|
await signInAs(page, `e2e-mobile-${Date.now()}@example.com`);
|
||||||
|
|
||||||
|
await page.goto(`${BASE}/schedule`);
|
||||||
|
await expect(page).toHaveURL(`${BASE}/schedule`);
|
||||||
|
|
||||||
|
// Header + page title.
|
||||||
|
await expect(page.getByRole("heading", { name: "Schedule", level: 1 })).toBeVisible();
|
||||||
|
|
||||||
|
// Five nav tabs, one per label.
|
||||||
|
for (const label of TAB_LABELS) {
|
||||||
|
await expect(page.getByRole("link", { name: label, exact: true })).toBeVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The current tab is marked active.
|
||||||
|
await expect(page.getByRole("link", { name: "Schedule" })).toHaveAttribute(
|
||||||
|
"aria-current",
|
||||||
|
"page",
|
||||||
|
);
|
||||||
|
|
||||||
|
// Empty state renders inside the shell.
|
||||||
|
await expect(page.getByText("Nothing scheduled yet")).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("shows the desktop rail inside the shell at desktop width", async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 1024, height: 768 });
|
||||||
|
await signInAs(page, `e2e-desktop-${Date.now()}@example.com`);
|
||||||
|
|
||||||
|
await page.goto(`${BASE}/roster`);
|
||||||
|
for (const label of TAB_LABELS) {
|
||||||
|
await expect(page.getByRole("link", { name: label, exact: true })).toBeVisible();
|
||||||
|
}
|
||||||
|
// Active tab follows the route.
|
||||||
|
await expect(page.getByRole("link", { name: "Roster" })).toHaveAttribute(
|
||||||
|
"aria-current",
|
||||||
|
"page",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("redirects unauthenticated users away from the shell", async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 360, height: 780 });
|
||||||
|
await page.goto(`${BASE}/schedule`);
|
||||||
|
await expect(page).toHaveURL(`${BASE}/login`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe("health", () => {
|
||||||
|
test("/api/health returns ok", async ({ request }) => {
|
||||||
|
const res = await request.get(`${BASE}/api/health`);
|
||||||
|
expect(res.ok()).toBe(true);
|
||||||
|
const body = (await res.json()) as { status: string };
|
||||||
|
expect(body.status).toBe("ok");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:watch": "vitest",
|
"test:watch": "vitest",
|
||||||
|
"test:e2e": "playwright test",
|
||||||
"db:generate": "drizzle-kit generate",
|
"db:generate": "drizzle-kit generate",
|
||||||
"db:migrate": "drizzle-kit migrate",
|
"db:migrate": "drizzle-kit migrate",
|
||||||
"db:seed": "tsx src/db/seed.ts"
|
"db:seed": "tsx src/db/seed.ts"
|
||||||
@@ -33,6 +34,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "^3",
|
"@eslint/eslintrc": "^3",
|
||||||
|
"@playwright/test": "^1.65.1",
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
"@testing-library/jest-dom": "^7.0.1",
|
"@testing-library/jest-dom": "^7.0.1",
|
||||||
"@testing-library/react": "^16.3.3",
|
"@testing-library/react": "^16.3.3",
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { defineConfig, devices } from "@playwright/test";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* E2E for the app shell. The done-criteria is "passes at 360px viewport", so
|
||||||
|
* the shell tests pin a mobile viewport. The webServer builds + starts the app
|
||||||
|
* against the same Postgres the app uses in production.
|
||||||
|
*/
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: "./e2e",
|
||||||
|
fullyParallel: true,
|
||||||
|
retries: process.env.CI ? 2 : 0,
|
||||||
|
workers: process.env.CI ? 1 : undefined,
|
||||||
|
reporter: "list",
|
||||||
|
use: {
|
||||||
|
baseURL: "http://localhost:3000",
|
||||||
|
trace: "on-first-retry",
|
||||||
|
},
|
||||||
|
projects: [
|
||||||
|
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
|
||||||
|
],
|
||||||
|
webServer: {
|
||||||
|
command: "pnpm db:migrate && pnpm build && PORT=3000 pnpm start",
|
||||||
|
url: "http://localhost:3000",
|
||||||
|
reuseExistingServer: true,
|
||||||
|
env: {
|
||||||
|
DATABASE_URL: "postgres://media:media@localhost:5433/media",
|
||||||
|
NEXTAUTH_SECRET: "e2e-secret-for-shell-tests",
|
||||||
|
AUTO_ACTIVATE_NEW_USERS: "true",
|
||||||
|
},
|
||||||
|
timeout: 180_000,
|
||||||
|
},
|
||||||
|
});
|
||||||
Generated
+34
-5
@@ -31,10 +31,10 @@ importers:
|
|||||||
version: 1.74.0(@types/react@19.3.0)(react@19.1.0)
|
version: 1.74.0(@types/react@19.3.0)(react@19.1.0)
|
||||||
next:
|
next:
|
||||||
specifier: 15.5.29
|
specifier: 15.5.29
|
||||||
version: 15.5.29(@babel/core@7.29.13)(@types/node@20.19.43)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
version: 15.5.29(@babel/core@7.29.13)(@playwright/test@1.65.1)(@types/node@20.19.43)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||||
next-auth:
|
next-auth:
|
||||||
specifier: 5.0.0-beta.32
|
specifier: 5.0.0-beta.32
|
||||||
version: 5.0.0-beta.32(next@15.5.29(@babel/core@7.29.13)(@types/node@20.19.43)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react@19.1.0)
|
version: 5.0.0-beta.32(next@15.5.29(@babel/core@7.29.13)(@playwright/test@1.65.1)(@types/node@20.19.43)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react@19.1.0)
|
||||||
postgres:
|
postgres:
|
||||||
specifier: ^4.1.1
|
specifier: ^4.1.1
|
||||||
version: 4.1.1
|
version: 4.1.1
|
||||||
@@ -57,6 +57,9 @@ importers:
|
|||||||
'@eslint/eslintrc':
|
'@eslint/eslintrc':
|
||||||
specifier: ^3
|
specifier: ^3
|
||||||
version: 3.3.7
|
version: 3.3.7
|
||||||
|
'@playwright/test':
|
||||||
|
specifier: ^1.65.1
|
||||||
|
version: 1.65.1
|
||||||
'@tailwindcss/postcss':
|
'@tailwindcss/postcss':
|
||||||
specifier: ^4
|
specifier: ^4
|
||||||
version: 4.3.5
|
version: 4.3.5
|
||||||
@@ -1062,6 +1065,11 @@ packages:
|
|||||||
'@panva/hkdf@1.2.1':
|
'@panva/hkdf@1.2.1':
|
||||||
resolution: {integrity: sha512-6oclG6Y3PiDFcoyk8srjLfVKyMfVCKJ27JwNPViuXziFpmdz+MZnZN/aKY0JGXgYuO/VghU0jcOAZgWXZ1Dmrw==}
|
resolution: {integrity: sha512-6oclG6Y3PiDFcoyk8srjLfVKyMfVCKJ27JwNPViuXziFpmdz+MZnZN/aKY0JGXgYuO/VghU0jcOAZgWXZ1Dmrw==}
|
||||||
|
|
||||||
|
'@playwright/test@1.65.1':
|
||||||
|
resolution: {integrity: sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw==}
|
||||||
|
engines: {node: '>=20'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
'@radix-ui/react-compose-refs@1.1.5':
|
'@radix-ui/react-compose-refs@1.1.5':
|
||||||
resolution: {integrity: sha512-+48PbAAbq3didjJxa+OaWY2ZwgAKsNiRGyeHKszblZMQ+kcpd9pAaT11cMkGEie0vsOi3QdeTE6d5Fe3Gn61kA==}
|
resolution: {integrity: sha512-+48PbAAbq3didjJxa+OaWY2ZwgAKsNiRGyeHKszblZMQ+kcpd9pAaT11cMkGEie0vsOi3QdeTE6d5Fe3Gn61kA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -3123,6 +3131,16 @@ packages:
|
|||||||
resolution: {integrity: sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==}
|
resolution: {integrity: sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
playwright-core@1.65.1:
|
||||||
|
resolution: {integrity: sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==}
|
||||||
|
engines: {node: '>=20'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
|
playwright@1.65.1:
|
||||||
|
resolution: {integrity: sha512-vJ1FuoOrNwOKHUIVEvSt3jT1L+wjjDpwhwIstKtfvTh8XIG4FG4bIFuvNdMxi81LGfAhUgUZleVFaOLY4RIUUw==}
|
||||||
|
engines: {node: '>=20'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
possible-typed-array-names@1.1.0:
|
possible-typed-array-names@1.1.0:
|
||||||
resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==}
|
resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
@@ -4498,6 +4516,10 @@ snapshots:
|
|||||||
|
|
||||||
'@panva/hkdf@1.2.1': {}
|
'@panva/hkdf@1.2.1': {}
|
||||||
|
|
||||||
|
'@playwright/test@1.65.1':
|
||||||
|
dependencies:
|
||||||
|
playwright: 1.65.1
|
||||||
|
|
||||||
'@radix-ui/react-compose-refs@1.1.5(@types/react@19.3.0)(react@19.1.0)':
|
'@radix-ui/react-compose-refs@1.1.5(@types/react@19.3.0)(react@19.1.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
react: 19.1.0
|
react: 19.1.0
|
||||||
@@ -6354,13 +6376,13 @@ snapshots:
|
|||||||
|
|
||||||
natural-compare@1.4.0: {}
|
natural-compare@1.4.0: {}
|
||||||
|
|
||||||
next-auth@5.0.0-beta.32(next@15.5.29(@babel/core@7.29.13)(@types/node@20.19.43)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react@19.1.0):
|
next-auth@5.0.0-beta.32(next@15.5.29(@babel/core@7.29.13)(@playwright/test@1.65.1)(@types/node@20.19.43)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react@19.1.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@auth/core': 0.41.3
|
'@auth/core': 0.41.3
|
||||||
next: 15.5.29(@babel/core@7.29.13)(@types/node@20.19.43)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
next: 15.5.29(@babel/core@7.29.13)(@playwright/test@1.65.1)(@types/node@20.19.43)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||||
react: 19.1.0
|
react: 19.1.0
|
||||||
|
|
||||||
next@15.5.29(@babel/core@7.29.13)(@types/node@20.19.43)(react-dom@19.1.0(react@19.1.0))(react@19.1.0):
|
next@15.5.29(@babel/core@7.29.13)(@playwright/test@1.65.1)(@types/node@20.19.43)(react-dom@19.1.0(react@19.1.0))(react@19.1.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@next/env': 15.5.29
|
'@next/env': 15.5.29
|
||||||
'@swc/helpers': 0.5.15
|
'@swc/helpers': 0.5.15
|
||||||
@@ -6378,6 +6400,7 @@ snapshots:
|
|||||||
'@next/swc-linux-x64-musl': 15.5.29
|
'@next/swc-linux-x64-musl': 15.5.29
|
||||||
'@next/swc-win32-arm64-msvc': 15.5.29
|
'@next/swc-win32-arm64-msvc': 15.5.29
|
||||||
'@next/swc-win32-x64-msvc': 15.5.29
|
'@next/swc-win32-x64-msvc': 15.5.29
|
||||||
|
'@playwright/test': 1.65.1
|
||||||
sharp: 0.35.5(@types/node@20.19.43)
|
sharp: 0.35.5(@types/node@20.19.43)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@babel/core'
|
- '@babel/core'
|
||||||
@@ -6555,6 +6578,12 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
find-up: 3.0.0
|
find-up: 3.0.0
|
||||||
|
|
||||||
|
playwright-core@1.65.1: {}
|
||||||
|
|
||||||
|
playwright@1.65.1:
|
||||||
|
dependencies:
|
||||||
|
playwright-core: 1.65.1
|
||||||
|
|
||||||
possible-typed-array-names@1.1.0: {}
|
possible-typed-array-names@1.1.0: {}
|
||||||
|
|
||||||
postcss-selector-parser@7.2.1:
|
postcss-selector-parser@7.2.1:
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { StateMessage } from "@/components/app/state-message";
|
||||||
|
|
||||||
|
export const metadata = { title: "Announcements" };
|
||||||
|
|
||||||
|
export default function AnnouncementsPage() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1 className="text-lg font-semibold tracking-tight">Announcements</h1>
|
||||||
|
<p className="text-sm text-muted-foreground">News and notes from the media team.</p>
|
||||||
|
<StateMessage
|
||||||
|
title="No announcements"
|
||||||
|
description="Team announcements will appear here as rich-text posts."
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { auth } from "@/auth/config";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
import { AppLayout } from "@/components/app/app-layout";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authenticated shell wrapper. Any route under the `(app)` group requires a
|
||||||
|
* session; unauthenticated visitors are sent to /login. The visible shell
|
||||||
|
* (header, nav, main, footer) is provided by AppLayout.
|
||||||
|
*/
|
||||||
|
export default async function AppGroupLayout({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
const session = await auth();
|
||||||
|
if (!session?.user) redirect("/login");
|
||||||
|
return <AppLayout>{children}</AppLayout>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { StateMessage } from "@/components/app/state-message";
|
||||||
|
|
||||||
|
export const metadata = { title: "Roster" };
|
||||||
|
|
||||||
|
export default function RosterPage() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1 className="text-lg font-semibold tracking-tight">Roster</h1>
|
||||||
|
<p className="text-sm text-muted-foreground">The team, their roles, and how to reach them.</p>
|
||||||
|
<StateMessage
|
||||||
|
title="No one on the roster yet"
|
||||||
|
description="Volunteers appear here once an admin invites and approves them."
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { StateMessage } from "@/components/app/state-message";
|
||||||
|
|
||||||
|
export const metadata = { title: "Schedule" };
|
||||||
|
|
||||||
|
export default function SchedulePage() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1 className="text-lg font-semibold tracking-tight">Schedule</h1>
|
||||||
|
<p className="text-sm text-muted-foreground">Your upcoming slots and what to do the day of service.</p>
|
||||||
|
<StateMessage
|
||||||
|
title="Nothing scheduled yet"
|
||||||
|
description="Slots confirmed for you will show up here, with call times and a way to add them to your calendar."
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { StateMessage } from "@/components/app/state-message";
|
||||||
|
|
||||||
|
export const metadata = { title: "Settings" };
|
||||||
|
|
||||||
|
export default function SettingsPage() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1 className="text-lg font-semibold tracking-tight">Settings</h1>
|
||||||
|
<p className="text-sm text-muted-foreground">Church details, timezone, and scheduling rules.</p>
|
||||||
|
<StateMessage
|
||||||
|
title="No settings to show"
|
||||||
|
description="Church and scheduling settings appear here. Branding and admin settings are restricted to admins."
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { StateMessage } from "@/components/app/state-message";
|
||||||
|
|
||||||
|
export const metadata = { title: "Training" };
|
||||||
|
|
||||||
|
export default function TrainingPage() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h1 className="text-lg font-semibold tracking-tight">Training</h1>
|
||||||
|
<p className="text-sm text-muted-foreground">How-tos and tutorials, with progress tied to your roles.</p>
|
||||||
|
<StateMessage
|
||||||
|
title="No courses available"
|
||||||
|
description="Training lessons will appear here. Some are required before you can serve certain roles."
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -20,9 +20,17 @@ export const GET = async (req: NextRequest) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await signIn("magic-link", { token, redirect: false });
|
try {
|
||||||
return new Response(JSON.stringify({ ok: true, url: result.url }), {
|
const result = await signIn("magic-link", { token, redirect: false });
|
||||||
status: 200,
|
return new Response(JSON.stringify({ ok: true, url: result.url }), {
|
||||||
headers: JSON_HEADERS,
|
status: 200,
|
||||||
});
|
headers: JSON_HEADERS,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error("[complete] signIn failed:", (err as Error).message, (err as Error).stack);
|
||||||
|
return new Response(JSON.stringify({ error: "failed to sign in" }), {
|
||||||
|
status: 500,
|
||||||
|
headers: JSON_HEADERS,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Liveness probe for the reverse proxy / cron worker. Cheap, no DB, no auth.
|
||||||
|
* The cron worker's heartbeat is a separate concern (G3); this just answers
|
||||||
|
* "is this process up?".
|
||||||
|
*/
|
||||||
|
export const GET = async () => {
|
||||||
|
return NextResponse.json({
|
||||||
|
status: "ok",
|
||||||
|
time: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -38,6 +38,12 @@ export const authConfig = {
|
|||||||
],
|
],
|
||||||
session: { strategy: "jwt" },
|
session: { strategy: "jwt" },
|
||||||
secret: process.env.AUTH_SECRET ?? process.env.NEXTAUTH_SECRET,
|
secret: process.env.AUTH_SECRET ?? process.env.NEXTAUTH_SECRET,
|
||||||
|
// Auth.js v5 gates the callback on the request `Host` header and throws
|
||||||
|
// `UntrustedHost` unless `trustHost` is true. In `pnpm start` (production)
|
||||||
|
// the env-based default is false, which silently drops the session cookie
|
||||||
|
// on the magic-link callback (the A4 blocker). This is a localhost app behind
|
||||||
|
// a reverse proxy, so trusting the Host header is the documented fix.
|
||||||
|
trustHost: true,
|
||||||
pages: { signIn: "/login" },
|
pages: { signIn: "/login" },
|
||||||
callbacks: {
|
callbacks: {
|
||||||
async jwt({ token, user }) {
|
async jwt({ token, user }) {
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { NavTabs, NavRail } from "./nav";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* App shell: sticky header (app title + mobile tab bar), desktop side rail,
|
||||||
|
* scrollable main, and a footer. Wraps every authenticated page. Pure layout —
|
||||||
|
* no data, no auth — so the auth guard lives in the route group that uses it.
|
||||||
|
*/
|
||||||
|
export function AppLayout({ children }: { children: React.ReactNode }) {
|
||||||
|
return (
|
||||||
|
<div className="flex min-h-screen flex-col bg-background text-foreground">
|
||||||
|
<header className="sticky top-0 z-20 border-b bg-background">
|
||||||
|
<div className="flex h-14 items-center px-4">
|
||||||
|
<span className="text-base font-semibold tracking-tight">Media Team Hub</span>
|
||||||
|
</div>
|
||||||
|
<NavTabs className="md:hidden" />
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div className="flex flex-1">
|
||||||
|
<aside className="hidden md:block md:w-64 md:shrink-0">
|
||||||
|
<NavRail />
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<main className="flex min-w-0 flex-1">
|
||||||
|
<div className="flex w-full flex-1 flex-col p-4 md:p-8">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer className="border-t bg-muted/40">
|
||||||
|
<div className="flex h-12 items-center px-4">
|
||||||
|
<p className="text-xs text-muted-foreground">Media Team Hub</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import Link from "next/link";
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
|
import { Calendar, Users, BookOpen, Megaphone, Settings } from "lucide-react";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The five primary navigation destinations. Single source of truth so the
|
||||||
|
* mobile tab bar and the desktop rail stay in sync.
|
||||||
|
*/
|
||||||
|
export const NAV_ITEMS = [
|
||||||
|
{ href: "/schedule", label: "Schedule", icon: Calendar },
|
||||||
|
{ href: "/roster", label: "Roster", icon: Users },
|
||||||
|
{ href: "/training", label: "Training", icon: BookOpen },
|
||||||
|
{ href: "/announcements", label: "Announcements", icon: Megaphone },
|
||||||
|
{ href: "/settings", label: "Settings", icon: Settings },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
type IconName = (typeof NAV_ITEMS)[number]["icon"];
|
||||||
|
|
||||||
|
function isActive(pathname: string, href: string): boolean {
|
||||||
|
if (pathname === href) return true;
|
||||||
|
// Landing tab highlights on the empty root.
|
||||||
|
return pathname === "/" && href === "/schedule";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Mobile: full-width tab bar, icon + label, one cell per tab. */
|
||||||
|
export function NavTabs({ className = "" }: { className?: string }) {
|
||||||
|
const pathname = usePathname();
|
||||||
|
return (
|
||||||
|
<nav
|
||||||
|
aria-label="Primary"
|
||||||
|
className={`flex border-b bg-background ${className}`}
|
||||||
|
>
|
||||||
|
{NAV_ITEMS.map((item) => {
|
||||||
|
const active = isActive(pathname, item.href);
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
key={item.href}
|
||||||
|
href={item.href}
|
||||||
|
aria-current={active ? "page" : undefined}
|
||||||
|
className="flex flex-1 flex-col items-center gap-1 border-transparent px-2 py-2.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground [&[aria-current=page]:border-b]:border-primary [&[aria-current=page]:border-b]:text-primary"
|
||||||
|
>
|
||||||
|
<item.icon className="h-5 w-5" aria-hidden="true" />
|
||||||
|
<span>{item.label}</span>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Desktop: vertical rail, icon + label, padded. */
|
||||||
|
export function NavRail({ className = "" }: { className?: string }) {
|
||||||
|
const pathname = usePathname();
|
||||||
|
return (
|
||||||
|
<nav
|
||||||
|
aria-label="Primary"
|
||||||
|
className={`flex flex-col gap-1 p-2 ${className}`}
|
||||||
|
>
|
||||||
|
{NAV_ITEMS.map((item) => {
|
||||||
|
const active = isActive(pathname, item.href);
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
key={item.href}
|
||||||
|
href={item.href}
|
||||||
|
aria-current={active ? "page" : undefined}
|
||||||
|
className={`flex items-center gap-3 rounded-md px-3 py-2 text-sm font-medium transition-colors ${
|
||||||
|
active
|
||||||
|
? "bg-primary text-primary-foreground"
|
||||||
|
: "text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<item.icon className="h-4 w-4" aria-hidden="true" />
|
||||||
|
<span>{item.label}</span>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { IconName };
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { AlertTriangle, Inbox } from "lucide-react";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared empty + error states so every page speaks with one voice. Kept pure
|
||||||
|
* (no data, no auth) so it is trivially testable and reusable.
|
||||||
|
*/
|
||||||
|
export function StateMessage({
|
||||||
|
kind = "empty",
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
}: {
|
||||||
|
kind?: "empty" | "error";
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
}) {
|
||||||
|
const isError = kind === "error";
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
role={isError ? "alert" : undefined}
|
||||||
|
className="flex flex-1 flex-col items-center justify-center gap-3 px-6 py-24 text-center"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={`flex h-12 w-12 items-center justify-center rounded-full ${
|
||||||
|
isError ? "bg-destructive/10 text-destructive" : "bg-muted text-muted-foreground"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{isError ? (
|
||||||
|
<AlertTriangle className="h-6 w-6" />
|
||||||
|
) : (
|
||||||
|
<Inbox className="h-6 w-6" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{title && <p className="text-sm font-semibold text-foreground">{title}</p>}
|
||||||
|
{description && <p className="max-w-sm text-sm text-muted-foreground">{description}</p>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user