StaffLDB-Minify #1

Merged
fred.boniface merged 27 commits from StaffLDB-Minify into main 2023-10-03 21:37:00 +01:00
2 changed files with 22 additions and 9 deletions
Showing only changes of commit 7e6568d13a - Show all commits

View File

@ -5,12 +5,14 @@
import { detailInit, defineDetail } from './train-detail';
import TrainDetail from './train-detail.svelte';
import { fetchStaffLdb } from './fetch';
import { error } from '@sveltejs/kit';
export let station: string;
export let title: string | undefined = 'Loading...';
export let error = {
state: false,
name: 'none'
let errorDetail = {
code: '',
message: '',
};
let detail = detailInit();
@ -29,6 +31,8 @@
title = data.data.locationName;
return data.data;
}
errorDetail.code = data.obStatus.toString() || "UNKNOWN";
errorDetail.message = data.obMsg || "An unknown error occoured";
throw new Error('Unable to Fetch Data');
}
</script>
@ -59,11 +63,17 @@
{/if}
{/if}
{:catch}
Error Loading Data
<h2>Error</h2>
<p>ERR-CODE: {errorDetail.code}</p>
<p>Message:<br>{errorDetail.message}</p>
{/await}
{#if error.state}
{#if error.name === 'unauthorized'}
<p>Error: {error.name.toLocaleUpperCase()}</p>
{/if}
{/if}
<style>
.transport-mode {
padding-top: 20px;
height: 17px;
}
.table-head-text {
color: white;
}
</style>

View File

@ -1,3 +1,4 @@
// Contains the details required to lookup train details
export interface Detail {
show: boolean;
headcode: string;
@ -5,6 +6,7 @@ export interface Detail {
uid: string;
}
// Initiates/Resets a `Detail` interface
export function detailInit(): Detail {
const detail: Detail = {
show: false,
@ -15,6 +17,7 @@ export function detailInit(): Detail {
return detail;
}
// Initiates/Updates a `Detail` interface using the given values
export function defineDetail(rid: string, uid: string, tid: string) {
const detail: Detail = {
rid: rid,