Sprint 4 — Etapa 7 completada. Build limpio, 521/521 tests verdes. Resumen:
Some checks failed
/ Deploy to Cloudflare Pages (push) Has been cancelled
Some checks failed
/ Deploy to Cloudflare Pages (push) Has been cancelled
Tipos: Resource.processId? eliminado (vestigial); ResourceType ya tenía los 5 valores correctos, sin cambios. resource-repo.ts: agregado getAllWithCreator() con JOIN a users!created_by (mismo patrón que Etapa 6) y tipo ResourceWithCreator. delete() ahora valida que no haya asignaciones activas en activity_resource_assignments antes de borrar — lanza error explicativo si las hay. Verifiqué ambos contra Supabase real: el JOIN funciona (FK reconocida por PostgREST) y el conteo de guarda también. Nuevo — src/features/resources/: resource-display.tsx — labels, colores/íconos por tipo (Lucide: User/Briefcase/Server/Wrench/Package) y ResourceTypeAvatar compartido ResourceFormSheet.tsx — Sheet reutilizable para crear/editar, usado tanto en el catálogo como en el panel del workspace ResourceCatalogPage.tsx — página /recursos: búsqueda, filtro por tipo, tabla con badge de tipo, costo, "creado por", editar/eliminar con confirmación Nuevo — src/components/ui/sheet.tsx: componente shadcn Sheet (no existía), construido sobre @radix-ui/react-dialog que ya estaba instalado — no agregué dependencias nuevas. ResourcesPanel.tsx rediseñado: ahora solo muestra recursos usados en el proceso actual (derivado de assignedResources), con conteo de actividades por recurso. CRUD completo se mudó a /recursos; el panel solo permite "Nuevo" (catálogo global) y tiene el link "Ver catálogo completo". Router: ruta /recursos registrada. ActivityPanel no se tocó, como indicaba el scope.
This commit is contained in:
36
src/features/resources/resource-display.tsx
Normal file
36
src/features/resources/resource-display.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { User, Briefcase, Server, Wrench, Package, type LucideIcon } from 'lucide-react'
|
||||
import type { ResourceType } from '@/domain/types'
|
||||
|
||||
export const RESOURCE_TYPE_LABELS: Record<ResourceType, string> = {
|
||||
person: 'Persona',
|
||||
role: 'Rol',
|
||||
system: 'Sistema',
|
||||
equipment: 'Equipo',
|
||||
supply: 'Insumo',
|
||||
}
|
||||
|
||||
interface ResourceTypeStyle {
|
||||
icon: LucideIcon
|
||||
bg: string
|
||||
fg: string
|
||||
}
|
||||
|
||||
export const RESOURCE_TYPE_STYLES: Record<ResourceType, ResourceTypeStyle> = {
|
||||
person: { icon: User, bg: '#FEF3E7', fg: '#F59845' },
|
||||
role: { icon: Briefcase, bg: '#FEF3E7', fg: '#D97706' },
|
||||
system: { icon: Server, bg: '#EEF2FF', fg: '#6366F1' },
|
||||
equipment: { icon: Wrench, bg: '#F0FDF4', fg: '#16A34A' },
|
||||
supply: { icon: Package, bg: '#F1F5F9', fg: '#64748B' },
|
||||
}
|
||||
|
||||
export function ResourceTypeAvatar({ type, size = 32 }: { type: ResourceType; size?: number }) {
|
||||
const { icon: Icon, bg, fg } = RESOURCE_TYPE_STYLES[type]
|
||||
return (
|
||||
<div
|
||||
className="flex items-center justify-center rounded-full flex-shrink-0"
|
||||
style={{ width: size, height: size, background: bg }}
|
||||
>
|
||||
<Icon style={{ color: fg, width: size * 0.55, height: size * 0.55 }} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user