Re-enable 'Find by Code'

Backend fixes now mean this feature works again.
This commit is contained in:
Fred Boniface 2024-11-10 19:13:32 +00:00
parent 8a030964a4
commit 1d1e9416ab

View File

@ -2,7 +2,6 @@
import Header from "$lib/navigation/header.svelte"; import Header from "$lib/navigation/header.svelte";
import Nav from "$lib/navigation/nav.svelte"; import Nav from "$lib/navigation/nav.svelte";
import Island from "$lib/islands/island.svelte"; import Island from "$lib/islands/island.svelte";
import Loading from "$lib/navigation/loading.svelte";
import { uuid } from "$lib/stores/uuid"; import { uuid } from "$lib/stores/uuid";
import StylesToc from "$lib/train/styles-toc.svelte"; import StylesToc from "$lib/train/styles-toc.svelte";
import { getApiUrl } from "$lib/scripts/upstream"; import { getApiUrl } from "$lib/scripts/upstream";
@ -17,23 +16,17 @@
let data = []; let data = [];
let error = false; let error = false;
let errMsg = "Unknown Error"; let errMsg = "Unknown Error";
let isLoading = false;
async function findByStartEnd() { async function findByStartEnd() {
isLoading = true;
const url = `${getApiUrl()}/api/v2/pis/byStartEnd/${entryStartCRS}/${entryEndCRS}`; const url = `${getApiUrl()}/api/v2/pis/byStartEnd/${entryStartCRS}/${entryEndCRS}`;
await fetchData(url); await fetchData(url);
isLoading = false;
} }
/* Temporarily Disabled
async function findByPis() { async function findByPis() {
isLoading = true;
const url = `${getApiUrl()}/api/v2/pis/byCode/${entryPIS}`; const url = `${getApiUrl()}/api/v2/pis/byCode/${entryPIS}`;
await fetchData(url); await fetchData(url);
isLoading = false;
} }
*/
async function fetchData(url: string) { async function fetchData(url: string) {
const options = { const options = {
@ -77,7 +70,6 @@
entryStartCRS = ""; entryStartCRS = "";
entryEndCRS = ""; entryEndCRS = "";
toast.success("Form reset"); toast.success("Form reset");
isLoading = false;
} }
onMount(() => { onMount(() => {
@ -89,10 +81,6 @@
<Header {title} /> <Header {title} />
{#if isLoading}
<Loading />
{/if}
{#if error} {#if error}
<Island {variables}> <Island {variables}>
<p class="error">{errMsg}</p> <p class="error">{errMsg}</p>
@ -124,14 +112,14 @@
<br /> <br />
<button type="submit">Search</button> <button type="submit">Search</button>
</form> </form>
<!-- FIND BY PIS CODE NOT WORKING AT PRESENT
<p class="label">Find By PIS Code:</p> <p class="label">Find By PIS Code:</p>
<form on:submit={findByPis}> <form on:submit={findByPis}>
<input type="number" max="9999" autocomplete="off" placeholder="PIS" bind:value={entryPIS} /> <input type="number" max="9999" autocomplete="off" placeholder="PIS" bind:value={entryPIS} />
<br /> <br />
<button type="submit">Search</button> <button type="submit">Search</button>
</form> </form>
-->
{/if} {/if}
<button id="reset" type="reset" on:click={reset}>Reset</button> <button id="reset" type="reset" on:click={reset}>Reset</button>
<Nav /> <Nav />