Some checks are pending
CI/CD Pipeline / Backend CI (push) Waiting to run
CI/CD Pipeline / Frontend CI (push) Waiting to run
CI/CD Pipeline / WhatsApp Service CI (push) Waiting to run
CI/CD Pipeline / Mobile CI (push) Waiting to run
CI/CD Pipeline / Docker Build (./apps/backend, ./apps/backend/Dockerfile, backend) (push) Blocked by required conditions
CI/CD Pipeline / Docker Build (./apps/frontend, ./apps/frontend/Dockerfile, frontend) (push) Blocked by required conditions
CI/CD Pipeline / Docker Build (./apps/whatsapp-service, ./apps/whatsapp-service/Dockerfile, whatsapp-service) (push) Blocked by required conditions
CI/CD Pipeline / Deploy to Production (push) Blocked by required conditions
- Move 7 non-standard folders to _archive/ - Archive 3 extra root files - Update _MAP.md with standardized structure Standard: SIMCO-ESTANDAR-ORCHESTRATION v1.0.0 Level: CONSUMER (L2) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3.7 KiB
3.7 KiB
SUBAGENTE SA-012: Settings Frontend Integration
Metadata
| Campo | Valor |
|---|---|
| ID | SA-012 |
| Agent ID | a799038 |
| Tipo | general-purpose |
| Perfil | Frontend Developer |
| Tarea | T3.7-FE |
| Estado | COMPLETADO |
| Commit | 1b2fca8 |
| Dependencia | SA-007 (Settings Backend) |
Prompt Enviado
## TAREA: Conectar Settings.tsx a las APIs reales
**Proyecto:** michangarrito
**Ubicación:** /home/isem/workspace-v2/projects/michangarrito
### CONTEXTO
La página Settings.tsx actualmente usa datos mock. El backend ya tiene el módulo de settings implementado (SA-007). Ahora necesita conectarse a las APIs reales.
### REFERENCIAS A CONSULTAR
1. `frontend/src/pages/Settings.tsx` - Página actual con mock data
2. `frontend/src/lib/api.ts` - Agregar settingsApi
3. `backend/src/modules/settings/settings.controller.ts` - Endpoints disponibles
### APIs A IMPLEMENTAR EN api.ts
```typescript
export const settingsApi = {
getAll: () => api.get('/v1/settings'),
get: (key: string) => api.get(`/v1/settings/${key}`),
update: (key: string, value: any) => api.put(`/v1/settings/${key}`, { value }),
bulkUpdate: (settings: Record<string, any>) => api.post('/v1/settings/bulk', { settings })
};
INSTRUCCIONES
- Agregar settingsApi en
api.ts - Leer el archivo Settings.tsx actual
- Identificar los datos mock a reemplazar
- Implementar useQuery para cargar configuraciones
- Implementar useMutation para guardar cambios
- Agrupar settings por categoría (store, notifications, tax)
- Agregar feedback de éxito/error al guardar
- Mantener la estructura visual existente
- Hacer commit con mensaje:
[MCH-FE] feat: Connect Settings to real API - Push al remote
VALIDACIONES
- Build debe pasar:
npm run build - No errores de TypeScript
---
## Contexto Adicional Proporcionado
- Referencia al backend ya implementado (SA-007)
- Estructura de endpoints del backend
- Patrón de api.ts existente
---
## Resultado
### Archivos Modificados
| Archivo | Cambios |
|---------|---------|
| `frontend/src/lib/api.ts` | +settingsApi |
| `frontend/src/pages/Settings.tsx` | +useQuery, +useMutation, -mock data |
### Cambios Implementados
1. **Settings API en api.ts:**
```typescript
export const settingsApi = {
getAll: () => api.get('/v1/settings').then(r => r.data),
get: (key: string) => api.get(`/v1/settings/${key}`).then(r => r.data),
update: (key: string, value: any) =>
api.put(`/v1/settings/${key}`, { value }).then(r => r.data),
bulkUpdate: (settings: Record<string, any>) =>
api.post('/v1/settings/bulk', { settings }).then(r => r.data)
};
-
React Query hooks:
const { data: settings, isLoading } = useQuery({ queryKey: ['settings'], queryFn: () => settingsApi.getAll() }); const saveMutation = useMutation({ mutationFn: (changes: Record<string, any>) => settingsApi.bulkUpdate(changes), onSuccess: () => { queryClient.invalidateQueries(['settings']); toast.success('Configuración guardada'); } }); -
Agrupación por categoría:
- Store Settings (nombre, dirección, teléfono)
- Notification Settings (email, umbrales)
- Tax Settings (tasa IVA, incluido en precio)
-
UX:
- Loading skeleton mientras carga
- Botón de guardar con estado de loading
- Toast de éxito/error
Lecciones del Subagente
Que funcionó bien
- La dependencia de SA-007 estaba completa
- Los endpoints estaban bien documentados
- El patrón de api.ts fue fácil de extender
Mejoras sugeridas
- Agregar validación de formulario antes de enviar
- Incluir confirmación antes de cambios críticos