feat: initialisation complète du projet CESIZen

- Backend Laravel 11 (API REST, JWT auth, PostgreSQL)
- Frontend Next.js 14 (React, TypeScript, Tailwind CSS)
- Docker Compose (PostgreSQL, backend, frontend)
- Modules : auth, profil, tracker émotions, informations, admin
This commit is contained in:
Azmog
2026-03-11 16:27:01 +01:00
commit e3da625927
158 changed files with 25139 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
"use client";
import { ThemeProvider } from "next-themes";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Toaster } from "react-hot-toast";
import { useState } from "react";
export default function Providers({ children }: { children: React.ReactNode }) {
const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: {
queries: {
staleTime: 5 * 60 * 1000, // 5 minutes
},
},
})
);
return (
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<QueryClientProvider client={queryClient}>
{children}
<Toaster position="top-right" />
</QueryClientProvider>
</ThemeProvider>
);
}
@@ -0,0 +1,160 @@
'use client';
import React from 'react';
import {
BarChart,
Bar,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
ResponsiveContainer,
PieChart,
Pie,
Cell,
LineChart,
Line,
Legend,
} from 'recharts';
import type { RapportData } from '@/types';
interface EmotionChartProps {
data: RapportData;
type?: 'repartition' | 'evolution' | 'intensite';
}
export default function EmotionChart({ data, type = 'repartition' }: EmotionChartProps) {
if (type === 'repartition') {
const pieData = data.repartition.map((item) => ({
name: item.nom,
value: item.count,
color: item.couleur,
pourcentage: item.pourcentage,
}));
if (pieData.length === 0) {
return <EmptyChart message="Aucune donnée pour cette période" />;
}
return (
<div className="w-full h-80">
<ResponsiveContainer width="100%" height={320}>
<PieChart>
<Pie
data={pieData}
cx="50%"
cy="50%"
innerRadius={60}
outerRadius={120}
paddingAngle={3}
dataKey="value"
label={({ name, pourcentage }: any) => `${name} (${pourcentage}%)`}
>
{pieData.map((entry, index) => (
<Cell key={`cell-${index}`} fill={entry.color} />
))}
</Pie>
<Tooltip
formatter={(value: any, name: any) => [`${value} saisies`, name]}
contentStyle={{
backgroundColor: 'rgba(255,255,255,0.95)',
border: 'none',
borderRadius: '12px',
boxShadow: '0 4px 12px rgba(0,0,0,0.1)',
}}
/>
</PieChart>
</ResponsiveContainer>
</div>
);
}
if (type === 'evolution') {
const lineData = data.evolution.labels.map((label, index) => {
const point: Record<string, string | number> = { date: label };
data.evolution.emotions.forEach((emotion) => {
point[emotion.nom] = emotion.data[index] || 0;
});
return point;
});
if (lineData.length === 0) {
return <EmptyChart message="Aucune donnée d'évolution" />;
}
return (
<div className="w-full h-80">
<ResponsiveContainer width="100%" height={320}>
<LineChart data={lineData}>
<CartesianGrid strokeDasharray="3 3" className="opacity-30" />
<XAxis dataKey="date" tick={{ fontSize: 12 }} />
<YAxis tick={{ fontSize: 12 }} />
<Tooltip
contentStyle={{
backgroundColor: 'rgba(255,255,255,0.95)',
border: 'none',
borderRadius: '12px',
boxShadow: '0 4px 12px rgba(0,0,0,0.1)',
}}
/>
<Legend />
{data.evolution.emotions.map((emotion) => (
<Line
key={emotion.nom}
type="monotone"
dataKey={emotion.nom}
stroke={emotion.couleur}
strokeWidth={2}
dot={{ fill: emotion.couleur, r: 4 }}
activeDot={{ r: 6 }}
/>
))}
</LineChart>
</ResponsiveContainer>
</div>
);
}
if (type === 'intensite') {
const barData = data.evolution.labels.map((label, index) => ({
date: label,
intensite: data.evolution.intensite_moyenne[index] || 0,
}));
if (barData.length === 0) {
return <EmptyChart message="Aucune donnée d'intensité" />;
}
return (
<div className="w-full h-80">
<ResponsiveContainer width="100%" height={320}>
<BarChart data={barData}>
<CartesianGrid strokeDasharray="3 3" className="opacity-30" />
<XAxis dataKey="date" tick={{ fontSize: 12 }} />
<YAxis domain={[0, 10]} tick={{ fontSize: 12 }} />
<Tooltip
contentStyle={{
backgroundColor: 'rgba(255,255,255,0.95)',
border: 'none',
borderRadius: '12px',
boxShadow: '0 4px 12px rgba(0,0,0,0.1)',
}}
formatter={(value: any) => [`${Number(value).toFixed(1)}`, 'Intensité moyenne']}
/>
<Bar dataKey="intensite" fill="#fce117" radius={[6, 6, 0, 0]} />
</BarChart>
</ResponsiveContainer>
</div>
);
}
return null;
}
function EmptyChart({ message }: { message: string }) {
return (
<div className="w-full h-80 flex items-center justify-center text-gray-400 dark:text-gray-600">
<p className="text-lg">{message}</p>
</div>
);
}
@@ -0,0 +1,105 @@
'use client';
import React, { useState } from 'react';
import { useEmotions } from '@/hooks/useEmotions';
import type { Emotion } from '@/types';
interface EmotionPickerProps {
value?: number;
onChange: (emotionId: number) => void;
}
export default function EmotionPicker({ value, onChange }: EmotionPickerProps) {
const { data: emotions, isLoading } = useEmotions();
const [selectedParent, setSelectedParent] = useState<Emotion | null>(null);
if (isLoading) {
return (
<div className="grid grid-cols-3 sm:grid-cols-4 gap-3">
{Array.from({ length: 7 }).map((_, i) => (
<div key={i} className="h-20 rounded-xl bg-gray-100 dark:bg-gray-800 animate-pulse" />
))}
</div>
);
}
// Si une émotion parent est sélectionnée et qu'elle a des enfants, afficher les sous-émotions
if (selectedParent?.enfants && selectedParent.enfants.length > 0) {
return (
<div>
<button
type="button"
onClick={() => setSelectedParent(null)}
className="mb-4 text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 flex items-center gap-1"
>
← Retour aux émotions
</button>
<p className="text-sm text-gray-600 dark:text-gray-400 mb-3">
Précisez votre émotion de <span className="font-medium" style={{ color: selectedParent.couleur }}>{selectedParent.nom}</span> :
</p>
<div className="grid grid-cols-2 sm:grid-cols-3 gap-3">
{selectedParent.enfants.map((child) => (
<button
key={child.id}
type="button"
onClick={() => onChange(child.id)}
className={`
flex flex-col items-center gap-2 p-4 rounded-xl border-2 transition-all duration-200
${value === child.id
? 'border-current shadow-lg scale-105'
: 'border-gray-200 dark:border-gray-700 hover:border-current hover:shadow-md'
}
`}
style={{
color: child.couleur,
borderColor: value === child.id ? child.couleur : undefined,
}}
>
<span className="text-2xl">{child.icone || '🔵'}</span>
<span className="text-sm font-medium text-gray-700 dark:text-gray-300">{child.nom}</span>
</button>
))}
</div>
</div>
);
}
return (
<div className="grid grid-cols-3 sm:grid-cols-4 gap-3">
{emotions?.map((emotion) => {
const hasChildren = emotion.enfants && emotion.enfants.length > 0;
const isSelected = value === emotion.id || emotion.enfants?.some(e => e.id === value);
return (
<button
key={emotion.id}
type="button"
onClick={() => {
if (hasChildren) {
setSelectedParent(emotion);
} else {
onChange(emotion.id);
}
}}
className={`
flex flex-col items-center gap-2 p-4 rounded-xl border-2 transition-all duration-200
${isSelected
? 'shadow-lg scale-105'
: 'border-gray-200 dark:border-gray-700 hover:shadow-md'
}
`}
style={{
borderColor: isSelected ? emotion.couleur : undefined,
}}
>
<span className="text-3xl">{emotion.icone || '🔵'}</span>
<span className="text-sm font-medium text-gray-700 dark:text-gray-300">{emotion.nom}</span>
{hasChildren && (
<span className="text-xs text-gray-400">▼</span>
)}
</button>
);
})}
</div>
);
}
@@ -0,0 +1,113 @@
'use client';
import React from 'react';
import type { SaisieTracker } from '@/types';
import Badge from '@/components/ui/Badge';
import { Trash2, Edit2 } from 'lucide-react';
interface TrackerTimelineProps {
saisies: SaisieTracker[];
onEdit?: (saisie: SaisieTracker) => void;
onDelete?: (id: number) => void;
}
export default function TrackerTimeline({ saisies, onEdit, onDelete }: TrackerTimelineProps) {
if (saisies.length === 0) {
return (
<div className="text-center py-12 text-gray-400 dark:text-gray-600">
<p className="text-lg mb-2">Aucune saisie enregistrée</p>
<p className="text-sm">Commencez par enregistrer votre première émotion</p>
</div>
);
}
// Grouper les saisies par date
const grouped = saisies.reduce<Record<string, SaisieTracker[]>>((acc, saisie) => {
const date = new Date(saisie.date_saisie).toLocaleDateString('fr-FR', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
});
if (!acc[date]) acc[date] = [];
acc[date].push(saisie);
return acc;
}, {});
return (
<div className="space-y-8">
{Object.entries(grouped).map(([date, items]) => (
<div key={date}>
<h3 className="text-sm font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-4">
{date}
</h3>
<div className="space-y-3">
{items.map((saisie) => (
<div
key={saisie.id}
className="flex items-start gap-4 p-4 bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 hover:shadow-md transition-all duration-200"
>
{/* Icône émotion */}
<div
className="shrink-0 w-12 h-12 rounded-xl flex items-center justify-center text-xl"
style={{ backgroundColor: `${saisie.emotion?.couleur}20` }}
>
{saisie.emotion?.icone || '🔵'}
</div>
{/* Contenu */}
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 mb-1">
<Badge color={saisie.emotion?.couleur}>
{saisie.emotion?.nom}
</Badge>
<span className="text-sm text-gray-400 dark:text-gray-500">
Intensité : {saisie.intensite}/10
</span>
</div>
{/* Barre d'intensité */}
<div className="w-full h-1.5 bg-gray-100 dark:bg-gray-800 rounded-full mb-2">
<div
className="h-full rounded-full transition-all duration-500"
style={{
width: `${saisie.intensite * 10}%`,
backgroundColor: saisie.emotion?.couleur || '#fce117',
}}
/>
</div>
{saisie.note && (
<p className="text-sm text-gray-600 dark:text-gray-400 line-clamp-2">
{saisie.note}
</p>
)}
</div>
{/* Actions */}
<div className="flex items-center gap-1 shrink-0">
{onEdit && (
<button
onClick={() => onEdit(saisie)}
className="p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"
aria-label="Modifier"
>
<Edit2 size={16} />
</button>
)}
{onDelete && (
<button
onClick={() => onDelete(saisie.id)}
className="p-2 rounded-lg hover:bg-red-50 dark:hover:bg-red-950/30 text-gray-400 hover:text-red-500 transition-colors"
aria-label="Supprimer"
>
<Trash2 size={16} />
</button>
)}
</div>
</div>
))}
</div>
</div>
))}
</div>
);
}
+62
View File
@@ -0,0 +1,62 @@
"use client";
import React from "react";
import Link from "next/link";
import { Phone } from "lucide-react";
export default function Footer() {
return (
<footer className="bg-gray-50 dark:bg-gray-950 border-t border-gray-200 dark:border-gray-800">
{/* Bandeau urgence */}
<div className="bg-red-50 dark:bg-red-950/50 border-b border-red-100 dark:border-red-900">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-3">
<p className="flex items-center justify-center gap-2 text-sm text-red-700 dark:text-red-400 font-medium text-center">
<Phone size={16} className="shrink-0" />
En cas d&apos;urgence : 3114 (numéro national de prévention du suicide)
</p>
</div>
</div>
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div className="flex flex-col md:flex-row items-center justify-between gap-6">
{/* Logo + Copyright */}
<div className="flex flex-col items-center md:items-start gap-2">
<div className="flex items-center gap-0.5">
<span className="text-xl font-bold font-display text-malachite-500">
CESI
</span>
<span className="text-xl font-bold font-display text-candlelight-500">
ZEN
</span>
</div>
<p className="text-sm text-gray-500 dark:text-gray-400 text-center md:text-left">
CESIZen 2024 - Ministère des Solidarités et de la Santé
</p>
</div>
{/* Links */}
<nav className="flex flex-wrap items-center justify-center gap-6">
<Link
href="/mentions-legales"
className="text-sm text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors"
>
Mentions légales
</Link>
<Link
href="/politique-de-confidentialite"
className="text-sm text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors"
>
Politique de confidentialité
</Link>
<Link
href="/contacts-urgence"
className="text-sm text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors"
>
Contacts d&apos;urgence
</Link>
</nav>
</div>
</div>
</footer>
);
}
+245
View File
@@ -0,0 +1,245 @@
"use client";
import React, { useState } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import {
Menu,
X,
User,
LogOut,
Settings,
BarChart3,
BookOpen,
Home,
} from "lucide-react";
import ThemeToggle from "@/components/ui/ThemeToggle";
import { useAuthStore } from "@/lib/auth-store";
interface NavLink {
href: string;
label: string;
icon: React.ReactNode;
}
export default function Header() {
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const [userDropdownOpen, setUserDropdownOpen] = useState(false);
const pathname = usePathname();
const { user, token, logout } = useAuthStore();
const isAuthenticated = !!token;
const isAdmin = user?.role?.nom === "administrateur";
const publicLinks: NavLink[] = [
{ href: "/", label: "Accueil", icon: <Home size={18} /> },
{ href: "/informations", label: "Informations", icon: <BookOpen size={18} /> },
];
const authLinks: NavLink[] = [
{ href: "/journal", label: "Journal", icon: <BookOpen size={18} /> },
{ href: "/journal/rapports", label: "Rapports", icon: <BarChart3 size={18} /> },
];
const adminLinks: NavLink[] = [
{ href: "/admin", label: "Admin", icon: <Settings size={18} /> },
];
const navLinks = [
...publicLinks,
...(isAuthenticated ? authLinks : []),
...(isAdmin ? adminLinks : []),
];
const isActive = (href: string) => {
if (href === "/") return pathname === "/";
return pathname.startsWith(href);
};
const handleLogout = () => {
logout();
setUserDropdownOpen(false);
setMobileMenuOpen(false);
};
return (
<header className="sticky top-0 z-50 bg-white/80 dark:bg-gray-950/80 backdrop-blur-lg border-b border-gray-200 dark:border-gray-800">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex items-center justify-between h-16">
{/* Logo */}
<Link href="/" className="flex items-center gap-0.5 shrink-0">
<span className="text-2xl font-bold font-display text-malachite-500">
CESI
</span>
<span className="text-2xl font-bold font-display text-candlelight-500">
ZEN
</span>
</Link>
{/* Desktop Navigation */}
<nav className="hidden md:flex items-center gap-1">
{navLinks.map((link) => (
<Link
key={link.href}
href={link.href}
className={`
flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-medium transition-all duration-200
${
isActive(link.href)
? "bg-candlelight-100 dark:bg-candlelight-950 text-candlelight-700 dark:text-candlelight-400"
: "text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"
}
`}
>
{link.icon}
{link.label}
</Link>
))}
</nav>
{/* Right actions */}
<div className="flex items-center gap-2">
<ThemeToggle />
{/* Desktop auth */}
<div className="hidden md:flex items-center gap-2">
{isAuthenticated ? (
<div className="relative">
<button
onClick={() => setUserDropdownOpen(!userDropdownOpen)}
className="flex items-center gap-2 px-3 py-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
>
<div className="h-8 w-8 rounded-full bg-malachite-100 dark:bg-malachite-900 flex items-center justify-center">
<User
size={16}
className="text-malachite-600 dark:text-malachite-400"
/>
</div>
<span className="text-sm font-medium text-gray-700 dark:text-gray-300">
{user?.prenom || "Utilisateur"}
</span>
</button>
{userDropdownOpen && (
<>
<div
className="fixed inset-0 z-10"
onClick={() => setUserDropdownOpen(false)}
/>
<div className="absolute right-0 mt-2 w-48 z-20 bg-white dark:bg-gray-900 rounded-xl shadow-lg border border-gray-100 dark:border-gray-800 py-1 animate-in fade-in zoom-in-95 duration-150">
<Link
href="/profil"
onClick={() => setUserDropdownOpen(false)}
className="flex items-center gap-2 px-4 py-2.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"
>
<Settings size={16} />
Mon profil
</Link>
<button
onClick={handleLogout}
className="w-full flex items-center gap-2 px-4 py-2.5 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-950 transition-colors"
>
<LogOut size={16} />
Déconnexion
</button>
</div>
</>
)}
</div>
) : (
<>
<Link
href="/connexion"
className="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-xl transition-colors"
>
Connexion
</Link>
<Link
href="/inscription"
className="px-4 py-2 text-sm font-semibold bg-candlelight-500 hover:bg-candlelight-600 text-black rounded-xl transition-all duration-200 shadow-sm hover:shadow-md"
>
Inscription
</Link>
</>
)}
</div>
{/* Mobile hamburger */}
<button
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
className="md:hidden p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors text-gray-600 dark:text-gray-400"
aria-label="Menu"
>
{mobileMenuOpen ? <X size={24} /> : <Menu size={24} />}
</button>
</div>
</div>
</div>
{/* Mobile menu */}
{mobileMenuOpen && (
<div className="md:hidden border-t border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-950 animate-in slide-in-from-top duration-200">
<nav className="px-4 py-4 space-y-1">
{navLinks.map((link) => (
<Link
key={link.href}
href={link.href}
onClick={() => setMobileMenuOpen(false)}
className={`
flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium transition-all duration-200
${
isActive(link.href)
? "bg-candlelight-100 dark:bg-candlelight-950 text-candlelight-700 dark:text-candlelight-400"
: "text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"
}
`}
>
{link.icon}
{link.label}
</Link>
))}
<div className="pt-4 border-t border-gray-200 dark:border-gray-800 mt-4 space-y-1">
{isAuthenticated ? (
<>
<Link
href="/profil"
onClick={() => setMobileMenuOpen(false)}
className="flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
>
<User size={18} />
Mon profil
</Link>
<button
onClick={handleLogout}
className="w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-950 transition-colors"
>
<LogOut size={18} />
Déconnexion
</button>
</>
) : (
<>
<Link
href="/connexion"
onClick={() => setMobileMenuOpen(false)}
className="flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
>
Connexion
</Link>
<Link
href="/inscription"
onClick={() => setMobileMenuOpen(false)}
className="flex items-center justify-center gap-2 px-4 py-3 rounded-xl text-sm font-semibold bg-candlelight-500 hover:bg-candlelight-600 text-black transition-all duration-200"
>
Inscription
</Link>
</>
)}
</div>
</nav>
</div>
)}
</header>
);
}
+133
View File
@@ -0,0 +1,133 @@
"use client";
import React, { useState } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import {
LayoutDashboard,
Users,
FileText,
Heart,
Menu,
X,
} from "lucide-react";
interface SidebarLink {
href: string;
label: string;
icon: React.ReactNode;
}
const sidebarLinks: SidebarLink[] = [
{
href: "/admin",
label: "Dashboard",
icon: <LayoutDashboard size={20} />,
},
{
href: "/admin/utilisateurs",
label: "Utilisateurs",
icon: <Users size={20} />,
},
{
href: "/admin/contenus",
label: "Contenus",
icon: <FileText size={20} />,
},
{
href: "/admin/emotions",
label: "Émotions",
icon: <Heart size={20} />,
},
];
export default function Sidebar() {
const [collapsed, setCollapsed] = useState(false);
const pathname = usePathname();
const isActive = (href: string) => {
if (href === "/admin") return pathname === "/admin";
return pathname.startsWith(href);
};
return (
<>
{/* Mobile toggle */}
<button
onClick={() => setCollapsed(!collapsed)}
className="lg:hidden fixed top-20 left-4 z-40 p-2 bg-white dark:bg-gray-900 rounded-xl shadow-lg border border-gray-200 dark:border-gray-800 text-gray-600 dark:text-gray-400"
aria-label="Toggle sidebar"
>
{collapsed ? <X size={20} /> : <Menu size={20} />}
</button>
{/* Overlay mobile */}
{collapsed && (
<div
className="lg:hidden fixed inset-0 z-30 bg-black/50 backdrop-blur-sm"
onClick={() => setCollapsed(false)}
/>
)}
{/* Sidebar */}
<aside
className={`
fixed lg:sticky top-0 left-0 z-40 lg:z-auto
h-screen w-64
bg-white dark:bg-gray-950
border-r border-gray-200 dark:border-gray-800
flex flex-col
transition-transform duration-300 ease-in-out
${collapsed ? "translate-x-0" : "-translate-x-full lg:translate-x-0"}
`}
>
{/* Logo */}
<div className="flex items-center justify-between h-16 px-6 border-b border-gray-200 dark:border-gray-800">
<Link href="/admin" className="flex items-center gap-0.5">
<span className="text-xl font-bold font-display text-malachite-500">
CESI
</span>
<span className="text-xl font-bold font-display text-candlelight-500">
ZEN
</span>
</Link>
<button
onClick={() => setCollapsed(false)}
className="lg:hidden p-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500"
>
<X size={18} />
</button>
</div>
{/* Navigation */}
<nav className="flex-1 px-3 py-4 space-y-1 overflow-y-auto">
{sidebarLinks.map((link) => (
<Link
key={link.href}
href={link.href}
onClick={() => setCollapsed(false)}
className={`
flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium transition-all duration-200
${
isActive(link.href)
? "bg-candlelight-100 dark:bg-candlelight-950 text-candlelight-700 dark:text-candlelight-400 shadow-sm"
: "text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-gray-200"
}
`}
>
{link.icon}
{link.label}
</Link>
))}
</nav>
{/* Footer */}
<div className="px-6 py-4 border-t border-gray-200 dark:border-gray-800">
<p className="text-xs text-gray-400 dark:text-gray-600">
Administration CESIZen
</p>
</div>
</aside>
</>
);
}
+34
View File
@@ -0,0 +1,34 @@
"use client";
import React from "react";
interface BadgeProps {
children: React.ReactNode;
color?: string;
className?: string;
}
export default function Badge({
children,
color = "#fce117",
className = "",
}: BadgeProps) {
return (
<span
className={`
inline-flex items-center
px-2.5 py-0.5
rounded-full
text-xs font-medium
transition-all duration-200
${className}
`}
style={{
backgroundColor: `${color}20`,
color: color,
}}
>
{children}
</span>
);
}
+82
View File
@@ -0,0 +1,82 @@
"use client";
import React from "react";
type ButtonVariant = "primary" | "secondary" | "outline" | "ghost" | "danger";
type ButtonSize = "sm" | "md" | "lg";
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: ButtonVariant;
size?: ButtonSize;
loading?: boolean;
}
const variantClasses: Record<ButtonVariant, string> = {
primary:
"bg-candlelight-500 hover:bg-candlelight-600 text-black font-semibold shadow-sm hover:shadow-md",
secondary:
"bg-malachite-500 hover:bg-malachite-600 text-white font-semibold shadow-sm hover:shadow-md",
outline:
"border-2 border-candlelight-500 text-candlelight-700 dark:text-candlelight-400 hover:bg-candlelight-50 dark:hover:bg-candlelight-950",
ghost:
"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300",
danger:
"bg-red-500 hover:bg-red-600 text-white font-semibold shadow-sm hover:shadow-md",
};
const sizeClasses: Record<ButtonSize, string> = {
sm: "px-3 py-1.5 text-sm",
md: "px-5 py-2.5 text-base",
lg: "px-7 py-3.5 text-lg",
};
export default function Button({
variant = "primary",
size = "md",
loading = false,
disabled,
children,
className = "",
...rest
}: ButtonProps) {
return (
<button
disabled={disabled || loading}
className={`
inline-flex items-center justify-center gap-2
rounded-xl transition-all duration-200
focus:outline-none focus:ring-2 focus:ring-candlelight-500 focus:ring-offset-2
dark:focus:ring-offset-gray-900
disabled:opacity-50 disabled:cursor-not-allowed
${variantClasses[variant]}
${sizeClasses[size]}
${className}
`}
{...rest}
>
{loading && (
<svg
className="animate-spin h-4 w-4"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
/>
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
/>
</svg>
)}
{children}
</button>
);
}
+27
View File
@@ -0,0 +1,27 @@
"use client";
import React from "react";
interface CardProps {
children: React.ReactNode;
className?: string;
hover?: boolean;
}
export default function Card({ children, className = "", hover = false }: CardProps) {
return (
<div
className={`
bg-white dark:bg-gray-900
rounded-2xl shadow-sm
border border-gray-100 dark:border-gray-800
p-6
transition-all duration-200
${hover ? "hover:shadow-lg hover:-translate-y-0.5" : ""}
${className}
`}
>
{children}
</div>
);
}
+61
View File
@@ -0,0 +1,61 @@
"use client";
import React from "react";
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
label?: string;
error?: string;
icon?: React.ReactNode;
}
export default function Input({
label,
error,
icon,
className = "",
id,
...inputProps
}: InputProps) {
const inputId = id || label?.toLowerCase().replace(/\s+/g, "-");
return (
<div className="w-full">
{label && (
<label
htmlFor={inputId}
className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5"
>
{label}
</label>
)}
<div className="relative">
{icon && (
<div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none text-gray-400 dark:text-gray-500">
{icon}
</div>
)}
<input
id={inputId}
className={`
w-full rounded-xl border border-gray-300 dark:border-gray-700
bg-white dark:bg-gray-900
text-gray-900 dark:text-gray-100
placeholder:text-gray-400 dark:placeholder:text-gray-500
focus:outline-none focus:ring-2 focus:ring-candlelight-500 focus:border-candlelight-500
transition-all duration-200
px-4 py-2.5 text-base
${icon ? "pl-10" : ""}
${error ? "border-red-500 focus:ring-red-500 focus:border-red-500" : ""}
${className}
`}
{...inputProps}
/>
</div>
{error && (
<p className="mt-1.5 text-sm text-red-500 dark:text-red-400">
{error}
</p>
)}
</div>
);
}
+89
View File
@@ -0,0 +1,89 @@
"use client";
import React, { useEffect, useCallback } from "react";
import { X } from "lucide-react";
type ModalSize = "sm" | "md" | "lg";
interface ModalProps {
isOpen: boolean;
onClose: () => void;
title?: string;
children: React.ReactNode;
size?: ModalSize;
}
const sizeClasses: Record<ModalSize, string> = {
sm: "max-w-sm",
md: "max-w-lg",
lg: "max-w-2xl",
};
export default function Modal({
isOpen,
onClose,
title,
children,
size = "md",
}: ModalProps) {
const handleKeyDown = useCallback(
(e: KeyboardEvent) => {
if (e.key === "Escape") onClose();
},
[onClose]
);
useEffect(() => {
if (isOpen) {
document.addEventListener("keydown", handleKeyDown);
document.body.style.overflow = "hidden";
}
return () => {
document.removeEventListener("keydown", handleKeyDown);
document.body.style.overflow = "";
};
}, [isOpen, handleKeyDown]);
if (!isOpen) return null;
return (
<div className="fixed inset-0 z-100 flex items-center justify-center p-4">
{/* Overlay */}
<div
className="absolute inset-0 bg-black/50 backdrop-blur-sm animate-in fade-in duration-200"
onClick={onClose}
/>
{/* Modal */}
<div
className={`
relative w-full ${sizeClasses[size]}
bg-white dark:bg-gray-900
rounded-2xl shadow-2xl
border border-gray-100 dark:border-gray-800
p-6
animate-in zoom-in-95 fade-in duration-200
`}
>
{/* Header */}
<div className="flex items-center justify-between mb-4">
{title && (
<h2 className="text-xl font-bold font-display text-gray-900 dark:text-gray-100">
{title}
</h2>
)}
<button
onClick={onClose}
className="ml-auto p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors text-gray-500 dark:text-gray-400"
aria-label="Fermer"
>
<X size={20} />
</button>
</div>
{/* Content */}
<div>{children}</div>
</div>
</div>
);
}
+32
View File
@@ -0,0 +1,32 @@
"use client";
import React from "react";
type SkeletonVariant = "text" | "circle" | "rect";
interface SkeletonProps {
className?: string;
variant?: SkeletonVariant;
}
const variantClasses: Record<SkeletonVariant, string> = {
text: "h-4 w-full rounded",
circle: "h-10 w-10 rounded-full",
rect: "h-24 w-full rounded-xl",
};
export default function Skeleton({
className = "",
variant = "text",
}: SkeletonProps) {
return (
<div
className={`
animate-pulse
bg-gray-200 dark:bg-gray-700
${variantClasses[variant]}
${className}
`}
/>
);
}
+52
View File
@@ -0,0 +1,52 @@
"use client";
import React from "react";
interface SliderProps {
value: number;
onChange: (value: number) => void;
min?: number;
max?: number;
label?: string;
showValue?: boolean;
}
export default function Slider({
value,
onChange,
min = 1,
max = 10,
label,
showValue = true,
}: SliderProps) {
return (
<div className="w-full">
{(label || showValue) && (
<div className="flex items-center justify-between mb-2">
{label && (
<label className="text-sm font-medium text-gray-700 dark:text-gray-300">
{label}
</label>
)}
{showValue && (
<span className="text-sm font-bold text-candlelight-600 dark:text-candlelight-400 bg-candlelight-50 dark:bg-candlelight-950 px-2 py-0.5 rounded-lg">
{value}
</span>
)}
</div>
)}
<input
type="range"
min={min}
max={max}
value={value}
onChange={(e) => onChange(Number(e.target.value))}
className="w-full h-2 rounded-full appearance-none cursor-pointer bg-gray-200 dark:bg-gray-700 accent-candlelight-500"
/>
<div className="flex justify-between mt-1">
<span className="text-xs text-gray-400 dark:text-gray-500">{min}</span>
<span className="text-xs text-gray-400 dark:text-gray-500">{max}</span>
</div>
</div>
);
}
@@ -0,0 +1,35 @@
"use client";
import React from "react";
import { useTheme } from "next-themes";
import { Sun, Moon } from "lucide-react";
export default function ThemeToggle() {
const { theme, setTheme } = useTheme();
const [mounted, setMounted] = React.useState(false);
React.useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return (
<button
className="p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
aria-label="Changer le thème"
>
<div className="h-5 w-5" />
</button>
);
}
return (
<button
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
className="p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 transition-all duration-200 text-gray-600 dark:text-gray-400"
aria-label={theme === "dark" ? "Passer en mode clair" : "Passer en mode sombre"}
>
{theme === "dark" ? <Sun size={20} /> : <Moon size={20} />}
</button>
);
}