Remove superfluous warning toasts.

Change registration code input to single input field
This commit is contained in:
Fred Boniface 2025-01-22 00:10:30 +00:00
parent 58ef9c153e
commit 6d2ddb9966
3 changed files with 12 additions and 37 deletions

View File

@ -7,37 +7,11 @@
const title = "Submit Registration"; const title = "Submit Registration";
let state = false; let state = false;
let status: string; let status: string;
let inputString: 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();
}
}
}
async function handleSubmit() { async function handleSubmit() {
let submitString: string = ""; console.log(`Code: ${inputString}`);
for (const input of inputs) { const res = await submit(inputString);
submitString += input.value.toUpperCase();
}
console.log(`Code: ${submitString}`);
const res = await submit(submitString);
console.log(`Registration Status: ${res}`); console.log(`Registration Status: ${res}`);
if (res == 201) { if (res == 201) {
status = "okay"; status = "okay";
@ -85,9 +59,7 @@
{:else} {:else}
<p class="title-ish">Enter your registration code below</p> <p class="title-ish">Enter your registration code below</p>
<form on:submit={handleSubmit} id="codeInputForm"> <form on:submit={handleSubmit} id="codeInputForm">
{#each inputs as input, index} <input class="code-in" bind:value={inputString} id={'input'} maxlength="6" autocomplete="off">
<input class="code-in" bind:value={input.value} id={`input-${input.id}`} maxlength="1" autocomplete="off" on:keydown={(event) => handleInput(index, event)} />
{/each}
<br /> <br />
<button type="submit">Submit</button> <button type="submit">Submit</button>
</form> </form>
@ -102,7 +74,7 @@
.code-in { .code-in {
margin: 3px; margin: 3px;
margin-bottom: 20px; margin-bottom: 20px;
width: 29px; width: calc(29px * 6);
height: 39px; height: 39px;
font-size: 30px; font-size: 30px;
text-align: center; text-align: center;

View File

@ -73,9 +73,11 @@
} }
onMount(() => { 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, duration: 3000,
}); });
}
}); });
const resultsCard: CardConfig = { const resultsCard: CardConfig = {

View File

@ -48,10 +48,11 @@
id = (await getHeadcode()) || ""; id = (await getHeadcode()) || "";
load(); 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, duration: 3000,
}); });
}
}); });
function load() { function load() {
@ -70,7 +71,7 @@
{ {
loading: 'Searching Timetable', loading: 'Searching Timetable',
success: 'Done', success: 'Done',
error: 'Error' error: 'No Services Found'
} }
) )
} }