Cursor prompt

Build Admin Dashboard with CRUD

Data table with server-side CRUD, column sorting and filtering, bulk actions, and role-protected admin panel.

Build an admin dashboard for managing {{entity}} in {{project_name}}.

## Columns: {{columns}}
## Actions: {{actions}}

### Data Table (TanStack Table v8)
- Server-side pagination, sorting, filtering
- Column visibility toggle with localStorage persistence
- Row selection: checkbox per row + select all on page + select all matching
- Column-level filter inputs (text, select, date range)
- Export current view to CSV

### CRUD Operations

**List: GET /api/admin/{{entity_plural}}**
Parameters: page, pageSize, sortBy, sortDir, filters (JSON)
Response: { data: T[], total: number, page: number }

**Create: POST /api/admin/{{entity_plural}}**
Modal form with all fields + client/server zod validation.
Show field-level errors inline.

**Update: PATCH /api/admin/{{entity_plural}}/:id**
Same form in edit mode. Detect no-op updates (no changes = no API call).

**Delete: DELETE /api/admin/{{entity_plural}}/:id**
Soft delete via deletedAt timestamp. Confirmation dialog: "Delete [name]? This cannot be undone."

**Bulk Delete**
"Delete N selected items?" — require typing "delete" to confirm for > 10 items.

### Authorization (Enforce on Every Route)
```typescript
// Every admin route starts with this
const session = await requireRole(request, 'admin');
```

### Audit Log
Write to AuditLog table: actorId, action, entityType, entityId, before, after, createdAt.

### Output
Table component, all admin API routes, form components, audit log schema.

Fill in: {{entity}}, {{project_name}}, {{columns}}, {{actions}}, {{entity_plural}}. In Loopy you fill these in a form and copy the finished prompt in one click.