GRV-Admin/README.md
kirukib 408b707437 Add GRV Summit admin portal
Vite + React 19 + TypeScript staff/admin SPA built against GRV-Backend/API.md:
email OTP login (staff/admin only, 401 -> login), dashboard stats and
leaderboard, application review (filters, bulk status, CSV export, scoring),
inquiries by intent, orders and ticket check-in, tiers, discount codes, merch
items and pickup queue, QR checkpoints with printable A6 cards, startup badges,
raffles with draw, and attendees.

Shell and UI primitives adapted from the Booking platform admin; theme, fonts,
logo and topography pattern match the public GRVSummit site. Static deploy to
Cloudflare Pages via public/_redirects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 21:37:33 +03:00

3.6 KiB
Raw Blame History

GRV Summit Admin

Staff/admin portal for the GRV Summit: application review, inquiries, orders and ticket check-in, tiers, discount codes, merch pickup, QR checkpoints (with printable A6 cards), startup badges, raffles and attendees.

It is a static Vite + React 19 SPA that talks to the NestJS backend in ../GRV-Backend. The API contract it is built against is ../GRV-Backend/API.md; all admin calls go to /admin/* with a Bearer token.

Stack: React 19, TypeScript (strict), Tailwind CSS 4, Radix/shadcn-style components, TanStack Query and Table, react-router, qrcode, cmdk, sonner. Theme tokens and fonts (Antebas headings, DM Sans body) match the public site (GRVSummit/app/globals.css).

Setup

pnpm install
cp .env.example .env   # then edit if the API is not on localhost:4000
pnpm dev               # http://localhost:5175
Env var Default Meaning
VITE_API_URL http://localhost:4000 Base URL of the GRV backend API

VITE_* values are baked in at build time, so set it before pnpm build. The backend must allow this origin in CORS.

Scripts

  • pnpm dev: dev server
  • pnpm build: typecheck + production build into dist/
  • pnpm typecheck: tsc --noEmit
  • pnpm check: money-conversion self-check (src/lib/utils.check.ts)
  • pnpm preview: serve the built dist/

How login works

  1. Enter your email; the portal calls POST /auth/otp/request, and the backend emails a 6-digit code. In dev the code is printed in the backend console (the login page shows this hint in dev builds).
  2. Enter the code; POST /auth/otp/verify returns { accessToken, user }.
  3. The role comes from the backend's ADMIN_EMAILS / STAFF_EMAILS allowlists. ATTENDEE accounts are refused with a message. STAFF and ADMIN get in.
  4. The token and user are kept in localStorage. Tokens last 12 hours and can't be refreshed: any 401 clears the session and sends you back to /login.

STAFF can do day-to-day operations (review, statuses, orders, check-in, pickup). Create/edit buttons for ADMIN-only endpoints (★ in API.md: tiers, discounts, merch items, checkpoints, raffles and draws) are hidden from STAFF. The backend enforces this too.

Printing QR cards

Checkpoints → select rows → Print selected (or the printer icon on a row, or Print badges on the Startups page) opens /checkpoints/print?ids=…. Each card is A6 (105 × 148 mm), one per page. Use the browser's print dialog; on A4 paper choose "4 pages per sheet" and cut. Mystery investee cards print only "?" and the QR.

Deploy (Cloudflare Pages)

  • Build command: pnpm build
  • Output directory: dist
  • Environment variable: VITE_API_URL=https://<api host>

public/_redirects (/* /index.html 200) makes client-side routes work on refresh.

Layout

src/
  main.tsx, router.tsx, index.css   entry, routes, theme tokens + fonts
  lib/api.ts                        fetch wrapper (bearer, JSON, errors, 401 → login), session, CSV download
  lib/types.ts                      types hand-written from API.md
  lib/utils.ts                      cn, money / minor-unit helpers, dates, useDebounced
  components/ui/                    shadcn-style primitives (from the Booking platform admin)
  components/layout/                AppLayout + PageShell, Sidebar, CommandPalette (⌘K), nav
  components/DataTable.tsx          TanStack Table: sorting, row selection, expandable rows
  components/common.tsx             StatCard, QrImage, FormDialog, useSave, AdminOnly, badges
  pages/                            one file per screen