diff --git a/src/app.html b/src/app.html index 77a5ff5..60e4e08 100644 --- a/src/app.html +++ b/src/app.html @@ -2,8 +2,8 @@ - + %sveltekit.head% diff --git a/src/lib/images/logo-autobus.png b/src/lib/images/logo-autobus.png new file mode 100644 index 0000000..b72bada Binary files /dev/null and b/src/lib/images/logo-autobus.png differ diff --git a/src/routes/Counter.svelte b/src/routes/Counter.svelte deleted file mode 100644 index 69a5b2a..0000000 --- a/src/routes/Counter.svelte +++ /dev/null @@ -1,102 +0,0 @@ - - -
- - -
-
- - {Math.floor($displayed_count)} -
-
- - -
- - diff --git a/src/routes/Navigator.svelte b/src/routes/Navigator.svelte index 8620cde..defec58 100644 --- a/src/routes/Navigator.svelte +++ b/src/routes/Navigator.svelte @@ -4,7 +4,7 @@
- Inicio + Inicio
diff --git a/src/routes/paradero/+page.js b/src/routes/paradero/+page.js new file mode 100644 index 0000000..3680b09 --- /dev/null +++ b/src/routes/paradero/+page.js @@ -0,0 +1,54 @@ + +const base = 'https://transporte.hz.kursor.cl/api' + +export async function load({ url }) { + const id = url.searchParams.get('id'); + + if (!id) return null; + + const token = await getToken() + return await fetchParaderoData(id, token) +} + +async function getToken() { + try { + const rut = '11111111-1' + const password = 'usuario1' + + const res = await fetch(`${base}/auth/`, { + method: 'POST', + body: JSON.stringify({ rut, password }) + }) + if (!res.ok) throw await res.text() + + const { token } = await res.json() + + // console.log({ token }) + return token; + } catch (error) { + console.log('token',{ error }) + } +} + +async function fetchParaderoData(id, token) { + try { + const data = { + GetInfoDevice: { + idDispositivo: id, + KeyAuthorizacion: "token" + } + } + + const res = await fetch(`${base}/dispositivos/getInfoDevice/`, { + method: 'POST', + body: JSON.stringify(data), + headers: { "Authorization": `Bearer ${token}`, "Content-Type": "application/json" } + }) + + if (!res.ok) throw await res.text() + return res.json() + + } catch (error) { + console.log('paradero',{ error }) + } +} \ No newline at end of file diff --git a/src/routes/paradero/+page.svelte b/src/routes/paradero/+page.svelte new file mode 100644 index 0000000..55cda6f --- /dev/null +++ b/src/routes/paradero/+page.svelte @@ -0,0 +1,218 @@ + + + + Transformación digital: Paradero + + + +
+
+ Bus +
{nombreParadero}
+
+ +
Buses que se detienen en esta parada
+ +
+ {#if paraderoData?.DetalleLineas} + {#each paraderoData.DetalleLineas as linea} +
+
+
+ {LetraoNumeroMicro(linea.Descripcion, 0)} +
+
+ {LetraoNumeroMicro(linea.Descripcion, 1)} +
+
+
+
{linea.Linea}
+ {#if linea.Llegadas[0]?.EstimadaGPS} + {formatTimeMinutes(linea.Llegadas[0])} + ({linea.Llegadas[0].patente}) + {:else} + Sin información + {/if} +
+
+ {/each} + {:else} +

Cargando datos...

+ {/if} +
+
+ +