101 lines
3.6 KiB
HTML
101 lines
3.6 KiB
HTML
<!doctype html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
|
<title>IntegraRepara — Registro</title>
|
|
<style>
|
|
body{font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;margin:0;background:#f6f7fb}
|
|
.wrap{max-width:520px;margin:40px auto;padding:0 16px}
|
|
.card{background:#fff;border:1px solid #eee;border-radius:18px;padding:18px;box-shadow:0 10px 30px rgba(0,0,0,.05)}
|
|
h1{margin:0 0 6px;font-size:22px}
|
|
.muted{color:#666;font-size:14px;margin:0 0 14px}
|
|
label{display:block;font-size:13px;color:#444;margin:10px 0 6px}
|
|
input{width:100%;padding:12px;border-radius:12px;border:1px solid #ddd;font-size:15px}
|
|
button{width:100%;padding:12px;border-radius:12px;border:0;background:#111;color:#fff;font-size:15px;cursor:pointer;margin-top:14px}
|
|
.row{display:flex;gap:10px}
|
|
.row > div{flex:1}
|
|
.msg{margin-top:12px;background:#0b0b0b;color:#eaeaea;padding:12px;border-radius:12px;white-space:pre-wrap;overflow:auto}
|
|
a{color:#111}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="wrap">
|
|
<div class="card">
|
|
<h1>Crear cuenta</h1>
|
|
<p class="muted">Te mandamos un código por WhatsApp para activar tu cuenta.</p>
|
|
|
|
<label>URL API</label>
|
|
<input id="api" value="https://integrarepara-api.integrarepara.es"/>
|
|
|
|
<label>Nombre</label>
|
|
<input id="fullName" placeholder="Ej: Marsalva Servicios"/>
|
|
|
|
<div class="row">
|
|
<div>
|
|
<label>Teléfono (WhatsApp)</label>
|
|
<input id="phone" placeholder="Ej: 600123123 o +34600123123"/>
|
|
</div>
|
|
<div>
|
|
<label>DNI</label>
|
|
<input id="dni" placeholder="Ej: 12345678A"/>
|
|
</div>
|
|
</div>
|
|
|
|
<label>Dirección</label>
|
|
<input id="address" placeholder="Ej: Calle X, 12, Algeciras"/>
|
|
|
|
<label>Email</label>
|
|
<input id="email" placeholder="Ej: hola@tuempresa.com"/>
|
|
|
|
<label>Contraseña</label>
|
|
<input id="password" type="password" placeholder="Mínimo 8 caracteres"/>
|
|
|
|
<button id="btn">Crear cuenta y enviar código</button>
|
|
|
|
<div id="out" class="msg">{ "ready": true }</div>
|
|
<p class="muted">¿Ya tienes cuenta? <a href="/login.html">Entrar</a></p>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const out = document.getElementById("out");
|
|
const api = () => document.getElementById("api").value.replace(/\/$/,"");
|
|
|
|
function show(x){ out.textContent = typeof x==="string" ? x : JSON.stringify(x,null,2); }
|
|
|
|
async function post(path, body){
|
|
const res = await fetch(api()+path,{
|
|
method:"POST",
|
|
headers:{ "Content-Type":"application/json" },
|
|
body: JSON.stringify(body)
|
|
});
|
|
const text = await res.text();
|
|
let data; try{ data=JSON.parse(text);}catch{ data=text; }
|
|
if(!res.ok) throw { status:res.status, data };
|
|
return data;
|
|
}
|
|
|
|
document.getElementById("btn").onclick = async () => {
|
|
try{
|
|
show({loading:true});
|
|
const payload = {
|
|
fullName: document.getElementById("fullName").value,
|
|
phone: document.getElementById("phone").value,
|
|
address: document.getElementById("address").value,
|
|
dni: document.getElementById("dni").value,
|
|
email: document.getElementById("email").value,
|
|
password: document.getElementById("password").value
|
|
};
|
|
const r = await post("/auth/register", payload);
|
|
show(r);
|
|
// redirige a verificación
|
|
const phone = encodeURIComponent(r.phone || payload.phone);
|
|
window.location.href = `/verify.html?phone=${phone}&api=${encodeURIComponent(api())}`;
|
|
}catch(e){
|
|
show({error:true,...e});
|
|
}
|
|
};
|
|
</script>
|
|
</body>
|
|
</html> |