# F-073 — Architect: Activate/deactivate VAT types in admin tax rates page ## Current state `/tax-rates/page.tsx` has inline edit for the `active` field: 1. Click "RowActions" (✏️) → enters edit mode 2. Change dropdown "Activo"/"Inactivo" 3. Click "Guardar" This is cumbersome for a simple toggle. The `active` field should be a direct **toggle switch** in the "Estado" column, with immediate feedback. ## Goal Add a prominent toggle switch (pill/checkbox style) in the "Estado" column that directly calls `taxApi.update(id, { active: !current })` without entering edit mode. ## Scope IN - `project/apps/admin/src/app/(dashboard)/tax-rates/page.tsx`: - Add `toggling` state (`Record`) to track in-flight toggle requests - Replace badge-only display in "Estado" column with a toggle switch - Toggle switch calls `taxApi.update(r.id, { active: !r.active })` directly - Shows spinner while toggling - Shows error message on failure and reverts optimistically - Maintains the existing inline edit functionality for name/rate changes ## Scope OUT - Backend API — already supports `active` field toggle via `PATCH /admin/tax-rates/:id` - No migration needed - No other pages ## Design Toggle switch (pill style): ```tsx ``` `toggleActive` function: ```ts const toggleActive = async (id: string, newActive: boolean) => { setToggling(prev => ({ ...prev, [id]: true })); try { await taxApi.update(id, { active: newActive }); setRates(prev => prev.map(r => r.id === id ? { ...r, active: newActive } : r)); } catch (er) { alert(er instanceof Error ? er.message : 'Error al cambiar estado'); } finally { setToggling(prev => ({ ...prev, [id]: false })); } }; ``` ## Risk - **Low risk**: purely frontend UX change, no backend or DB changes - Fallback: existing inline edit still works if toggle fails ## Verification - `npx tsc --noEmit` admin - `npx eslint` on changed file - `./scripts/verify.sh` green - Manual: toggle a tax rate active/inactive in /tax-rates page → pricing tab updates dropdown