Compare commits
No commits in common. "0ce32f4a342f32d9f5c80977b0bfd06298239893" and "ef7d965523fd32c4c586c77065eef23fb3561b76" have entirely different histories.
0ce32f4a34
...
ef7d965523
|
@ -25,7 +25,6 @@ export async function fetchStaffLdb(station: string): Promise<ApiResponse<StaffL
|
||||||
return parseFormat(JSON.stringify(resJs));
|
return parseFormat(JSON.stringify(resJs));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse dates within the JSON response
|
|
||||||
function parseFormat(jsonString: any): ApiResponse<StaffLdb> {
|
function parseFormat(jsonString: any): ApiResponse<StaffLdb> {
|
||||||
return JSON.parse(jsonString, (key, value) => {
|
return JSON.parse(jsonString, (key, value) => {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
|
|
|
@ -5,14 +5,12 @@
|
||||||
import { detailInit, defineDetail } from './train-detail';
|
import { detailInit, defineDetail } from './train-detail';
|
||||||
import TrainDetail from './train-detail.svelte';
|
import TrainDetail from './train-detail.svelte';
|
||||||
import { fetchStaffLdb } from './fetch';
|
import { fetchStaffLdb } from './fetch';
|
||||||
import { error } from '@sveltejs/kit';
|
|
||||||
|
|
||||||
export let station: string;
|
export let station: string;
|
||||||
export let title: string | undefined = 'Loading...';
|
export let title: string | undefined = 'Loading...';
|
||||||
|
export let error = {
|
||||||
let errorDetail = {
|
state: false,
|
||||||
code: '',
|
name: 'none'
|
||||||
message: '',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let detail = detailInit();
|
let detail = detailInit();
|
||||||
|
@ -31,8 +29,6 @@
|
||||||
title = data.data.locationName;
|
title = data.data.locationName;
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
errorDetail.code = data.obStatus.toString() || "UNKNOWN";
|
|
||||||
errorDetail.message = data.obMsg || "An unknown error occoured";
|
|
||||||
throw new Error('Unable to Fetch Data');
|
throw new Error('Unable to Fetch Data');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -63,17 +59,11 @@
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{:catch}
|
{:catch}
|
||||||
<h2>Error</h2>
|
Error Loading Data
|
||||||
<p>ERR-CODE: {errorDetail.code}</p>
|
|
||||||
<p>Message:<br>{errorDetail.message}</p>
|
|
||||||
{/await}
|
{/await}
|
||||||
|
|
||||||
<style>
|
{#if error.state}
|
||||||
.transport-mode {
|
{#if error.name === 'unauthorized'}
|
||||||
padding-top: 20px;
|
<p>Error: {error.name.toLocaleUpperCase()}</p>
|
||||||
height: 17px;
|
{/if}
|
||||||
}
|
{/if}
|
||||||
.table-head-text {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// Contains the details required to lookup train details
|
|
||||||
export interface Detail {
|
export interface Detail {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
headcode: string;
|
headcode: string;
|
||||||
|
@ -6,7 +5,6 @@ export interface Detail {
|
||||||
uid: string;
|
uid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initiates/Resets a `Detail` interface
|
|
||||||
export function detailInit(): Detail {
|
export function detailInit(): Detail {
|
||||||
const detail: Detail = {
|
const detail: Detail = {
|
||||||
show: false,
|
show: false,
|
||||||
|
@ -17,7 +15,6 @@ export function detailInit(): Detail {
|
||||||
return detail;
|
return detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initiates/Updates a `Detail` interface using the given values
|
|
||||||
export function defineDetail(rid: string, uid: string, tid: string) {
|
export function defineDetail(rid: string, uid: string, tid: string) {
|
||||||
const detail: Detail = {
|
const detail: Detail = {
|
||||||
rid: rid,
|
rid: rid,
|
||||||
|
|
Loading…
Reference in New Issue