fix(ui): could not submit pin due to localization updates (#2324)
Co-authored-by: Elia Zammuto <theelixzammuto@gmail.com>
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
<h1 class="my-4">{{ $t('pin.pin_pairing') }}</h1>
|
<h1 class="my-4">{{ $t('pin.pin_pairing') }}</h1>
|
||||||
<form action="" class="form d-flex flex-column align-items-center" id="form">
|
<form action="" class="form d-flex flex-column align-items-center" id="form">
|
||||||
<div class="card flex-column d-flex p-4 mb-4">
|
<div class="card flex-column d-flex p-4 mb-4">
|
||||||
<input type="text" pattern="\d*" placeholder="PIN" id="pin-input" class="form-control my-4" />
|
<input type="text" pattern="\d*" placeholder="PIN" id="pin-input" class="form-control my-4" />
|
||||||
<button class="btn btn-primary">{{ $t('pin.send') }}</button>
|
<button class="btn btn-primary">{{ $t('pin.send') }}</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import {createApp} from 'vue'
|
import { createApp } from 'vue'
|
||||||
import i18n from './locale.js'
|
import i18n from './locale.js'
|
||||||
import Navbar from './Navbar.vue'
|
import Navbar from './Navbar.vue'
|
||||||
|
|
||||||
@@ -37,26 +37,27 @@
|
|||||||
i18n().then(i18n => {
|
i18n().then(i18n => {
|
||||||
app.use(i18n);
|
app.use(i18n);
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelector("#form").addEventListener("submit", (e) => {
|
// this must be after mounting the app
|
||||||
e.preventDefault();
|
document.querySelector("#form").addEventListener("submit", (e) => {
|
||||||
let pin = document.querySelector("#pin-input").value;
|
e.preventDefault();
|
||||||
document.querySelector("#status").innerHTML = "";
|
let pin = document.querySelector("#pin-input").value;
|
||||||
let b = JSON.stringify({ pin: pin });
|
document.querySelector("#status").innerHTML = "";
|
||||||
fetch("/api/pin", { method: "POST", body: b })
|
let b = JSON.stringify({ pin: pin });
|
||||||
.then((response) => response.json())
|
fetch("/api/pin", { method: "POST", body: b })
|
||||||
.then((response) => {
|
.then((response) => response.json())
|
||||||
if (response.status.toString().toLowerCase() === "true") {
|
.then((response) => {
|
||||||
document.querySelector(
|
if (response.status.toString().toLowerCase() === "true") {
|
||||||
"#status"
|
document.querySelector(
|
||||||
).innerHTML = `<div class="alert alert-success" role="alert">$t('pin.pair_success')</div>`;
|
"#status"
|
||||||
document.querySelector("#pin-input").value = "";
|
).innerHTML = `<div class="alert alert-success" role="alert">${i18n.global.t('pin.pair_success')}</div>`;
|
||||||
} else {
|
document.querySelector("#pin-input").value = "";
|
||||||
document.querySelector(
|
} else {
|
||||||
"#status"
|
document.querySelector(
|
||||||
).innerHTML = `<div class="alert alert-danger" role="alert">$t('pin.pair_failure')</div>`;
|
"#status"
|
||||||
}
|
).innerHTML = `<div class="alert alert-danger" role="alert">${i18n.global.t('pin.pair_failure')}</div>`;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user