470 lignes
23 KiB
HTML
470 lignes
23 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
|
<title>Jobrunner — Espace projet</title>
|
|
<meta name="robots" content="noindex">
|
|
<link rel="icon" type="image/png" href="assets/img/logo.png">
|
|
<link rel="preload" href="assets/fonts/chillax-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin>
|
|
<link rel="preload" href="assets/fonts/chillax-latin-600-normal.woff2" as="font" type="font/woff2" crossorigin>
|
|
<link rel="stylesheet" href="assets/css/fonts.css">
|
|
<link rel="stylesheet" href="assets/css/espace.css">
|
|
</head>
|
|
<body>
|
|
|
|
<!-- ================= TABLEAU DE BORD ================= -->
|
|
<!-- Accès protégé côté serveur (Caddy, basic_auth sur jobrunner.fr) : aucun contrôle dans la page. -->
|
|
<div id="tableau">
|
|
<header class="entete">
|
|
<a class="marque" href="index.html"><img src="assets/img/logo.png" alt="Logo Jobrunner" width="30" height="30" style="object-fit:contain;">jobrunner</a>
|
|
<span class="espace">Espace projet</span>
|
|
<span class="vide"></span>
|
|
</header>
|
|
|
|
<main>
|
|
<div class="bonjour">
|
|
<h1>Bonjour 👋</h1>
|
|
<p>Tout le projet au même endroit : ce qui est prêt, et ce qui arrive.</p>
|
|
</div>
|
|
|
|
<section class="dispo">
|
|
<h2>Disponible <span class="compte">3</span></h2>
|
|
<div class="grille">
|
|
<a class="tuile" href="app.html">
|
|
<span class="ico"><svg viewBox="14 14 72 72" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="25" y="28" width="50" height="34" rx="4"/><path d="M19 62 H81 L79.5 67.5 C79 69.5 77.5 71 75.5 71 H24.5 C22.5 71 21 69.5 20.5 67.5 Z"/><path d="M45 41 L57 45 L45 49 Z" stroke-width="3.5"/></svg></span>
|
|
<div><h3>Site en démo</h3><p>La maquette du site, avec un compte de démonstration.</p></div>
|
|
<div class="bas"><span class="statut ok"><i></i>En ligne</span><span class="fleche">→</span></div>
|
|
</a>
|
|
<a class="tuile" href="charte.html">
|
|
<span class="ico"><svg viewBox="14 14 72 72" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M50 24 C33 24 22 36 22 50 C22 64 33 76 47 76 C52 76 53 72 51 69 C49 66 51 62 55 62 H62 C70 62 78 57 78 48 C78 34 66 24 50 24 Z"/><circle cx="36" cy="46" r="3.5"/><circle cx="46" cy="35" r="3.5"/><circle cx="60" cy="37" r="3.5"/><circle cx="67" cy="49" r="3.5"/></svg></span>
|
|
<div><h3>Charte graphique</h3><p>Couleurs, typographie, logo, icônes et animations.</p></div>
|
|
<div class="bas"><span class="statut ok"><i></i>v1.1</span><span class="fleche">→</span></div>
|
|
</a>
|
|
<a class="tuile" href="legal.html">
|
|
<span class="ico"><svg viewBox="14 14 72 72" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M30 22 H56 L70 36 V74 C70 76 68.5 78 66 78 H30 C28 78 26 76 26 74 V26 C26 24 28 22 30 22 Z"/><path d="M56 22 V36 H70"/><path d="M35 48 H60 M35 57 H60 M35 66 H50" stroke-width="3.5"/></svg></span>
|
|
<div><h3>CGU et documents légaux</h3><p>CGU, CGV, confidentialité, cookies et mentions légales.</p></div>
|
|
<div class="bas"><span class="statut chantier"><i></i>Brouillon</span><span class="fleche">→</span></div>
|
|
</a>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- ================= GESTION DE LA BÊTA (INSCRIPTIONS LIBRES & IP 13 MOIS) ================= -->
|
|
<section class="beta-zone">
|
|
<div class="beta-zone-entete">
|
|
<h2>Inscriptions & Accès Bêta <span class="compte" id="compte-total-testeurs">0</span></h2>
|
|
<a class="lien-externe" href="https://jobrunner.fr" target="_blank" rel="noopener">Ouvrir jobrunner.fr ↗</a>
|
|
</div>
|
|
|
|
<div class="carte-gestion-beta">
|
|
<!-- Bloc principal : Testeurs inscrits en direct -->
|
|
<div>
|
|
<div class="liste-codes-entete">
|
|
<div>
|
|
<h3 style="margin:0 0 4px;font-size:18px;">👥 Testeurs inscrits (accès libre)</h3>
|
|
<p style="margin:0;font-size:13.5px;color:var(--doux);">Tout utilisateur ayant rempli le formulaire reçoit un accès immédiat. Les adresses IP sont conservées 13 mois (obligation légale LCEN).</p>
|
|
</div>
|
|
<button type="button" id="btn-rafraichir-candidatures" class="btn-rafraichir" title="Actualiser">↻ Actualiser</button>
|
|
</div>
|
|
<div id="conteneur-tableau-candidatures" class="tableau-scroll" style="margin-top:16px;">
|
|
<p class="chargement">Chargement des testeurs...</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Bloc secondaire : Générateur de codes d'exception (manuel) -->
|
|
<div class="bloc-secondaire">
|
|
<details>
|
|
<summary style="cursor:pointer;font-weight:700;font-size:14.5px;color:var(--texte);outline:none;user-select:none;">
|
|
⚙️ Créer un code d'accès spécial (invitation manuelle / sans formulaire)
|
|
</summary>
|
|
<div style="margin-top:18px;">
|
|
<form id="form-creer-code" class="form-generateur" autocomplete="off">
|
|
<div class="ligne-form">
|
|
<div class="champ">
|
|
<label for="code-label">Nom ou référence</label>
|
|
<input type="text" id="code-label" placeholder="Ex. Partenaire Spécial">
|
|
</div>
|
|
<div class="champ">
|
|
<label for="code-duree">Validité</label>
|
|
<select id="code-duree">
|
|
<option value="30" selected>30 jours</option>
|
|
<option value="60">60 jours</option>
|
|
<option value="90">90 jours</option>
|
|
<option value="0">Illimitée</option>
|
|
</select>
|
|
</div>
|
|
<button type="submit" id="btn-soumettre-code" class="btn-creer">
|
|
<span>Créer le code</span>
|
|
<span aria-hidden="true">→</span>
|
|
</button>
|
|
</div>
|
|
<div id="code-erreur" class="alerte-erreur" style="display:none;"></div>
|
|
</form>
|
|
|
|
<!-- Encart du code généré -->
|
|
<div id="zone-nouveau-code" class="zone-nouveau-code" style="display:none;">
|
|
<div class="nouveau-code-entete">
|
|
<span class="badge-succes">✓ Code prêt à l'emploi</span>
|
|
<span id="label-cree-affiche" class="label-testeur"></span>
|
|
</div>
|
|
<div class="code-valeur-ligne">
|
|
<code id="code-genere-valeur" class="code-gros">JRB-XXXX-XXXX-XXXX</code>
|
|
<button type="button" id="btn-copier-code-seul" class="btn-copier">
|
|
<span>📋 Copier le code</span>
|
|
</button>
|
|
</div>
|
|
<div class="whatsapp-partage">
|
|
<div class="whatsapp-partage-titre">
|
|
<span>💬 Message d'invitation prêt à envoyer :</span>
|
|
<button type="button" id="btn-copier-msg" class="btn-copier-petit">
|
|
<span>Copier le message</span>
|
|
</button>
|
|
</div>
|
|
<textarea id="texte-msg-whatsapp" readonly rows="3" class="whatsapp-champ"></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Historique des codes manuels -->
|
|
<div class="historique-codes">
|
|
<div class="liste-codes-entete">
|
|
<h4>Codes d'accès manuels émis <span class="compte" id="compte-codes">0</span></h4>
|
|
<button type="button" id="btn-rafraichir-codes" class="btn-rafraichir" title="Actualiser">↻ Actualiser</button>
|
|
</div>
|
|
<div id="conteneur-tableau-codes" class="tableau-scroll">
|
|
<p class="chargement">Chargement des codes en cours...</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</details>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="construction">
|
|
<h2>En construction <span class="compte">5</span></h2>
|
|
<div class="grille petite">
|
|
<div class="tuile">
|
|
<span class="ico"><svg viewBox="14 14 72 72" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="25" y="28" width="50" height="34" rx="4"/><path d="M19 62 H81 L79.5 67.5 C79 69.5 77.5 71 75.5 71 H24.5 C22.5 71 21 69.5 20.5 67.5 Z"/><path d="M42 38 L36 45 L42 52 M58 38 L64 45 L58 52" stroke-width="3.5"/></svg></span>
|
|
<div><h3>Site fonctionnel de test</h3><p>Avec un vrai serveur et de vrais comptes.</p></div>
|
|
<div class="bas"><span class="statut chantier"><i></i>À venir</span></div>
|
|
<div class="barre"><span></span></div>
|
|
</div>
|
|
<div class="tuile">
|
|
<span class="ico"><svg viewBox="14 14 72 72" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="34" y="20" width="32" height="60" rx="7"/><path d="M46 72 H54"/><path d="M44 40 L39 46 L44 52 M56 40 L61 46 L56 52" stroke-width="3.5"/></svg></span>
|
|
<div><h3>APK fonctionnel de test</h3><p>L'application Android branchée sur le serveur de test.</p></div>
|
|
<div class="bas"><span class="statut chantier"><i></i>À venir</span></div>
|
|
<div class="barre"><span></span></div>
|
|
</div>
|
|
<div class="tuile">
|
|
<span class="ico"><svg viewBox="14 14 72 72" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="34" y="20" width="32" height="60" rx="7"/><path d="M46 72 H54"/><path d="M45 38 L58 46 L45 54 Z" stroke-width="3.5"/></svg></span>
|
|
<div><h3>APK démonstratif</h3><p>L'application Android avec des données de démonstration.</p></div>
|
|
<div class="bas"><span class="statut chantier"><i></i>À venir</span></div>
|
|
<div class="barre"><span></span></div>
|
|
</div>
|
|
<div class="tuile">
|
|
<span class="ico"><svg viewBox="14 14 72 72" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M26 34 H74 M26 50 H74 M26 66 H74"/><circle cx="40" cy="34" r="6" stroke-width="3.5"/><circle cx="60" cy="50" r="6" stroke-width="3.5"/><circle cx="34" cy="66" r="6" stroke-width="3.5"/></svg></span>
|
|
<div><h3>Admin panel</h3><p>Gestion de Jobrunner : comptes, annonces, signalements.</p></div>
|
|
<div class="bas"><span class="statut chantier"><i></i>À venir</span></div>
|
|
<div class="barre"><span></span></div>
|
|
</div>
|
|
<div class="tuile">
|
|
<span class="ico"><svg viewBox="14 14 72 72" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M50 32 C44 28 34 27 24 29 V70 C34 68 44 69 50 73 Z M50 32 C56 28 66 27 76 29 V70 C66 68 56 69 50 73"/></svg></span>
|
|
<div><h3>Documentation globale</h3><p>Le projet, la technique et les décisions, au même endroit.</p></div>
|
|
<div class="bas"><span class="statut chantier"><i></i>À venir</span></div>
|
|
<div class="barre"><span></span></div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
<footer>Jobrunner · espace projet réservé</footer>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
(function() {
|
|
const form = document.getElementById('form-creer-code');
|
|
const inputLabel = document.getElementById('code-label');
|
|
const selectDuree = document.getElementById('code-duree');
|
|
const btnSoumettre = document.getElementById('btn-soumettre-code');
|
|
const errBox = document.getElementById('code-erreur');
|
|
|
|
const zoneResultat = document.getElementById('zone-nouveau-code');
|
|
const labelAffiche = document.getElementById('label-cree-affiche');
|
|
const codeAffiche = document.getElementById('code-genere-valeur');
|
|
const btnCopierCode = document.getElementById('btn-copier-code-seul');
|
|
const btnCopierMsg = document.getElementById('btn-copier-msg');
|
|
const whatsappTexte = document.getElementById('texte-msg-whatsapp');
|
|
|
|
const conteneurTableauCodes = document.getElementById('conteneur-tableau-codes');
|
|
const btnRafraichirCodes = document.getElementById('btn-rafraichir-codes');
|
|
const compteCodesEl = document.getElementById('compte-codes');
|
|
|
|
const conteneurTableauCandidatures = document.getElementById('conteneur-tableau-candidatures');
|
|
const btnRafraichirCandidatures = document.getElementById('btn-rafraichir-candidatures');
|
|
const compteTotalTesteurs = document.getElementById('compte-total-testeurs');
|
|
|
|
let dernierCode = '';
|
|
|
|
function fmtDate(ts) {
|
|
if (!ts) return '-';
|
|
const d = new Date(ts * 1000);
|
|
return d.toLocaleDateString('fr-FR', { day: '2-digit', month: '2-digit', year: 'numeric' });
|
|
}
|
|
|
|
function fmtDateHeure(ts) {
|
|
if (!ts) return '-';
|
|
const d = new Date(ts * 1000);
|
|
return d.toLocaleDateString('fr-FR', { day: '2-digit', month: '2-digit', year: 'numeric' }) +
|
|
' à ' + d.toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' });
|
|
}
|
|
|
|
function escapeHtml(str) {
|
|
const div = document.createElement('div');
|
|
div.textContent = str || '';
|
|
return div.innerHTML;
|
|
}
|
|
|
|
function escapeJs(str) {
|
|
return (str || '').replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
}
|
|
|
|
// --- Gestion des testeurs inscrits (libre) ---
|
|
async function chargerTesteurs() {
|
|
try {
|
|
const res = await fetch('/_admin/api/candidatures/liste');
|
|
if (!res.ok) {
|
|
conteneurTableauCandidatures.innerHTML = '<p class="chargement" style="color:#A0554B;">Impossible de charger les inscrits (' + res.status + ').</p>';
|
|
return;
|
|
}
|
|
const data = await res.json();
|
|
afficherTableauTesteurs(data.candidatures || []);
|
|
} catch (e) {
|
|
conteneurTableauCandidatures.innerHTML = '<p class="chargement">Impossible de contacter le serveur.</p>';
|
|
}
|
|
}
|
|
|
|
function afficherTableauTesteurs(liste) {
|
|
if (compteTotalTesteurs) compteTotalTesteurs.textContent = liste.length;
|
|
if (!liste.length) {
|
|
conteneurTableauCandidatures.innerHTML = '<p class="chargement">Aucun testeur inscrit pour le moment. Partagez le lien <b>https://jobrunner.fr</b> !</p>';
|
|
return;
|
|
}
|
|
let html = '<table class="table-codes"><thead><tr>' +
|
|
'<th>Date</th><th>Testeur</th><th>Contact</th><th>IP (LCEN 13 mois)</th><th>Statut</th><th>Actions</th>' +
|
|
'</tr></thead><tbody>';
|
|
|
|
for (const item of liste) {
|
|
const ageBadge = item.mineur
|
|
? '<span class="badge-age mineur">15-17 ans (mineur)</span>'
|
|
: '<span class="badge-age">Majeur</span>';
|
|
const parentHtml = (item.mineur && item.parent_nom)
|
|
? '<span class="parent-info">Resp. légal : ' + escapeHtml(item.parent_nom) + ' (' + escapeHtml(item.parent_email || '') + ')</span>'
|
|
: '';
|
|
|
|
const ipAffichage = item.ip
|
|
? '<span class="badge-ip">' + escapeHtml(item.ip) + '</span>' +
|
|
(item.expire_ip_at ? '<span class="ip-purge-info">Purge le ' + fmtDate(item.expire_ip_at) + '</span>' : '')
|
|
: '<span style="color:var(--doux);font-size:12px;">Non renseignée</span>';
|
|
|
|
const statutBadge = item.actif
|
|
? '<span class="badge-statut actif">Actif</span>'
|
|
: '<span class="badge-statut revoque">Suspendu</span>';
|
|
|
|
const btnToggle = item.actif
|
|
? '<button type="button" class="btn-action-toggle suspendre" onclick="window.jobrunnerBeta.changerStatut(' + item.id + ', false, \'' + escapeJs(item.prenom + ' ' + item.nom) + '\')">Suspendre</button>'
|
|
: '<button type="button" class="btn-action-toggle reactiver" onclick="window.jobrunnerBeta.changerStatut(' + item.id + ', true, \'' + escapeJs(item.prenom + ' ' + item.nom) + '\')">Réactiver</button>';
|
|
|
|
html += '<tr>' +
|
|
'<td>' + fmtDateHeure(item.ts) + '</td>' +
|
|
'<td><strong>' + escapeHtml(item.prenom) + ' ' + escapeHtml(item.nom) + '</strong> ' + ageBadge + parentHtml + '</td>' +
|
|
'<td><div class="contact-ligne">' +
|
|
'<a href="mailto:' + escapeHtml(item.email) + '">' + escapeHtml(item.email) + '</a>' +
|
|
'<a href="tel:' + escapeHtml(item.tel) + '">' + escapeHtml(item.tel) + '</a>' +
|
|
'</div></td>' +
|
|
'<td>' + ipAffichage + '</td>' +
|
|
'<td>' + statutBadge + '</td>' +
|
|
'<td><div class="actions-cell">' +
|
|
btnToggle +
|
|
'<button type="button" class="btn-action-suppr" onclick="window.jobrunnerBeta.supprimerTesteur(' + item.id + ', \'' + escapeJs(item.prenom + ' ' + item.nom) + '\')">Supprimer</button>' +
|
|
'</div></td>' +
|
|
'</tr>';
|
|
}
|
|
html += '</tbody></table>';
|
|
conteneurTableauCandidatures.innerHTML = html;
|
|
}
|
|
|
|
// --- Actions globales exposées ---
|
|
window.jobrunnerBeta = {
|
|
changerStatut: async function(id, actif, nom) {
|
|
const action = actif ? 'réactiver' : 'suspendre';
|
|
if (!confirm('Voulez-vous ' + action + ' l\'accès de "' + nom + '" ?')) return;
|
|
try {
|
|
const res = await fetch('/_admin/api/testeurs/statut', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ id: id, actif: actif })
|
|
});
|
|
const data = await res.json().catch(() => ({}));
|
|
if (res.ok && data.ok) {
|
|
chargerTesteurs();
|
|
} else {
|
|
alert(data.erreur || 'Erreur lors du changement de statut.');
|
|
}
|
|
} catch (e) {
|
|
alert('Erreur réseau.');
|
|
}
|
|
},
|
|
supprimerTesteur: async function(id, nom) {
|
|
if (!confirm('Supprimer définitivement le compte et les données de "' + nom + '" ?')) return;
|
|
try {
|
|
const res = await fetch('/_admin/api/testeurs/supprimer', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ id: id })
|
|
});
|
|
const data = await res.json().catch(() => ({}));
|
|
if (res.ok && data.ok) {
|
|
chargerTesteurs();
|
|
} else {
|
|
alert(data.erreur || 'Erreur lors de la suppression.');
|
|
}
|
|
} catch (e) {
|
|
alert('Erreur réseau.');
|
|
}
|
|
},
|
|
supprimerCode: async function(id, label) {
|
|
if (!confirm('Supprimer définitivement le code de "' + label + '" ?')) return;
|
|
try {
|
|
const res = await fetch('/_admin/api/codes/supprimer', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ id: id })
|
|
});
|
|
const data = await res.json().catch(() => ({}));
|
|
if (res.ok && data.ok) {
|
|
chargerCodes();
|
|
} else {
|
|
alert(data.erreur || 'Erreur lors de la suppression.');
|
|
}
|
|
} catch (e) {
|
|
alert('Erreur réseau.');
|
|
}
|
|
}
|
|
};
|
|
|
|
// --- Gestion des codes d'exception ---
|
|
async function chargerCodes() {
|
|
try {
|
|
const res = await fetch('/_admin/api/codes/liste');
|
|
if (!res.ok) {
|
|
conteneurTableauCodes.innerHTML = '<p class="chargement" style="color:#A0554B;">Impossible de charger les codes (' + res.status + ').</p>';
|
|
return;
|
|
}
|
|
const data = await res.json();
|
|
afficherTableauCodes(data.codes || []);
|
|
} catch (e) {
|
|
conteneurTableauCodes.innerHTML = '<p class="chargement">Impossible de contacter le serveur.</p>';
|
|
}
|
|
}
|
|
|
|
function afficherTableauCodes(codes) {
|
|
if (compteCodesEl) compteCodesEl.textContent = codes.length;
|
|
if (!codes.length) {
|
|
conteneurTableauCodes.innerHTML = '<p class="chargement">Aucun code d\'exception émis.</p>';
|
|
return;
|
|
}
|
|
let html = '<table class="table-codes"><thead><tr><th>ID</th><th>Référence</th><th>Créé le</th><th>Expire</th><th>Utilisations</th><th>Statut</th><th>Action</th></tr></thead><tbody>';
|
|
for (const c of codes) {
|
|
const usesHtml = c.uses > 0
|
|
? '<span class="badge-usages actif">' + c.uses + ' connexion' + (c.uses > 1 ? 's' : '') + '</span>'
|
|
: '<span class="badge-usages">0</span>';
|
|
|
|
html += '<tr>' +
|
|
'<td>#' + c.id + '</td>' +
|
|
'<td><strong>' + escapeHtml(c.label) + '</strong></td>' +
|
|
'<td>' + fmtDate(c.created_at) + '</td>' +
|
|
'<td>' + (c.expires_at ? fmtDate(c.expires_at) : 'Illimité') + '</td>' +
|
|
'<td>' + usesHtml + '</td>' +
|
|
'<td><span class="badge-statut ' + (c.status === 'actif' ? 'actif' : (c.status === 'révoqué' ? 'revoque' : 'expire')) + '">' + escapeHtml(c.status) + '</span></td>' +
|
|
'<td><button type="button" class="btn-action-suppr" onclick="window.jobrunnerBeta.supprimerCode(' + c.id + ', \'' + escapeJs(c.label) + '\')">Supprimer</button></td>' +
|
|
'</tr>';
|
|
}
|
|
html += '</tbody></table>';
|
|
conteneurTableauCodes.innerHTML = html;
|
|
}
|
|
|
|
form.addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
errBox.style.display = 'none';
|
|
errBox.textContent = '';
|
|
|
|
const label = inputLabel.value.trim();
|
|
const jours = parseInt(selectDuree.value, 10);
|
|
|
|
if (!label) {
|
|
errBox.textContent = 'Veuillez saisir un nom ou référence.';
|
|
errBox.style.display = 'block';
|
|
return;
|
|
}
|
|
|
|
btnSoumettre.disabled = true;
|
|
btnSoumettre.querySelector('span').textContent = 'Génération...';
|
|
|
|
try {
|
|
const res = await fetch('/_admin/api/codes/creer', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ label: label, jours: jours })
|
|
});
|
|
const data = await res.json().catch(() => ({}));
|
|
|
|
if (res.ok && data.ok) {
|
|
dernierCode = data.code;
|
|
labelAffiche.textContent = data.label;
|
|
codeAffiche.textContent = data.code;
|
|
|
|
const msg = "Salut " + label + " ! Voici ton accès spécial pour tester JobRunner en avant-première : " + data.code + "\n\nRendez-vous sur https://jobrunner.fr pour te connecter.";
|
|
whatsappTexte.value = msg;
|
|
|
|
zoneResultat.style.display = 'block';
|
|
inputLabel.value = '';
|
|
chargerCodes();
|
|
} else {
|
|
errBox.textContent = data.erreur || 'Erreur lors de la création du code.';
|
|
errBox.style.display = 'block';
|
|
}
|
|
} catch (err) {
|
|
errBox.textContent = 'Erreur réseau.';
|
|
errBox.style.display = 'block';
|
|
} finally {
|
|
btnSoumettre.disabled = false;
|
|
btnSoumettre.querySelector('span').textContent = 'Créer le code';
|
|
}
|
|
});
|
|
|
|
btnCopierCode.addEventListener('click', function() {
|
|
if (!dernierCode) return;
|
|
navigator.clipboard.writeText(dernierCode).then(() => {
|
|
const span = btnCopierCode.querySelector('span');
|
|
span.textContent = '✓ Code copié !';
|
|
setTimeout(() => { span.textContent = '📋 Copier le code'; }, 2000);
|
|
});
|
|
});
|
|
|
|
btnCopierMsg.addEventListener('click', function() {
|
|
navigator.clipboard.writeText(whatsappTexte.value).then(() => {
|
|
const span = btnCopierMsg.querySelector('span');
|
|
span.textContent = '✓ Message copié !';
|
|
setTimeout(() => { span.textContent = 'Copier le message'; }, 2000);
|
|
});
|
|
});
|
|
|
|
btnRafraichirCodes.addEventListener('click', chargerCodes);
|
|
btnRafraichirCandidatures.addEventListener('click', chargerTesteurs);
|
|
|
|
chargerTesteurs();
|
|
chargerCodes();
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html> |