feat: página admin /admin-sugerencias + enlace en sidebar

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-27 19:46:30 -05:00
co-authored by Claude Sonnet 4.6
parent 8a1f9687cd
commit a9b5e413e3
2 changed files with 105 additions and 0 deletions
+103
View File
@@ -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<Suggestion[]>([]);
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 (
<div className="space-y-6">
<div className="flex items-center gap-3">
<Lightbulb className="h-6 w-6 text-yellow-500" />
<h1 className="text-2xl font-bold">Sugerencias</h1>
{!loading && (
<span className="rounded-full bg-muted px-2.5 py-0.5 text-sm text-muted-foreground">
{suggestions.length}
</span>
)}
</div>
{loading && (
<div className="text-center py-12 text-muted-foreground">Cargando...</div>
)}
{error && (
<div className="rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-destructive text-sm">
{error}
</div>
)}
{!loading && !error && suggestions.length === 0 && (
<Card>
<CardContent className="flex flex-col items-center justify-center py-16 gap-3">
<Lightbulb className="h-12 w-12 text-muted-foreground/30" />
<p className="text-muted-foreground">No hay sugerencias todavía.</p>
<p className="text-sm text-muted-foreground/60">
Aparecerán aquí cuando los usuarios envíen sugerencias desde la app.
</p>
</CardContent>
</Card>
)}
{!loading && suggestions.length > 0 && (
<div className="grid gap-3">
{suggestions.map((s) => (
<Card key={s.id} className="hover:shadow-md transition-shadow">
<CardContent className="pt-4 pb-4">
<div className="flex items-start gap-4">
<div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-yellow-100 text-yellow-600">
<Lightbulb className="h-4 w-4" />
</div>
<div className="flex-1 min-w-0">
<p className="text-sm leading-relaxed">{s.message}</p>
<div className="mt-2 flex items-center gap-4 text-xs text-muted-foreground">
{s.name && (
<span className="flex items-center gap-1">
<User className="h-3 w-3" />
{s.name}
</span>
)}
<span className="flex items-center gap-1">
<Clock className="h-3 w-3" />
{new Date(s.created_at).toLocaleString('es-CO', {
day: '2-digit',
month: 'short',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
})}
</span>
</div>
</div>
</div>
</CardContent>
</Card>
))}
</div>
)}
</div>
);
}
+2
View File
@@ -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 },
];