diff --git a/src/layouts/DashboardLayout.tsx b/src/layouts/DashboardLayout.tsx index be60f9e..1827a1c 100644 --- a/src/layouts/DashboardLayout.tsx +++ b/src/layouts/DashboardLayout.tsx @@ -1,4 +1,27 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; +import { pb } from '../config/pocketbase'; + +interface User { + id: string; + email: string; + emailVisibility: boolean; + verified: boolean; + name: string; + role: string; + company: string; + mfa_enabled: boolean; + created: string; + updated: string +} + +interface Company { + id: string; + name: string; + no: string; + vip_level: string; + created: string; + updated: string +} // Définition stricte des propriétés attendues par le Layout interface DashboardLayoutProps { @@ -9,6 +32,27 @@ interface DashboardLayoutProps { } export default function DashboardLayout({ children, activeView, onNavigate, onLogout }: DashboardLayoutProps) { + const [user, setUser] = useState(null); + const [company, setCompany] = useState(null); + const [isLoading, setIsLoading] = useState(true); + + const fetchInformations = async () => { + setIsLoading(true); + try { + const userRecords = await pb.collection('aegis_users').getFullList(); + setUser(userRecords[0]); + const companyRecords = await pb.collection('aegis_companies').getFullList(); + setCompany(companyRecords[0]) + } catch (error) { + console.error("Erreur lors de la récupération des infos utilisateur :", error); + } finally { + setIsLoading(false); + } + }; + + useEffect(()=>{ + fetchInformations(); + },[]); const navItems = [ { id: 'dashboard', label: 'Tableau de bord', icon: ( @@ -66,10 +110,14 @@ export default function DashboardLayout({ children, activeView, onNavigate, onLo }`} >
- DC + {isLoading? "":user?.name.split(" ").map((n)=>n[0]).join("")}
-

Direction Client

+ {isLoading? +

*

+ : +

{user?.name}

+ }

Paramètres du compte

diff --git a/src/pages/Account/AccountSettings.tsx b/src/pages/Account/AccountSettings.tsx index a0ca946..724dcbd 100644 --- a/src/pages/Account/AccountSettings.tsx +++ b/src/pages/Account/AccountSettings.tsx @@ -1,7 +1,62 @@ import { useState, useEffect } from 'react'; import { pb } from '../../config/pocketbase'; +interface User { + id: string; + email: string; + emailVisibility: boolean; + verified: boolean; + name: string; + role: string; + company: string; + mfa_enabled: boolean; + created: string; + updated: string +} + +interface Company { + id: string; + name: string; + no: string; + vip_level: string; + created: string; + updated: string +} + +function switchVip(vip_level:string | undefined){ + switch (vip_level?.toLowerCase()) { + case "platinum": + return {vip_level?.toUpperCase()}; + case "premium": + return {vip_level?.toUpperCase()}; + default: + return {vip_level?.toUpperCase()}; + } +} + export default function AccountSettings() { + const [user, setUser] = useState(null); + const [company, setCompany] = useState(null); + const [isLoading, setIsLoading] = useState(true); + + const fetchInformations = async () => { + setIsLoading(true); + try { + const userRecords = await pb.collection('aegis_users').getFullList(); + setUser(userRecords[0]); + const companyRecords = await pb.collection('aegis_companies').getFullList(); + setCompany(companyRecords[0]) + } catch (error) { + console.error("Erreur lors de la récupération des infos utilisateur :", error); + } finally { + setIsLoading(false); + } + }; + + useEffect(()=>{ + fetchInformations(); + },[]); + return (
@@ -17,6 +72,10 @@ export default function AccountSettings() { {/* Contenu Principal */}
+ {isLoading? +
+
+
:
@@ -35,10 +94,16 @@ export default function AccountSettings() {

Authentification à double facteur (MFA)

Exigée par les politiques de sécurité GISE

+ {user?.mfa_enabled? Actif + : + + + Inactif + }
@@ -46,7 +111,6 @@ export default function AccountSettings() { Générer de nouveaux codes de secours
- {/* Mot de passe */}

Mot de passe institutionnel

@@ -70,16 +134,20 @@ export default function AccountSettings() {
Entité Légale
-
Cabinet Juridique Example & Associés
+
{company?.name}
Administrateur du compte
-
Direction Générale (direction@example.com)
+
+ {user?.role} + {user?.name} +
+
{!user?.emailVisibility? user?.email : ""}
Niveau d'Infogérance (SLA)
- VIP PLATINUM + {switchVip(company?.vip_level)} Couverture 24/7 (99.99%)
@@ -87,7 +155,7 @@ export default function AccountSettings() {
- + } diff --git a/src/pages/Support/TicketDetail.tsx b/src/pages/Support/TicketDetail.tsx index e2aa06b..27c8349 100644 --- a/src/pages/Support/TicketDetail.tsx +++ b/src/pages/Support/TicketDetail.tsx @@ -39,6 +39,7 @@ export default function TicketDetail({ ticketId, onBack }: TicketDetailProps) { // Récupération du ticket et de ses messages associés const fetchTicketData = async () => { + setIsLoading(true); try { const ticketData = await pb.collection('aegis_tickets').getOne(ticketId); setTicket(ticketData);