diff --git a/admin/src/app/admin-sugerencias/page.tsx b/admin/src/app/admin-sugerencias/page.tsx new file mode 100644 index 0000000..4fd6b3a --- /dev/null +++ b/admin/src/app/admin-sugerencias/page.tsx @@ -0,0 +1,103 @@ +'use client'; + +import { useEffect, useState, useCallback } from 'react'; +import { api } from '@/lib/api'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { Lightbulb, User, Clock } from 'lucide-react'; + +interface Suggestion { + id: string; + name?: string; + message: string; + created_at: string; +} + +export default function AdminSugerenciasPage() { + const [suggestions, setSuggestions] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(''); + + const load = useCallback(() => { + setLoading(true); + setError(''); + api.get<{ data: Suggestion[]; meta: any }>('/suggestions?limit=100') + .then((res) => setSuggestions(res.data)) + .catch(() => setError('Error al cargar las sugerencias')) + .finally(() => setLoading(false)); + }, []); + + useEffect(() => { load(); }, [load]); + + return ( +
+
+ +

Sugerencias

+ {!loading && ( + + {suggestions.length} + + )} +
+ + {loading && ( +
Cargando...
+ )} + + {error && ( +
+ {error} +
+ )} + + {!loading && !error && suggestions.length === 0 && ( + + + +

No hay sugerencias todavía.

+

+ Aparecerán aquí cuando los usuarios envíen sugerencias desde la app. +

+
+
+ )} + + {!loading && suggestions.length > 0 && ( +
+ {suggestions.map((s) => ( + + +
+
+ +
+
+

{s.message}

+
+ {s.name && ( + + + {s.name} + + )} + + + {new Date(s.created_at).toLocaleString('es-CO', { + day: '2-digit', + month: 'short', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + })} + +
+
+
+
+
+ ))} +
+ )} +
+ ); +} diff --git a/admin/src/components/sidebar.tsx b/admin/src/components/sidebar.tsx index 04ee767..eabf43f 100644 --- a/admin/src/components/sidebar.tsx +++ b/admin/src/components/sidebar.tsx @@ -13,6 +13,7 @@ import { Settings, MessageSquare, Star, + Lightbulb, LogOut, ChevronLeft, Menu, @@ -30,6 +31,7 @@ const menu = [ { href: '/locations', label: 'Ubicaciones', icon: MapPin }, { href: '/professions', label: 'Profesiones', icon: Wrench }, { href: '/comments', label: 'Comentarios', icon: Star }, + { href: '/admin-sugerencias', label: 'Sugerencias', icon: Lightbulb }, { href: '/sms', label: 'SMS', icon: MessageSquare }, { href: '/settings', label: 'Configuración', icon: Settings }, ];