update frontend
This commit is contained in:
parent
34414ebaca
commit
dc9498cc7a
|
|
@ -21,11 +21,11 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
const [showAuth, setShowAuth] = useState(false);
|
||||
const [mode, setMode] = useState("login"); // "login" | "signup"
|
||||
|
||||
// login
|
||||
// login form
|
||||
const [loginUser, setLoginUser] = useState("");
|
||||
const [loginPass, setLoginPass] = useState("");
|
||||
|
||||
// signup
|
||||
// signup form
|
||||
const [firstName, setFirstName] = useState("");
|
||||
const [lastName, setLastName] = useState("");
|
||||
const [regUser, setRegUser] = useState("");
|
||||
|
|
@ -46,12 +46,11 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
|
||||
const closeModal = () => {
|
||||
setShowAuth(false);
|
||||
// reset basique des champs
|
||||
setLoginPass("");
|
||||
setSignupError("");
|
||||
};
|
||||
|
||||
// 🔒 Quand on devient authentifié → fermer automatiquement le popup
|
||||
// When auth becomes true, close the popup automatically
|
||||
useEffect(() => {
|
||||
if (authenticated) {
|
||||
setShowAuth(false);
|
||||
|
|
@ -61,7 +60,7 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
const handleLoginSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
await login(loginUser, loginPass);
|
||||
// le useEffect ci-dessus va fermer le modal quand authenticated passe à true
|
||||
// popup closes via useEffect when authenticated becomes true
|
||||
};
|
||||
|
||||
const handleSignupSubmit = async (e) => {
|
||||
|
|
@ -74,7 +73,9 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
!regEmail.trim() ||
|
||||
!regPass
|
||||
) {
|
||||
setSignupError("Nom, prénom, user, email et mot de passe sont requis.");
|
||||
setSignupError(
|
||||
"First name, last name, username, email and password are required."
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
|
@ -86,12 +87,12 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
firstName: firstName.trim(),
|
||||
lastName: lastName.trim(),
|
||||
});
|
||||
// après création, on tente le login direct
|
||||
// auto-login after registration
|
||||
await login(regUser.trim(), regPass);
|
||||
// la fermeture est gérée aussi par le useEffect(authenticated)
|
||||
// popup closes via useEffect
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
setSignupError(err.message || "Register error.");
|
||||
setSignupError(err.message || "Registration error.");
|
||||
} finally {
|
||||
setSignupLoading(false);
|
||||
}
|
||||
|
|
@ -198,7 +199,7 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
{mode === "login" ? (
|
||||
<form className="auth-form" onSubmit={handleLoginSubmit}>
|
||||
<label>
|
||||
Nom d'utilisateur
|
||||
Username
|
||||
<input
|
||||
type="text"
|
||||
value={loginUser}
|
||||
|
|
@ -207,7 +208,7 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
/>
|
||||
</label>
|
||||
<label>
|
||||
Mot de passe
|
||||
Password
|
||||
<input
|
||||
type="password"
|
||||
value={loginPass}
|
||||
|
|
@ -220,14 +221,14 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
className="btn-primary btn-full"
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? "..." : "Se connecter"}
|
||||
{loading ? "..." : "Sign in"}
|
||||
</button>
|
||||
</form>
|
||||
) : (
|
||||
<form className="auth-form" onSubmit={handleSignupSubmit}>
|
||||
<div className="auth-row">
|
||||
<label>
|
||||
Prénom
|
||||
First name
|
||||
<input
|
||||
type="text"
|
||||
value={firstName}
|
||||
|
|
@ -235,7 +236,7 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
/>
|
||||
</label>
|
||||
<label>
|
||||
Nom
|
||||
Last name
|
||||
<input
|
||||
type="text"
|
||||
value={lastName}
|
||||
|
|
@ -244,7 +245,7 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
</label>
|
||||
</div>
|
||||
<label>
|
||||
Nom d'utilisateur
|
||||
Username
|
||||
<input
|
||||
type="text"
|
||||
value={regUser}
|
||||
|
|
@ -252,7 +253,7 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
/>
|
||||
</label>
|
||||
<label>
|
||||
Courriel
|
||||
Email
|
||||
<input
|
||||
type="email"
|
||||
value={regEmail}
|
||||
|
|
@ -260,7 +261,7 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
/>
|
||||
</label>
|
||||
<label>
|
||||
Mot de passe
|
||||
Password
|
||||
<input
|
||||
type="password"
|
||||
value={regPass}
|
||||
|
|
@ -277,7 +278,7 @@ export default function TopBar({ theme = "dark", onChangeTheme }) {
|
|||
className="btn-primary btn-full"
|
||||
disabled={signupLoading}
|
||||
>
|
||||
{signupLoading ? "..." : "Créer le compte"}
|
||||
{signupLoading ? "..." : "Create account"}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,144 +1,155 @@
|
|||
/* src/styles/auth-modal.css */
|
||||
/* ==========================================
|
||||
SocioWire auth modal (login / signup)
|
||||
Follows body[data-theme]: dark | blue | light
|
||||
========================================== */
|
||||
|
||||
/* BACKDROP sombre plein écran */
|
||||
.auth-modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 50;
|
||||
background: rgba(15, 23, 42, 0.88);
|
||||
z-index: 60;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(2, 6, 23, 0.65);
|
||||
backdrop-filter: blur(8px);
|
||||
}
|
||||
|
||||
/* BOÎTE MODAL */
|
||||
/* Base modal box */
|
||||
.auth-modal {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
background: rgba(15, 23, 42, 0.98);
|
||||
border-radius: 16px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.9);
|
||||
box-shadow:
|
||||
0 18px 40px rgba(0, 0, 0, 0.9),
|
||||
0 0 24px rgba(56, 189, 248, 0.55);
|
||||
padding: 0.75rem 0.9rem 0.9rem 0.9rem;
|
||||
color: #e5e7eb;
|
||||
width: min(640px, 95vw);
|
||||
border-radius: 22px;
|
||||
padding: 1.1rem 1.25rem 1.35rem;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
|
||||
border: 1px solid rgba(148, 163, 184, 0.7);
|
||||
}
|
||||
|
||||
/* HEADER TABS (Login / Sign up) */
|
||||
/* Theme variants */
|
||||
body[data-theme="dark"] .auth-modal {
|
||||
background: radial-gradient(circle at top left, #0f172a, #020617 70%);
|
||||
}
|
||||
|
||||
body[data-theme="blue"] .auth-modal {
|
||||
background: radial-gradient(circle at top left, #0ea5e9, #020617 65%);
|
||||
border-color: rgba(96, 165, 250, 0.9);
|
||||
}
|
||||
|
||||
body[data-theme="light"] .auth-modal {
|
||||
background: radial-gradient(circle at top left, #ffffff, #e5e7eb 70%);
|
||||
color: #020617;
|
||||
border-color: rgba(148, 163, 184, 0.7);
|
||||
}
|
||||
|
||||
/* Header: tabs + close */
|
||||
.auth-modal-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
margin-bottom: 0.6rem;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.9rem;
|
||||
}
|
||||
|
||||
.auth-tab {
|
||||
flex: 1;
|
||||
border: 1px solid rgba(75, 85, 99, 0.9);
|
||||
background: rgba(15, 23, 42, 0.95);
|
||||
color: #e5e7eb;
|
||||
padding: 0.45rem 0.95rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.8rem;
|
||||
padding: 0.35rem 0.4rem;
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
font-size: 0.85rem;
|
||||
color: #e5e7eb;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.auth-tab-active {
|
||||
background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
|
||||
border-color: #93c5fd;
|
||||
background: linear-gradient(135deg, #1d4ed8, #38bdf8);
|
||||
border-color: rgba(191, 219, 254, 0.9);
|
||||
color: #f9fafb;
|
||||
}
|
||||
|
||||
/* light theme override for tab text */
|
||||
body[data-theme="light"] .auth-tab {
|
||||
color: #0f172a;
|
||||
}
|
||||
body[data-theme="light"] .auth-tab-active {
|
||||
color: #f9fafb;
|
||||
box-shadow: 0 0 14px rgba(59, 130, 246, 0.7);
|
||||
}
|
||||
|
||||
/* Bouton X */
|
||||
.auth-close {
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #9ca3af;
|
||||
font-size: 0.9rem;
|
||||
padding: 0.1rem 0.3rem;
|
||||
margin-left: auto;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(148, 163, 184, 0.6);
|
||||
background: rgba(15, 23, 42, 0.85);
|
||||
color: #e5e7eb;
|
||||
font-size: 0.8rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* FORMULAIRE */
|
||||
/* Close button for light theme */
|
||||
body[data-theme="light"] .auth-close {
|
||||
background: #e5e7eb;
|
||||
color: #020617;
|
||||
}
|
||||
|
||||
/* Form layout */
|
||||
.auth-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.7rem;
|
||||
}
|
||||
|
||||
.auth-row {
|
||||
display: flex;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
.auth-row label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* Chaque label = colonne verticale */
|
||||
.auth-form label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2rem;
|
||||
font-size: 0.78rem;
|
||||
margin-bottom: 0.45rem;
|
||||
font-size: 0.8rem;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
/* CHAMPS TEXTE */
|
||||
/* Inputs */
|
||||
.auth-form input {
|
||||
border-radius: 999px;
|
||||
border: 1px solid #4b5563;
|
||||
padding: 0.38rem 0.7rem;
|
||||
background: #020617;
|
||||
border: 1px solid rgba(51, 65, 85, 0.9);
|
||||
background: rgba(15, 23, 42, 0.96);
|
||||
color: #e5e7eb;
|
||||
font-size: 0.8rem;
|
||||
outline: none;
|
||||
width: 100%;
|
||||
padding: 0.55rem 0.85rem;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.auth-form input:focus {
|
||||
border-color: #60a5fa;
|
||||
box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.7);
|
||||
/* Light theme inputs */
|
||||
body[data-theme="light"] .auth-form input {
|
||||
background: #f9fafb;
|
||||
color: #020617;
|
||||
border-color: rgba(148, 163, 184, 0.9);
|
||||
}
|
||||
|
||||
/* LIGNE PRÉNOM / NOM */
|
||||
.auth-row {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.3rem;
|
||||
}
|
||||
|
||||
/* Les deux labels prennent chacun 50% (moins le gap) */
|
||||
.auth-row label {
|
||||
flex: 1;
|
||||
min-width: 0; /* évite de dépasser le modal */
|
||||
}
|
||||
|
||||
/* MESSAGE D’ERREUR */
|
||||
.auth-error {
|
||||
margin-top: 0.25rem;
|
||||
font-size: 0.74rem;
|
||||
color: #fecaca;
|
||||
background: rgba(127, 29, 29, 0.35);
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.25rem 0.5rem;
|
||||
}
|
||||
|
||||
/* BOUTON FULL WIDTH */
|
||||
/* Full-width primary button */
|
||||
.btn-full {
|
||||
width: 100%;
|
||||
margin-top: 0.4rem;
|
||||
}
|
||||
|
||||
/* Petite variation visuelle pour Sign up si .btn-secondary non définie */
|
||||
.btn-secondary {
|
||||
padding: 0.25rem 0.7rem;
|
||||
font-size: 0.75rem;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #60a5fa;
|
||||
background: #0b1120;
|
||||
color: #dbeafe;
|
||||
cursor: pointer;
|
||||
/* Error message */
|
||||
.auth-error {
|
||||
margin-top: 0.25rem;
|
||||
font-size: 0.8rem;
|
||||
color: #fecaca;
|
||||
background: rgba(127, 29, 29, 0.55);
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.4rem 0.6rem;
|
||||
border: 1px solid rgba(248, 113, 113, 0.7);
|
||||
}
|
||||
|
||||
/* Responsive: sur petits écrans, Prénom/Nom se mettent l’un sous l’autre */
|
||||
/* Small screen tweaks */
|
||||
@media (max-width: 480px) {
|
||||
.auth-modal {
|
||||
margin: 0 0.7rem;
|
||||
padding: 0.95rem 0.9rem 1.1rem;
|
||||
}
|
||||
|
||||
.auth-row {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue