First master-data CRUD module on the phase-1 RBAC foundation. API: - Customer gains archivedAt (soft-delete marker, distinct from the legacy `status` business flag); pushed to dev (nullable, non-destructive). - CustomersService: create/update/archive/restore. list() and the browser default to archivedAt=null; ?includeArchived=true opts in. App-created rows set nameMissing=false and leave legacy provenance null. - CustomersController write routes guarded per the matrix: create/update need STAFF+ (customer:create/update), archive/restore need ADMIN (customer:delete). Every mutation audit-logged. - create/update DTOs (class-validator); date strings coerced to Date. Web: - Shared CustomerForm (create + edit) with identity/address/account sections; new routes /clientes/nuevo and /clientes/[id]/editar, each self-gated on the ability. - List page: ability-gated "Nuevo cliente" button. Detail page: gated Editar / Archivar (Restaurar) action bar; archived badge. - api.ts create/update/archive/restore; CustomerInput type; archived flag on list items. Verified against dev: create (dates coerced, archivedAt null), edit 200, VIEWER create 403, STAFF create 201 but archive 403, ADMIN archive drops the row from the default list and includeArchived surfaces it, restore returns it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
790 B
TypeScript
37 lines
790 B
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { AppShell } from "@/components/AppShell";
|
|
import { CustomerForm } from "@/components/CustomerForm";
|
|
import { useCan } from "@/lib/abilities";
|
|
|
|
export default function NuevoClientePage() {
|
|
return (
|
|
<AppShell>
|
|
<NuevoCliente />
|
|
</AppShell>
|
|
);
|
|
}
|
|
|
|
function NuevoCliente() {
|
|
const allowed = useCan("customer:create");
|
|
|
|
return (
|
|
<>
|
|
<div className="page-head">
|
|
<Link href="/clientes" className="back-link">
|
|
← Clientes
|
|
</Link>
|
|
<h1 className="page-title">Nuevo cliente</h1>
|
|
</div>
|
|
{allowed ? (
|
|
<CustomerForm />
|
|
) : (
|
|
<div className="state-box state-error">
|
|
No tiene permisos para crear clientes.
|
|
</div>
|
|
)}
|
|
</>
|
|
);
|
|
}
|