site-mva-global-fret/setup-password.html
Serge RAKOTO HARRY-NAIVO af58c04776 feat(site): page setup-password.html pour bridge lead -> user
Compagnon de api PR #55 (bridge lead -> user).

Flow:
- Lead clique email setup compte
- Arrive sur /setup-password.html?token=XXX
- JS POST /auth/lookup-setup-token pre-remplit email + firstname + ref
- Form 2 password avec validation (min 8 majuscule chiffre)
- Submit POST /auth/setup-from-lead -> user cree + JWT
- Affiche success + lien vers application.html pour download app

Design: card centree, MVA gold/navy, mobile responsive, vanilla JS.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 22:31:36 +02:00

287 lines
8.7 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noindex, nofollow">
<title>Créez votre compte — MVA Global Fret</title>
<link rel="icon" type="image/png" href="PNG MVA GLOBAL FRET.png">
<style>
* { box-sizing: border-box; }
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 0;
background: linear-gradient(135deg, #1a1a3e 0%, #2d2d5e 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
}
.card {
background: #fff;
border-radius: 16px;
max-width: 480px;
width: 100%;
padding: 2.5rem 2rem;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.header {
text-align: center;
margin-bottom: 1.5rem;
}
.header .brand {
color: #c5a55a;
font-size: 22px;
font-weight: 700;
letter-spacing: 2px;
margin-bottom: 0.25rem;
}
.header .subtitle {
color: #7a7a8a;
font-size: 13px;
}
h1 {
color: #1a1a3e;
font-size: 1.5rem;
margin: 1.5rem 0 0.5rem;
text-align: center;
}
.ref-badge {
background: #f0ead8;
border-left: 4px solid #c5a55a;
padding: 12px 16px;
border-radius: 4px;
margin: 1rem 0 1.5rem;
font-size: 14px;
color: #1a1a3e;
}
.ref-badge strong { letter-spacing: 1px; }
label {
display: block;
color: #1a1a3e;
font-size: 13px;
font-weight: 600;
margin: 1rem 0 0.4rem;
}
input[type="email"], input[type="password"] {
width: 100%;
padding: 0.7rem 0.9rem;
border: 1px solid #d4d4d8;
border-radius: 8px;
font-size: 15px;
font-family: inherit;
}
input[disabled] { background: #f7f7f9; color: #6b6b75; cursor: not-allowed; }
input:focus { outline: none; border-color: #c5a55a; box-shadow: 0 0 0 3px rgba(197, 165, 90, 0.18); }
.hint {
color: #7a7a8a;
font-size: 12px;
margin-top: 0.35rem;
line-height: 1.4;
}
button {
width: 100%;
margin-top: 1.5rem;
padding: 0.85rem;
background: #c5a55a;
color: #1a1a3e;
border: 0;
border-radius: 50px;
font-size: 16px;
font-weight: 700;
cursor: pointer;
transition: background 0.15s;
}
button:hover:not(:disabled) { background: #b3954a; }
button:disabled { opacity: 0.6; cursor: wait; }
.alert {
padding: 0.85rem 1rem;
border-radius: 8px;
font-size: 14px;
margin: 1rem 0;
line-height: 1.5;
}
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.footer {
margin-top: 1.75rem;
text-align: center;
font-size: 12px;
color: #9ca3af;
}
.footer a { color: #c5a55a; text-decoration: none; }
.loading {
text-align: center;
padding: 2rem;
color: #7a7a8a;
}
.hidden { display: none; }
</style>
</head>
<body>
<div class="card">
<div class="header">
<div class="brand">MVA GLOBAL FRET</div>
<div class="subtitle">Fret Aérien Paris — Antananarivo</div>
</div>
<div id="loading" class="loading">Chargement du lien…</div>
<div id="error-state" class="hidden">
<h1>Lien invalide</h1>
<div id="error-message" class="alert alert-error"></div>
<p class="footer">
Si le problème persiste, contactez-nous via <a href="contact.html">la page contact</a>.
</p>
</div>
<div id="success-state" class="hidden">
<h1>Compte créé ✓</h1>
<div class="alert alert-success">
Votre compte MVA Global Fret a été créé avec succès.
Téléchargez l'application sur votre téléphone pour commander :
</div>
<p style="text-align:center;margin:1rem 0;">
<a href="application.html" style="color:#c5a55a;font-weight:600;text-decoration:none;">
📱 Télécharger l'application
</a>
</p>
</div>
<form id="setup-form" class="hidden" novalidate>
<h1>Créez votre compte</h1>
<p id="welcome-text" style="color:#1a1a3e;text-align:center;font-size:14px;margin-bottom:0;"></p>
<div id="ref-display" class="ref-badge hidden">
Référence client : <strong id="ref-value"></strong>
</div>
<label for="email-display">Email</label>
<input id="email-display" type="email" disabled>
<label for="password">Mot de passe</label>
<input id="password" type="password" autocomplete="new-password" required minlength="8" maxlength="72">
<div class="hint">Minimum 8 caractères, avec au moins une majuscule et un chiffre.</div>
<label for="password-confirm">Confirmer le mot de passe</label>
<input id="password-confirm" type="password" autocomplete="new-password" required>
<div id="form-error" class="alert alert-error hidden"></div>
<button type="submit" id="submit-btn">Créer mon compte</button>
<p class="footer">
En créant votre compte, vous acceptez nos <a href="cgv.html">CGV</a>
et notre <a href="politique-confidentialite.html">politique de confidentialité</a>.
</p>
</form>
</div>
<script>
(function() {
const API_BASE = "https://api.mva.mind4solutions.com";
const token = new URLSearchParams(window.location.search).get('token');
const $ = (id) => document.getElementById(id);
const show = (id) => $(id).classList.remove('hidden');
const hide = (id) => $(id).classList.add('hidden');
function showError(message) {
hide('loading');
hide('setup-form');
$('error-message').textContent = message;
show('error-state');
}
function showFormError(message) {
$('form-error').textContent = message;
show('form-error');
}
async function init() {
if (!token || token.length !== 64 || !/^[a-f0-9]+$/i.test(token)) {
showError("Lien invalide ou incomplet.");
return;
}
try {
const res = await fetch(API_BASE + "/auth/lookup-setup-token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ token }),
});
const data = await res.json();
if (!res.ok) {
showError(data.message || "Lien invalide.");
return;
}
$('email-display').value = data.email || '';
$('welcome-text').textContent = data.firstname
? `Bonjour ${data.firstname}, choisissez votre mot de passe pour activer votre compte.`
: "Choisissez votre mot de passe pour activer votre compte.";
if (data.reference_client) {
$('ref-value').textContent = data.reference_client;
show('ref-display');
}
hide('loading');
show('setup-form');
} catch (err) {
showError("Impossible de joindre le serveur. Vérifiez votre connexion.");
}
}
$('setup-form').addEventListener('submit', async (e) => {
e.preventDefault();
hide('form-error');
const password = $('password').value;
const confirm = $('password-confirm').value;
if (password.length < 8) {
showFormError("Le mot de passe doit contenir au moins 8 caractères.");
return;
}
if (!/[A-Z]/.test(password) || !/[0-9]/.test(password)) {
showFormError("Le mot de passe doit contenir au moins une majuscule et un chiffre.");
return;
}
if (password !== confirm) {
showFormError("Les deux mots de passe ne correspondent pas.");
return;
}
const btn = $('submit-btn');
btn.disabled = true;
btn.textContent = "Création en cours…";
try {
const res = await fetch(API_BASE + "/auth/setup-from-lead", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ token, password }),
});
const data = await res.json();
if (!res.ok) {
btn.disabled = false;
btn.textContent = "Créer mon compte";
showFormError(data.message || "Erreur lors de la création du compte.");
return;
}
hide('setup-form');
show('success-state');
} catch (err) {
btn.disabled = false;
btn.textContent = "Créer mon compte";
showFormError("Impossible de joindre le serveur. Réessayez dans un instant.");
}
});
init();
})();
</script>
</body>
</html>