Remove superfluous warning toasts.
Change registration code input to single input field
This commit is contained in:
parent
58ef9c153e
commit
6d2ddb9966
@ -7,37 +7,11 @@
|
||||
const title = "Submit Registration";
|
||||
let state = false;
|
||||
let status: string;
|
||||
|
||||
let inputs: { id: string; value: string }[] = [
|
||||
{ id: "1", value: "" },
|
||||
{ id: "2", value: "" },
|
||||
{ id: "3", value: "" },
|
||||
{ id: "4", value: "" },
|
||||
{ id: "5", value: "" },
|
||||
{ id: "6", value: "" },
|
||||
];
|
||||
|
||||
function handleInput(index: number, event: KeyboardEvent): void {
|
||||
if (event.key === "Backspace" && index > 0 && inputs[index].value === "") {
|
||||
const prevInput = document.getElementById(`input-${index}`);
|
||||
if (prevInput) {
|
||||
prevInput.focus();
|
||||
}
|
||||
} else if (inputs[index].value.length === 1) {
|
||||
const nextInput = document.getElementById(`input-${index + 2}`);
|
||||
if (nextInput) {
|
||||
nextInput.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
let inputString: string;
|
||||
|
||||
async function handleSubmit() {
|
||||
let submitString: string = "";
|
||||
for (const input of inputs) {
|
||||
submitString += input.value.toUpperCase();
|
||||
}
|
||||
console.log(`Code: ${submitString}`);
|
||||
const res = await submit(submitString);
|
||||
console.log(`Code: ${inputString}`);
|
||||
const res = await submit(inputString);
|
||||
console.log(`Registration Status: ${res}`);
|
||||
if (res == 201) {
|
||||
status = "okay";
|
||||
@ -85,9 +59,7 @@
|
||||
{:else}
|
||||
<p class="title-ish">Enter your registration code below</p>
|
||||
<form on:submit={handleSubmit} id="codeInputForm">
|
||||
{#each inputs as input, index}
|
||||
<input class="code-in" bind:value={input.value} id={`input-${input.id}`} maxlength="1" autocomplete="off" on:keydown={(event) => handleInput(index, event)} />
|
||||
{/each}
|
||||
<input class="code-in" bind:value={inputString} id={'input'} maxlength="6" autocomplete="off">
|
||||
<br />
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
@ -102,7 +74,7 @@
|
||||
.code-in {
|
||||
margin: 3px;
|
||||
margin-bottom: 20px;
|
||||
width: 29px;
|
||||
width: calc(29px * 6);
|
||||
height: 39px;
|
||||
font-size: 30px;
|
||||
text-align: center;
|
||||
|
@ -73,9 +73,11 @@
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
toast("Registration soon required for PIS features.\n\nClick 'Register' in the menu.", {
|
||||
if ($uuid == null || $uuid == "") {
|
||||
toast("This feature will soon require registration. Register in the menu.", {
|
||||
duration: 3000,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const resultsCard: CardConfig = {
|
||||
|
@ -48,10 +48,11 @@
|
||||
id = (await getHeadcode()) || "";
|
||||
load();
|
||||
|
||||
toast("Registration soon required for timetable features.\n\nClick 'Register' in the menu.", {
|
||||
if ($uuid == null || $uuid == "") {
|
||||
toast("PIS Codes will soon be hidden for unregistered users. Register in the menu.", {
|
||||
duration: 3000,
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function load() {
|
||||
@ -70,7 +71,7 @@
|
||||
{
|
||||
loading: 'Searching Timetable',
|
||||
success: 'Done',
|
||||
error: 'Error'
|
||||
error: 'No Services Found'
|
||||
}
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user