Compare commits
3 Commits
9f4062b5f6
...
a91a34dbf8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a91a34dbf8 | ||
|
|
5da5290a6d | ||
|
|
a7f8596947 |
@@ -1,18 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "primereact/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "primereact/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { InputText } from "primereact/inputtext";
|
||||||
import {
|
|
||||||
BookOpen,
|
|
||||||
Search,
|
|
||||||
ChevronRight,
|
|
||||||
FileText,
|
|
||||||
Download,
|
|
||||||
ExternalLink,
|
|
||||||
ArrowLeft,
|
|
||||||
} from "lucide-react";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,8 +103,8 @@ export default function DocumentationPage() {
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<Link href="/aide">
|
<Link href="/aide">
|
||||||
<Button variant="ghost" size="sm">
|
<Button text size="small">
|
||||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
<i className="pi pi-arrow-left mr-2"></i>
|
||||||
Retour à l'aide
|
Retour à l'aide
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -124,8 +115,8 @@ export default function DocumentationPage() {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Button variant="outline">
|
<Button outlined>
|
||||||
<Download className="mr-2 h-4 w-4" />
|
<i className="pi pi-download mr-2"></i>
|
||||||
Télécharger PDF
|
Télécharger PDF
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -133,13 +124,15 @@ export default function DocumentationPage() {
|
|||||||
{/* Barre de recherche */}
|
{/* Barre de recherche */}
|
||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400" />
|
<span className="p-input-icon-left w-full">
|
||||||
<Input
|
<i className="pi pi-search" />
|
||||||
|
<InputText
|
||||||
placeholder="Rechercher dans la documentation..."
|
placeholder="Rechercher dans la documentation..."
|
||||||
className="pl-10"
|
className="w-full"
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Résultats de recherche */}
|
{/* Résultats de recherche */}
|
||||||
@@ -159,7 +152,7 @@ export default function DocumentationPage() {
|
|||||||
<p className="font-medium">{result.article}</p>
|
<p className="font-medium">{result.article}</p>
|
||||||
<p className="text-sm text-gray-500">{result.category}</p>
|
<p className="text-sm text-gray-500">{result.category}</p>
|
||||||
</div>
|
</div>
|
||||||
<ChevronRight className="h-4 w-4 text-gray-400" />
|
<i className="pi pi-chevron-right text-gray-400"></i>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -176,7 +169,7 @@ export default function DocumentationPage() {
|
|||||||
>
|
>
|
||||||
<div className="flex items-start gap-4 mb-4">
|
<div className="flex items-start gap-4 mb-4">
|
||||||
<div className="p-3 bg-blue-100 rounded-lg">
|
<div className="p-3 bg-blue-100 rounded-lg">
|
||||||
<BookOpen className="h-6 w-6 text-blue-600" />
|
<i className="pi pi-book text-blue-600" style={{ fontSize: '1.5rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<h3 className="font-semibold text-lg mb-1">{category.title}</h3>
|
<h3 className="font-semibold text-lg mb-1">{category.title}</h3>
|
||||||
@@ -190,20 +183,20 @@ export default function DocumentationPage() {
|
|||||||
key={index}
|
key={index}
|
||||||
className="flex items-center gap-2 p-2 hover:bg-gray-50 rounded cursor-pointer group"
|
className="flex items-center gap-2 p-2 hover:bg-gray-50 rounded cursor-pointer group"
|
||||||
>
|
>
|
||||||
<FileText className="h-4 w-4 text-gray-400" />
|
<i className="pi pi-file text-gray-400"></i>
|
||||||
<span className="text-sm flex-1">{article}</span>
|
<span className="text-sm flex-1">{article}</span>
|
||||||
<ExternalLink className="h-3 w-3 text-gray-400 opacity-0 group-hover:opacity-100 transition-opacity" />
|
<i className="pi pi-external-link text-gray-400 opacity-0 group-hover:opacity-100 transition-opacity" style={{ fontSize: '0.75rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="link"
|
link
|
||||||
className="mt-4 p-0 h-auto text-blue-600"
|
className="mt-4 p-0 h-auto text-blue-600"
|
||||||
onClick={() => setSelectedCategory(category.id)}
|
onClick={() => setSelectedCategory(category.id)}
|
||||||
>
|
>
|
||||||
Voir tous les articles
|
Voir tous les articles
|
||||||
<ChevronRight className="ml-1 h-4 w-4" />
|
<i className="pi pi-chevron-right ml-1"></i>
|
||||||
</Button>
|
</Button>
|
||||||
</Card>
|
</Card>
|
||||||
))}
|
))}
|
||||||
@@ -213,7 +206,7 @@ export default function DocumentationPage() {
|
|||||||
<Card className="p-6 bg-gradient-to-r from-blue-50 to-purple-50">
|
<Card className="p-6 bg-gradient-to-r from-blue-50 to-purple-50">
|
||||||
<div className="flex items-start gap-4">
|
<div className="flex items-start gap-4">
|
||||||
<div className="p-3 bg-blue-600 rounded-lg">
|
<div className="p-3 bg-blue-600 rounded-lg">
|
||||||
<BookOpen className="h-6 w-6 text-white" />
|
<i className="pi pi-book text-white" style={{ fontSize: '1.5rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<h3 className="font-semibold text-lg mb-2">
|
<h3 className="font-semibold text-lg mb-2">
|
||||||
@@ -226,10 +219,10 @@ export default function DocumentationPage() {
|
|||||||
</p>
|
</p>
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<Button className="bg-blue-600 hover:bg-blue-700">
|
<Button className="bg-blue-600 hover:bg-blue-700">
|
||||||
<Download className="mr-2 h-4 w-4" />
|
<i className="pi pi-download mr-2"></i>
|
||||||
Télécharger le guide (PDF)
|
Télécharger le guide (PDF)
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline">
|
<Button outlined>
|
||||||
Voir la version en ligne
|
Voir la version en ligne
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,225 +1,287 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "primereact/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "primereact/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { InputText } from "primereact/inputtext";
|
||||||
import {
|
|
||||||
BookOpen,
|
|
||||||
Video,
|
|
||||||
MessageCircle,
|
|
||||||
Search,
|
|
||||||
FileText,
|
|
||||||
HelpCircle,
|
|
||||||
Lightbulb,
|
|
||||||
Phone,
|
|
||||||
Mail,
|
|
||||||
ExternalLink,
|
|
||||||
} from "lucide-react";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page principale du centre d'aide
|
* Page principale du centre d'aide
|
||||||
* Point d'entrée pour accéder à toute l'aide et la documentation
|
* Point d'entrée pour accéder à toute l'aide et la documentation
|
||||||
*/
|
*/
|
||||||
export default function AidePage() {
|
export default function AidePage() {
|
||||||
|
const router = useRouter();
|
||||||
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
|
|
||||||
const categories = [
|
const categories = [
|
||||||
{
|
{
|
||||||
title: "Démarrage rapide",
|
title: "Démarrage rapide",
|
||||||
description: "Premiers pas avec BTPXpress",
|
description: "Premiers pas avec BTPXpress",
|
||||||
icon: Lightbulb,
|
icon: "pi pi-lightbulb",
|
||||||
color: "bg-blue-100 text-blue-600",
|
color: "bg-blue-100 text-blue-600",
|
||||||
articles: 12,
|
articles: 12,
|
||||||
|
link: "/aide/documentation",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Gestion des chantiers",
|
title: "Gestion des chantiers",
|
||||||
description: "Créer et gérer vos chantiers",
|
description: "Créer et gérer vos chantiers",
|
||||||
icon: FileText,
|
icon: "pi pi-file",
|
||||||
color: "bg-green-100 text-green-600",
|
color: "bg-green-100 text-green-600",
|
||||||
articles: 25,
|
articles: 25,
|
||||||
|
link: "/aide/documentation",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Facturation",
|
title: "Facturation",
|
||||||
description: "Devis, factures et paiements",
|
description: "Devis, factures et paiements",
|
||||||
icon: BookOpen,
|
icon: "pi pi-book",
|
||||||
color: "bg-purple-100 text-purple-600",
|
color: "bg-purple-100 text-purple-600",
|
||||||
articles: 18,
|
articles: 18,
|
||||||
|
link: "/aide/documentation",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Équipes et planning",
|
title: "Équipes et planning",
|
||||||
description: "Gérer vos équipes et plannings",
|
description: "Gérer vos équipes et plannings",
|
||||||
icon: Video,
|
icon: "pi pi-users",
|
||||||
color: "bg-orange-100 text-orange-600",
|
color: "bg-yellow-100 text-yellow-600",
|
||||||
articles: 15,
|
articles: 15,
|
||||||
|
link: "/aide/documentation",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Matériel",
|
||||||
|
description: "Gestion du matériel et stock",
|
||||||
|
icon: "pi pi-box",
|
||||||
|
color: "bg-red-100 text-red-600",
|
||||||
|
articles: 10,
|
||||||
|
link: "/aide/documentation",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Rapports",
|
||||||
|
description: "Générer et analyser vos rapports",
|
||||||
|
icon: "pi pi-chart-bar",
|
||||||
|
color: "bg-indigo-100 text-indigo-600",
|
||||||
|
articles: 8,
|
||||||
|
link: "/aide/documentation",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const articlesPopulaires = [
|
const resources = [
|
||||||
"Comment créer un nouveau chantier ?",
|
{
|
||||||
"Gérer les devis et les factures",
|
title: "Documentation complète",
|
||||||
"Planifier l'utilisation du matériel",
|
description: "Guides détaillés et tutoriels pas à pas",
|
||||||
"Ajouter des membres à une équipe",
|
icon: "pi pi-book",
|
||||||
"Générer des rapports d'activité",
|
color: "bg-blue-600",
|
||||||
|
link: "/aide/documentation",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Tutoriels vidéo",
|
||||||
|
description: "Apprenez en vidéo avec nos tutoriels",
|
||||||
|
icon: "pi pi-video",
|
||||||
|
color: "bg-red-600",
|
||||||
|
link: "/aide/tutoriels",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Support technique",
|
||||||
|
description: "Contactez notre équipe d'assistance",
|
||||||
|
icon: "pi pi-headphones",
|
||||||
|
color: "bg-green-600",
|
||||||
|
link: "/aide/support",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const popularArticles = [
|
||||||
|
{
|
||||||
|
title: "Comment créer votre premier chantier ?",
|
||||||
|
views: 1543,
|
||||||
|
category: "Chantiers",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Gérer les phases et sous-phases",
|
||||||
|
views: 1234,
|
||||||
|
category: "Chantiers",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Créer un devis rapidement",
|
||||||
|
views: 1156,
|
||||||
|
category: "Facturation",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Planifier les équipes efficacement",
|
||||||
|
views: 987,
|
||||||
|
category: "Équipes",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Exporter vos données",
|
||||||
|
views: 876,
|
||||||
|
category: "Rapports",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const handleSearch = (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (searchTerm.trim()) {
|
||||||
|
router.push(`/aide/documentation?search=${encodeURIComponent(searchTerm)}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8 p-6">
|
<div className="space-y-6 p-6">
|
||||||
{/* En-tête */}
|
{/* En-tête */}
|
||||||
<div className="text-center space-y-4">
|
<div className="text-center mb-8">
|
||||||
<h1 className="text-4xl font-bold text-gray-900">
|
<h1 className="text-4xl font-bold text-gray-900 mb-3">
|
||||||
Comment pouvons-nous vous aider ?
|
<i className="pi pi-question-circle mr-3"></i>
|
||||||
|
Centre d'aide
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-lg text-gray-600">
|
<p className="text-xl text-gray-600">
|
||||||
Recherchez dans notre base de connaissances ou contactez notre support
|
Comment pouvons-nous vous aider aujourd'hui ?
|
||||||
</p>
|
</p>
|
||||||
<div className="max-w-2xl mx-auto">
|
</div>
|
||||||
<div className="relative">
|
|
||||||
<Search className="absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400" />
|
{/* Barre de recherche */}
|
||||||
<Input
|
<Card className="mb-6">
|
||||||
|
<form onSubmit={handleSearch}>
|
||||||
|
<div className="p-inputgroup flex-1">
|
||||||
|
<span className="p-inputgroup-addon">
|
||||||
|
<i className="pi pi-search"></i>
|
||||||
|
</span>
|
||||||
|
<InputText
|
||||||
placeholder="Rechercher dans l'aide..."
|
placeholder="Rechercher dans l'aide..."
|
||||||
className="pl-12 h-12 text-lg"
|
value={searchTerm}
|
||||||
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
|
className="w-full"
|
||||||
|
style={{ fontSize: '1.1rem', padding: '1rem' }}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
label="Rechercher"
|
||||||
|
type="submit"
|
||||||
|
icon="pi pi-search"
|
||||||
|
className="bg-blue-600 hover:bg-blue-700"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Accès rapide */}
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
||||||
<Link href="/aide/documentation">
|
|
||||||
<Card className="p-6 hover:shadow-lg transition-shadow cursor-pointer">
|
|
||||||
<div className="flex items-start gap-4">
|
|
||||||
<div className="p-3 bg-blue-100 rounded-lg">
|
|
||||||
<BookOpen className="h-6 w-6 text-blue-600" />
|
|
||||||
</div>
|
|
||||||
<div className="flex-1">
|
|
||||||
<h3 className="font-semibold text-lg mb-2">Documentation</h3>
|
|
||||||
<p className="text-sm text-gray-600">
|
|
||||||
Guides complets et documentation technique
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
</Link>
|
|
||||||
|
|
||||||
<Link href="/aide/tutoriels">
|
{/* Ressources principales */}
|
||||||
<Card className="p-6 hover:shadow-lg transition-shadow cursor-pointer">
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
|
||||||
<div className="flex items-start gap-4">
|
{resources.map((resource, index) => (
|
||||||
<div className="p-3 bg-green-100 rounded-lg">
|
<Link key={index} href={resource.link}>
|
||||||
<Video className="h-6 w-6 text-green-600" />
|
<Card className="hover:shadow-lg transition-shadow cursor-pointer h-full">
|
||||||
</div>
|
<div className="flex flex-column align-items-center text-center">
|
||||||
<div className="flex-1">
|
<div
|
||||||
<h3 className="font-semibold text-lg mb-2">Tutoriels</h3>
|
className={`${resource.color} text-white border-round`}
|
||||||
<p className="text-sm text-gray-600">
|
style={{ padding: '1.5rem', marginBottom: '1rem' }}
|
||||||
Vidéos et guides pas-à-pas
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</Link>
|
|
||||||
|
|
||||||
<Link href="/aide/support">
|
|
||||||
<Card className="p-6 hover:shadow-lg transition-shadow cursor-pointer">
|
|
||||||
<div className="flex items-start gap-4">
|
|
||||||
<div className="p-3 bg-purple-100 rounded-lg">
|
|
||||||
<MessageCircle className="h-6 w-6 text-purple-600" />
|
|
||||||
</div>
|
|
||||||
<div className="flex-1">
|
|
||||||
<h3 className="font-semibold text-lg mb-2">Support</h3>
|
|
||||||
<p className="text-sm text-gray-600">
|
|
||||||
Contactez notre équipe d'assistance
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Catégories populaires */}
|
|
||||||
<div>
|
|
||||||
<h2 className="text-2xl font-bold text-gray-900 mb-6">
|
|
||||||
Catégories populaires
|
|
||||||
</h2>
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
||||||
{categories.map((category) => (
|
|
||||||
<Card
|
|
||||||
key={category.title}
|
|
||||||
className="p-6 hover:shadow-lg transition-shadow cursor-pointer"
|
|
||||||
>
|
>
|
||||||
<div className={`p-3 ${category.color} rounded-lg w-fit mb-4`}>
|
<i className={`${resource.icon} text-4xl`}></i>
|
||||||
<category.icon className="h-6 w-6" />
|
</div>
|
||||||
|
<h3 className="text-xl font-bold mb-2">{resource.title}</h3>
|
||||||
|
<p className="text-gray-600">{resource.description}</p>
|
||||||
|
<Button
|
||||||
|
label="Accéder"
|
||||||
|
icon="pi pi-arrow-right"
|
||||||
|
className="mt-3"
|
||||||
|
outlined
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<h3 className="font-semibold text-lg mb-2">{category.title}</h3>
|
|
||||||
<p className="text-sm text-gray-600 mb-4">{category.description}</p>
|
|
||||||
<p className="text-sm text-blue-600 font-medium">
|
|
||||||
{category.articles} articles
|
|
||||||
</p>
|
|
||||||
</Card>
|
</Card>
|
||||||
|
</Link>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||||
|
{/* Catégories */}
|
||||||
|
<div className="lg:col-span-2">
|
||||||
|
<Card>
|
||||||
|
<h2 className="text-2xl font-semibold mb-4">
|
||||||
|
<i className="pi pi-th-large mr-2"></i>
|
||||||
|
Parcourir par catégorie
|
||||||
|
</h2>
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
{categories.map((category, index) => (
|
||||||
|
<Link key={index} href={category.link}>
|
||||||
|
<div className="p-4 border border-gray-200 rounded hover:shadow-md transition-shadow cursor-pointer">
|
||||||
|
<div className="flex align-items-start gap-3">
|
||||||
|
<div className={`${category.color} border-round p-3`}>
|
||||||
|
<i className={`${category.icon} text-2xl`}></i>
|
||||||
|
</div>
|
||||||
|
<div className="flex-1">
|
||||||
|
<h3 className="font-semibold text-lg mb-1">
|
||||||
|
{category.title}
|
||||||
|
</h3>
|
||||||
|
<p className="text-sm text-gray-600 mb-2">
|
||||||
|
{category.description}
|
||||||
|
</p>
|
||||||
|
<span className="text-xs text-gray-500">
|
||||||
|
{category.articles} articles
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<i className="pi pi-chevron-right text-gray-400"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Sidebar */}
|
||||||
|
<div className="space-y-6">
|
||||||
{/* Articles populaires */}
|
{/* Articles populaires */}
|
||||||
<div>
|
|
||||||
<h2 className="text-2xl font-bold text-gray-900 mb-6">
|
|
||||||
Articles populaires
|
|
||||||
</h2>
|
|
||||||
<Card>
|
<Card>
|
||||||
<div className="divide-y">
|
<h3 className="text-xl font-semibold mb-4">
|
||||||
{articlesPopulaires.map((article, index) => (
|
<i className="pi pi-star mr-2"></i>
|
||||||
|
Articles populaires
|
||||||
|
</h3>
|
||||||
|
<div className="space-y-3">
|
||||||
|
{popularArticles.map((article, index) => (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
className="p-4 hover:bg-gray-50 cursor-pointer flex items-center justify-between group"
|
className="p-3 bg-gray-50 rounded hover:bg-gray-100 cursor-pointer transition-colors"
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-3">
|
<h4 className="font-medium text-sm mb-1">{article.title}</h4>
|
||||||
<HelpCircle className="h-5 w-5 text-gray-400" />
|
<div className="flex justify-content-between align-items-center text-xs text-gray-500">
|
||||||
<span className="text-gray-900">{article}</span>
|
<span className="bg-gray-200 px-2 py-1 rounded">
|
||||||
|
{article.category}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<i className="pi pi-eye mr-1"></i>
|
||||||
|
{article.views.toLocaleString()}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<ExternalLink className="h-4 w-4 text-gray-400 opacity-0 group-hover:opacity-100 transition-opacity" />
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Contact direct */}
|
{/* Contact */}
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<Card className="bg-gradient-to-br from-blue-50 to-blue-100">
|
||||||
<Card className="p-6 bg-blue-50 border-blue-200">
|
<div className="text-center">
|
||||||
<div className="flex items-start gap-4">
|
<div className="bg-blue-600 text-white border-round inline-block p-3 mb-3">
|
||||||
<div className="p-3 bg-blue-600 rounded-lg">
|
<i className="pi pi-phone text-2xl"></i>
|
||||||
<Phone className="h-6 w-6 text-white" />
|
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<h3 className="font-semibold text-lg mb-2">Besoin d'aide ?</h3>
|
||||||
<h3 className="font-semibold text-lg mb-2 text-blue-900">
|
<p className="text-sm text-gray-700 mb-3">
|
||||||
Support téléphonique
|
Notre équipe est disponible pour vous assister
|
||||||
</h3>
|
|
||||||
<p className="text-sm text-blue-700 mb-3">
|
|
||||||
Disponible du lundi au vendredi de 9h à 18h
|
|
||||||
</p>
|
</p>
|
||||||
<Button className="bg-blue-600 hover:bg-blue-700">
|
<div className="space-y-2">
|
||||||
+33 1 23 45 67 89
|
<div className="text-sm">
|
||||||
</Button>
|
<i className="pi pi-phone mr-2"></i>
|
||||||
|
<span className="font-semibold">+33 1 23 45 67 89</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="text-sm">
|
||||||
|
<i className="pi pi-envelope mr-2"></i>
|
||||||
|
<span className="font-semibold">support@btpxpress.fr</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
label="Contacter le support"
|
||||||
|
icon="pi pi-send"
|
||||||
|
className="mt-3 w-full"
|
||||||
|
onClick={() => router.push('/aide/support')}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card className="p-6 bg-green-50 border-green-200">
|
|
||||||
<div className="flex items-start gap-4">
|
|
||||||
<div className="p-3 bg-green-600 rounded-lg">
|
|
||||||
<Mail className="h-6 w-6 text-white" />
|
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
|
||||||
<h3 className="font-semibold text-lg mb-2 text-green-900">
|
|
||||||
Support par email
|
|
||||||
</h3>
|
|
||||||
<p className="text-sm text-green-700 mb-3">
|
|
||||||
Réponse sous 24h ouvrées
|
|
||||||
</p>
|
|
||||||
<Button className="bg-green-600 hover:bg-green-700">
|
|
||||||
support@btpxpress.fr
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,23 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "primereact/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "primereact/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { InputText } from "primereact/inputtext";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { InputTextarea } from "primereact/inputtextarea";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Tag } from "primereact/tag";
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import {
|
|
||||||
MessageCircle,
|
|
||||||
Phone,
|
|
||||||
Mail,
|
|
||||||
Clock,
|
|
||||||
CheckCircle,
|
|
||||||
AlertCircle,
|
|
||||||
Send,
|
|
||||||
ArrowLeft,
|
|
||||||
Headphones,
|
|
||||||
} from "lucide-react";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
@@ -71,24 +59,24 @@ export default function SupportPage() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const getStatusBadge = (status: string) => {
|
const getStatusTag = (status: string) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "resolved":
|
case "resolved":
|
||||||
return (
|
return (
|
||||||
<Badge className="bg-green-100 text-green-800">
|
<Tag severity="success">
|
||||||
<CheckCircle className="h-3 w-3 mr-1" />
|
<i className="pi pi-check-circle mr-1"></i>
|
||||||
Résolu
|
Résolu
|
||||||
</Badge>
|
</Tag>
|
||||||
);
|
);
|
||||||
case "in-progress":
|
case "in-progress":
|
||||||
return (
|
return (
|
||||||
<Badge className="bg-blue-100 text-blue-800">
|
<Tag severity="info">
|
||||||
<Clock className="h-3 w-3 mr-1" />
|
<i className="pi pi-clock mr-1"></i>
|
||||||
En cours
|
En cours
|
||||||
</Badge>
|
</Tag>
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return <Badge>Nouveau</Badge>;
|
return <Tag>Nouveau</Tag>;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -98,8 +86,8 @@ export default function SupportPage() {
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<Link href="/aide">
|
<Link href="/aide">
|
||||||
<Button variant="ghost" size="sm">
|
<Button text size="small">
|
||||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
<i className="pi pi-arrow-left mr-2"></i>
|
||||||
Retour à l'aide
|
Retour à l'aide
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -120,8 +108,8 @@ export default function SupportPage() {
|
|||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="nom">Nom complet *</Label>
|
<label htmlFor="nom" className="block mb-2">Nom complet *</label>
|
||||||
<Input
|
<InputText
|
||||||
id="nom"
|
id="nom"
|
||||||
name="nom"
|
name="nom"
|
||||||
type="text"
|
type="text"
|
||||||
@@ -129,12 +117,12 @@ export default function SupportPage() {
|
|||||||
value={formData.nom}
|
value={formData.nom}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
required
|
required
|
||||||
className="mt-2"
|
className="w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="email">Email *</Label>
|
<label htmlFor="email" className="block mb-2">Email *</label>
|
||||||
<Input
|
<InputText
|
||||||
id="email"
|
id="email"
|
||||||
name="email"
|
name="email"
|
||||||
type="email"
|
type="email"
|
||||||
@@ -142,14 +130,14 @@ export default function SupportPage() {
|
|||||||
value={formData.email}
|
value={formData.email}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
required
|
required
|
||||||
className="mt-2"
|
className="w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="sujet">Sujet *</Label>
|
<label htmlFor="sujet" className="block mb-2">Sujet *</label>
|
||||||
<Input
|
<InputText
|
||||||
id="sujet"
|
id="sujet"
|
||||||
name="sujet"
|
name="sujet"
|
||||||
type="text"
|
type="text"
|
||||||
@@ -157,18 +145,18 @@ export default function SupportPage() {
|
|||||||
value={formData.sujet}
|
value={formData.sujet}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
required
|
required
|
||||||
className="mt-2"
|
className="w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="priorite">Priorité</Label>
|
<label htmlFor="priorite" className="block mb-2">Priorité</label>
|
||||||
<select
|
<select
|
||||||
id="priorite"
|
id="priorite"
|
||||||
name="priorite"
|
name="priorite"
|
||||||
value={formData.priorite}
|
value={formData.priorite}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
className="mt-2 w-full border border-gray-300 rounded-md p-2"
|
className="w-full border border-gray-300 rounded-md p-2"
|
||||||
>
|
>
|
||||||
<option value="basse">Basse</option>
|
<option value="basse">Basse</option>
|
||||||
<option value="normale">Normale</option>
|
<option value="normale">Normale</option>
|
||||||
@@ -178,8 +166,8 @@ export default function SupportPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="message">Description du problème *</Label>
|
<label htmlFor="message" className="block mb-2">Description du problème *</label>
|
||||||
<Textarea
|
<InputTextarea
|
||||||
id="message"
|
id="message"
|
||||||
name="message"
|
name="message"
|
||||||
placeholder="Décrivez votre problème en détail..."
|
placeholder="Décrivez votre problème en détail..."
|
||||||
@@ -187,7 +175,7 @@ export default function SupportPage() {
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
required
|
required
|
||||||
rows={8}
|
rows={8}
|
||||||
className="mt-2"
|
className="w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -196,7 +184,7 @@ export default function SupportPage() {
|
|||||||
className="w-full bg-blue-600 hover:bg-blue-700"
|
className="w-full bg-blue-600 hover:bg-blue-700"
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
>
|
>
|
||||||
<Send className="mr-2 h-4 w-4" />
|
<i className="pi pi-send mr-2"></i>
|
||||||
{isSubmitting ? "Envoi en cours..." : "Envoyer le ticket"}
|
{isSubmitting ? "Envoi en cours..." : "Envoyer le ticket"}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
@@ -217,7 +205,7 @@ export default function SupportPage() {
|
|||||||
<span className="font-mono text-sm text-gray-600">
|
<span className="font-mono text-sm text-gray-600">
|
||||||
{ticket.id}
|
{ticket.id}
|
||||||
</span>
|
</span>
|
||||||
{getStatusBadge(ticket.status)}
|
{getStatusTag(ticket.status)}
|
||||||
</div>
|
</div>
|
||||||
<p className="font-medium mt-1">{ticket.sujet}</p>
|
<p className="font-medium mt-1">{ticket.sujet}</p>
|
||||||
<p className="text-sm text-gray-500">
|
<p className="text-sm text-gray-500">
|
||||||
@@ -242,7 +230,7 @@ export default function SupportPage() {
|
|||||||
<Card className="p-6">
|
<Card className="p-6">
|
||||||
<div className="flex items-center gap-3 mb-4">
|
<div className="flex items-center gap-3 mb-4">
|
||||||
<div className="p-3 bg-blue-100 rounded-lg">
|
<div className="p-3 bg-blue-100 rounded-lg">
|
||||||
<Headphones className="h-6 w-6 text-blue-600" />
|
<i className="pi pi-headphones text-blue-600" style={{ fontSize: '1.5rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 className="font-semibold">Support disponible</h3>
|
<h3 className="font-semibold">Support disponible</h3>
|
||||||
@@ -251,7 +239,7 @@ export default function SupportPage() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="space-y-3 text-sm">
|
<div className="space-y-3 text-sm">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Clock className="h-4 w-4 text-gray-400" />
|
<i className="pi pi-clock text-gray-400"></i>
|
||||||
<span>9h00 - 18h00 (CET)</span>
|
<span>9h00 - 18h00 (CET)</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-gray-500">
|
<p className="text-xs text-gray-500">
|
||||||
@@ -264,7 +252,7 @@ export default function SupportPage() {
|
|||||||
<Card className="p-6 bg-blue-50 border-blue-200">
|
<Card className="p-6 bg-blue-50 border-blue-200">
|
||||||
<div className="flex items-start gap-3">
|
<div className="flex items-start gap-3">
|
||||||
<div className="p-3 bg-blue-600 rounded-lg">
|
<div className="p-3 bg-blue-600 rounded-lg">
|
||||||
<Phone className="h-5 w-5 text-white" />
|
<i className="pi pi-phone text-white" style={{ fontSize: '1.25rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<h3 className="font-semibold text-blue-900 mb-1">
|
<h3 className="font-semibold text-blue-900 mb-1">
|
||||||
@@ -274,8 +262,7 @@ export default function SupportPage() {
|
|||||||
Pour une assistance immédiate
|
Pour une assistance immédiate
|
||||||
</p>
|
</p>
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
size="small"
|
||||||
size="sm"
|
|
||||||
className="bg-blue-600 hover:bg-blue-700 w-full"
|
className="bg-blue-600 hover:bg-blue-700 w-full"
|
||||||
>
|
>
|
||||||
+33 1 23 45 67 89
|
+33 1 23 45 67 89
|
||||||
@@ -288,14 +275,13 @@ export default function SupportPage() {
|
|||||||
<Card className="p-6 bg-green-50 border-green-200">
|
<Card className="p-6 bg-green-50 border-green-200">
|
||||||
<div className="flex items-start gap-3">
|
<div className="flex items-start gap-3">
|
||||||
<div className="p-3 bg-green-600 rounded-lg">
|
<div className="p-3 bg-green-600 rounded-lg">
|
||||||
<Mail className="h-5 w-5 text-white" />
|
<i className="pi pi-envelope text-white" style={{ fontSize: '1.25rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<h3 className="font-semibold text-green-900 mb-1">Email support</h3>
|
<h3 className="font-semibold text-green-900 mb-1">Email support</h3>
|
||||||
<p className="text-sm text-green-700 mb-2">Réponse sous 24h</p>
|
<p className="text-sm text-green-700 mb-2">Réponse sous 24h</p>
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
size="small"
|
||||||
size="sm"
|
|
||||||
className="bg-green-600 hover:bg-green-700 w-full"
|
className="bg-green-600 hover:bg-green-700 w-full"
|
||||||
>
|
>
|
||||||
support@btpxpress.fr
|
support@btpxpress.fr
|
||||||
@@ -308,7 +294,7 @@ export default function SupportPage() {
|
|||||||
<Card className="p-6 bg-purple-50 border-purple-200">
|
<Card className="p-6 bg-purple-50 border-purple-200">
|
||||||
<div className="flex items-start gap-3">
|
<div className="flex items-start gap-3">
|
||||||
<div className="p-3 bg-purple-600 rounded-lg">
|
<div className="p-3 bg-purple-600 rounded-lg">
|
||||||
<MessageCircle className="h-5 w-5 text-white" />
|
<i className="pi pi-comments text-white" style={{ fontSize: '1.25rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<h3 className="font-semibold text-purple-900 mb-1">
|
<h3 className="font-semibold text-purple-900 mb-1">
|
||||||
@@ -318,8 +304,7 @@ export default function SupportPage() {
|
|||||||
Discutez avec un agent
|
Discutez avec un agent
|
||||||
</p>
|
</p>
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
size="small"
|
||||||
size="sm"
|
|
||||||
className="bg-purple-600 hover:bg-purple-700 w-full"
|
className="bg-purple-600 hover:bg-purple-700 w-full"
|
||||||
>
|
>
|
||||||
Démarrer le chat
|
Démarrer le chat
|
||||||
@@ -331,7 +316,7 @@ export default function SupportPage() {
|
|||||||
{/* Note importante */}
|
{/* Note importante */}
|
||||||
<Card className="p-4 bg-yellow-50 border-yellow-200">
|
<Card className="p-4 bg-yellow-50 border-yellow-200">
|
||||||
<div className="flex items-start gap-2">
|
<div className="flex items-start gap-2">
|
||||||
<AlertCircle className="h-5 w-5 text-yellow-600 flex-shrink-0 mt-0.5" />
|
<i className="pi pi-exclamation-circle text-yellow-600 flex-shrink-0 mt-0.5" style={{ fontSize: '1.25rem' }}></i>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<p className="text-sm text-yellow-800">
|
<p className="text-sm text-yellow-800">
|
||||||
Pour les urgences critiques affectant votre production, appelez
|
Pour les urgences critiques affectant votre production, appelez
|
||||||
|
|||||||
@@ -1,21 +1,10 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "primereact/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "primereact/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { InputText } from "primereact/inputtext";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Tag } from "primereact/tag";
|
||||||
import {
|
|
||||||
Video,
|
|
||||||
Search,
|
|
||||||
Play,
|
|
||||||
Clock,
|
|
||||||
Star,
|
|
||||||
ThumbsUp,
|
|
||||||
Eye,
|
|
||||||
ArrowLeft,
|
|
||||||
Filter,
|
|
||||||
} from "lucide-react";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,16 +104,16 @@ export default function TutorielsPage() {
|
|||||||
return matchesSearch && matchesCategory;
|
return matchesSearch && matchesCategory;
|
||||||
});
|
});
|
||||||
|
|
||||||
const getLevelColor = (level: string) => {
|
const getLevelSeverity = (level: string): "success" | "info" | "warning" | undefined => {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case "Débutant":
|
case "Débutant":
|
||||||
return "bg-green-100 text-green-800";
|
return "success";
|
||||||
case "Intermédiaire":
|
case "Intermédiaire":
|
||||||
return "bg-blue-100 text-blue-800";
|
return "info";
|
||||||
case "Avancé":
|
case "Avancé":
|
||||||
return "bg-purple-100 text-purple-800";
|
return "warning";
|
||||||
default:
|
default:
|
||||||
return "bg-gray-100 text-gray-800";
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -134,8 +123,8 @@ export default function TutorielsPage() {
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<Link href="/aide">
|
<Link href="/aide">
|
||||||
<Button variant="ghost" size="sm">
|
<Button text size="small">
|
||||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
<i className="pi pi-arrow-left mr-2"></i>
|
||||||
Retour à l'aide
|
Retour à l'aide
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -152,22 +141,22 @@ export default function TutorielsPage() {
|
|||||||
{/* Barre de recherche et filtres */}
|
{/* Barre de recherche et filtres */}
|
||||||
<div className="flex gap-4 flex-wrap">
|
<div className="flex gap-4 flex-wrap">
|
||||||
<div className="flex-1 min-w-[300px]">
|
<div className="flex-1 min-w-[300px]">
|
||||||
<div className="relative">
|
<span className="p-input-icon-left w-full">
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400" />
|
<i className="pi pi-search" />
|
||||||
<Input
|
<InputText
|
||||||
placeholder="Rechercher un tutoriel..."
|
placeholder="Rechercher un tutoriel..."
|
||||||
className="pl-10"
|
className="w-full"
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2 flex-wrap">
|
<div className="flex gap-2 flex-wrap">
|
||||||
{categories.map((category) => (
|
{categories.map((category) => (
|
||||||
<Button
|
<Button
|
||||||
key={category}
|
key={category}
|
||||||
variant={selectedCategory === category ? "default" : "outline"}
|
outlined={selectedCategory !== category}
|
||||||
size="sm"
|
size="small"
|
||||||
onClick={() => setSelectedCategory(category)}
|
onClick={() => setSelectedCategory(category)}
|
||||||
>
|
>
|
||||||
{category === "all" ? "Toutes les catégories" : category}
|
{category === "all" ? "Toutes les catégories" : category}
|
||||||
@@ -192,11 +181,11 @@ export default function TutorielsPage() {
|
|||||||
/>
|
/>
|
||||||
<div className="absolute inset-0 bg-black bg-opacity-40 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity">
|
<div className="absolute inset-0 bg-black bg-opacity-40 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity">
|
||||||
<div className="p-4 bg-white rounded-full">
|
<div className="p-4 bg-white rounded-full">
|
||||||
<Play className="h-8 w-8 text-blue-600" />
|
<i className="pi pi-play text-blue-600" style={{ fontSize: '2rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="absolute bottom-2 right-2 bg-black bg-opacity-75 text-white px-2 py-1 rounded text-xs flex items-center gap-1">
|
<div className="absolute bottom-2 right-2 bg-black bg-opacity-75 text-white px-2 py-1 rounded text-xs flex items-center gap-1">
|
||||||
<Clock className="h-3 w-3" />
|
<i className="pi pi-clock" style={{ fontSize: '0.75rem' }}></i>
|
||||||
{tutoriel.duration}
|
{tutoriel.duration}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -204,10 +193,8 @@ export default function TutorielsPage() {
|
|||||||
{/* Contenu */}
|
{/* Contenu */}
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
<div className="flex items-start justify-between gap-2 mb-2">
|
<div className="flex items-start justify-between gap-2 mb-2">
|
||||||
<Badge className={getLevelColor(tutoriel.level)}>
|
<Tag severity={getLevelSeverity(tutoriel.level)} value={tutoriel.level} />
|
||||||
{tutoriel.level}
|
<Tag severity="secondary" value={tutoriel.category} />
|
||||||
</Badge>
|
|
||||||
<Badge variant="outline">{tutoriel.category}</Badge>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 className="font-semibold text-lg mb-2">{tutoriel.title}</h3>
|
<h3 className="font-semibold text-lg mb-2">{tutoriel.title}</h3>
|
||||||
@@ -219,16 +206,16 @@ export default function TutorielsPage() {
|
|||||||
<div className="flex items-center justify-between text-sm text-gray-500">
|
<div className="flex items-center justify-between text-sm text-gray-500">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Eye className="h-4 w-4" />
|
<i className="pi pi-eye"></i>
|
||||||
{tutoriel.views.toLocaleString()}
|
{tutoriel.views.toLocaleString()}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<ThumbsUp className="h-4 w-4" />
|
<i className="pi pi-thumbs-up"></i>
|
||||||
{tutoriel.likes}
|
{tutoriel.likes}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Star className="h-4 w-4 fill-yellow-400 text-yellow-400" />
|
<i className="pi pi-star-fill text-yellow-400"></i>
|
||||||
<span className="font-medium">{tutoriel.rating}</span>
|
<span className="font-medium">{tutoriel.rating}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -240,7 +227,7 @@ export default function TutorielsPage() {
|
|||||||
{filteredTutoriels.length === 0 && (
|
{filteredTutoriels.length === 0 && (
|
||||||
<Card className="p-12">
|
<Card className="p-12">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<Video className="h-12 w-12 text-gray-400 mx-auto mb-4" />
|
<i className="pi pi-video text-gray-400 mx-auto mb-4" style={{ fontSize: '3rem' }}></i>
|
||||||
<p className="text-gray-500">Aucun tutoriel trouvé</p>
|
<p className="text-gray-500">Aucun tutoriel trouvé</p>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -250,7 +237,7 @@ export default function TutorielsPage() {
|
|||||||
<Card className="p-6 bg-gradient-to-r from-purple-50 to-blue-50">
|
<Card className="p-6 bg-gradient-to-r from-purple-50 to-blue-50">
|
||||||
<div className="flex items-start gap-4">
|
<div className="flex items-start gap-4">
|
||||||
<div className="p-3 bg-purple-600 rounded-lg">
|
<div className="p-3 bg-purple-600 rounded-lg">
|
||||||
<Video className="h-6 w-6 text-white" />
|
<i className="pi pi-video text-white" style={{ fontSize: '1.5rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<h3 className="font-semibold text-lg mb-2">
|
<h3 className="font-semibold text-lg mb-2">
|
||||||
|
|||||||
301
app/(main)/chantiers/[id]/budget/page.tsx
Normal file
301
app/(main)/chantiers/[id]/budget/page.tsx
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { Card } from 'primereact/card';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
import { ProgressBar } from 'primereact/progressbar';
|
||||||
|
import { Chart } from 'primereact/chart';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
|
||||||
|
interface BudgetChantier {
|
||||||
|
id: number;
|
||||||
|
chantierNom: string;
|
||||||
|
budgetTotal: number;
|
||||||
|
depenseTotal: number;
|
||||||
|
resteAEngager: number;
|
||||||
|
lignesBudget: LigneBudget[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LigneBudget {
|
||||||
|
id: number;
|
||||||
|
categorie: string;
|
||||||
|
budgetPrevu: number;
|
||||||
|
depenseReel: number;
|
||||||
|
ecart: number;
|
||||||
|
pourcentageUtilisation: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ChantierBudgetPage() {
|
||||||
|
const params = useParams();
|
||||||
|
const router = useRouter();
|
||||||
|
const id = params.id as string;
|
||||||
|
|
||||||
|
const [budget, setBudget] = useState<BudgetChantier | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (id) {
|
||||||
|
loadBudget();
|
||||||
|
}
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const loadBudget = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'https://api.lions.dev/btpxpress';
|
||||||
|
|
||||||
|
// Charger le budget du chantier
|
||||||
|
const response = await fetch(`${API_URL}/api/v1/budgets/chantier/${id}`);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Erreur lors du chargement du budget');
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
setBudget(data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur:', error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatMontant = (montant: number) => {
|
||||||
|
return new Intl.NumberFormat('fr-FR', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'EUR'
|
||||||
|
}).format(montant);
|
||||||
|
};
|
||||||
|
|
||||||
|
const montantBodyTemplate = (rowData: LigneBudget, field: string) => {
|
||||||
|
const value = (rowData as any)[field];
|
||||||
|
return formatMontant(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ecartBodyTemplate = (rowData: LigneBudget) => {
|
||||||
|
const severity = rowData.ecart >= 0 ? 'success' : 'danger';
|
||||||
|
const icon = rowData.ecart >= 0 ? 'pi-check' : 'pi-exclamation-triangle';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tag
|
||||||
|
value={formatMontant(Math.abs(rowData.ecart))}
|
||||||
|
severity={severity}
|
||||||
|
icon={`pi ${icon}`}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const progressionBodyTemplate = (rowData: LigneBudget) => {
|
||||||
|
const severity = rowData.pourcentageUtilisation > 100 ? 'danger' :
|
||||||
|
rowData.pourcentageUtilisation > 80 ? 'warning' : 'success';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<ProgressBar value={rowData.pourcentageUtilisation} showValue={false} color={severity === 'danger' ? '#ef4444' : severity === 'warning' ? '#f59e0b' : '#10b981'} />
|
||||||
|
<span className="text-sm">{rowData.pourcentageUtilisation.toFixed(1)}%</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getChartData = () => {
|
||||||
|
if (!budget) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
labels: budget.lignesBudget?.map(l => l.categorie) || [],
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
label: 'Budget prévu',
|
||||||
|
backgroundColor: '#42A5F5',
|
||||||
|
data: budget.lignesBudget?.map(l => l.budgetPrevu) || []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Dépenses réelles',
|
||||||
|
backgroundColor: '#FFA726',
|
||||||
|
data: budget.lignesBudget?.map(l => l.depenseReel) || []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const getChartOptions = () => {
|
||||||
|
return {
|
||||||
|
maintainAspectRatio: false,
|
||||||
|
aspectRatio: 0.8,
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
position: 'top',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
y: {
|
||||||
|
beginAtZero: true,
|
||||||
|
ticks: {
|
||||||
|
callback: function(value: any) {
|
||||||
|
return formatMontant(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPourcentageUtilisation = () => {
|
||||||
|
if (!budget || budget.budgetTotal === 0) return 0;
|
||||||
|
return (budget.depenseTotal / budget.budgetTotal) * 100;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12">
|
||||||
|
<div className="flex justify-content-between align-items-center mb-3">
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<Button
|
||||||
|
icon="pi pi-arrow-left"
|
||||||
|
className="p-button-text mr-2"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}`)}
|
||||||
|
tooltip="Retour"
|
||||||
|
/>
|
||||||
|
<h2 className="m-0">Budget du chantier</h2>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
label="Ajouter une ligne"
|
||||||
|
icon="pi pi-plus"
|
||||||
|
className="p-button-success"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Vue d'ensemble */}
|
||||||
|
<div className="col-12 lg:col-4">
|
||||||
|
<Card title="Budget total">
|
||||||
|
<div className="text-center">
|
||||||
|
<div className="text-5xl font-bold text-primary mb-2">
|
||||||
|
{budget ? formatMontant(budget.budgetTotal) : formatMontant(0)}
|
||||||
|
</div>
|
||||||
|
<div className="text-600">Montant budgété</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 lg:col-4">
|
||||||
|
<Card title="Dépenses réelles">
|
||||||
|
<div className="text-center">
|
||||||
|
<div className="text-5xl font-bold text-orange-500 mb-2">
|
||||||
|
{budget ? formatMontant(budget.depenseTotal) : formatMontant(0)}
|
||||||
|
</div>
|
||||||
|
<div className="text-600">Montant dépensé</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 lg:col-4">
|
||||||
|
<Card title="Reste à engager">
|
||||||
|
<div className="text-center">
|
||||||
|
<div className="text-5xl font-bold text-green-500 mb-2">
|
||||||
|
{budget ? formatMontant(budget.resteAEngager) : formatMontant(0)}
|
||||||
|
</div>
|
||||||
|
<div className="text-600">Montant disponible</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Progression */}
|
||||||
|
<div className="col-12">
|
||||||
|
<Card title="Utilisation du budget">
|
||||||
|
<div className="mb-2">
|
||||||
|
<ProgressBar
|
||||||
|
value={getPourcentageUtilisation()}
|
||||||
|
showValue={false}
|
||||||
|
color={getPourcentageUtilisation() > 100 ? '#ef4444' : getPourcentageUtilisation() > 80 ? '#f59e0b' : '#10b981'}
|
||||||
|
style={{ height: '30px' }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="text-center text-xl font-bold">
|
||||||
|
{getPourcentageUtilisation().toFixed(1)}% du budget utilisé
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Graphique */}
|
||||||
|
<div className="col-12 lg:col-6">
|
||||||
|
<Card title="Comparaison Budget / Dépenses">
|
||||||
|
<Chart type="bar" data={getChartData()} options={getChartOptions()} style={{ height: '400px' }} />
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Répartition */}
|
||||||
|
<div className="col-12 lg:col-6">
|
||||||
|
<Card title="Répartition du budget">
|
||||||
|
<Chart
|
||||||
|
type="doughnut"
|
||||||
|
data={{
|
||||||
|
labels: budget?.lignesBudget?.map(l => l.categorie) || [],
|
||||||
|
datasets: [{
|
||||||
|
data: budget?.lignesBudget?.map(l => l.budgetPrevu) || [],
|
||||||
|
backgroundColor: [
|
||||||
|
'#42A5F5',
|
||||||
|
'#66BB6A',
|
||||||
|
'#FFA726',
|
||||||
|
'#EF5350',
|
||||||
|
'#AB47BC',
|
||||||
|
'#26C6DA'
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}}
|
||||||
|
style={{ height: '400px' }}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Tableau détaillé */}
|
||||||
|
<div className="col-12">
|
||||||
|
<Card title="Détail par catégorie">
|
||||||
|
<DataTable
|
||||||
|
value={budget?.lignesBudget || []}
|
||||||
|
loading={loading}
|
||||||
|
responsiveLayout="scroll"
|
||||||
|
emptyMessage="Aucune ligne budgétaire"
|
||||||
|
>
|
||||||
|
<Column field="categorie" header="Catégorie" sortable />
|
||||||
|
<Column
|
||||||
|
field="budgetPrevu"
|
||||||
|
header="Budget prévu"
|
||||||
|
body={(rowData) => montantBodyTemplate(rowData, 'budgetPrevu')}
|
||||||
|
sortable
|
||||||
|
/>
|
||||||
|
<Column
|
||||||
|
field="depenseReel"
|
||||||
|
header="Dépenses réelles"
|
||||||
|
body={(rowData) => montantBodyTemplate(rowData, 'depenseReel')}
|
||||||
|
sortable
|
||||||
|
/>
|
||||||
|
<Column
|
||||||
|
field="ecart"
|
||||||
|
header="Écart"
|
||||||
|
body={ecartBodyTemplate}
|
||||||
|
sortable
|
||||||
|
/>
|
||||||
|
<Column
|
||||||
|
field="pourcentageUtilisation"
|
||||||
|
header="Utilisation"
|
||||||
|
body={progressionBodyTemplate}
|
||||||
|
sortable
|
||||||
|
/>
|
||||||
|
<Column
|
||||||
|
header="Actions"
|
||||||
|
body={() => (
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button icon="pi pi-pencil" className="p-button-text p-button-sm" />
|
||||||
|
<Button icon="pi pi-trash" className="p-button-text p-button-sm p-button-danger" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</DataTable>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
131
app/(main)/chantiers/[id]/documents/page.tsx
Normal file
131
app/(main)/chantiers/[id]/documents/page.tsx
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { Card } from 'primereact/card';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
import { FileUpload } from 'primereact/fileupload';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
|
||||||
|
interface Document {
|
||||||
|
id: number;
|
||||||
|
nom: string;
|
||||||
|
type: string;
|
||||||
|
taille: number;
|
||||||
|
dateAjout: string;
|
||||||
|
ajoutePar: string;
|
||||||
|
categorie: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ChantierDocumentsPage() {
|
||||||
|
const params = useParams();
|
||||||
|
const router = useRouter();
|
||||||
|
const id = params.id as string;
|
||||||
|
|
||||||
|
const [documents] = useState<Document[]>([
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
nom: 'Plan d\'architecte.pdf',
|
||||||
|
type: 'PDF',
|
||||||
|
taille: 2500000,
|
||||||
|
dateAjout: '2025-01-15',
|
||||||
|
ajoutePar: 'Jean Dupont',
|
||||||
|
categorie: 'Plans'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
nom: 'Devis matériaux.xlsx',
|
||||||
|
type: 'Excel',
|
||||||
|
taille: 150000,
|
||||||
|
dateAjout: '2025-01-20',
|
||||||
|
ajoutePar: 'Marie Martin',
|
||||||
|
categorie: 'Devis'
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
const formatTaille = (bytes: number) => {
|
||||||
|
if (bytes === 0) return '0 Bytes';
|
||||||
|
const k = 1024;
|
||||||
|
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
||||||
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
|
return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i];
|
||||||
|
};
|
||||||
|
|
||||||
|
const typeBodyTemplate = (rowData: Document) => {
|
||||||
|
const icon = rowData.type === 'PDF' ? 'pi-file-pdf' :
|
||||||
|
rowData.type === 'Excel' ? 'pi-file-excel' : 'pi-file';
|
||||||
|
return <i className={`pi ${icon} text-2xl`}></i>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const tailleBodyTemplate = (rowData: Document) => {
|
||||||
|
return formatTaille(rowData.taille);
|
||||||
|
};
|
||||||
|
|
||||||
|
const categorieBodyTemplate = (rowData: Document) => {
|
||||||
|
return <Tag value={rowData.categorie} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
const actionsBodyTemplate = () => {
|
||||||
|
return (
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button icon="pi pi-download" className="p-button-text p-button-sm" tooltip="Télécharger" />
|
||||||
|
<Button icon="pi pi-eye" className="p-button-text p-button-sm" tooltip="Prévisualiser" />
|
||||||
|
<Button icon="pi pi-trash" className="p-button-text p-button-sm p-button-danger" tooltip="Supprimer" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12">
|
||||||
|
<div className="flex justify-content-between align-items-center mb-3">
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<Button
|
||||||
|
icon="pi pi-arrow-left"
|
||||||
|
className="p-button-text mr-2"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}`)}
|
||||||
|
tooltip="Retour"
|
||||||
|
/>
|
||||||
|
<h2 className="m-0">Documents du chantier</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12">
|
||||||
|
<Card>
|
||||||
|
<FileUpload
|
||||||
|
name="documents"
|
||||||
|
multiple
|
||||||
|
accept="*/*"
|
||||||
|
maxFileSize={10000000}
|
||||||
|
emptyTemplate={<p className="m-0">Glissez-déposez vos fichiers ici</p>}
|
||||||
|
chooseLabel="Choisir des fichiers"
|
||||||
|
uploadLabel="Téléverser"
|
||||||
|
cancelLabel="Annuler"
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12">
|
||||||
|
<Card title="Liste des documents">
|
||||||
|
<DataTable
|
||||||
|
value={documents}
|
||||||
|
paginator
|
||||||
|
rows={10}
|
||||||
|
responsiveLayout="scroll"
|
||||||
|
>
|
||||||
|
<Column body={typeBodyTemplate} header="Type" style={{ width: '5rem' }} />
|
||||||
|
<Column field="nom" header="Nom" sortable filter />
|
||||||
|
<Column body={categorieBodyTemplate} header="Catégorie" sortable filter />
|
||||||
|
<Column body={tailleBodyTemplate} header="Taille" sortable />
|
||||||
|
<Column field="dateAjout" header="Date d'ajout" sortable />
|
||||||
|
<Column field="ajoutePar" header="Ajouté par" sortable />
|
||||||
|
<Column body={actionsBodyTemplate} header="Actions" />
|
||||||
|
</DataTable>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
197
app/(main)/chantiers/[id]/equipe/page.tsx
Normal file
197
app/(main)/chantiers/[id]/equipe/page.tsx
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { Card } from 'primereact/card';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
import { Avatar } from 'primereact/avatar';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
import { Badge } from 'primereact/badge';
|
||||||
|
|
||||||
|
interface MembreEquipe {
|
||||||
|
id: number;
|
||||||
|
nom: string;
|
||||||
|
prenom: string;
|
||||||
|
role: string;
|
||||||
|
specialite: string;
|
||||||
|
email: string;
|
||||||
|
telephone: string;
|
||||||
|
dateAffectation: string;
|
||||||
|
statut: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ChantierEquipePage() {
|
||||||
|
const params = useParams();
|
||||||
|
const router = useRouter();
|
||||||
|
const id = params.id as string;
|
||||||
|
|
||||||
|
const [membres] = useState<MembreEquipe[]>([
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
nom: 'Dupont',
|
||||||
|
prenom: 'Jean',
|
||||||
|
role: 'Chef de chantier',
|
||||||
|
specialite: 'Gestion',
|
||||||
|
email: 'jean.dupont@btpxpress.fr',
|
||||||
|
telephone: '06 12 34 56 78',
|
||||||
|
dateAffectation: '2025-01-01',
|
||||||
|
statut: 'Actif'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
nom: 'Martin',
|
||||||
|
prenom: 'Marie',
|
||||||
|
role: 'Maçon',
|
||||||
|
specialite: 'Maçonnerie',
|
||||||
|
email: 'marie.martin@btpxpress.fr',
|
||||||
|
telephone: '06 23 45 67 89',
|
||||||
|
dateAffectation: '2025-01-05',
|
||||||
|
statut: 'Actif'
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
const nomBodyTemplate = (rowData: MembreEquipe) => {
|
||||||
|
return (
|
||||||
|
<div className="flex align-items-center gap-2">
|
||||||
|
<Avatar
|
||||||
|
label={`${rowData.prenom[0]}${rowData.nom[0]}`}
|
||||||
|
size="large"
|
||||||
|
shape="circle"
|
||||||
|
className="mr-2"
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<div className="font-bold">{rowData.prenom} {rowData.nom}</div>
|
||||||
|
<div className="text-sm text-600">{rowData.role}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const specialiteBodyTemplate = (rowData: MembreEquipe) => {
|
||||||
|
return <Tag value={rowData.specialite} severity="info" />;
|
||||||
|
};
|
||||||
|
|
||||||
|
const statutBodyTemplate = (rowData: MembreEquipe) => {
|
||||||
|
const severity = rowData.statut === 'Actif' ? 'success' : 'danger';
|
||||||
|
return <Tag value={rowData.statut} severity={severity} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
const actionsBodyTemplate = () => {
|
||||||
|
return (
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button icon="pi pi-eye" className="p-button-text p-button-sm" tooltip="Voir le profil" />
|
||||||
|
<Button icon="pi pi-pencil" className="p-button-text p-button-sm" tooltip="Modifier" />
|
||||||
|
<Button icon="pi pi-times" className="p-button-text p-button-sm p-button-danger" tooltip="Retirer du chantier" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12">
|
||||||
|
<div className="flex justify-content-between align-items-center mb-3">
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<Button
|
||||||
|
icon="pi pi-arrow-left"
|
||||||
|
className="p-button-text mr-2"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}`)}
|
||||||
|
tooltip="Retour"
|
||||||
|
/>
|
||||||
|
<h2 className="m-0">Équipe du chantier</h2>
|
||||||
|
<Badge value={membres.length} severity="info" className="ml-2" />
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
label="Affecter un membre"
|
||||||
|
icon="pi pi-plus"
|
||||||
|
className="p-button-success"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Statistiques équipe */}
|
||||||
|
<div className="col-12 md:col-3">
|
||||||
|
<Card>
|
||||||
|
<div className="flex justify-content-between align-items-center">
|
||||||
|
<div>
|
||||||
|
<span className="block text-500 font-medium mb-1">Total membres</span>
|
||||||
|
<div className="text-900 font-medium text-xl">{membres.length}</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex align-items-center justify-content-center bg-blue-100 border-round" style={{width: '2.5rem', height: '2.5rem'}}>
|
||||||
|
<i className="pi pi-users text-blue-500 text-xl"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 md:col-3">
|
||||||
|
<Card>
|
||||||
|
<div className="flex justify-content-between align-items-center">
|
||||||
|
<div>
|
||||||
|
<span className="block text-500 font-medium mb-1">Membres actifs</span>
|
||||||
|
<div className="text-900 font-medium text-xl">
|
||||||
|
{membres.filter(m => m.statut === 'Actif').length}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex align-items-center justify-content-center bg-green-100 border-round" style={{width: '2.5rem', height: '2.5rem'}}>
|
||||||
|
<i className="pi pi-check-circle text-green-500 text-xl"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 md:col-3">
|
||||||
|
<Card>
|
||||||
|
<div className="flex justify-content-between align-items-center">
|
||||||
|
<div>
|
||||||
|
<span className="block text-500 font-medium mb-1">Spécialités</span>
|
||||||
|
<div className="text-900 font-medium text-xl">
|
||||||
|
{new Set(membres.map(m => m.specialite)).size}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex align-items-center justify-content-center bg-orange-100 border-round" style={{width: '2.5rem', height: '2.5rem'}}>
|
||||||
|
<i className="pi pi-star text-orange-500 text-xl"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 md:col-3">
|
||||||
|
<Card>
|
||||||
|
<div className="flex justify-content-between align-items-center">
|
||||||
|
<div>
|
||||||
|
<span className="block text-500 font-medium mb-1">Chef de chantier</span>
|
||||||
|
<div className="text-900 font-medium text-xl">
|
||||||
|
{membres.filter(m => m.role === 'Chef de chantier').length}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex align-items-center justify-content-center bg-purple-100 border-round" style={{width: '2.5rem', height: '2.5rem'}}>
|
||||||
|
<i className="pi pi-user text-purple-500 text-xl"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Liste des membres */}
|
||||||
|
<div className="col-12">
|
||||||
|
<Card title="Liste des membres">
|
||||||
|
<DataTable
|
||||||
|
value={membres}
|
||||||
|
paginator
|
||||||
|
rows={10}
|
||||||
|
responsiveLayout="scroll"
|
||||||
|
>
|
||||||
|
<Column body={nomBodyTemplate} header="Nom" sortable filter />
|
||||||
|
<Column body={specialiteBodyTemplate} header="Spécialité" sortable filter />
|
||||||
|
<Column field="email" header="Email" sortable />
|
||||||
|
<Column field="telephone" header="Téléphone" sortable />
|
||||||
|
<Column field="dateAffectation" header="Date d'affectation" sortable />
|
||||||
|
<Column body={statutBodyTemplate} header="Statut" sortable filter />
|
||||||
|
<Column body={actionsBodyTemplate} header="Actions" />
|
||||||
|
</DataTable>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
336
app/(main)/chantiers/[id]/page.tsx
Normal file
336
app/(main)/chantiers/[id]/page.tsx
Normal file
@@ -0,0 +1,336 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { Card } from 'primereact/card';
|
||||||
|
import { TabView, TabPanel } from 'primereact/tabview';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
import { ProgressBar } from 'primereact/progressbar';
|
||||||
|
import { Divider } from 'primereact/divider';
|
||||||
|
import { Skeleton } from 'primereact/skeleton';
|
||||||
|
|
||||||
|
interface Chantier {
|
||||||
|
id: number;
|
||||||
|
nom: string;
|
||||||
|
description: string;
|
||||||
|
adresse: string;
|
||||||
|
ville: string;
|
||||||
|
codePostal: string;
|
||||||
|
dateDebut: string;
|
||||||
|
dateFin: string;
|
||||||
|
dateLivraison: string;
|
||||||
|
statut: string;
|
||||||
|
budget: number;
|
||||||
|
client: {
|
||||||
|
id: number;
|
||||||
|
nom: string;
|
||||||
|
email: string;
|
||||||
|
telephone: string;
|
||||||
|
};
|
||||||
|
responsable: {
|
||||||
|
id: number;
|
||||||
|
nom: string;
|
||||||
|
prenom: string;
|
||||||
|
};
|
||||||
|
progression: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ChantierDetailsPage() {
|
||||||
|
const params = useParams();
|
||||||
|
const router = useRouter();
|
||||||
|
const id = params.id as string;
|
||||||
|
|
||||||
|
const [chantier, setChantier] = useState<Chantier | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [activeTab, setActiveTab] = useState(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (id) {
|
||||||
|
loadChantier();
|
||||||
|
}
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const loadChantier = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'https://api.lions.dev/btpxpress';
|
||||||
|
const response = await fetch(`${API_URL}/api/v1/chantiers/${id}`);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Erreur lors du chargement du chantier');
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
setChantier(data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur:', error);
|
||||||
|
// TODO: Afficher un toast d'erreur
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStatutSeverity = (statut: string) => {
|
||||||
|
switch (statut?.toUpperCase()) {
|
||||||
|
case 'PLANIFIE':
|
||||||
|
return 'info';
|
||||||
|
case 'EN_COURS':
|
||||||
|
return 'warning';
|
||||||
|
case 'TERMINE':
|
||||||
|
return 'success';
|
||||||
|
case 'SUSPENDU':
|
||||||
|
return 'danger';
|
||||||
|
case 'ANNULE':
|
||||||
|
return 'secondary';
|
||||||
|
default:
|
||||||
|
return 'info';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStatutLabel = (statut: string) => {
|
||||||
|
const labels: { [key: string]: string } = {
|
||||||
|
'PLANIFIE': 'Planifié',
|
||||||
|
'EN_COURS': 'En cours',
|
||||||
|
'TERMINE': 'Terminé',
|
||||||
|
'SUSPENDU': 'Suspendu',
|
||||||
|
'ANNULE': 'Annulé'
|
||||||
|
};
|
||||||
|
return labels[statut] || statut;
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatDate = (dateString: string) => {
|
||||||
|
if (!dateString) return 'N/A';
|
||||||
|
return new Date(dateString).toLocaleDateString('fr-FR');
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatMontant = (montant: number) => {
|
||||||
|
return new Intl.NumberFormat('fr-FR', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'EUR'
|
||||||
|
}).format(montant);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12">
|
||||||
|
<Card>
|
||||||
|
<Skeleton width="100%" height="150px" />
|
||||||
|
<Divider />
|
||||||
|
<Skeleton width="100%" height="300px" className="mt-3" />
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!chantier) {
|
||||||
|
return (
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12">
|
||||||
|
<Card>
|
||||||
|
<div className="text-center">
|
||||||
|
<i className="pi pi-exclamation-triangle text-6xl text-orange-500 mb-3"></i>
|
||||||
|
<h3>Chantier non trouvé</h3>
|
||||||
|
<p>Le chantier demandé n'existe pas ou a été supprimé.</p>
|
||||||
|
<Button
|
||||||
|
label="Retour à la liste"
|
||||||
|
icon="pi pi-arrow-left"
|
||||||
|
onClick={() => router.push('/chantiers')}
|
||||||
|
className="mt-3"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid">
|
||||||
|
{/* En-tête du chantier */}
|
||||||
|
<div className="col-12">
|
||||||
|
<Card>
|
||||||
|
<div className="flex justify-content-between align-items-center mb-3">
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
icon="pi pi-arrow-left"
|
||||||
|
className="p-button-text mr-2"
|
||||||
|
onClick={() => router.push('/chantiers')}
|
||||||
|
tooltip="Retour"
|
||||||
|
/>
|
||||||
|
<span className="text-3xl font-bold">{chantier.nom}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Tag
|
||||||
|
value={getStatutLabel(chantier.statut)}
|
||||||
|
severity={getStatutSeverity(chantier.statut)}
|
||||||
|
className="mr-2"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
icon="pi pi-pencil"
|
||||||
|
label="Modifier"
|
||||||
|
className="p-button-outlined mr-2"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}/modifier`)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
icon="pi pi-ellipsis-v"
|
||||||
|
className="p-button-outlined"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12 md:col-8">
|
||||||
|
<p className="text-600 mb-3">{chantier.description}</p>
|
||||||
|
|
||||||
|
<div className="flex align-items-center mb-2">
|
||||||
|
<i className="pi pi-map-marker mr-2 text-600"></i>
|
||||||
|
<span>{chantier.adresse}, {chantier.codePostal} {chantier.ville}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex align-items-center mb-2">
|
||||||
|
<i className="pi pi-user mr-2 text-600"></i>
|
||||||
|
<span><strong>Client:</strong> {chantier.client?.nom}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex align-items-center mb-2">
|
||||||
|
<i className="pi pi-users mr-2 text-600"></i>
|
||||||
|
<span><strong>Responsable:</strong> {chantier.responsable?.prenom} {chantier.responsable?.nom}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 md:col-4">
|
||||||
|
<div className="surface-100 border-round p-3">
|
||||||
|
<div className="mb-3">
|
||||||
|
<span className="text-600 text-sm">Progression</span>
|
||||||
|
<ProgressBar value={chantier.progression || 0} className="mt-2" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-3">
|
||||||
|
<span className="text-600 text-sm">Début</span>
|
||||||
|
<div className="font-bold">{formatDate(chantier.dateDebut)}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-3">
|
||||||
|
<span className="text-600 text-sm">Fin prévue</span>
|
||||||
|
<div className="font-bold">{formatDate(chantier.dateFin)}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span className="text-600 text-sm">Budget</span>
|
||||||
|
<div className="font-bold text-xl text-primary">{formatMontant(chantier.budget)}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Onglets */}
|
||||||
|
<div className="col-12">
|
||||||
|
<Card>
|
||||||
|
<TabView activeIndex={activeTab} onTabChange={(e) => setActiveTab(e.index)}>
|
||||||
|
<TabPanel header="Vue d'ensemble" leftIcon="pi pi-home mr-2">
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12 md:col-3">
|
||||||
|
<Card className="text-center">
|
||||||
|
<i className="pi pi-calendar text-4xl text-blue-500 mb-2"></i>
|
||||||
|
<div className="text-600 text-sm mb-1">Durée</div>
|
||||||
|
<div className="text-2xl font-bold">
|
||||||
|
{Math.ceil((new Date(chantier.dateFin).getTime() - new Date(chantier.dateDebut).getTime()) / (1000 * 60 * 60 * 24))} jours
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 md:col-3">
|
||||||
|
<Card className="text-center">
|
||||||
|
<i className="pi pi-check-circle text-4xl text-green-500 mb-2"></i>
|
||||||
|
<div className="text-600 text-sm mb-1">Avancement</div>
|
||||||
|
<div className="text-2xl font-bold">{chantier.progression || 0}%</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 md:col-3">
|
||||||
|
<Card className="text-center">
|
||||||
|
<i className="pi pi-euro text-4xl text-orange-500 mb-2"></i>
|
||||||
|
<div className="text-600 text-sm mb-1">Budget</div>
|
||||||
|
<div className="text-2xl font-bold">{formatMontant(chantier.budget)}</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 md:col-3">
|
||||||
|
<Card className="text-center">
|
||||||
|
<i className="pi pi-users text-4xl text-purple-500 mb-2"></i>
|
||||||
|
<div className="text-600 text-sm mb-1">Équipe</div>
|
||||||
|
<div className="text-2xl font-bold">0</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12">
|
||||||
|
<h3>Accès rapides</h3>
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
<Button
|
||||||
|
label="Phases"
|
||||||
|
icon="pi pi-list"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}/phases`)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
label="Budget"
|
||||||
|
icon="pi pi-chart-line"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}/budget`)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
label="Planning"
|
||||||
|
icon="pi pi-calendar"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}/planning`)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
label="Documents"
|
||||||
|
icon="pi pi-file"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}/documents`)}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
label="Équipe"
|
||||||
|
icon="pi pi-users"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}/equipe`)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Phases" leftIcon="pi pi-list mr-2">
|
||||||
|
<Button
|
||||||
|
label="Voir toutes les phases"
|
||||||
|
icon="pi pi-arrow-right"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}/phases`)}
|
||||||
|
/>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Budget" leftIcon="pi pi-chart-line mr-2">
|
||||||
|
<Button
|
||||||
|
label="Voir le budget détaillé"
|
||||||
|
icon="pi pi-arrow-right"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}/budget`)}
|
||||||
|
/>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Planning" leftIcon="pi pi-calendar mr-2">
|
||||||
|
<Button
|
||||||
|
label="Voir le planning complet"
|
||||||
|
icon="pi pi-arrow-right"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}/planning`)}
|
||||||
|
/>
|
||||||
|
</TabPanel>
|
||||||
|
</TabView>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
288
app/(main)/chantiers/[id]/planning/page.tsx
Normal file
288
app/(main)/chantiers/[id]/planning/page.tsx
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { Card } from 'primereact/card';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { Calendar } from 'primereact/calendar';
|
||||||
|
import { Timeline } from 'primereact/timeline';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
|
||||||
|
interface TacheChantier {
|
||||||
|
id: number;
|
||||||
|
nom: string;
|
||||||
|
description: string;
|
||||||
|
dateDebut: string;
|
||||||
|
dateFin: string;
|
||||||
|
statut: string;
|
||||||
|
responsable: {
|
||||||
|
nom: string;
|
||||||
|
prenom: string;
|
||||||
|
};
|
||||||
|
equipe: {
|
||||||
|
nom: string;
|
||||||
|
};
|
||||||
|
progression: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ChantierPlanningPage() {
|
||||||
|
const params = useParams();
|
||||||
|
const router = useRouter();
|
||||||
|
const id = params.id as string;
|
||||||
|
|
||||||
|
const [taches, setTaches] = useState<TacheChantier[]>([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (id) {
|
||||||
|
loadPlanning();
|
||||||
|
}
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const loadPlanning = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'https://api.lions.dev/btpxpress';
|
||||||
|
|
||||||
|
// Charger les tâches du chantier
|
||||||
|
const response = await fetch(`${API_URL}/api/v1/chantiers/${id}/taches`);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Erreur lors du chargement du planning');
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
setTaches(data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur:', error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatDate = (dateString: string) => {
|
||||||
|
if (!dateString) return 'N/A';
|
||||||
|
return new Date(dateString).toLocaleDateString('fr-FR');
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStatutSeverity = (statut: string) => {
|
||||||
|
switch (statut?.toUpperCase()) {
|
||||||
|
case 'A_FAIRE':
|
||||||
|
return 'info';
|
||||||
|
case 'EN_COURS':
|
||||||
|
return 'warning';
|
||||||
|
case 'TERMINE':
|
||||||
|
return 'success';
|
||||||
|
case 'EN_RETARD':
|
||||||
|
return 'danger';
|
||||||
|
default:
|
||||||
|
return 'info';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStatutLabel = (statut: string) => {
|
||||||
|
const labels: { [key: string]: string } = {
|
||||||
|
'A_FAIRE': 'À faire',
|
||||||
|
'EN_COURS': 'En cours',
|
||||||
|
'TERMINE': 'Terminé',
|
||||||
|
'EN_RETARD': 'En retard'
|
||||||
|
};
|
||||||
|
return labels[statut] || statut;
|
||||||
|
};
|
||||||
|
|
||||||
|
const statutBodyTemplate = (rowData: TacheChantier) => {
|
||||||
|
return (
|
||||||
|
<Tag
|
||||||
|
value={getStatutLabel(rowData.statut)}
|
||||||
|
severity={getStatutSeverity(rowData.statut)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const dateBodyTemplate = (rowData: TacheChantier) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div><strong>Début:</strong> {formatDate(rowData.dateDebut)}</div>
|
||||||
|
<div><strong>Fin:</strong> {formatDate(rowData.dateFin)}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const responsableBodyTemplate = (rowData: TacheChantier) => {
|
||||||
|
return `${rowData.responsable?.prenom} ${rowData.responsable?.nom}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const equipeBodyTemplate = (rowData: TacheChantier) => {
|
||||||
|
return rowData.equipe?.nom || 'Non assignée';
|
||||||
|
};
|
||||||
|
|
||||||
|
const progressionBodyTemplate = (rowData: TacheChantier) => {
|
||||||
|
return (
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<div className="flex-1 mr-2">
|
||||||
|
<div className="surface-300 border-round" style={{ height: '8px' }}>
|
||||||
|
<div
|
||||||
|
className="bg-primary border-round"
|
||||||
|
style={{ height: '8px', width: `${rowData.progression}%` }}
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span>{rowData.progression}%</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const actionsBodyTemplate = (rowData: TacheChantier) => {
|
||||||
|
return (
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button
|
||||||
|
icon="pi pi-eye"
|
||||||
|
className="p-button-text p-button-sm"
|
||||||
|
tooltip="Voir les détails"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
icon="pi pi-pencil"
|
||||||
|
className="p-button-text p-button-sm"
|
||||||
|
tooltip="Modifier"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
icon="pi pi-trash"
|
||||||
|
className="p-button-text p-button-sm p-button-danger"
|
||||||
|
tooltip="Supprimer"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const customizedMarker = (item: TacheChantier) => {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className="flex w-2rem h-2rem align-items-center justify-content-center text-white border-circle z-1 shadow-1"
|
||||||
|
style={{ backgroundColor: item.statut === 'TERMINE' ? '#10b981' : '#3b82f6' }}
|
||||||
|
>
|
||||||
|
<i className={item.statut === 'TERMINE' ? 'pi pi-check' : 'pi pi-clock'}></i>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const customizedContent = (item: TacheChantier) => {
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<div className="flex justify-content-between align-items-center mb-2">
|
||||||
|
<span className="font-bold">{item.nom}</span>
|
||||||
|
<Tag value={getStatutLabel(item.statut)} severity={getStatutSeverity(item.statut)} />
|
||||||
|
</div>
|
||||||
|
<p className="text-600 mb-2">{item.description}</p>
|
||||||
|
<div className="text-sm">
|
||||||
|
<div><strong>Responsable:</strong> {item.responsable?.prenom} {item.responsable?.nom}</div>
|
||||||
|
<div><strong>Équipe:</strong> {item.equipe?.nom || 'Non assignée'}</div>
|
||||||
|
<div><strong>Dates:</strong> {formatDate(item.dateDebut)} - {formatDate(item.dateFin)}</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12">
|
||||||
|
<div className="flex justify-content-between align-items-center mb-3">
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<Button
|
||||||
|
icon="pi pi-arrow-left"
|
||||||
|
className="p-button-text mr-2"
|
||||||
|
onClick={() => router.push(`/chantiers/${id}`)}
|
||||||
|
tooltip="Retour"
|
||||||
|
/>
|
||||||
|
<h2 className="m-0">Planning du chantier</h2>
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button
|
||||||
|
label="Vue Gantt"
|
||||||
|
icon="pi pi-chart-bar"
|
||||||
|
className="p-button-outlined"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
label="Ajouter une tâche"
|
||||||
|
icon="pi pi-plus"
|
||||||
|
className="p-button-success"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Calendrier */}
|
||||||
|
<div className="col-12 lg:col-4">
|
||||||
|
<Card title="Calendrier">
|
||||||
|
<Calendar
|
||||||
|
value={selectedDate}
|
||||||
|
onChange={(e) => setSelectedDate(e.value as Date)}
|
||||||
|
inline
|
||||||
|
showWeek
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="mt-3">
|
||||||
|
<h4>Légende</h4>
|
||||||
|
<div className="flex flex-column gap-2">
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<div className="w-1rem h-1rem bg-blue-500 border-round mr-2"></div>
|
||||||
|
<span>En cours</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<div className="w-1rem h-1rem bg-green-500 border-round mr-2"></div>
|
||||||
|
<span>Terminé</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<div className="w-1rem h-1rem bg-red-500 border-round mr-2"></div>
|
||||||
|
<span>En retard</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<div className="w-1rem h-1rem bg-gray-500 border-round mr-2"></div>
|
||||||
|
<span>À faire</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Timeline */}
|
||||||
|
<div className="col-12 lg:col-8">
|
||||||
|
<Card title="Chronologie des tâches">
|
||||||
|
<Timeline
|
||||||
|
value={taches}
|
||||||
|
align="alternate"
|
||||||
|
className="customized-timeline"
|
||||||
|
marker={customizedMarker}
|
||||||
|
content={customizedContent}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Tableau des tâches */}
|
||||||
|
<div className="col-12">
|
||||||
|
<Card title="Liste des tâches">
|
||||||
|
<DataTable
|
||||||
|
value={taches}
|
||||||
|
loading={loading}
|
||||||
|
responsiveLayout="scroll"
|
||||||
|
paginator
|
||||||
|
rows={10}
|
||||||
|
emptyMessage="Aucune tâche planifiée"
|
||||||
|
sortField="dateDebut"
|
||||||
|
sortOrder={1}
|
||||||
|
>
|
||||||
|
<Column field="nom" header="Tâche" sortable filter />
|
||||||
|
<Column field="statut" header="Statut" body={statutBodyTemplate} sortable filter />
|
||||||
|
<Column header="Dates" body={dateBodyTemplate} sortable />
|
||||||
|
<Column header="Responsable" body={responsableBodyTemplate} sortable filter />
|
||||||
|
<Column header="Équipe" body={equipeBodyTemplate} sortable filter />
|
||||||
|
<Column header="Progression" body={progressionBodyTemplate} sortable />
|
||||||
|
<Column header="Actions" body={actionsBodyTemplate} />
|
||||||
|
</DataTable>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
222
app/(main)/clients/[id]/page.tsx
Normal file
222
app/(main)/clients/[id]/page.tsx
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { Card } from 'primereact/card';
|
||||||
|
import { TabView, TabPanel } from 'primereact/tabview';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { Avatar } from 'primereact/avatar';
|
||||||
|
import { Divider } from 'primereact/divider';
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
|
||||||
|
interface Client {
|
||||||
|
id: number;
|
||||||
|
nom: string;
|
||||||
|
email: string;
|
||||||
|
telephone: string;
|
||||||
|
adresse: string;
|
||||||
|
ville: string;
|
||||||
|
codePostal: string;
|
||||||
|
typeClient: string;
|
||||||
|
dateCreation: string;
|
||||||
|
chantiers: Chantier[];
|
||||||
|
factures: Facture[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Chantier {
|
||||||
|
id: number;
|
||||||
|
nom: string;
|
||||||
|
statut: string;
|
||||||
|
dateDebut: string;
|
||||||
|
budget: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Facture {
|
||||||
|
id: number;
|
||||||
|
numero: string;
|
||||||
|
montant: number;
|
||||||
|
dateEmission: string;
|
||||||
|
statut: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ClientDetailsPage() {
|
||||||
|
const params = useParams();
|
||||||
|
const router = useRouter();
|
||||||
|
const id = params.id as string;
|
||||||
|
|
||||||
|
const [client, setClient] = useState<Client | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (id) {
|
||||||
|
loadClient();
|
||||||
|
}
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const loadClient = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'https://api.lions.dev/btpxpress';
|
||||||
|
const response = await fetch(`${API_URL}/api/v1/clients/${id}`);
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
const data = await response.json();
|
||||||
|
setClient(data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur:', error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatMontant = (montant: number) => {
|
||||||
|
return new Intl.NumberFormat('fr-FR', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'EUR'
|
||||||
|
}).format(montant);
|
||||||
|
};
|
||||||
|
|
||||||
|
const statutChantierTemplate = (rowData: Chantier) => {
|
||||||
|
const severity = rowData.statut === 'EN_COURS' ? 'warning' :
|
||||||
|
rowData.statut === 'TERMINE' ? 'success' : 'info';
|
||||||
|
return <Tag value={rowData.statut} severity={severity} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
const statutFactureTemplate = (rowData: Facture) => {
|
||||||
|
const severity = rowData.statut === 'PAYEE' ? 'success' :
|
||||||
|
rowData.statut === 'EN_ATTENTE' ? 'warning' : 'danger';
|
||||||
|
return <Tag value={rowData.statut} severity={severity} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (loading || !client) {
|
||||||
|
return <div>Chargement...</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12">
|
||||||
|
<Card>
|
||||||
|
<div className="flex justify-content-between align-items-center mb-3">
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<Button
|
||||||
|
icon="pi pi-arrow-left"
|
||||||
|
className="p-button-text mr-2"
|
||||||
|
onClick={() => router.push('/clients')}
|
||||||
|
tooltip="Retour"
|
||||||
|
/>
|
||||||
|
<Avatar label={client.nom[0]} size="xlarge" shape="circle" className="mr-3" />
|
||||||
|
<div>
|
||||||
|
<h2 className="m-0">{client.nom}</h2>
|
||||||
|
<p className="text-600 m-0">{client.typeClient}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
icon="pi pi-pencil"
|
||||||
|
label="Modifier"
|
||||||
|
className="p-button-outlined"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12 md:col-6">
|
||||||
|
<h3>Coordonnées</h3>
|
||||||
|
<div className="flex align-items-center mb-2">
|
||||||
|
<i className="pi pi-envelope mr-2"></i>
|
||||||
|
<span>{client.email}</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex align-items-center mb-2">
|
||||||
|
<i className="pi pi-phone mr-2"></i>
|
||||||
|
<span>{client.telephone}</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex align-items-center mb-2">
|
||||||
|
<i className="pi pi-map-marker mr-2"></i>
|
||||||
|
<span>{client.adresse}, {client.codePostal} {client.ville}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 md:col-6">
|
||||||
|
<h3>Statistiques</h3>
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-6">
|
||||||
|
<Card className="text-center">
|
||||||
|
<div className="text-600">Chantiers</div>
|
||||||
|
<div className="text-2xl font-bold">{client.chantiers?.length || 0}</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
<div className="col-6">
|
||||||
|
<Card className="text-center">
|
||||||
|
<div className="text-600">Factures</div>
|
||||||
|
<div className="text-2xl font-bold">{client.factures?.length || 0}</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12">
|
||||||
|
<Card>
|
||||||
|
<TabView>
|
||||||
|
<TabPanel header="Chantiers" leftIcon="pi pi-home mr-2">
|
||||||
|
<DataTable value={client.chantiers || []} emptyMessage="Aucun chantier">
|
||||||
|
<Column field="nom" header="Nom" sortable />
|
||||||
|
<Column field="statut" header="Statut" body={statutChantierTemplate} sortable />
|
||||||
|
<Column field="dateDebut" header="Date début" sortable />
|
||||||
|
<Column
|
||||||
|
field="budget"
|
||||||
|
header="Budget"
|
||||||
|
body={(rowData) => formatMontant(rowData.budget)}
|
||||||
|
sortable
|
||||||
|
/>
|
||||||
|
<Column
|
||||||
|
header="Actions"
|
||||||
|
body={(rowData) => (
|
||||||
|
<Button
|
||||||
|
icon="pi pi-eye"
|
||||||
|
className="p-button-text p-button-sm"
|
||||||
|
onClick={() => router.push(`/chantiers/${rowData.id}`)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</DataTable>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Factures" leftIcon="pi pi-file mr-2">
|
||||||
|
<DataTable value={client.factures || []} emptyMessage="Aucune facture">
|
||||||
|
<Column field="numero" header="Numéro" sortable />
|
||||||
|
<Column
|
||||||
|
field="montant"
|
||||||
|
header="Montant"
|
||||||
|
body={(rowData) => formatMontant(rowData.montant)}
|
||||||
|
sortable
|
||||||
|
/>
|
||||||
|
<Column field="dateEmission" header="Date" sortable />
|
||||||
|
<Column field="statut" header="Statut" body={statutFactureTemplate} sortable />
|
||||||
|
<Column
|
||||||
|
header="Actions"
|
||||||
|
body={(rowData) => (
|
||||||
|
<Button
|
||||||
|
icon="pi pi-eye"
|
||||||
|
className="p-button-text p-button-sm"
|
||||||
|
onClick={() => router.push(`/factures/${rowData.id}`)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</DataTable>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Documents" leftIcon="pi pi-folder mr-2">
|
||||||
|
<p>Documents du client</p>
|
||||||
|
</TabPanel>
|
||||||
|
</TabView>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
197
app/(main)/materiels/[id]/page.tsx
Normal file
197
app/(main)/materiels/[id]/page.tsx
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { Card } from 'primereact/card';
|
||||||
|
import { TabView, TabPanel } from 'primereact/tabview';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
import { Calendar } from 'primereact/calendar';
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
import { Timeline } from 'primereact/timeline';
|
||||||
|
|
||||||
|
interface Materiel {
|
||||||
|
id: number;
|
||||||
|
nom: string;
|
||||||
|
reference: string;
|
||||||
|
type: string;
|
||||||
|
marque: string;
|
||||||
|
modele: string;
|
||||||
|
statut: string;
|
||||||
|
dateAchat: string;
|
||||||
|
prixAchat: number;
|
||||||
|
tauxJournalier: number;
|
||||||
|
disponibilite: string;
|
||||||
|
reservations: Reservation[];
|
||||||
|
maintenances: Maintenance[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Reservation {
|
||||||
|
id: number;
|
||||||
|
chantier: string;
|
||||||
|
dateDebut: string;
|
||||||
|
dateFin: string;
|
||||||
|
statut: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Maintenance {
|
||||||
|
id: number;
|
||||||
|
type: string;
|
||||||
|
date: string;
|
||||||
|
description: string;
|
||||||
|
cout: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function MaterielDetailsPage() {
|
||||||
|
const params = useParams();
|
||||||
|
const router = useRouter();
|
||||||
|
const id = params.id as string;
|
||||||
|
|
||||||
|
const [materiel, setMateriel] = useState<Materiel | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (id) {
|
||||||
|
loadMateriel();
|
||||||
|
}
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const loadMateriel = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'https://api.lions.dev/btpxpress';
|
||||||
|
const response = await fetch(`${API_URL}/api/v1/materiels/${id}`);
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
const data = await response.json();
|
||||||
|
setMateriel(data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur:', error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatMontant = (montant: number) => {
|
||||||
|
return new Intl.NumberFormat('fr-FR', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'EUR'
|
||||||
|
}).format(montant);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStatutSeverity = (statut: string) => {
|
||||||
|
switch (statut?.toUpperCase()) {
|
||||||
|
case 'DISPONIBLE':
|
||||||
|
return 'success';
|
||||||
|
case 'EN_UTILISATION':
|
||||||
|
return 'warning';
|
||||||
|
case 'EN_MAINTENANCE':
|
||||||
|
return 'info';
|
||||||
|
case 'HORS_SERVICE':
|
||||||
|
return 'danger';
|
||||||
|
default:
|
||||||
|
return 'info';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const statutTemplate = (rowData: Reservation) => {
|
||||||
|
return <Tag value={rowData.statut} severity={getStatutSeverity(rowData.statut)} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (loading || !materiel) {
|
||||||
|
return <div>Chargement...</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12">
|
||||||
|
<Card>
|
||||||
|
<div className="flex justify-content-between align-items-center mb-3">
|
||||||
|
<div className="flex align-items-center">
|
||||||
|
<Button
|
||||||
|
icon="pi pi-arrow-left"
|
||||||
|
className="p-button-text mr-2"
|
||||||
|
onClick={() => router.push('/materiels')}
|
||||||
|
tooltip="Retour"
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<h2 className="m-0">{materiel.nom}</h2>
|
||||||
|
<p className="text-600 m-0">{materiel.reference}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Tag
|
||||||
|
value={materiel.statut}
|
||||||
|
severity={getStatutSeverity(materiel.statut)}
|
||||||
|
className="mr-2"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
icon="pi pi-pencil"
|
||||||
|
label="Modifier"
|
||||||
|
className="p-button-outlined"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid">
|
||||||
|
<div className="col-12 md:col-6">
|
||||||
|
<h3>Informations</h3>
|
||||||
|
<div className="mb-2"><strong>Type:</strong> {materiel.type}</div>
|
||||||
|
<div className="mb-2"><strong>Marque:</strong> {materiel.marque}</div>
|
||||||
|
<div className="mb-2"><strong>Modèle:</strong> {materiel.modele}</div>
|
||||||
|
<div className="mb-2"><strong>Date d'achat:</strong> {materiel.dateAchat}</div>
|
||||||
|
<div className="mb-2"><strong>Prix d'achat:</strong> {formatMontant(materiel.prixAchat)}</div>
|
||||||
|
<div className="mb-2"><strong>Tarif journalier:</strong> {formatMontant(materiel.tauxJournalier)}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 md:col-6">
|
||||||
|
<h3>Disponibilité</h3>
|
||||||
|
<Calendar inline showWeek />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12">
|
||||||
|
<Card>
|
||||||
|
<TabView>
|
||||||
|
<TabPanel header="Réservations" leftIcon="pi pi-calendar mr-2">
|
||||||
|
<DataTable value={materiel.reservations || []} emptyMessage="Aucune réservation">
|
||||||
|
<Column field="chantier" header="Chantier" sortable />
|
||||||
|
<Column field="dateDebut" header="Date début" sortable />
|
||||||
|
<Column field="dateFin" header="Date fin" sortable />
|
||||||
|
<Column field="statut" header="Statut" body={statutTemplate} sortable />
|
||||||
|
<Column
|
||||||
|
header="Actions"
|
||||||
|
body={() => (
|
||||||
|
<Button icon="pi pi-eye" className="p-button-text p-button-sm" />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</DataTable>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Maintenances" leftIcon="pi pi-wrench mr-2">
|
||||||
|
<Timeline
|
||||||
|
value={materiel.maintenances || []}
|
||||||
|
content={(item: Maintenance) => (
|
||||||
|
<Card>
|
||||||
|
<div><strong>{item.type}</strong></div>
|
||||||
|
<div className="text-600">{item.date}</div>
|
||||||
|
<p>{item.description}</p>
|
||||||
|
<div><strong>Coût:</strong> {formatMontant(item.cout)}</div>
|
||||||
|
</Card>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</TabPanel>
|
||||||
|
|
||||||
|
<TabPanel header="Documents" leftIcon="pi pi-folder mr-2">
|
||||||
|
<p>Documents techniques et certificats</p>
|
||||||
|
</TabPanel>
|
||||||
|
</TabView>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "primereact/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "primereact/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { InputText } from "primereact/inputtext";
|
||||||
import { Archive, Search, Mail, Send, RotateCcw, Trash2, MoreVertical } from "lucide-react";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +71,7 @@ export default function MessagesArchivesPage() {
|
|||||||
</div>
|
</div>
|
||||||
<Link href="/messages/nouveau">
|
<Link href="/messages/nouveau">
|
||||||
<Button className="bg-blue-600 hover:bg-blue-700">
|
<Button className="bg-blue-600 hover:bg-blue-700">
|
||||||
<Send className="mr-2 h-4 w-4" />
|
<i className="pi pi-send mr-2"></i>
|
||||||
Nouveau message
|
Nouveau message
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -80,35 +79,35 @@ export default function MessagesArchivesPage() {
|
|||||||
|
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Link href="/messages">
|
<Link href="/messages">
|
||||||
<Button variant="outline">
|
<Button outlined>
|
||||||
<Mail className="mr-2 h-4 w-4" />
|
<i className="pi pi-envelope mr-2"></i>
|
||||||
Reçus
|
Reçus
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href="/messages/envoyes">
|
<Link href="/messages/envoyes">
|
||||||
<Button variant="outline">
|
<Button outlined>
|
||||||
<Send className="mr-2 h-4 w-4" />
|
<i className="pi pi-send mr-2"></i>
|
||||||
Envoyés
|
Envoyés
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href="/messages/archives">
|
<Link href="/messages/archives">
|
||||||
<Button variant="default" className="bg-blue-600">
|
<Button className="bg-blue-600">
|
||||||
<Archive className="mr-2 h-4 w-4" />
|
<i className="pi pi-inbox mr-2"></i>
|
||||||
Archives
|
Archives
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
<div className="relative">
|
<span className="p-input-icon-left w-full">
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400" />
|
<i className="pi pi-search" />
|
||||||
<Input
|
<InputText
|
||||||
placeholder="Rechercher dans les archives..."
|
placeholder="Rechercher dans les archives..."
|
||||||
className="pl-10"
|
className="w-full"
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</span>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
@@ -136,20 +135,20 @@ export default function MessagesArchivesPage() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2 flex-shrink-0">
|
<div className="flex items-center gap-2 flex-shrink-0">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
outlined
|
||||||
size="sm"
|
size="small"
|
||||||
onClick={() => handleRestore(message.id)}
|
onClick={() => handleRestore(message.id)}
|
||||||
>
|
>
|
||||||
<RotateCcw className="h-4 w-4 mr-2" />
|
<i className="pi pi-replay mr-2"></i>
|
||||||
Restaurer
|
Restaurer
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
outlined
|
||||||
size="sm"
|
size="small"
|
||||||
onClick={() => handleDelete(message.id)}
|
onClick={() => handleDelete(message.id)}
|
||||||
className="text-red-600 hover:text-red-700"
|
className="text-red-600 hover:text-red-700"
|
||||||
>
|
>
|
||||||
<Trash2 className="h-4 w-4" />
|
<i className="pi pi-trash"></i>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -159,7 +158,7 @@ export default function MessagesArchivesPage() {
|
|||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<div className="p-12 text-center">
|
<div className="p-12 text-center">
|
||||||
<Archive className="h-12 w-12 text-gray-400 mx-auto mb-4" />
|
<i className="pi pi-inbox text-gray-400 mx-auto mb-4" style={{ fontSize: '3rem' }}></i>
|
||||||
<p className="text-gray-500">Aucun message archivé</p>
|
<p className="text-gray-500">Aucun message archivé</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -168,7 +167,7 @@ export default function MessagesArchivesPage() {
|
|||||||
|
|
||||||
<Card className="p-4 bg-blue-50 border-blue-200">
|
<Card className="p-4 bg-blue-50 border-blue-200">
|
||||||
<div className="flex items-start gap-3">
|
<div className="flex items-start gap-3">
|
||||||
<Archive className="h-5 w-5 text-blue-600 flex-shrink-0 mt-0.5" />
|
<i className="pi pi-inbox text-blue-600 flex-shrink-0 mt-0.5" style={{ fontSize: '1.25rem' }}></i>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<h3 className="font-semibold text-blue-900">À propos des archives</h3>
|
<h3 className="font-semibold text-blue-900">À propos des archives</h3>
|
||||||
<p className="text-sm text-blue-700 mt-1">
|
<p className="text-sm text-blue-700 mt-1">
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "primereact/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "primereact/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { InputText } from "primereact/inputtext";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Tag } from "primereact/tag";
|
||||||
import { Send, Search, Mail, Archive, Trash2, MoreVertical } from "lucide-react";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,14 +60,14 @@ export default function MessagesEnvoyesPage() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStatusBadge = (status: string) => {
|
const getStatusTag = (status: string) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "read":
|
case "read":
|
||||||
return <Badge className="bg-green-100 text-green-800">Lu</Badge>;
|
return <Tag severity="success" value="Lu" />;
|
||||||
case "delivered":
|
case "delivered":
|
||||||
return <Badge className="bg-blue-100 text-blue-800">Envoyé</Badge>;
|
return <Tag severity="info" value="Envoyé" />;
|
||||||
default:
|
default:
|
||||||
return <Badge>En cours</Badge>;
|
return <Tag value="En cours" />;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -84,7 +83,7 @@ export default function MessagesEnvoyesPage() {
|
|||||||
</div>
|
</div>
|
||||||
<Link href="/messages/nouveau">
|
<Link href="/messages/nouveau">
|
||||||
<Button className="bg-blue-600 hover:bg-blue-700">
|
<Button className="bg-blue-600 hover:bg-blue-700">
|
||||||
<Send className="mr-2 h-4 w-4" />
|
<i className="pi pi-send mr-2"></i>
|
||||||
Nouveau message
|
Nouveau message
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -92,35 +91,35 @@ export default function MessagesEnvoyesPage() {
|
|||||||
|
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Link href="/messages">
|
<Link href="/messages">
|
||||||
<Button variant="outline">
|
<Button outlined>
|
||||||
<Mail className="mr-2 h-4 w-4" />
|
<i className="pi pi-envelope mr-2"></i>
|
||||||
Reçus
|
Reçus
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href="/messages/envoyes">
|
<Link href="/messages/envoyes">
|
||||||
<Button variant="default" className="bg-blue-600">
|
<Button className="bg-blue-600">
|
||||||
<Send className="mr-2 h-4 w-4" />
|
<i className="pi pi-send mr-2"></i>
|
||||||
Envoyés
|
Envoyés
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href="/messages/archives">
|
<Link href="/messages/archives">
|
||||||
<Button variant="outline">
|
<Button outlined>
|
||||||
<Archive className="mr-2 h-4 w-4" />
|
<i className="pi pi-inbox mr-2"></i>
|
||||||
Archives
|
Archives
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
<div className="relative">
|
<span className="p-input-icon-left w-full">
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400" />
|
<i className="pi pi-search" />
|
||||||
<Input
|
<InputText
|
||||||
placeholder="Rechercher dans les messages envoyés..."
|
placeholder="Rechercher dans les messages envoyés..."
|
||||||
className="pl-10"
|
className="w-full"
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</span>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
@@ -137,7 +136,7 @@ export default function MessagesEnvoyesPage() {
|
|||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<p className="font-semibold">À: {message.to}</p>
|
<p className="font-semibold">À: {message.to}</p>
|
||||||
{getStatusBadge(message.status)}
|
{getStatusTag(message.status)}
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm font-medium text-gray-900 truncate">
|
<p className="text-sm font-medium text-gray-900 truncate">
|
||||||
{message.subject}
|
{message.subject}
|
||||||
@@ -151,7 +150,7 @@ export default function MessagesEnvoyesPage() {
|
|||||||
{formatDate(message.date)}
|
{formatDate(message.date)}
|
||||||
</span>
|
</span>
|
||||||
<button className="hover:bg-gray-200 rounded p-1">
|
<button className="hover:bg-gray-200 rounded p-1">
|
||||||
<MoreVertical className="h-4 w-4 text-gray-400" />
|
<i className="pi pi-ellipsis-v text-gray-400"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -161,7 +160,7 @@ export default function MessagesEnvoyesPage() {
|
|||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<div className="p-12 text-center">
|
<div className="p-12 text-center">
|
||||||
<Send className="h-12 w-12 text-gray-400 mx-auto mb-4" />
|
<i className="pi pi-send text-gray-400 mx-auto mb-4" style={{ fontSize: '3rem' }}></i>
|
||||||
<p className="text-gray-500">Aucun message envoyé</p>
|
<p className="text-gray-500">Aucun message envoyé</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "primereact/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "primereact/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { InputText } from "primereact/inputtext";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { InputTextarea } from "primereact/inputtextarea";
|
||||||
import { Label } from "@/components/ui/label";
|
|
||||||
import { Send, Paperclip, X, ArrowLeft } from "lucide-react";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
@@ -48,8 +46,8 @@ export default function NouveauMessagePage() {
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<Link href="/messages">
|
<Link href="/messages">
|
||||||
<Button variant="ghost" size="sm">
|
<Button text size="small">
|
||||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
<i className="pi pi-arrow-left mr-2"></i>
|
||||||
Retour
|
Retour
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -63,61 +61,61 @@ export default function NouveauMessagePage() {
|
|||||||
<Card className="p-6">
|
<Card className="p-6">
|
||||||
<form onSubmit={handleSubmit} className="space-y-6">
|
<form onSubmit={handleSubmit} className="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="destinataire">Destinataire *</Label>
|
<label htmlFor="destinataire" className="block mb-2">Destinataire *</label>
|
||||||
<Input
|
<InputText
|
||||||
id="destinataire"
|
id="destinataire"
|
||||||
type="email"
|
type="email"
|
||||||
placeholder="email@exemple.com"
|
placeholder="email@exemple.com"
|
||||||
value={destinataire}
|
value={destinataire}
|
||||||
onChange={(e) => setDestinataire(e.target.value)}
|
onChange={(e) => setDestinataire(e.target.value)}
|
||||||
required
|
required
|
||||||
className="mt-2"
|
className="w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="sujet">Sujet *</Label>
|
<label htmlFor="sujet" className="block mb-2">Sujet *</label>
|
||||||
<Input
|
<InputText
|
||||||
id="sujet"
|
id="sujet"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Objet du message"
|
placeholder="Objet du message"
|
||||||
value={sujet}
|
value={sujet}
|
||||||
onChange={(e) => setSujet(e.target.value)}
|
onChange={(e) => setSujet(e.target.value)}
|
||||||
required
|
required
|
||||||
className="mt-2"
|
className="w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="message">Message *</Label>
|
<label htmlFor="message" className="block mb-2">Message *</label>
|
||||||
<Textarea
|
<InputTextarea
|
||||||
id="message"
|
id="message"
|
||||||
placeholder="Tapez votre message ici..."
|
placeholder="Tapez votre message ici..."
|
||||||
value={message}
|
value={message}
|
||||||
onChange={(e) => setMessage(e.target.value)}
|
onChange={(e) => setMessage(e.target.value)}
|
||||||
required
|
required
|
||||||
rows={12}
|
rows={12}
|
||||||
className="mt-2"
|
className="w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label>Pièces jointes</Label>
|
<label className="block mb-2">Pièces jointes</label>
|
||||||
<div className="mt-2 space-y-2">
|
<div className="space-y-2">
|
||||||
{fichiers.map((file, index) => (
|
{fichiers.map((file, index) => (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
className="flex items-center gap-2 p-2 bg-gray-50 rounded"
|
className="flex items-center gap-2 p-2 bg-gray-50 rounded"
|
||||||
>
|
>
|
||||||
<Paperclip className="h-4 w-4 text-gray-400" />
|
<i className="pi pi-paperclip text-gray-400"></i>
|
||||||
<span className="text-sm flex-1">{file.name}</span>
|
<span className="text-sm flex-1">{file.name}</span>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="ghost"
|
text
|
||||||
size="sm"
|
size="small"
|
||||||
onClick={() => removeFile(index)}
|
onClick={() => removeFile(index)}
|
||||||
>
|
>
|
||||||
<X className="h-4 w-4" />
|
<i className="pi pi-times"></i>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -130,10 +128,10 @@ export default function NouveauMessagePage() {
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
outlined
|
||||||
onClick={() => document.getElementById("file-upload")?.click()}
|
onClick={() => document.getElementById("file-upload")?.click()}
|
||||||
>
|
>
|
||||||
<Paperclip className="mr-2 h-4 w-4" />
|
<i className="pi pi-paperclip mr-2"></i>
|
||||||
Ajouter une pièce jointe
|
Ajouter une pièce jointe
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -145,11 +143,11 @@ export default function NouveauMessagePage() {
|
|||||||
className="bg-blue-600 hover:bg-blue-700"
|
className="bg-blue-600 hover:bg-blue-700"
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
>
|
>
|
||||||
<Send className="mr-2 h-4 w-4" />
|
<i className="pi pi-send mr-2"></i>
|
||||||
{isSubmitting ? "Envoi en cours..." : "Envoyer"}
|
{isSubmitting ? "Envoi en cours..." : "Envoyer"}
|
||||||
</Button>
|
</Button>
|
||||||
<Link href="/messages">
|
<Link href="/messages">
|
||||||
<Button type="button" variant="outline">
|
<Button type="button" outlined>
|
||||||
Annuler
|
Annuler
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,23 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "primereact/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "primereact/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { InputText } from "primereact/inputtext";
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import {
|
|
||||||
Mail,
|
|
||||||
Search,
|
|
||||||
Send,
|
|
||||||
Archive,
|
|
||||||
Star,
|
|
||||||
Trash2,
|
|
||||||
Reply,
|
|
||||||
Forward,
|
|
||||||
MoreVertical,
|
|
||||||
Paperclip,
|
|
||||||
Clock,
|
|
||||||
} from "lucide-react";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +120,7 @@ export default function MessagesPage() {
|
|||||||
</div>
|
</div>
|
||||||
<Link href="/messages/nouveau">
|
<Link href="/messages/nouveau">
|
||||||
<Button className="bg-blue-600 hover:bg-blue-700">
|
<Button className="bg-blue-600 hover:bg-blue-700">
|
||||||
<Send className="mr-2 h-4 w-4" />
|
<i className="pi pi-send mr-2"></i>
|
||||||
Nouveau message
|
Nouveau message
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -143,20 +129,20 @@ export default function MessagesPage() {
|
|||||||
{/* Navigation */}
|
{/* Navigation */}
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Link href="/messages">
|
<Link href="/messages">
|
||||||
<Button variant="default" className="bg-blue-600">
|
<Button className="bg-blue-600">
|
||||||
<Mail className="mr-2 h-4 w-4" />
|
<i className="pi pi-envelope mr-2"></i>
|
||||||
Reçus
|
Reçus
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href="/messages/envoyes">
|
<Link href="/messages/envoyes">
|
||||||
<Button variant="outline">
|
<Button outlined>
|
||||||
<Send className="mr-2 h-4 w-4" />
|
<i className="pi pi-send mr-2"></i>
|
||||||
Envoyés
|
Envoyés
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href="/messages/archives">
|
<Link href="/messages/archives">
|
||||||
<Button variant="outline">
|
<Button outlined>
|
||||||
<Archive className="mr-2 h-4 w-4" />
|
<i className="pi pi-inbox mr-2"></i>
|
||||||
Archives
|
Archives
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -166,34 +152,34 @@ export default function MessagesPage() {
|
|||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
<div className="flex gap-4 flex-wrap">
|
<div className="flex gap-4 flex-wrap">
|
||||||
<div className="flex-1 min-w-[300px]">
|
<div className="flex-1 min-w-[300px]">
|
||||||
<div className="relative">
|
<span className="p-input-icon-left w-full">
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400" />
|
<i className="pi pi-search" />
|
||||||
<Input
|
<InputText
|
||||||
placeholder="Rechercher dans les messages..."
|
placeholder="Rechercher dans les messages..."
|
||||||
className="pl-10"
|
className="w-full"
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Button
|
<Button
|
||||||
variant={filterStatus === "all" ? "default" : "outline"}
|
outlined={filterStatus !== "all"}
|
||||||
onClick={() => setFilterStatus("all")}
|
onClick={() => setFilterStatus("all")}
|
||||||
>
|
>
|
||||||
Tous
|
Tous
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant={filterStatus === "unread" ? "default" : "outline"}
|
outlined={filterStatus !== "unread"}
|
||||||
onClick={() => setFilterStatus("unread")}
|
onClick={() => setFilterStatus("unread")}
|
||||||
>
|
>
|
||||||
Non lus ({unreadCount})
|
Non lus ({unreadCount})
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant={filterStatus === "starred" ? "default" : "outline"}
|
outlined={filterStatus !== "starred"}
|
||||||
onClick={() => setFilterStatus("starred")}
|
onClick={() => setFilterStatus("starred")}
|
||||||
>
|
>
|
||||||
<Star className="mr-1 h-4 w-4" />
|
<i className="pi pi-star mr-1"></i>
|
||||||
Favoris
|
Favoris
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -209,19 +195,19 @@ export default function MessagesPage() {
|
|||||||
sélectionné{selectedMessages.length > 1 ? "s" : ""}
|
sélectionné{selectedMessages.length > 1 ? "s" : ""}
|
||||||
</span>
|
</span>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
outlined
|
||||||
size="sm"
|
size="small"
|
||||||
onClick={() => setSelectedMessages([])}
|
onClick={() => setSelectedMessages([])}
|
||||||
>
|
>
|
||||||
Tout désélectionner
|
Tout désélectionner
|
||||||
</Button>
|
</Button>
|
||||||
<div className="flex-1" />
|
<div className="flex-1" />
|
||||||
<Button variant="outline" size="sm">
|
<Button outlined size="small">
|
||||||
<Archive className="mr-2 h-4 w-4" />
|
<i className="pi pi-inbox mr-2"></i>
|
||||||
Archiver
|
Archiver
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline" size="sm">
|
<Button outlined size="small">
|
||||||
<Trash2 className="mr-2 h-4 w-4" />
|
<i className="pi pi-trash mr-2"></i>
|
||||||
Supprimer
|
Supprimer
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -257,13 +243,14 @@ export default function MessagesPage() {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Star
|
<i
|
||||||
className={`h-5 w-5 ${
|
className={`pi ${
|
||||||
message.isStarred
|
message.isStarred
|
||||||
? "fill-yellow-400 text-yellow-400"
|
? "pi-star-fill text-yellow-400"
|
||||||
: "text-gray-400"
|
: "pi-star text-gray-400"
|
||||||
}`}
|
}`}
|
||||||
/>
|
style={{ fontSize: '1.25rem' }}
|
||||||
|
></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{/* Contenu du message */}
|
{/* Contenu du message */}
|
||||||
@@ -279,7 +266,7 @@ export default function MessagesPage() {
|
|||||||
{message.from}
|
{message.from}
|
||||||
</p>
|
</p>
|
||||||
{message.hasAttachment && (
|
{message.hasAttachment && (
|
||||||
<Paperclip className="h-4 w-4 text-gray-400" />
|
<i className="pi pi-paperclip text-gray-400"></i>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p
|
<p
|
||||||
@@ -303,7 +290,7 @@ export default function MessagesPage() {
|
|||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
className="hover:bg-gray-200 rounded p-1"
|
className="hover:bg-gray-200 rounded p-1"
|
||||||
>
|
>
|
||||||
<MoreVertical className="h-4 w-4 text-gray-400" />
|
<i className="pi pi-ellipsis-v text-gray-400"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -313,7 +300,7 @@ export default function MessagesPage() {
|
|||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<div className="p-12 text-center">
|
<div className="p-12 text-center">
|
||||||
<Mail className="h-12 w-12 text-gray-400 mx-auto mb-4" />
|
<i className="pi pi-envelope text-gray-400 mx-auto mb-4" style={{ fontSize: '3rem' }}></i>
|
||||||
<p className="text-gray-500">Aucun message trouvé</p>
|
<p className="text-gray-500">Aucun message trouvé</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -325,7 +312,7 @@ export default function MessagesPage() {
|
|||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<div className="p-3 bg-blue-100 rounded-lg">
|
<div className="p-3 bg-blue-100 rounded-lg">
|
||||||
<Mail className="h-6 w-6 text-blue-600" />
|
<i className="pi pi-envelope text-blue-600" style={{ fontSize: '1.5rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-2xl font-bold">{messages.length}</p>
|
<p className="text-2xl font-bold">{messages.length}</p>
|
||||||
@@ -336,7 +323,7 @@ export default function MessagesPage() {
|
|||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<div className="p-3 bg-orange-100 rounded-lg">
|
<div className="p-3 bg-orange-100 rounded-lg">
|
||||||
<Clock className="h-6 w-6 text-orange-600" />
|
<i className="pi pi-clock text-orange-600" style={{ fontSize: '1.5rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-2xl font-bold">{unreadCount}</p>
|
<p className="text-2xl font-bold">{unreadCount}</p>
|
||||||
@@ -347,7 +334,7 @@ export default function MessagesPage() {
|
|||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<div className="p-3 bg-yellow-100 rounded-lg">
|
<div className="p-3 bg-yellow-100 rounded-lg">
|
||||||
<Star className="h-6 w-6 text-yellow-600" />
|
<i className="pi pi-star text-yellow-600" style={{ fontSize: '1.5rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-2xl font-bold">
|
<p className="text-2xl font-bold">
|
||||||
@@ -360,7 +347,7 @@ export default function MessagesPage() {
|
|||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<div className="p-3 bg-green-100 rounded-lg">
|
<div className="p-3 bg-green-100 rounded-lg">
|
||||||
<Send className="h-6 w-6 text-green-600" />
|
<i className="pi pi-send text-green-600" style={{ fontSize: '1.5rem' }}></i>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-2xl font-bold">12</p>
|
<p className="text-2xl font-bold">12</p>
|
||||||
|
|||||||
@@ -351,6 +351,7 @@ const FournisseursPage = () => {
|
|||||||
globalFilter={globalFilter}
|
globalFilter={globalFilter}
|
||||||
selection={selectedFournisseurs}
|
selection={selectedFournisseurs}
|
||||||
onSelectionChange={(e) => setSelectedFournisseurs(e.value)}
|
onSelectionChange={(e) => setSelectedFournisseurs(e.value)}
|
||||||
|
selectionMode="multiple"
|
||||||
dataKey="id"
|
dataKey="id"
|
||||||
emptyMessage="Aucun fournisseur trouvé"
|
emptyMessage="Aucun fournisseur trouvé"
|
||||||
className="p-datatable-sm"
|
className="p-datatable-sm"
|
||||||
@@ -501,7 +502,7 @@ const FournisseursPage = () => {
|
|||||||
<InputText
|
<InputText
|
||||||
id="delaiLivraison"
|
id="delaiLivraison"
|
||||||
type="number"
|
type="number"
|
||||||
value={formData.delaiLivraison}
|
value={formData.delaiLivraison.toString()}
|
||||||
onChange={(e) => setFormData({ ...formData, delaiLivraison: parseInt(e.target.value) || 0 })}
|
onChange={(e) => setFormData({ ...formData, delaiLivraison: parseInt(e.target.value) || 0 })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
29
app/api/auth/login/route.ts
Normal file
29
app/api/auth/login/route.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
const KEYCLOAK_URL = process.env.NEXT_PUBLIC_KEYCLOAK_URL || 'https://security.lions.dev';
|
||||||
|
const KEYCLOAK_REALM = process.env.NEXT_PUBLIC_KEYCLOAK_REALM || 'btpxpress';
|
||||||
|
const CLIENT_ID = process.env.NEXT_PUBLIC_KEYCLOAK_CLIENT_ID || 'btpxpress-frontend';
|
||||||
|
const REDIRECT_URI = process.env.NEXT_PUBLIC_APP_URL
|
||||||
|
? `${process.env.NEXT_PUBLIC_APP_URL}/auth/callback`
|
||||||
|
: 'https://btpxpress.lions.dev/auth/callback';
|
||||||
|
|
||||||
|
export async function GET(request: NextRequest) {
|
||||||
|
console.log('🔐 Login API called');
|
||||||
|
|
||||||
|
// Générer un state aléatoire pour CSRF protection
|
||||||
|
const state = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
||||||
|
|
||||||
|
// Construire l'URL d'autorisation Keycloak
|
||||||
|
const authUrl = new URL(`${KEYCLOAK_URL}/realms/${KEYCLOAK_REALM}/protocol/openid-connect/auth`);
|
||||||
|
|
||||||
|
authUrl.searchParams.set('client_id', CLIENT_ID);
|
||||||
|
authUrl.searchParams.set('redirect_uri', REDIRECT_URI);
|
||||||
|
authUrl.searchParams.set('response_type', 'code');
|
||||||
|
authUrl.searchParams.set('scope', 'openid profile email');
|
||||||
|
authUrl.searchParams.set('state', state);
|
||||||
|
|
||||||
|
console.log('✅ Redirecting to Keycloak:', authUrl.toString());
|
||||||
|
|
||||||
|
// Rediriger vers Keycloak pour l'authentification
|
||||||
|
return NextResponse.redirect(authUrl.toString());
|
||||||
|
}
|
||||||
48
app/api/auth/logout/route.ts
Normal file
48
app/api/auth/logout/route.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
import { cookies } from 'next/headers';
|
||||||
|
|
||||||
|
const KEYCLOAK_URL = process.env.NEXT_PUBLIC_KEYCLOAK_URL || 'https://security.lions.dev';
|
||||||
|
const KEYCLOAK_REALM = process.env.NEXT_PUBLIC_KEYCLOAK_REALM || 'btpxpress';
|
||||||
|
const CLIENT_ID = process.env.NEXT_PUBLIC_KEYCLOAK_CLIENT_ID || 'btpxpress-frontend';
|
||||||
|
const POST_LOGOUT_REDIRECT_URI = process.env.NEXT_PUBLIC_APP_URL || 'https://btpxpress.lions.dev';
|
||||||
|
|
||||||
|
export async function GET(request: NextRequest) {
|
||||||
|
console.log('🚪 Logout API called');
|
||||||
|
|
||||||
|
const cookieStore = cookies();
|
||||||
|
|
||||||
|
// Récupérer l'id_token avant de supprimer les cookies
|
||||||
|
const idToken = cookieStore.get('id_token')?.value;
|
||||||
|
|
||||||
|
// Supprimer tous les cookies d'authentification
|
||||||
|
cookieStore.delete('access_token');
|
||||||
|
cookieStore.delete('refresh_token');
|
||||||
|
cookieStore.delete('id_token');
|
||||||
|
cookieStore.delete('token_expires_at');
|
||||||
|
|
||||||
|
console.log('✅ Authentication cookies deleted');
|
||||||
|
|
||||||
|
// Si on a un id_token, on fait un logout Keycloak
|
||||||
|
if (idToken) {
|
||||||
|
const logoutUrl = new URL(
|
||||||
|
`${KEYCLOAK_URL}/realms/${KEYCLOAK_REALM}/protocol/openid-connect/logout`
|
||||||
|
);
|
||||||
|
|
||||||
|
logoutUrl.searchParams.set('client_id', CLIENT_ID);
|
||||||
|
logoutUrl.searchParams.set('post_logout_redirect_uri', POST_LOGOUT_REDIRECT_URI);
|
||||||
|
logoutUrl.searchParams.set('id_token_hint', idToken);
|
||||||
|
|
||||||
|
console.log('✅ Redirecting to Keycloak logout');
|
||||||
|
|
||||||
|
return NextResponse.redirect(logoutUrl.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sinon, rediriger directement vers la page d'accueil
|
||||||
|
console.log('✅ Redirecting to home page');
|
||||||
|
return NextResponse.redirect(POST_LOGOUT_REDIRECT_URI);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function POST(request: NextRequest) {
|
||||||
|
// Même logique pour POST
|
||||||
|
return GET(request);
|
||||||
|
}
|
||||||
138
app/api/auth/token/route.ts
Normal file
138
app/api/auth/token/route.ts
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
import { cookies } from 'next/headers';
|
||||||
|
|
||||||
|
const KEYCLOAK_URL = process.env.NEXT_PUBLIC_KEYCLOAK_URL || 'https://security.lions.dev';
|
||||||
|
const KEYCLOAK_REALM = process.env.NEXT_PUBLIC_KEYCLOAK_REALM || 'btpxpress';
|
||||||
|
const CLIENT_ID = process.env.NEXT_PUBLIC_KEYCLOAK_CLIENT_ID || 'btpxpress-frontend';
|
||||||
|
const REDIRECT_URI = process.env.NEXT_PUBLIC_APP_URL
|
||||||
|
? `${process.env.NEXT_PUBLIC_APP_URL}/auth/callback`
|
||||||
|
: 'https://btpxpress.lions.dev/auth/callback';
|
||||||
|
|
||||||
|
const TOKEN_ENDPOINT = `${KEYCLOAK_URL}/realms/${KEYCLOAK_REALM}/protocol/openid-connect/token`;
|
||||||
|
|
||||||
|
export async function POST(request: NextRequest) {
|
||||||
|
console.log('🔐 Token exchange API called');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const body = await request.json();
|
||||||
|
const { code, state } = body;
|
||||||
|
|
||||||
|
if (!code) {
|
||||||
|
console.error('❌ No authorization code provided');
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'Code d\'autorisation manquant' },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('✅ Exchanging code with Keycloak...');
|
||||||
|
console.log('📍 Token endpoint:', TOKEN_ENDPOINT);
|
||||||
|
console.log('📍 Client ID:', CLIENT_ID);
|
||||||
|
console.log('📍 Redirect URI:', REDIRECT_URI);
|
||||||
|
|
||||||
|
// Préparer les paramètres pour l'échange de code
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
grant_type: 'authorization_code',
|
||||||
|
client_id: CLIENT_ID,
|
||||||
|
code: code,
|
||||||
|
redirect_uri: REDIRECT_URI,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Échanger le code contre des tokens
|
||||||
|
const tokenResponse = await fetch(TOKEN_ENDPOINT, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
body: params.toString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!tokenResponse.ok) {
|
||||||
|
const errorText = await tokenResponse.text();
|
||||||
|
console.error('❌ Keycloak token exchange failed:', tokenResponse.status, errorText);
|
||||||
|
|
||||||
|
let errorData;
|
||||||
|
try {
|
||||||
|
errorData = JSON.parse(errorText);
|
||||||
|
} catch {
|
||||||
|
errorData = { error: 'Token exchange failed', details: errorText };
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
error: errorData.error || 'Échec de l\'échange de token',
|
||||||
|
error_description: errorData.error_description || 'Erreur lors de la communication avec Keycloak',
|
||||||
|
details: errorData
|
||||||
|
},
|
||||||
|
{ status: tokenResponse.status }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const tokens = await tokenResponse.json();
|
||||||
|
console.log('✅ Tokens received from Keycloak');
|
||||||
|
|
||||||
|
// Stocker les tokens dans des cookies HttpOnly sécurisés
|
||||||
|
const cookieStore = cookies();
|
||||||
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
|
// Access token (durée: expires_in secondes)
|
||||||
|
cookieStore.set('access_token', tokens.access_token, {
|
||||||
|
httpOnly: true,
|
||||||
|
secure: isProduction,
|
||||||
|
sameSite: 'lax',
|
||||||
|
maxAge: tokens.expires_in || 300, // Par défaut 5 minutes
|
||||||
|
path: '/',
|
||||||
|
});
|
||||||
|
|
||||||
|
// Refresh token (durée plus longue)
|
||||||
|
if (tokens.refresh_token) {
|
||||||
|
cookieStore.set('refresh_token', tokens.refresh_token, {
|
||||||
|
httpOnly: true,
|
||||||
|
secure: isProduction,
|
||||||
|
sameSite: 'lax',
|
||||||
|
maxAge: tokens.refresh_expires_in || 1800, // Par défaut 30 minutes
|
||||||
|
path: '/',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID token
|
||||||
|
if (tokens.id_token) {
|
||||||
|
cookieStore.set('id_token', tokens.id_token, {
|
||||||
|
httpOnly: true,
|
||||||
|
secure: isProduction,
|
||||||
|
sameSite: 'lax',
|
||||||
|
maxAge: tokens.expires_in || 300,
|
||||||
|
path: '/',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stocker aussi le temps d'expiration
|
||||||
|
cookieStore.set('token_expires_at', String(Date.now() + (tokens.expires_in * 1000)), {
|
||||||
|
httpOnly: true,
|
||||||
|
secure: isProduction,
|
||||||
|
sameSite: 'lax',
|
||||||
|
maxAge: tokens.expires_in || 300,
|
||||||
|
path: '/',
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('✅ Tokens stored in HttpOnly cookies');
|
||||||
|
|
||||||
|
// Retourner une réponse de succès (sans les tokens)
|
||||||
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
message: 'Authentification réussie',
|
||||||
|
expires_in: tokens.expires_in,
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ Error in token exchange API:', error);
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
error: 'Erreur serveur',
|
||||||
|
message: error instanceof Error ? error.message : 'Erreur inconnue'
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
82
app/api/auth/userinfo/route.ts
Normal file
82
app/api/auth/userinfo/route.ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
import { cookies } from 'next/headers';
|
||||||
|
|
||||||
|
const KEYCLOAK_URL = process.env.NEXT_PUBLIC_KEYCLOAK_URL || 'https://security.lions.dev';
|
||||||
|
const KEYCLOAK_REALM = process.env.NEXT_PUBLIC_KEYCLOAK_REALM || 'btpxpress';
|
||||||
|
|
||||||
|
const USERINFO_ENDPOINT = `${KEYCLOAK_URL}/realms/${KEYCLOAK_REALM}/protocol/openid-connect/userinfo`;
|
||||||
|
|
||||||
|
export async function GET(request: NextRequest) {
|
||||||
|
console.log('👤 Userinfo API called');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cookieStore = cookies();
|
||||||
|
const accessToken = cookieStore.get('access_token')?.value;
|
||||||
|
|
||||||
|
if (!accessToken) {
|
||||||
|
console.error('❌ No access token found');
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'Non authentifié', authenticated: false },
|
||||||
|
{ status: 401 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('✅ Access token found, fetching user info from Keycloak');
|
||||||
|
|
||||||
|
// Récupérer les informations utilisateur depuis Keycloak
|
||||||
|
const userinfoResponse = await fetch(USERINFO_ENDPOINT, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${accessToken}`,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!userinfoResponse.ok) {
|
||||||
|
const errorText = await userinfoResponse.text();
|
||||||
|
console.error('❌ Keycloak userinfo failed:', userinfoResponse.status, errorText);
|
||||||
|
|
||||||
|
// Si le token est invalide ou expiré
|
||||||
|
if (userinfoResponse.status === 401) {
|
||||||
|
// Supprimer les cookies invalides
|
||||||
|
cookieStore.delete('access_token');
|
||||||
|
cookieStore.delete('refresh_token');
|
||||||
|
cookieStore.delete('id_token');
|
||||||
|
cookieStore.delete('token_expires_at');
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: 'Token expiré ou invalide', authenticated: false },
|
||||||
|
{ status: 401 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
error: 'Erreur lors de la récupération des informations utilisateur',
|
||||||
|
authenticated: false
|
||||||
|
},
|
||||||
|
{ status: userinfoResponse.status }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const userinfo = await userinfoResponse.json();
|
||||||
|
console.log('✅ User info retrieved:', userinfo.preferred_username || userinfo.sub);
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
authenticated: true,
|
||||||
|
user: userinfo,
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ Error in userinfo API:', error);
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
error: 'Erreur serveur',
|
||||||
|
authenticated: false,
|
||||||
|
message: error instanceof Error ? error.message : 'Erreur inconnue'
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
70
app/auth/login/page.tsx
Normal file
70
app/auth/login/page.tsx
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import { useSearchParams } from 'next/navigation';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { Card } from 'primereact/card';
|
||||||
|
|
||||||
|
export default function LoginPage() {
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const returnUrl = searchParams.get('returnUrl') || '/dashboard';
|
||||||
|
|
||||||
|
const handleLogin = () => {
|
||||||
|
// Stocker l'URL de retour dans le sessionStorage
|
||||||
|
if (returnUrl) {
|
||||||
|
sessionStorage.setItem('returnUrl', returnUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rediriger vers l'API de login qui initiera le flux OAuth
|
||||||
|
window.location.href = '/api/auth/login';
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen flex align-items-center justify-content-center" style={{
|
||||||
|
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
|
||||||
|
}}>
|
||||||
|
<div className="surface-card p-4 shadow-2 border-round w-full lg:w-6">
|
||||||
|
<div className="text-center mb-5">
|
||||||
|
<div className="text-900 text-3xl font-medium mb-3">
|
||||||
|
BTP Xpress
|
||||||
|
</div>
|
||||||
|
<span className="text-600 font-medium line-height-3">
|
||||||
|
Plateforme de gestion pour le secteur du BTP
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<div className="text-center">
|
||||||
|
<i className="pi pi-lock text-6xl text-primary mb-4"></i>
|
||||||
|
<h2 className="text-900 font-bold text-2xl mb-2">
|
||||||
|
Connexion requise
|
||||||
|
</h2>
|
||||||
|
<p className="text-600 mb-4">
|
||||||
|
Veuillez vous connecter pour accéder à l'application
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
label="Se connecter avec Keycloak"
|
||||||
|
icon="pi pi-sign-in"
|
||||||
|
onClick={handleLogin}
|
||||||
|
className="w-full p-3 text-xl"
|
||||||
|
severity="info"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="mt-4 text-center">
|
||||||
|
<span className="text-600 text-sm">
|
||||||
|
Authentification sécurisée via Keycloak OAuth 2.0
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<div className="mt-5 text-center">
|
||||||
|
<span className="text-white-alpha-80 text-sm">
|
||||||
|
© 2025 BTP Xpress - Tous droits réservés
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
102
middleware.ts
102
middleware.ts
@@ -1,25 +1,97 @@
|
|||||||
/**
|
/**
|
||||||
* Middleware Next.js simplifié
|
* Middleware Next.js pour l'authentification OAuth avec Keycloak
|
||||||
*
|
*
|
||||||
* L'authentification est entièrement gérée par le backend Quarkus avec Keycloak OIDC.
|
* Ce middleware protège les routes privées en vérifiant la présence
|
||||||
* Le middleware frontend laisse passer toutes les requêtes.
|
* d'un access_token dans les cookies HttpOnly.
|
||||||
*
|
|
||||||
* Flux d'authentification:
|
|
||||||
* 1. User accède à une page protégée du frontend (ex: /dashboard)
|
|
||||||
* 2. Frontend appelle l'API backend (ex: http://localhost:8080/api/v1/dashboard)
|
|
||||||
* 3. Backend détecte absence de session -> redirige vers Keycloak (security.lions.dev)
|
|
||||||
* 4. User se connecte sur Keycloak
|
|
||||||
* 5. Keycloak redirige vers le backend avec le code OAuth
|
|
||||||
* 6. Backend échange le code, crée une session, renvoie un cookie
|
|
||||||
* 7. Frontend reçoit le cookie et peut maintenant appeler l'API
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
import type { NextRequest } from 'next/server';
|
import type { NextRequest } from 'next/server';
|
||||||
|
|
||||||
|
// Routes publiques accessibles sans authentification
|
||||||
|
const PUBLIC_ROUTES = [
|
||||||
|
'/',
|
||||||
|
'/auth/login',
|
||||||
|
'/auth/callback',
|
||||||
|
'/api/auth/login',
|
||||||
|
'/api/auth/callback',
|
||||||
|
'/api/auth/token',
|
||||||
|
'/api/health',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Routes API publiques (patterns)
|
||||||
|
const PUBLIC_API_PATTERNS = [
|
||||||
|
/^\/api\/auth\/.*/,
|
||||||
|
/^\/api\/health/,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Vérifie si une route est publique
|
||||||
|
function isPublicRoute(pathname: string): boolean {
|
||||||
|
// Vérifier les routes exactes
|
||||||
|
if (PUBLIC_ROUTES.includes(pathname)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vérifier les patterns
|
||||||
|
return PUBLIC_API_PATTERNS.some(pattern => pattern.test(pathname));
|
||||||
|
}
|
||||||
|
|
||||||
export function middleware(request: NextRequest) {
|
export function middleware(request: NextRequest) {
|
||||||
// Le middleware ne fait plus rien - l'authentification est gérée par le backend
|
const { pathname } = request.nextUrl;
|
||||||
// Toutes les requêtes sont autorisées côté frontend
|
|
||||||
|
console.log('🔒 Middleware - Checking:', pathname);
|
||||||
|
|
||||||
|
// Laisser passer les routes publiques
|
||||||
|
if (isPublicRoute(pathname)) {
|
||||||
|
console.log('✅ Middleware - Public route, allowing');
|
||||||
|
return NextResponse.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Laisser passer les fichiers statiques
|
||||||
|
if (
|
||||||
|
pathname.startsWith('/_next') ||
|
||||||
|
pathname.startsWith('/static') ||
|
||||||
|
pathname.includes('.')
|
||||||
|
) {
|
||||||
|
return NextResponse.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vérifier la présence du token d'authentification
|
||||||
|
const accessToken = request.cookies.get('access_token');
|
||||||
|
const tokenExpiresAt = request.cookies.get('token_expires_at');
|
||||||
|
|
||||||
|
if (!accessToken) {
|
||||||
|
console.log('❌ Middleware - No access token, redirecting to login');
|
||||||
|
|
||||||
|
// Rediriger vers la page de login avec l'URL de retour
|
||||||
|
const loginUrl = new URL('/auth/login', request.url);
|
||||||
|
loginUrl.searchParams.set('returnUrl', pathname);
|
||||||
|
|
||||||
|
return NextResponse.redirect(loginUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vérifier si le token est expiré
|
||||||
|
if (tokenExpiresAt) {
|
||||||
|
const expiresAt = parseInt(tokenExpiresAt.value, 10);
|
||||||
|
const now = Date.now();
|
||||||
|
|
||||||
|
if (now >= expiresAt) {
|
||||||
|
console.log('❌ Middleware - Token expired, redirecting to login');
|
||||||
|
|
||||||
|
// Supprimer les cookies expirés
|
||||||
|
const response = NextResponse.redirect(new URL('/auth/login', request.url));
|
||||||
|
response.cookies.delete('access_token');
|
||||||
|
response.cookies.delete('refresh_token');
|
||||||
|
response.cookies.delete('id_token');
|
||||||
|
response.cookies.delete('token_expires_at');
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('✅ Middleware - Authenticated, allowing');
|
||||||
|
|
||||||
|
// L'utilisateur est authentifié, laisser passer
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +105,6 @@ export const config = {
|
|||||||
* - favicon.ico (favicon file)
|
* - favicon.ico (favicon file)
|
||||||
* - public files (images, etc.)
|
* - public files (images, etc.)
|
||||||
*/
|
*/
|
||||||
'/((?!_next/static|_next/image|favicon.ico|.*\..*|public).*)',
|
'/((?!_next/static|_next/image|favicon.ico|.*\\..*|public).*)',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
62
package-lock.json
generated
62
package-lock.json
generated
@@ -8,7 +8,7 @@
|
|||||||
"name": "btpxpress-client",
|
"name": "btpxpress-client",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fullcalendar/core": "6.1.4",
|
"@fullcalendar/core": "^6.1.19",
|
||||||
"@fullcalendar/daygrid": "^6.1.4",
|
"@fullcalendar/daygrid": "^6.1.4",
|
||||||
"@fullcalendar/interaction": "^6.1.4",
|
"@fullcalendar/interaction": "^6.1.4",
|
||||||
"@fullcalendar/react": "^6.1.4",
|
"@fullcalendar/react": "^6.1.4",
|
||||||
@@ -116,12 +116,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@fullcalendar/core": {
|
"node_modules/@fullcalendar/core": {
|
||||||
"version": "6.1.4",
|
"version": "6.1.19",
|
||||||
"resolved": "https://registry.npmjs.org/@fullcalendar/core/-/core-6.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/@fullcalendar/core/-/core-6.1.19.tgz",
|
||||||
"integrity": "sha512-ZDD0Owv0LezAk14nsRNaOc9nbowItGmT0mnjOhEw+L6B8P5eads8yYaNA9itn70MWoOjiAG8xqD7Yk1iJGxqgQ==",
|
"integrity": "sha512-z0aVlO5e4Wah6p6mouM0UEqtRf1MZZPt4mwzEyU6kusaNL+dlWQgAasF2cK23hwT4cmxkEmr4inULXgpyeExdQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"preact": "^10.0.5"
|
"preact": "~10.12.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@fullcalendar/core/node_modules/preact": {
|
||||||
|
"version": "10.12.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/preact/-/preact-10.12.1.tgz",
|
||||||
|
"integrity": "sha512-l8386ixSsBdbreOAkqtrwqHwdvR35ID8c3rKPa8lCWuO86dBi32QWHV4vfsZK1utLLFMvw+Z5Ad4XLkZzchscg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/preact"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@fullcalendar/daygrid": {
|
"node_modules/@fullcalendar/daygrid": {
|
||||||
@@ -2114,7 +2124,7 @@
|
|||||||
"version": "4.0.3",
|
"version": "4.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
|
||||||
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
|
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
|
||||||
"dev": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"readdirp": "^4.0.1"
|
"readdirp": "^4.0.1"
|
||||||
@@ -3749,7 +3759,7 @@
|
|||||||
"version": "5.1.4",
|
"version": "5.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.4.tgz",
|
||||||
"integrity": "sha512-p6u1bG3YSnINT5RQmx/yRZBpenIl30kVxkTLDyHLIMk0gict704Q9n+thfDI7lTRm9vXdDYutVzXhzcThxTnXA==",
|
"integrity": "sha512-p6u1bG3YSnINT5RQmx/yRZBpenIl30kVxkTLDyHLIMk0gict704Q9n+thfDI7lTRm9vXdDYutVzXhzcThxTnXA==",
|
||||||
"dev": true,
|
"devOptional": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/import-fresh": {
|
"node_modules/import-fresh": {
|
||||||
@@ -4515,6 +4525,19 @@
|
|||||||
"node": ">=8.6"
|
"node": ">=8.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/micromatch/node_modules/picomatch": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mime-db": {
|
"node_modules/mime-db": {
|
||||||
"version": "1.52.0",
|
"version": "1.52.0",
|
||||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||||
@@ -5051,13 +5074,13 @@
|
|||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/picomatch": {
|
"node_modules/picomatch": {
|
||||||
"version": "2.3.1",
|
"version": "4.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
|
||||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.6"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
@@ -5324,7 +5347,7 @@
|
|||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
||||||
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
|
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
|
||||||
"dev": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 14.18.0"
|
"node": ">= 14.18.0"
|
||||||
@@ -5543,7 +5566,7 @@
|
|||||||
"version": "1.93.2",
|
"version": "1.93.2",
|
||||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.93.2.tgz",
|
"resolved": "https://registry.npmjs.org/sass/-/sass-1.93.2.tgz",
|
||||||
"integrity": "sha512-t+YPtOQHpGW1QWsh1CHQ5cPIr9lbbGZLZnbihP/D/qZj/yuV68m8qarcV17nvkOX81BCrvzAlq2klCQFZghyTg==",
|
"integrity": "sha512-t+YPtOQHpGW1QWsh1CHQ5cPIr9lbbGZLZnbihP/D/qZj/yuV68m8qarcV17nvkOX81BCrvzAlq2klCQFZghyTg==",
|
||||||
"dev": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chokidar": "^4.0.0",
|
"chokidar": "^4.0.0",
|
||||||
@@ -6044,19 +6067,6 @@
|
|||||||
"url": "https://github.com/sponsors/SuperchupuDev"
|
"url": "https://github.com/sponsors/SuperchupuDev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tinyglobby/node_modules/picomatch": {
|
|
||||||
"version": "4.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
|
|
||||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/to-regex-range": {
|
"node_modules/to-regex-range": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"lint": "next lint"
|
"lint": "next lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fullcalendar/core": "^6.1.4",
|
"@fullcalendar/core": "^6.1.19",
|
||||||
"@fullcalendar/daygrid": "^6.1.4",
|
"@fullcalendar/daygrid": "^6.1.4",
|
||||||
"@fullcalendar/interaction": "^6.1.4",
|
"@fullcalendar/interaction": "^6.1.4",
|
||||||
"@fullcalendar/react": "^6.1.4",
|
"@fullcalendar/react": "^6.1.4",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { apiService } from './api';
|
import axios from 'axios';
|
||||||
|
import { API_CONFIG } from '../config/api';
|
||||||
|
|
||||||
export interface Fournisseur {
|
export interface Fournisseur {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -53,13 +54,30 @@ export interface UpdateFournisseurRequest {
|
|||||||
actif?: boolean;
|
actif?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const api = axios.create({
|
||||||
|
baseURL: API_CONFIG.baseURL,
|
||||||
|
timeout: API_CONFIG.timeout,
|
||||||
|
headers: API_CONFIG.headers,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Interceptor pour ajouter le token
|
||||||
|
api.interceptors.request.use((config) => {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
const accessToken = localStorage.getItem('accessToken');
|
||||||
|
if (accessToken) {
|
||||||
|
config.headers['Authorization'] = `Bearer ${accessToken}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
|
||||||
export class FournisseurService {
|
export class FournisseurService {
|
||||||
/**
|
/**
|
||||||
* Récupère tous les fournisseurs
|
* Récupère tous les fournisseurs
|
||||||
*/
|
*/
|
||||||
async getAllFournisseurs(): Promise<Fournisseur[]> {
|
async getAllFournisseurs(): Promise<Fournisseur[]> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get('/fournisseurs');
|
const response = await api.get('/api/v1/fournisseurs');
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération des fournisseurs:', error);
|
console.error('Erreur lors de la récupération des fournisseurs:', error);
|
||||||
@@ -72,7 +90,7 @@ export class FournisseurService {
|
|||||||
*/
|
*/
|
||||||
async getFournisseurById(id: string): Promise<Fournisseur> {
|
async getFournisseurById(id: string): Promise<Fournisseur> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get(`/fournisseurs/${id}`);
|
const response = await api.get(`/api/v1/fournisseurs/${id}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération du fournisseur:', error);
|
console.error('Erreur lors de la récupération du fournisseur:', error);
|
||||||
@@ -85,7 +103,7 @@ export class FournisseurService {
|
|||||||
*/
|
*/
|
||||||
async createFournisseur(fournisseurData: CreateFournisseurRequest): Promise<Fournisseur> {
|
async createFournisseur(fournisseurData: CreateFournisseurRequest): Promise<Fournisseur> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.post('/fournisseurs', fournisseurData);
|
const response = await api.post('/api/v1/fournisseurs', fournisseurData);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la création du fournisseur:', error);
|
console.error('Erreur lors de la création du fournisseur:', error);
|
||||||
@@ -98,7 +116,7 @@ export class FournisseurService {
|
|||||||
*/
|
*/
|
||||||
async updateFournisseur(id: string, fournisseurData: UpdateFournisseurRequest): Promise<Fournisseur> {
|
async updateFournisseur(id: string, fournisseurData: UpdateFournisseurRequest): Promise<Fournisseur> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.put(`/fournisseurs/${id}`, fournisseurData);
|
const response = await api.put(`/api/v1/fournisseurs/${id}`, fournisseurData);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la mise à jour du fournisseur:', error);
|
console.error('Erreur lors de la mise à jour du fournisseur:', error);
|
||||||
@@ -111,7 +129,7 @@ export class FournisseurService {
|
|||||||
*/
|
*/
|
||||||
async deleteFournisseur(id: string): Promise<void> {
|
async deleteFournisseur(id: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await apiService.delete(`/fournisseurs/${id}`);
|
await api.delete(`/api/v1/fournisseurs/${id}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la suppression du fournisseur:', error);
|
console.error('Erreur lors de la suppression du fournisseur:', error);
|
||||||
throw error;
|
throw error;
|
||||||
@@ -123,7 +141,7 @@ export class FournisseurService {
|
|||||||
*/
|
*/
|
||||||
async searchFournisseurs(searchTerm: string): Promise<Fournisseur[]> {
|
async searchFournisseurs(searchTerm: string): Promise<Fournisseur[]> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get(`/fournisseurs/search?q=${encodeURIComponent(searchTerm)}`);
|
const response = await api.get(`/api/v1/fournisseurs/search?q=${encodeURIComponent(searchTerm)}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la recherche des fournisseurs:', error);
|
console.error('Erreur lors de la recherche des fournisseurs:', error);
|
||||||
@@ -141,7 +159,7 @@ export class FournisseurService {
|
|||||||
parPays: Record<string, number>;
|
parPays: Record<string, number>;
|
||||||
}> {
|
}> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get('/fournisseurs/stats');
|
const response = await api.get('/api/v1/fournisseurs/stats');
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération des statistiques:', error);
|
console.error('Erreur lors de la récupération des statistiques:', error);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { apiService } from './api';
|
import axios from 'axios';
|
||||||
|
import { API_CONFIG } from '../config/api';
|
||||||
|
|
||||||
export interface Notification {
|
export interface Notification {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -27,13 +28,30 @@ export interface NotificationStats {
|
|||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const api = axios.create({
|
||||||
|
baseURL: API_CONFIG.baseURL,
|
||||||
|
timeout: API_CONFIG.timeout,
|
||||||
|
headers: API_CONFIG.headers,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Interceptor pour ajouter le token
|
||||||
|
api.interceptors.request.use((config) => {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
const accessToken = localStorage.getItem('accessToken');
|
||||||
|
if (accessToken) {
|
||||||
|
config.headers['Authorization'] = `Bearer ${accessToken}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
|
||||||
class NotificationService {
|
class NotificationService {
|
||||||
/**
|
/**
|
||||||
* Récupérer toutes les notifications
|
* Récupérer toutes les notifications
|
||||||
*/
|
*/
|
||||||
async getNotifications(): Promise<Notification[]> {
|
async getNotifications(): Promise<Notification[]> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get('/notifications');
|
const response = await api.get('/api/v1/notifications');
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération des notifications:', error);
|
console.error('Erreur lors de la récupération des notifications:', error);
|
||||||
@@ -46,7 +64,7 @@ class NotificationService {
|
|||||||
*/
|
*/
|
||||||
async getUnreadNotifications(): Promise<Notification[]> {
|
async getUnreadNotifications(): Promise<Notification[]> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get('/notifications/unread');
|
const response = await api.get('/api/v1/notifications/unread');
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération des notifications non lues:', error);
|
console.error('Erreur lors de la récupération des notifications non lues:', error);
|
||||||
@@ -59,7 +77,7 @@ class NotificationService {
|
|||||||
*/
|
*/
|
||||||
async markAsRead(notificationId: string): Promise<void> {
|
async markAsRead(notificationId: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await apiService.put(`/notifications/${notificationId}/read`);
|
await api.put(`/api/v1/notifications/${notificationId}/read`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors du marquage de la notification comme lue:', error);
|
console.error('Erreur lors du marquage de la notification comme lue:', error);
|
||||||
}
|
}
|
||||||
@@ -70,7 +88,7 @@ class NotificationService {
|
|||||||
*/
|
*/
|
||||||
async markAllAsRead(): Promise<void> {
|
async markAllAsRead(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await apiService.put('/notifications/mark-all-read');
|
await api.put('/api/v1/notifications/mark-all-read');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors du marquage de toutes les notifications comme lues:', error);
|
console.error('Erreur lors du marquage de toutes les notifications comme lues:', error);
|
||||||
}
|
}
|
||||||
@@ -81,7 +99,7 @@ class NotificationService {
|
|||||||
*/
|
*/
|
||||||
async createNotification(notification: Omit<Notification, 'id' | 'date'>): Promise<Notification> {
|
async createNotification(notification: Omit<Notification, 'id' | 'date'>): Promise<Notification> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.post('/notifications', notification);
|
const response = await api.post('/api/v1/notifications', notification);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la création de la notification:', error);
|
console.error('Erreur lors de la création de la notification:', error);
|
||||||
@@ -99,7 +117,7 @@ class NotificationService {
|
|||||||
*/
|
*/
|
||||||
async deleteNotification(notificationId: string): Promise<void> {
|
async deleteNotification(notificationId: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await apiService.delete(`/notifications/${notificationId}`);
|
await api.delete(`/api/v1/notifications/${notificationId}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la suppression de la notification:', error);
|
console.error('Erreur lors de la suppression de la notification:', error);
|
||||||
}
|
}
|
||||||
@@ -110,7 +128,7 @@ class NotificationService {
|
|||||||
*/
|
*/
|
||||||
async getNotificationStats(): Promise<NotificationStats> {
|
async getNotificationStats(): Promise<NotificationStats> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get('/notifications/stats');
|
const response = await api.get('/api/v1/notifications/stats');
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération des statistiques:', error);
|
console.error('Erreur lors de la récupération des statistiques:', error);
|
||||||
@@ -129,7 +147,7 @@ class NotificationService {
|
|||||||
roles?: string[];
|
roles?: string[];
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await apiService.post('/notifications/broadcast', notification);
|
await api.post('/api/v1/notifications/broadcast', notification);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la diffusion de la notification:', error);
|
console.error('Erreur lors de la diffusion de la notification:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { apiService } from './api';
|
import axios from 'axios';
|
||||||
|
import { API_CONFIG } from '../config/api';
|
||||||
import type { User } from '../types/auth';
|
import type { User } from '../types/auth';
|
||||||
import { UserRole } from '../types/auth';
|
import { UserRole } from '../types/auth';
|
||||||
|
|
||||||
@@ -37,13 +38,30 @@ interface UserActivity {
|
|||||||
details?: string;
|
details?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const api = axios.create({
|
||||||
|
baseURL: API_CONFIG.baseURL,
|
||||||
|
timeout: API_CONFIG.timeout,
|
||||||
|
headers: API_CONFIG.headers,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Interceptor pour ajouter le token
|
||||||
|
api.interceptors.request.use((config) => {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
const accessToken = localStorage.getItem('accessToken');
|
||||||
|
if (accessToken) {
|
||||||
|
config.headers['Authorization'] = `Bearer ${accessToken}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
|
||||||
class UserService {
|
class UserService {
|
||||||
/**
|
/**
|
||||||
* Récupérer tous les utilisateurs
|
* Récupérer tous les utilisateurs
|
||||||
*/
|
*/
|
||||||
async getAllUsers(): Promise<User[]> {
|
async getAllUsers(): Promise<User[]> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get('/users');
|
const response = await api.get('/api/v1/users');
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération des utilisateurs:', error);
|
console.error('Erreur lors de la récupération des utilisateurs:', error);
|
||||||
@@ -56,7 +74,7 @@ class UserService {
|
|||||||
*/
|
*/
|
||||||
async getUserById(id: string): Promise<User> {
|
async getUserById(id: string): Promise<User> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get(`/users/${id}`);
|
const response = await api.get(`/api/v1/users/${id}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération de l\'utilisateur:', error);
|
console.error('Erreur lors de la récupération de l\'utilisateur:', error);
|
||||||
@@ -72,7 +90,7 @@ class UserService {
|
|||||||
*/
|
*/
|
||||||
async createUser(userData: CreateUserRequest): Promise<User> {
|
async createUser(userData: CreateUserRequest): Promise<User> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.post('/users', userData);
|
const response = await api.post('/api/v1/users', userData);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la création de l\'utilisateur:', error);
|
console.error('Erreur lors de la création de l\'utilisateur:', error);
|
||||||
@@ -106,7 +124,7 @@ class UserService {
|
|||||||
*/
|
*/
|
||||||
async updateUser(id: string, userData: UpdateUserRequest): Promise<User> {
|
async updateUser(id: string, userData: UpdateUserRequest): Promise<User> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.put(`/users/${id}`, userData);
|
const response = await api.put(`/api/v1/users/${id}`, userData);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la mise à jour de l\'utilisateur:', error);
|
console.error('Erreur lors de la mise à jour de l\'utilisateur:', error);
|
||||||
@@ -120,7 +138,7 @@ class UserService {
|
|||||||
*/
|
*/
|
||||||
async deleteUser(id: string): Promise<void> {
|
async deleteUser(id: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await apiService.delete(`/users/${id}`);
|
await api.delete(`/api/v1/users/${id}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la suppression de l\'utilisateur:', error);
|
console.error('Erreur lors de la suppression de l\'utilisateur:', error);
|
||||||
throw error;
|
throw error;
|
||||||
@@ -132,7 +150,7 @@ class UserService {
|
|||||||
*/
|
*/
|
||||||
async getGestionnaires(): Promise<User[]> {
|
async getGestionnaires(): Promise<User[]> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get('/users/gestionnaires');
|
const response = await api.get('/api/v1/users/gestionnaires');
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération des gestionnaires:', error);
|
console.error('Erreur lors de la récupération des gestionnaires:', error);
|
||||||
@@ -145,7 +163,7 @@ class UserService {
|
|||||||
*/
|
*/
|
||||||
async getUserStats(): Promise<UserStats> {
|
async getUserStats(): Promise<UserStats> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get('/users/stats');
|
const response = await api.get('/api/v1/users/stats');
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération des statistiques:', error);
|
console.error('Erreur lors de la récupération des statistiques:', error);
|
||||||
@@ -158,7 +176,7 @@ class UserService {
|
|||||||
*/
|
*/
|
||||||
async getUserActivity(): Promise<UserActivity[]> {
|
async getUserActivity(): Promise<UserActivity[]> {
|
||||||
try {
|
try {
|
||||||
const response = await apiService.get('/users/activity');
|
const response = await api.get('/api/v1/users/activity');
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération de l\'activité:', error);
|
console.error('Erreur lors de la récupération de l\'activité:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user