Skip to content

Commit 8feaa5f

Browse files
committed
show store name on store page
1 parent 1442ac6 commit 8feaa5f

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { redirect } from "@sveltejs/kit";
2+
import { getStoreMetadata, storeIdFromName } from "$lib/lttstore/lttstore_types.ts";
23

34

45
export const load = (async ({params, url, fetch, cookies}) => {
5-
if(!["us", "global"].includes(params.store.toLowerCase())) {
6+
const storeId = storeIdFromName(params.store);
7+
if(storeId === -1) {
68
const newUrl = new URL(url);
79
if(url.pathname.includes("tempGlobal")) {
810
newUrl.pathname = newUrl.pathname.replaceAll("tempGlobal", "global/products");
@@ -11,8 +13,13 @@ export const load = (async ({params, url, fetch, cookies}) => {
1113
throw redirect(302, newUrl)
1214
}
1315
}
16+
1417
return {
1518
exchangeRates: await fetch("/api/exchangeRates").then(r => r.json()),
16-
currency: cookies.get("currency") ?? "USD"
19+
currency: cookies.get("currency") ?? "USD",
20+
store: {
21+
id: storeId,
22+
...getStoreMetadata(storeId)
23+
}
1724
}
1825
})

src/routes/(info)/lttstore/[store]/+page.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { Progress } from "@skeletonlabs/skeleton-svelte";
99
import { invalidateAll } from "$app/navigation";
1010
import RelativeDate from "$lib/RelativeDate.svelte";
11+
import { Store } from "$lib/lttstore/lttstore_types.ts";
1112
1213
let { data } = $props();
1314
@@ -33,7 +34,7 @@
3334
<ol class="breadcrumb pt-2 pl-2">
3435
<li class="crumb"><a class="anchor hover-underline" href="/">{page.url.hostname === "whenwan.show" ? "whenwan.show" : "Whenplane"}</a></li>
3536
<li class="crumb-separator" aria-hidden="true">›</li>
36-
<li class="crumb" onclick={reload}>LTT Store Watcher</li>
37+
<li class="crumb" onclick={reload}>LTT Store Watcher ({data.store.storeName})</li>
3738
{#if loading}
3839
<li class="crumb" transition:fade|global={{duration: 100}}>
3940
<Progress width="w-6" stroke={250} value={loading ? undefined : 100}/>
@@ -44,12 +45,17 @@
4445

4546
<div class="container mx-auto pt-8 mb-96 px-2">
4647

47-
<h1 class="text-center mb-2">LTTStore Watcher</h1>
48+
<h1 class="text-center mb-2">{data.store.storeName} LTTStore Watcher</h1>
4849

4950
<div class="flex justify-between link-header mx-auto">
5051
<a href="/lttstore/{page.params.store}/products" class="btn preset-tonal-primary">All Products</a>
5152
<a href="/lttstore/{page.params.store}/archive" class="btn preset-tonal-primary">Product Archive</a>
5253
<a href="/lttstore/{page.params.store}/collections" class="btn preset-tonal-primary">Collections</a>
54+
{#if data.store.id === Store.US}
55+
<a href="/lttstore/global" class="btn preset-tonal-primary">Global Store Watcher</a>
56+
{:else}
57+
<a href="/lttstore/us" class="btn preset-tonal-primary">US Store Watcher</a>
58+
{/if}
5359
</div>
5460
<br>
5561
<br>

0 commit comments

Comments
 (0)