Reapply "V1_Sans_Congé_Anticipéfemini collaboratrice"

This reverts commit 7f15e380e3.
This commit is contained in:
2025-11-17 10:39:27 +01:00
parent f3a3746c3e
commit f22979a44a
41 changed files with 30347 additions and 2733 deletions

View File

@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useNavigate } from 'react-router-dom';
import { Building2, Mail, Lock, Eye, EyeOff, AlertTriangle } from 'lucide-react';
import { Building2, AlertTriangle } from 'lucide-react';
const Login = () => {
const [email, setEmail] = useState('');
@@ -9,10 +9,10 @@ const Login = () => {
const [showPassword, setShowPassword] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState('');
const [authMethod, setAuthMethod] = useState(''); // Pour tracker la méthode d'auth utilisée
const [authMethod, setAuthMethod] = useState('');
const navigate = useNavigate();
const { login, loginWithO365, isAuthorized } = useAuth();
const { login, loginWithO365 } = useAuth();
const handleSubmit = async (e) => {
e.preventDefault();
@@ -40,7 +40,6 @@ const Login = () => {
setAuthMethod('o365');
try {
// Étape 1 : Login O365
const success = await loginWithO365();
if (!success) {
@@ -49,30 +48,7 @@ const Login = () => {
return;
}
// Étape 2 : Récupération du token dauthentification (si ton context le fournit)
const token = localStorage.getItem("o365_token");
// ⚠️ Ici jimagine que tu stockes ton token quelque part (dans ton AuthContext ou localStorage).
// Adapte selon ton implémentation de loginWithO365
// Étape 3 : Appel de ton API PHP
const response = await fetch("http://localhost/GTA/project/public/php/initial-sync.php", {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json",
},
});
const data = await response.json();
console.log("Résultat syncGroups :", data);
if (!data.success) {
setError("Erreur de synchronisation des groupes : " + data.message);
setIsLoading(false);
return;
}
// Étape 4 : Redirection vers le dashboard
// Redirection vers le dashboard
navigate('/dashboard');
} catch (error) {
@@ -90,8 +66,8 @@ const Login = () => {
setIsLoading(false);
};
return (
<div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 flex flex-col lg:flex-row">
{/* Image côté gauche */}
<div className="h-32 lg:h-auto lg:flex lg:w-1/2 bg-cover bg-center"
@@ -105,17 +81,20 @@ const Login = () => {
<div className="max-w-md w-full">
<div className="bg-white rounded-2xl shadow-xl p-6 lg:p-8">
{/* Logo */}
<div className="text-center mb-6 lg:mb-8">
<div className="w-12 h-12 lg:w-16 lg:h-16 bg-cyan-600 rounded-2xl flex items-center justify-center mx-auto mb-4">
<Building2 className="w-6 h-6 lg:w-8 lg:h-8 text-white" />
</div>
<h1 className="text-xl lg:text-2xl font-bold text-gray-900">GTA</h1>
<p className="text-sm lg:text-base text-gray-600">Gestion de congés</p>
<div className="text-center mb-4">
<img
src="/assets/GA.svg"
alt="GTA Logo"
className="h-36 lg:h-40 w-auto mx-auto"
/>
<p className="text-lg lg:text-xl font-semibold mb-6" style={{ color: '#7e5aa2' }}>
GESTION DES TEMPS ET DES ACTIVITÉS
</p>
</div>
{/* Connexion Office 365 prioritaire */}
<div className="mb-6">
{/* Bouton Office 365 */}
<div>
<button
data-testid="o365-login-btn"
onClick={handleO365Login}
disabled={isLoading}
type="button"
@@ -134,42 +113,29 @@ const Login = () => {
</button>
</div>
{/* Formulaire classique */}
{/* Affichage des erreurs */}
{error && (
<div className="p-3 bg-red-50 border border-red-200 rounded-lg">
<div className="flex items-start space-x-2">
<AlertTriangle className="w-5 h-5 text-red-500 flex-shrink-0 mt-0.5" />
<div className="flex-1">
<p className="text-red-700 text-sm font-medium">
{error.includes('Accès refusé') ? 'Accès refusé' : 'Erreur de connexion'}
{/* Message d'erreur */}
{error && (
<div className="p-3 bg-red-50 border border-red-200 rounded-lg mt-4">
<div className="flex items-start space-x-2">
<AlertTriangle className="w-5 h-5 text-red-500 flex-shrink-0 mt-0.5" />
<div className="flex-1">
<p className="text-red-700 text-sm font-medium">
{error.includes('Accès refusé') ? 'Accès refusé' : 'Erreur de connexion'}
</p>
<p className="text-red-600 text-xs mt-1">{error}</p>
{error.includes('groupe autorisé') && (
<p className="text-red-600 text-xs mt-2">
Contactez votre administrateur pour être ajouté aux groupes appropriés.
</p>
<p className="text-red-600 text-xs mt-1">{error}</p>
{error.includes('groupe autorisé') && (
<p className="text-red-600 text-xs mt-2">
Contactez votre administrateur pour être ajouté aux groupes appropriés.
</p>
)}
</div>
)}
</div>
</div>
)}
{/* Info sur l'authentification */}
</div>
)}
</div>
</div>
</div>
</div>
</div>
);
};