chore: update

This commit is contained in:
2026-03-03 23:42:23 +01:00
parent 52b059fafa
commit 0073f80a48
95 changed files with 2720 additions and 40619 deletions
@@ -0,0 +1,218 @@
.cp-container {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #09090b;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
overflow-y: auto;
}
.cp-content {
width: 100%;
max-width: 28rem;
}
.cp-header {
text-align: center;
margin-bottom: 2rem;
}
.cp-logo {
display: inline-flex;
align-items: center;
justify-content: center;
width: 4rem;
height: 4rem;
background: linear-gradient(135deg, #7c3aed, #6d28d9);
border-radius: 1rem;
margin-bottom: 1rem;
box-shadow: 0 10px 24px rgba(109, 40, 217, 0.45);
}
.cp-title {
font-size: 1.6rem;
font-weight: 700;
color: #f4f4f5;
margin-bottom: 0.5rem;
}
.cp-subtitle {
color: #71717a;
font-size: 0.9rem;
line-height: 1.5;
padding: 0 0.5rem;
}
.cp-card {
background-color: #111115;
border-radius: 1rem;
border: 1px solid rgba(255, 255, 255, 0.07);
box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
padding: 2rem;
}
.cp-form {
display: flex;
flex-direction: column;
gap: 1.25rem;
}
.cp-form-group {
display: flex;
flex-direction: column;
gap: 0.4rem;
}
.cp-label {
font-size: 0.875rem;
font-weight: 500;
color: #d1d5db;
}
.cp-input-wrapper {
position: relative;
}
.cp-input-icon {
position: absolute;
top: 50%;
left: 1rem;
transform: translateY(-50%);
pointer-events: none;
color: #52525b;
}
.cp-input {
width: 100%;
padding: 0.75rem 3rem 0.75rem 3rem;
background-color: #09090b;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 0.5rem;
color: #f4f4f5;
font-size: 1rem;
transition: border-color 0.2s, box-shadow 0.2s;
box-sizing: border-box;
}
.cp-input::placeholder {
color: #52525b;
}
.cp-input:focus {
outline: none;
border-color: #7c3aed;
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}
.cp-input-error {
border-color: #ef4444;
}
.cp-toggle {
position: absolute;
top: 50%;
right: 0.75rem;
transform: translateY(-50%);
background: transparent;
border: none;
color: #52525b;
cursor: pointer;
padding: 0.25rem;
display: flex;
align-items: center;
transition: color 0.2s;
}
.cp-toggle:hover {
color: #a1a1aa;
}
.cp-hint {
font-size: 0.78rem;
color: #71717a;
margin: 0;
}
.cp-error-msg {
font-size: 0.78rem;
color: #f87171;
margin: 0;
}
.cp-error-banner {
padding: 0.75rem 1rem;
background: rgba(239, 68, 68, 0.1);
border: 1px solid rgba(239, 68, 68, 0.25);
border-radius: 0.5rem;
color: #f87171;
font-size: 0.875rem;
}
.cp-submit {
width: 100%;
padding: 0.8rem 1rem;
background: linear-gradient(135deg, #7c3aed, #6d28d9);
color: #fff;
font-weight: 600;
font-size: 0.95rem;
border: none;
border-radius: 0.5rem;
cursor: pointer;
transition: opacity 0.2s, transform 0.1s;
box-shadow: 0 4px 16px rgba(109, 40, 217, 0.4);
margin-top: 0.25rem;
}
.cp-submit:hover:not(:disabled) {
opacity: 0.9;
}
.cp-submit:active:not(:disabled) {
transform: scale(0.98);
}
.cp-submit:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Success state */
.cp-success {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.75rem;
padding: 1.5rem 0;
text-align: center;
color: #f4f4f5;
}
.cp-success-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 3.5rem;
height: 3.5rem;
background: rgba(34, 197, 94, 0.15);
border: 2px solid rgba(34, 197, 94, 0.4);
border-radius: 50%;
font-size: 1.5rem;
color: #4ade80;
}
.cp-success p {
margin: 0;
font-weight: 600;
font-size: 1rem;
}
.cp-success-sub {
color: #71717a;
font-size: 0.85rem;
font-weight: 400 !important;
}
@@ -0,0 +1,190 @@
import { useState } from "react";
import { Lock, Eye, EyeOff, ShieldCheck } from "lucide-react";
import "./ChangePassword.css";
import { changePassword } from "../../api/api";
import { useNavigate } from "react-router-dom";
const ChangePasswordPage = () => {
const navigate = useNavigate();
const [currentPassword, setCurrentPassword] = useState("");
const [newPassword, setNewPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [showCurrent, setShowCurrent] = useState(false);
const [showNew, setShowNew] = useState(false);
const [showConfirm, setShowConfirm] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState("");
const [success, setSuccess] = useState(false);
const validate = (): string | null => {
if (!currentPassword) return "Le mot de passe actuel est requis";
if (!newPassword) return "Le nouveau mot de passe est requis";
if (newPassword.length < 8) return "Le nouveau mot de passe doit contenir au moins 8 caractères";
if (newPassword === currentPassword) return "Le nouveau mot de passe doit être différent de l'ancien";
if (newPassword !== confirmPassword) return "Les mots de passe ne correspondent pas";
return null;
};
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
setError("");
const validationError = validate();
if (validationError) {
setError(validationError);
return;
}
setIsLoading(true);
try {
const result = await changePassword(currentPassword, newPassword);
if (result.success) {
setSuccess(true);
setTimeout(() => navigate("/user/accueil"), 1800);
} else {
setError(result.message);
}
} finally {
setIsLoading(false);
}
};
return (
<div className="cp-container">
<div className="cp-content">
<div className="cp-header">
<div className="cp-logo">
<ShieldCheck className="w-8 h-8 text-white" />
</div>
<h1 className="cp-title">Changement de mot de passe</h1>
<p className="cp-subtitle">
Pour votre sécurité, veuillez définir un nouveau mot de passe
avant de continuer.
</p>
</div>
<div className="cp-card">
{success ? (
<div className="cp-success">
<span className="cp-success-icon"></span>
<p>Mot de passe mis à jour avec succès !</p>
<p className="cp-success-sub">Redirection en cours</p>
</div>
) : (
<form className="cp-form" onSubmit={handleSubmit}>
{error && (
<div className="cp-error-banner">
{error}
</div>
)}
{/* Mot de passe actuel */}
<div className="cp-form-group">
<label className="cp-label">Mot de passe actuel</label>
<div className="cp-input-wrapper">
<Lock className="cp-input-icon" style={{ width: "18px", height: "18px" }} />
<input
type={showCurrent ? "text" : "password"}
value={currentPassword}
onChange={(e) => { setCurrentPassword(e.target.value); setError(""); }}
className="cp-input"
placeholder="••••••••"
disabled={isLoading}
autoComplete="current-password"
/>
<button
type="button"
className="cp-toggle"
onClick={() => setShowCurrent((v) => !v)}
disabled={isLoading}
>
{showCurrent ? (
<EyeOff style={{ width: "18px", height: "18px" }} />
) : (
<Eye style={{ width: "18px", height: "18px" }} />
)}
</button>
</div>
</div>
{/* Nouveau mot de passe */}
<div className="cp-form-group">
<label className="cp-label">Nouveau mot de passe</label>
<div className="cp-input-wrapper">
<Lock className="cp-input-icon" style={{ width: "18px", height: "18px" }} />
<input
type={showNew ? "text" : "password"}
value={newPassword}
onChange={(e) => { setNewPassword(e.target.value); setError(""); }}
className="cp-input"
placeholder="Minimum 8 caractères"
disabled={isLoading}
autoComplete="new-password"
/>
<button
type="button"
className="cp-toggle"
onClick={() => setShowNew((v) => !v)}
disabled={isLoading}
>
{showNew ? (
<EyeOff style={{ width: "18px", height: "18px" }} />
) : (
<Eye style={{ width: "18px", height: "18px" }} />
)}
</button>
</div>
{newPassword.length > 0 && newPassword.length < 8 && (
<p className="cp-hint">Encore {8 - newPassword.length} caractère{8 - newPassword.length > 1 ? "s" : ""} minimum</p>
)}
</div>
{/* Confirmer */}
<div className="cp-form-group">
<label className="cp-label">Confirmer le nouveau mot de passe</label>
<div className="cp-input-wrapper">
<Lock className="cp-input-icon" style={{ width: "18px", height: "18px" }} />
<input
type={showConfirm ? "text" : "password"}
value={confirmPassword}
onChange={(e) => { setConfirmPassword(e.target.value); setError(""); }}
className={`cp-input ${confirmPassword && confirmPassword !== newPassword ? "cp-input-error" : ""}`}
placeholder="••••••••"
disabled={isLoading}
autoComplete="new-password"
/>
<button
type="button"
className="cp-toggle"
onClick={() => setShowConfirm((v) => !v)}
disabled={isLoading}
>
{showConfirm ? (
<EyeOff style={{ width: "18px", height: "18px" }} />
) : (
<Eye style={{ width: "18px", height: "18px" }} />
)}
</button>
</div>
{confirmPassword && confirmPassword !== newPassword && (
<p className="cp-error-msg">Les mots de passe ne correspondent pas</p>
)}
</div>
<button
type="submit"
className="cp-submit"
disabled={isLoading}
>
{isLoading ? "Mise à jour…" : "Confirmer le nouveau mot de passe"}
</button>
</form>
)}
</div>
</div>
</div>
);
};
export default ChangePasswordPage;