# frontend-admin

An **auto-admin back-office** that discovers your api's entities at runtime and
renders a live, reactive, permission-gated UI per entity — assembled from
already-shipped framework primitives, as **editable template code** (not a
sealed runtime feature).

## What it does

- **Discovers entities** from the api's capability map
  (`useCapabilityManifest` + `deriveEntityAdmins`) — point it at any Voltro api
  and the sidebar + pages adapt. No per-entity code.
- **Per entity**: a live `<DataTable>` (the list query) + an `<AutoForm>` (the
  create mutation), fields/columns straight from the descriptors' schemas.
- **Permission-gated**: write actions are hidden via `useCan` on conventional
  `<table>:create` / `<table>:delete` scopes (UX gating — the api's
  `permission()` guards remain the real boundary).
- **Provenance**: a per-row "Why?" drawer (`useProvenance`, innovation/08).
- **Undo/redo**: the topbar bar wraps the `__voltro.undo.*` built-ins
  (`useUndoLog`) — revert the last change across the whole admin.

## Use it

```sh
voltro create-project myApp --api=api-backend --web=frontend-admin
voltro dev   # the admin discovers api-backend's entities
```

Sign in at `/login` (demo cookie gate) → `/admin`.

## Make it yours

Everything under `src/pages/admin/` is yours to edit. Common first changes:

- **Real auth**: swap the cookie gate in `src/lib/auth.ts` + the demo scopes in
  `src/lib/admin.ts` (feed your session's real scopes to `<PermissionProvider>`).
- **Undo off**: if you run with `VOLTRO_UNDO=off`, delete the `UndoBar` in
  `src/pages/admin/layout.tsx`.
- **Custom per-entity views**: replace the generic `[entity].tsx` binding with a
  hand-built page for an entity that needs more than CRUD.
