Run prettier
This commit is contained in:
parent
f1acc9b97a
commit
86b072f387
@ -1,38 +1,36 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { uuid } from '$lib/stores/uuid';
|
||||||
|
import { getApiUrl } from '$lib/scripts/upstream';
|
||||||
|
import type { ApiResponse, StaffLdb } from '@owlboard/ts-types';
|
||||||
|
|
||||||
import { uuid } from "$lib/stores/uuid";
|
export let station: string;
|
||||||
import { getApiUrl } from "$lib/scripts/upstream";
|
export let title: string | undefined = 'Loading...';
|
||||||
import type { ApiResponse, StaffLdb } from "@owlboard/ts-types";
|
|
||||||
|
|
||||||
export let station: string
|
const fetchUrl = getApiUrl();
|
||||||
export let title: string | undefined = "Loading..."
|
|
||||||
|
|
||||||
const fetchUrl = getApiUrl();
|
async function fetchStaffLdb(station: string) {
|
||||||
|
const url = `${fetchUrl}/api/v2/live/station/${station}/staff`;
|
||||||
async function fetchStaffLdb(station: string) {
|
const options = {
|
||||||
const url = `${fetchUrl}/api/v2/live/station/${station}/staff`
|
method: 'GET',
|
||||||
const options = {
|
headers: {
|
||||||
method: 'GET',
|
uuid: $uuid
|
||||||
headers: {
|
}
|
||||||
uuid: $uuid,
|
};
|
||||||
},
|
const res = await fetch(url, options);
|
||||||
|
let jsonData: ApiResponse<StaffLdb>;
|
||||||
|
if (res.status === 200) {
|
||||||
|
jsonData = await res.json();
|
||||||
|
title = jsonData.data?.locationName;
|
||||||
|
} else if (res.status === 401) {
|
||||||
|
console.log(`Request Status: ${res.status}`);
|
||||||
|
title = 'Unauthorised';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const res = await fetch(url, options)
|
|
||||||
let jsonData: ApiResponse<StaffLdb>
|
|
||||||
if (res.status === 200) {
|
|
||||||
jsonData = await res.json()
|
|
||||||
title = jsonData.data?.locationName
|
|
||||||
} else if (res.status === 401) {
|
|
||||||
console.log(`Request Status: ${res.status}`)
|
|
||||||
title = "Unauthorised"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await fetchStaffLdb(station)}
|
{#await fetchStaffLdb(station)}
|
||||||
Loading
|
Loading
|
||||||
{:then data}
|
{:then data}
|
||||||
Loaded {JSON.stringify(data)}
|
Loaded {JSON.stringify(data)}
|
||||||
{:catch}
|
{:catch}
|
||||||
Error Loading
|
Error Loading
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { dev } from "$app/environment";
|
import { dev } from '$app/environment';
|
||||||
|
|
||||||
export function getApiUrl() {
|
export function getApiUrl() {
|
||||||
if (dev) {
|
if (dev) {
|
||||||
console.info("DEVMODE active, using testing URL")
|
console.info('DEVMODE active, using testing URL');
|
||||||
return "https://testing.owlboard.info"
|
return 'https://testing.owlboard.info';
|
||||||
}
|
}
|
||||||
return "https://owlboard.info"
|
return 'https://owlboard.info';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user