"use client"; import { useState } from "react"; import { useForm } from "react-hook-form"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Separator } from "@/components/ui/separator"; import { Switch } from "@/components/ui/switch"; import { Textarea } from "@/components/ui/textarea"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"; import { toast } from "sonner"; import { Save, RefreshCw, Shield, Bell, Mail, Database, Server, FileJson, Loader2 } from "lucide-react"; export default function AdminSettingsPage() { const [activeTab, setActiveTab] = useState("general"); const [isLoading, setIsLoading] = useState(false); // Mock system settings const systemSettings = { general: { siteName: "Application de Création de Groupes", siteDescription: "Une application web moderne dédiée à la création et à la gestion de groupes", contactEmail: "admin@example.com", maxProjectsPerUser: "10", maxPersonsPerProject: "100", }, authentication: { enableGithubAuth: true, requireEmailVerification: false, sessionTimeout: "7", maxLoginAttempts: "5", passwordMinLength: "8", }, notifications: { enableEmailNotifications: true, enableSystemNotifications: true, notifyOnNewUser: true, notifyOnNewProject: false, adminEmailRecipients: "admin@example.com", }, maintenance: { maintenanceMode: false, maintenanceMessage: "Le site est actuellement en maintenance. Veuillez réessayer plus tard.", debugMode: false, logLevel: "error", }, }; const { register: registerGeneral, handleSubmit: handleSubmitGeneral, formState: { errors: errorsGeneral } } = useForm({ defaultValues: systemSettings.general, }); const { register: registerAuth, handleSubmit: handleSubmitAuth, formState: { errors: errorsAuth } } = useForm({ defaultValues: systemSettings.authentication, }); const { register: registerNotif, handleSubmit: handleSubmitNotif, formState: { errors: errorsNotif } } = useForm({ defaultValues: systemSettings.notifications, }); const { register: registerMaint, handleSubmit: handleSubmitMaint, formState: { errors: errorsMaint } } = useForm({ defaultValues: systemSettings.maintenance, }); const onSubmitGeneral = async (data: any) => { setIsLoading(true); // Simulate API call await new Promise((resolve) => setTimeout(resolve, 1000)); setIsLoading(false); toast.success("Paramètres généraux mis à jour avec succès"); }; const onSubmitAuth = async (data: any) => { setIsLoading(true); // Simulate API call await new Promise((resolve) => setTimeout(resolve, 1000)); setIsLoading(false); toast.success("Paramètres d'authentification mis à jour avec succès"); }; const onSubmitNotif = async (data: any) => { setIsLoading(true); // Simulate API call await new Promise((resolve) => setTimeout(resolve, 1000)); setIsLoading(false); toast.success("Paramètres de notification mis à jour avec succès"); }; const onSubmitMaint = async (data: any) => { setIsLoading(true); // Simulate API call await new Promise((resolve) => setTimeout(resolve, 1000)); setIsLoading(false); toast.success("Paramètres de maintenance mis à jour avec succès"); }; const handleExportConfig = async () => { setIsLoading(true); // Simulate API call await new Promise((resolve) => setTimeout(resolve, 1000)); setIsLoading(false); toast.success("Configuration exportée avec succès"); }; const handleClearCache = async () => { setIsLoading(true); // Simulate API call await new Promise((resolve) => setTimeout(resolve, 1000)); setIsLoading(false); toast.success("Cache vidé avec succès"); }; return (

Paramètres système

Configuration globale
Général Authentification Notifications Maintenance
Paramètres généraux Configurez les paramètres généraux de l'application
{errorsGeneral.siteName && (

{errorsGeneral.siteName.message as string}

)}
{errorsGeneral.contactEmail && (

{errorsGeneral.contactEmail.message as string}

)}