@zeyolabs/shopping 2026.11.38 → 2026.11.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/basket/pages/Basket.svelte +36 -33
- package/bundles/admin/BundleEditPage.svelte +7 -4
- package/bundles/admin/BundleForm.svelte +10 -7
- package/bundles/admin/BundlesPage.svelte +14 -10
- package/bundles/pages/Bundle.svelte +44 -41
- package/catalogue/admin/CategoriesPage.svelte +13 -10
- package/catalogue/admin/CategoryForm.svelte +4 -3
- package/catalogue/admin/ProductEditPage.svelte +7 -4
- package/catalogue/admin/ProductForm.svelte +31 -29
- package/catalogue/admin/ProductsPage.svelte +16 -14
- package/catalogue/components/ProductCard.svelte +22 -14
- package/catalogue/pages/Category.svelte +10 -7
- package/catalogue/pages/Product.svelte +37 -30
- package/catalogue/pages/Search.svelte +12 -7
- package/catalogue/pages/Shop.svelte +6 -3
- package/checkout/pages/CheckoutSuccess.svelte +10 -8
- package/customers/pages/Account.svelte +19 -15
- package/fulfilment/admin/OrderPage.svelte +60 -56
- package/fulfilment/admin/OrdersPage.svelte +26 -22
- package/orders/pages/Order.svelte +35 -29
- package/package.json +5 -4
- package/reviews/admin/ReviewsPage.svelte +23 -19
- package/reviews/components/ReviewForm.svelte +3 -2
- package/reviews/components/Reviews.svelte +17 -13
- package/stock/admin/StockPage.svelte +12 -9
- package/stock/admin/StockRow.svelte +3 -2
- package/ui/PageLinks.svelte +3 -3
- package/ui/PageTitle.svelte +2 -1
- package/ui/Stars.svelte +3 -1
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { ErrorMessage } from '../../utils/errors';
|
|
3
2
|
import { resolve } from '$app/paths';
|
|
3
|
+
import Minus from '@lucide/svelte/icons/minus';
|
|
4
|
+
import Plus from '@lucide/svelte/icons/plus';
|
|
5
|
+
import Trash from '@lucide/svelte/icons/trash-2';
|
|
6
|
+
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
7
|
+
import { Form } from '@zeyolabs/ui/form';
|
|
8
|
+
import Button from '@zeyolabs/ui/form/Button.svelte';
|
|
9
|
+
import { Select } from '@zeyolabs/ui/form/primitives';
|
|
10
|
+
import SkeletonCard from '@zeyolabs/ui/skeleton/SkeletonCard.svelte';
|
|
11
|
+
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
12
|
+
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
13
|
+
import { toast } from 'svelte-sonner';
|
|
14
|
+
|
|
15
|
+
import { shopContext } from '../../context';
|
|
4
16
|
import PageTitle from '../../ui/PageTitle.svelte';
|
|
17
|
+
import { ErrorMessage } from '../../utils/errors';
|
|
18
|
+
import { Images } from '../../utils/images';
|
|
19
|
+
import { Money } from '../../utils/money';
|
|
5
20
|
import {
|
|
6
21
|
basketQuantityForm,
|
|
7
22
|
getBasket,
|
|
@@ -10,18 +25,6 @@
|
|
|
10
25
|
setShipTo,
|
|
11
26
|
} from '../client.remote';
|
|
12
27
|
import { BasketQuantitySchema } from '../schema';
|
|
13
|
-
import Minus from '@lucide/svelte/icons/minus';
|
|
14
|
-
import Plus from '@lucide/svelte/icons/plus';
|
|
15
|
-
import Trash from '@lucide/svelte/icons/trash-2';
|
|
16
|
-
import { shopContext } from '../../context';
|
|
17
|
-
import { Images } from '../../utils/images';
|
|
18
|
-
import { Money } from '../../utils/money';
|
|
19
|
-
import { toast } from 'svelte-sonner';
|
|
20
|
-
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
21
|
-
import { Form } from '@zeyolabs/ui/form';
|
|
22
|
-
import Button from '@zeyolabs/ui/form/Button.svelte';
|
|
23
|
-
import { Select } from '@zeyolabs/ui/form/primitives';
|
|
24
|
-
import SkeletonCard from '@zeyolabs/ui/skeleton/SkeletonCard.svelte';
|
|
25
28
|
|
|
26
29
|
/** The app's own checkout remote function, which rate-limits before calling `createCheckout`. */
|
|
27
30
|
let { startCheckout }: { startCheckout: () => Promise<{ url: string }> } = $props();
|
|
@@ -47,10 +50,10 @@
|
|
|
47
50
|
{let [summary, countries] = $derived(await Promise.all([getBasket(), getShippableCountries()]))}
|
|
48
51
|
|
|
49
52
|
{#if summary.lines.length === 0 && summary.bundles.length === 0}
|
|
50
|
-
<
|
|
51
|
-
<
|
|
53
|
+
<Text>Your basket is empty.</Text>
|
|
54
|
+
<Text class="mt-4"><a class="underline" href={resolve('/')}>Continue shopping</a></Text>
|
|
52
55
|
{:else}
|
|
53
|
-
<ul class="divide-y divide-[var(--
|
|
56
|
+
<ul class="divide-y divide-[var(--bd)]">
|
|
54
57
|
{#each summary.lines as line (line.id)}
|
|
55
58
|
<li class="flex flex-wrap items-center gap-4 py-4">
|
|
56
59
|
{#if line.cover}
|
|
@@ -64,11 +67,11 @@
|
|
|
64
67
|
<a class="font-medium" href={resolve('/product/[slug]', { slug: line.slug })}>
|
|
65
68
|
{line.name}
|
|
66
69
|
</a>
|
|
67
|
-
<
|
|
70
|
+
<Text>{Money.format(line.pricePence)}</Text>
|
|
68
71
|
{#if line.available < line.quantity}
|
|
69
|
-
<
|
|
72
|
+
<Text class="text-[var(--danger)]">
|
|
70
73
|
{line.available === 0 ? 'Out of stock' : `Only ${line.available} available`}
|
|
71
|
-
</
|
|
74
|
+
</Text>
|
|
72
75
|
{/if}
|
|
73
76
|
</div>
|
|
74
77
|
{const form = basketQuantityForm.for(line.id)}
|
|
@@ -89,7 +92,7 @@
|
|
|
89
92
|
>
|
|
90
93
|
<Minus size={14} />
|
|
91
94
|
</Button>
|
|
92
|
-
<
|
|
95
|
+
<Span class="w-6" centered>{line.quantity}</Span>
|
|
93
96
|
<Button
|
|
94
97
|
{...form.fields.quantity.as('submit', line.quantity + 1)}
|
|
95
98
|
aria-label="Increase quantity of {line.name}"
|
|
@@ -102,7 +105,7 @@
|
|
|
102
105
|
<Plus size={14} />
|
|
103
106
|
</Button>
|
|
104
107
|
</Form>
|
|
105
|
-
<
|
|
108
|
+
<Text class="w-20 text-right">{Money.format(line.lineTotalPence)}</Text>
|
|
106
109
|
</li>
|
|
107
110
|
{/each}
|
|
108
111
|
{#each summary.bundles as bundle (bundle.index)}
|
|
@@ -120,7 +123,7 @@
|
|
|
120
123
|
{bundle.name}
|
|
121
124
|
</a>
|
|
122
125
|
{:else}
|
|
123
|
-
<
|
|
126
|
+
<Text bold>{bundle.name}</Text>
|
|
124
127
|
{/if}
|
|
125
128
|
{#if bundle.details.length > 0}
|
|
126
129
|
<ul class="mt-1 text-sm text-[var(--txs)]">
|
|
@@ -128,7 +131,7 @@
|
|
|
128
131
|
</ul>
|
|
129
132
|
{/if}
|
|
130
133
|
{#if bundle.problem}
|
|
131
|
-
<
|
|
134
|
+
<Text class="mt-1 text-[var(--danger)]">{bundle.problem}</Text>
|
|
132
135
|
{/if}
|
|
133
136
|
</div>
|
|
134
137
|
<Button
|
|
@@ -140,12 +143,12 @@
|
|
|
140
143
|
>
|
|
141
144
|
<Trash size={14} />
|
|
142
145
|
</Button>
|
|
143
|
-
<
|
|
146
|
+
<Text class="w-20 text-right">
|
|
144
147
|
{Money.format(bundle.pricePence)}
|
|
145
148
|
{#if bundle.listPricePence > bundle.pricePence}
|
|
146
149
|
<s class="block text-xs text-[var(--txt)]">{Money.format(bundle.listPricePence)}</s>
|
|
147
150
|
{/if}
|
|
148
|
-
</
|
|
151
|
+
</Text>
|
|
149
152
|
</li>
|
|
150
153
|
{/each}
|
|
151
154
|
</ul>
|
|
@@ -179,21 +182,21 @@
|
|
|
179
182
|
<dd class="text-right font-medium">{Money.format(summary.totalPence)}</dd>
|
|
180
183
|
</dl>
|
|
181
184
|
{#if summary.shipping === null}
|
|
182
|
-
<
|
|
185
|
+
<Text class="mt-2 text-right text-[var(--danger)]">
|
|
183
186
|
We cannot ship this order to the selected country.
|
|
184
|
-
</
|
|
187
|
+
</Text>
|
|
185
188
|
{:else}
|
|
186
|
-
<
|
|
189
|
+
<Text class="mt-2 text-right">
|
|
187
190
|
{summary.shipping.name}, {summary.shipping.deliveryTime}.
|
|
188
|
-
</
|
|
191
|
+
</Text>
|
|
189
192
|
{/if}
|
|
190
193
|
{#if summary.domestic && summary.shippingPence > 0}
|
|
191
|
-
<
|
|
194
|
+
<Text class="mt-2 text-right">
|
|
192
195
|
Free UK delivery on orders of {Money.format(summary.freeShippingFromPence)} or more.
|
|
193
|
-
</
|
|
196
|
+
</Text>
|
|
194
197
|
{/if}
|
|
195
198
|
|
|
196
|
-
<
|
|
199
|
+
<Text class="mt-6 text-right">
|
|
197
200
|
<Button
|
|
198
201
|
disabled={!summary.shipping ||
|
|
199
202
|
summary.lines.some((line) => line.available < 1) ||
|
|
@@ -205,7 +208,7 @@
|
|
|
205
208
|
>
|
|
206
209
|
Checkout
|
|
207
210
|
</Button>
|
|
208
|
-
</
|
|
211
|
+
</Text>
|
|
209
212
|
{/if}
|
|
210
213
|
|
|
211
214
|
{#snippet pending()}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { resolve } from '$app/paths';
|
|
3
|
+
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
4
|
+
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
5
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
6
|
+
|
|
3
7
|
import { getAdminBundle } from '../admin.remote';
|
|
4
8
|
import BundleForm from './BundleForm.svelte';
|
|
5
|
-
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
6
9
|
|
|
7
10
|
/** The bundle to edit; leave out for a new one. */
|
|
8
11
|
let { id }: { id?: number } = $props();
|
|
@@ -10,8 +13,8 @@
|
|
|
10
13
|
|
|
11
14
|
<svelte:head><title>{id ? 'Edit bundle' : 'New bundle'} · Admin</title></svelte:head>
|
|
12
15
|
|
|
13
|
-
<
|
|
14
|
-
<
|
|
16
|
+
<Text><a href={resolve('/bundles')}>← Bundles</a></Text>
|
|
17
|
+
<Title class="mt-2 mb-6" level={1} size="md">{id ? 'Edit bundle' : 'New bundle'}</Title>
|
|
15
18
|
|
|
16
19
|
<Boundary message="Could not load the bundle." statusMessages={{ 404: 'Bundle not found.' }}>
|
|
17
20
|
{let bundle = $derived(id ? await getAdminBundle(id) : null)}
|
|
@@ -19,6 +22,6 @@
|
|
|
19
22
|
<BundleForm {bundle} />
|
|
20
23
|
{/key}
|
|
21
24
|
{#snippet pending()}
|
|
22
|
-
<
|
|
25
|
+
<Text color="secondary">Loading…</Text>
|
|
23
26
|
{/snippet}
|
|
24
27
|
</Boundary>
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { goto } from '$app/navigation';
|
|
3
3
|
import { resolve } from '$app/paths';
|
|
4
|
+
import { CheckboxField, Form, MessageField, NumberField, TextField } from '@zeyolabs/ui/form';
|
|
5
|
+
import Button from '@zeyolabs/ui/form/Button.svelte';
|
|
6
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
7
|
+
|
|
4
8
|
import type { getAdminBundle } from '../admin.remote';
|
|
9
|
+
|
|
10
|
+
import { shopContext } from '../../context';
|
|
5
11
|
import { saveBundleForm } from '../admin.remote';
|
|
6
12
|
import { BundleFormSchema } from '../schema';
|
|
7
|
-
import { shopContext } from '../../context';
|
|
8
|
-
import { CheckboxField, Form, MessageField, NumberField, TextField } from '@zeyolabs/ui/form';
|
|
9
|
-
import Button from '@zeyolabs/ui/form/Button.svelte';
|
|
10
13
|
|
|
11
14
|
type Bundle = Awaited<ReturnType<typeof getAdminBundle>>;
|
|
12
15
|
|
|
@@ -35,8 +38,8 @@
|
|
|
35
38
|
{ label: 'Kit cover (one product for every slot)', value: 'cover' },
|
|
36
39
|
] as const;
|
|
37
40
|
|
|
38
|
-
const input = 'mt-1 w-full rounded-md border border-[var(--
|
|
39
|
-
const section = 'grid gap-4 rounded-xl border border-[var(--
|
|
41
|
+
const input = 'mt-1 w-full rounded-md border border-[var(--bd)] bg-white px-3 py-1.5';
|
|
42
|
+
const section = 'grid gap-4 rounded-xl border border-[var(--bd)] bg-white p-5';
|
|
40
43
|
</script>
|
|
41
44
|
|
|
42
45
|
<Form
|
|
@@ -82,10 +85,10 @@
|
|
|
82
85
|
{#each stepRows as _, i (i)}
|
|
83
86
|
<section class={section}>
|
|
84
87
|
<div class="flex items-center justify-between">
|
|
85
|
-
<
|
|
88
|
+
<Title level={2} size="sm">Step {i + 1}</Title>
|
|
86
89
|
{#if stepRows.length > 1}
|
|
87
90
|
<Button
|
|
88
|
-
onclick={() => steps.set(stepRows.filter((_, j) => j !== i))}
|
|
91
|
+
onclick={() => steps.set(stepRows.filter((_: unknown, j: number) => j !== i))}
|
|
89
92
|
size="sm"
|
|
90
93
|
variant="secondary">Remove step</Button
|
|
91
94
|
>
|
|
@@ -1,40 +1,44 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { resolve } from '$app/paths';
|
|
3
|
-
import { getAdminBundles } from '../admin.remote';
|
|
4
3
|
import Badge from '@zeyolabs/ui/badge/Badge.svelte';
|
|
5
4
|
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
5
|
+
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
6
|
+
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
7
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
8
|
+
|
|
9
|
+
import { getAdminBundles } from '../admin.remote';
|
|
6
10
|
</script>
|
|
7
11
|
|
|
8
12
|
<svelte:head><title>Bundles · Admin</title></svelte:head>
|
|
9
13
|
|
|
10
|
-
<
|
|
14
|
+
<Text><a href={resolve('/products')}>← Products</a></Text>
|
|
11
15
|
<div class="mt-2 flex items-center justify-between">
|
|
12
|
-
<
|
|
16
|
+
<Title level={1} size="md">Bundles</Title>
|
|
13
17
|
<a
|
|
14
|
-
class="rounded-md bg-[var(--
|
|
18
|
+
class="rounded-md bg-[var(--acc)] px-3 py-1.5 text-sm text-white no-underline"
|
|
15
19
|
href={resolve('/bundles/new')}>New bundle</a
|
|
16
20
|
>
|
|
17
21
|
</div>
|
|
18
|
-
<
|
|
22
|
+
<Text class="mt-1" color="secondary">
|
|
19
23
|
A bundle is built in steps; the customer's picks go into the basket as ordinary products at their
|
|
20
24
|
own prices. Use a Stripe promotion code for a bundle discount.
|
|
21
|
-
</
|
|
25
|
+
</Text>
|
|
22
26
|
|
|
23
27
|
<Boundary message="Could not load bundles.">
|
|
24
28
|
{let rows = $derived(await getAdminBundles())}
|
|
25
|
-
<ul class="mt-4 divide-y divide-[var(--
|
|
29
|
+
<ul class="mt-4 divide-y divide-[var(--bd)] rounded-xl border border-[var(--bd)] bg-white">
|
|
26
30
|
{#each rows as row (row.id)}
|
|
27
31
|
<li class="px-4 py-2 text-sm">
|
|
28
32
|
<a class="font-medium" href={resolve('/bundles/[id]', { id: String(row.id) })}>{row.name}</a
|
|
29
33
|
>
|
|
30
|
-
<
|
|
34
|
+
<Span color="secondary">/bundle/{row.slug}</Span>
|
|
31
35
|
{#if !row.active}<Badge color="neutral">inactive</Badge>{/if}
|
|
32
36
|
</li>
|
|
33
37
|
{:else}
|
|
34
|
-
<li class="px-4 py-6 text-[var(--
|
|
38
|
+
<li class="px-4 py-6 text-[var(--txs)]">No bundles yet.</li>
|
|
35
39
|
{/each}
|
|
36
40
|
</ul>
|
|
37
41
|
{#snippet pending()}
|
|
38
|
-
<
|
|
42
|
+
<Text class="mt-6" color="secondary">Loading…</Text>
|
|
39
43
|
{/snippet}
|
|
40
44
|
</Boundary>
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { ErrorMessage } from '../../utils/errors';
|
|
3
2
|
import { goto } from '$app/navigation';
|
|
4
3
|
import { resolve } from '$app/paths';
|
|
5
|
-
import PageTitle from '../../ui/PageTitle.svelte';
|
|
6
|
-
import { addBundleToBasket, type getBundle } from '../client.remote';
|
|
7
|
-
import { shopContext } from '../../context';
|
|
8
|
-
import { Images } from '../../utils/images';
|
|
9
|
-
import { Money } from '../../utils/money';
|
|
10
4
|
import Minus from '@lucide/svelte/icons/minus';
|
|
11
5
|
import Plus from '@lucide/svelte/icons/plus';
|
|
12
|
-
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
|
13
|
-
import { toast } from 'svelte-sonner';
|
|
14
6
|
import Button from '@zeyolabs/ui/form/Button.svelte';
|
|
7
|
+
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
8
|
+
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
9
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
10
|
+
import { toast } from 'svelte-sonner';
|
|
11
|
+
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
|
12
|
+
|
|
13
|
+
import { shopContext } from '../../context';
|
|
14
|
+
import PageTitle from '../../ui/PageTitle.svelte';
|
|
15
|
+
import { ErrorMessage } from '../../utils/errors';
|
|
16
|
+
import { Images } from '../../utils/images';
|
|
17
|
+
import { Money } from '../../utils/money';
|
|
18
|
+
import { addBundleToBasket, type getBundle } from '../client.remote';
|
|
15
19
|
|
|
16
20
|
let {
|
|
17
21
|
bundle,
|
|
@@ -20,8 +24,8 @@
|
|
|
20
24
|
bundle: Awaited<ReturnType<typeof getBundle>>;
|
|
21
25
|
} = $props();
|
|
22
26
|
|
|
23
|
-
type Step = (typeof bundle.steps)[number];
|
|
24
27
|
type Option = Step['products'][number];
|
|
28
|
+
type Step = (typeof bundle.steps)[number];
|
|
25
29
|
|
|
26
30
|
const context = shopContext();
|
|
27
31
|
/** pick / base / cover steps: step id to the chosen product ids. */
|
|
@@ -58,7 +62,7 @@
|
|
|
58
62
|
if (step.role === 'base') filled.clear();
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
function adjust(step: Step, product: Option, by: 1 |
|
|
65
|
+
function adjust(step: Step, product: Option, by: -1 | 1) {
|
|
62
66
|
const map = filled.get(step.id) ?? new SvelteMap<number, number>();
|
|
63
67
|
const next = (map.get(product.id) ?? 0) + by;
|
|
64
68
|
if (next <= 0) map.delete(product.id);
|
|
@@ -170,33 +174,33 @@
|
|
|
170
174
|
<PageTitle description={bundle.description.slice(0, 160)} title={bundle.name} />
|
|
171
175
|
|
|
172
176
|
{#if bundle.description}
|
|
173
|
-
<
|
|
177
|
+
<Text class="-mt-4 mb-4 max-w-prose whitespace-pre-line" color="secondary"
|
|
178
|
+
>{bundle.description}</Text
|
|
179
|
+
>
|
|
174
180
|
{/if}
|
|
175
181
|
{#if !kit && bundle.discountPercent > 0}
|
|
176
|
-
<
|
|
177
|
-
class="mb-8 inline-flex rounded-full bg-[var(--primary-soft)] px-3 py-1 text-
|
|
182
|
+
<Text
|
|
183
|
+
class="mb-8 inline-flex rounded-full bg-[var(--primary-soft)] px-3 py-1 text-[var(--primary-strong)]"
|
|
184
|
+
bold
|
|
178
185
|
>
|
|
179
186
|
{bundle.discountPercent}% off when bought as a bundle
|
|
180
|
-
</
|
|
187
|
+
</Text>
|
|
181
188
|
{/if}
|
|
182
189
|
|
|
183
190
|
{#if soldOut}
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
>
|
|
188
|
-
Not available right now: every {soldOut.title.toLowerCase()} option is sold out.
|
|
189
|
-
</p>
|
|
191
|
+
<div class="mb-6 rounded-xl border border-[var(--bd)] bg-[var(--sfh)] px-4 py-3" role="status">
|
|
192
|
+
<Text>Not available right now: every {soldOut.title.toLowerCase()} option is sold out.</Text>
|
|
193
|
+
</div>
|
|
190
194
|
{/if}
|
|
191
195
|
|
|
192
196
|
<ol class="mt-4 space-y-10">
|
|
193
197
|
{#each bundle.steps as step, i (step.id)}
|
|
194
198
|
{const locked = $derived((step.role === 'fill' || step.role === 'cover') && slots === 0)}
|
|
195
199
|
<li class={locked ? 'opacity-50' : ''}>
|
|
196
|
-
<
|
|
197
|
-
<
|
|
200
|
+
<Title level={2} size="sm">{i + 1}. {step.title}</Title>
|
|
201
|
+
<Text color="secondary">
|
|
198
202
|
{rule(step)}{step.description ? ` · ${step.description}` : ''}
|
|
199
|
-
</
|
|
203
|
+
</Text>
|
|
200
204
|
<ul class="mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
|
201
205
|
{#each step.products as product (product.id)}
|
|
202
206
|
{const sold = $derived(out(step, product))}
|
|
@@ -219,13 +223,13 @@
|
|
|
219
223
|
src={Images.url(context.imageBaseUrl, product.cover.src)}
|
|
220
224
|
/>
|
|
221
225
|
{/if}
|
|
222
|
-
<
|
|
223
|
-
<
|
|
224
|
-
<
|
|
226
|
+
<div class="min-w-0 flex-1">
|
|
227
|
+
<Span class="block" bold>{label}</Span>
|
|
228
|
+
<Span class="block" color="secondary" size="sm">
|
|
225
229
|
{sold ? 'Out of stock' : priceLabel(step, product)}
|
|
226
|
-
</
|
|
227
|
-
</
|
|
228
|
-
<
|
|
230
|
+
</Span>
|
|
231
|
+
</div>
|
|
232
|
+
<div class="flex shrink-0 items-center gap-1">
|
|
229
233
|
<Button
|
|
230
234
|
aria-label="One fewer {product.name}"
|
|
231
235
|
disabled={n === 0}
|
|
@@ -236,7 +240,7 @@
|
|
|
236
240
|
>
|
|
237
241
|
<Minus size={14} />
|
|
238
242
|
</Button>
|
|
239
|
-
<
|
|
243
|
+
<div class="w-6 text-center" aria-live="polite"><Span bold>{n}</Span></div>
|
|
240
244
|
<Button
|
|
241
245
|
aria-label="One more {product.name}"
|
|
242
246
|
disabled={sold || locked || !canAdd(step, product)}
|
|
@@ -247,7 +251,7 @@
|
|
|
247
251
|
>
|
|
248
252
|
<Plus size={14} />
|
|
249
253
|
</Button>
|
|
250
|
-
</
|
|
254
|
+
</div>
|
|
251
255
|
</div>
|
|
252
256
|
{:else}
|
|
253
257
|
{const on = $derived(chosen(step.id).has(product.id))}
|
|
@@ -268,12 +272,12 @@
|
|
|
268
272
|
src={Images.url(context.imageBaseUrl, product.cover.src)}
|
|
269
273
|
/>
|
|
270
274
|
{/if}
|
|
271
|
-
<
|
|
272
|
-
<
|
|
273
|
-
<
|
|
275
|
+
<Span class="min-w-0">
|
|
276
|
+
<Span class="block" bold>{label}</Span>
|
|
277
|
+
<Span class="block" color="secondary" size="sm">
|
|
274
278
|
{sold ? 'Out of stock' : priceLabel(step, product)}
|
|
275
|
-
</
|
|
276
|
-
</
|
|
279
|
+
</Span>
|
|
280
|
+
</Span>
|
|
277
281
|
</button>
|
|
278
282
|
{/if}
|
|
279
283
|
</li>
|
|
@@ -286,16 +290,15 @@
|
|
|
286
290
|
<div
|
|
287
291
|
class="sticky bottom-0 mt-10 flex flex-wrap items-center justify-between gap-3 border-t border-[var(--bd)] bg-white py-4"
|
|
288
292
|
>
|
|
289
|
-
<
|
|
290
|
-
<
|
|
293
|
+
<Text class="flex items-baseline gap-2">
|
|
294
|
+
<Span color="secondary">Total</Span>
|
|
291
295
|
<strong class="text-xl">{Money.format(totalPence)}</strong>
|
|
292
296
|
{#if totalPence < listPence}
|
|
293
297
|
<s class="text-sm text-[var(--txt)]">{Money.format(listPence)}</s>
|
|
294
298
|
{/if}
|
|
295
|
-
</
|
|
299
|
+
</Text>
|
|
296
300
|
<div class="flex items-center gap-3">
|
|
297
|
-
{#if missing}<
|
|
298
|
-
>{/if}
|
|
301
|
+
{#if missing}<Span color="secondary">{missing.title}: {rule(missing)}</Span>{/if}
|
|
299
302
|
<Button
|
|
300
303
|
disabled={busy || soldOut !== undefined || missing !== undefined || totalPence === 0}
|
|
301
304
|
onclick={add}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { resolve } from '$app/paths';
|
|
3
|
-
import { getAdminCategories } from '../admin.remote';
|
|
4
|
-
import CategoryForm from './CategoryForm.svelte';
|
|
5
3
|
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
6
4
|
import Button from '@zeyolabs/ui/form/Button.svelte';
|
|
5
|
+
import Span from '@zeyolabs/ui/text/Span.svelte';
|
|
6
|
+
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
7
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
8
|
+
|
|
9
|
+
import { getAdminCategories } from '../admin.remote';
|
|
10
|
+
import CategoryForm from './CategoryForm.svelte';
|
|
7
11
|
|
|
8
12
|
type Category = {
|
|
9
13
|
description: string;
|
|
@@ -19,9 +23,9 @@
|
|
|
19
23
|
|
|
20
24
|
<svelte:head><title>Categories · Admin</title></svelte:head>
|
|
21
25
|
|
|
22
|
-
<
|
|
26
|
+
<Text><a href={resolve('/products')}>← Products</a></Text>
|
|
23
27
|
<div class="mt-2 flex items-center justify-between">
|
|
24
|
-
<
|
|
28
|
+
<Title level={1} size="md">Categories</Title>
|
|
25
29
|
<Button onclick={() => (editing = null)}>New category</Button>
|
|
26
30
|
</div>
|
|
27
31
|
|
|
@@ -33,21 +37,20 @@
|
|
|
33
37
|
|
|
34
38
|
<Boundary message="Could not load categories.">
|
|
35
39
|
{let rows = $derived(await getAdminCategories())}
|
|
36
|
-
<ul class="mt-4 divide-y divide-[var(--
|
|
40
|
+
<ul class="mt-4 divide-y divide-[var(--bd)] rounded-xl border border-[var(--bd)] bg-white">
|
|
37
41
|
{#each rows as row (row.id)}
|
|
38
42
|
<li class="flex items-center justify-between gap-3 px-4 py-2 text-sm">
|
|
39
|
-
<
|
|
43
|
+
<Span
|
|
40
44
|
><strong>{row.name}</strong>
|
|
41
|
-
<
|
|
42
|
-
></span
|
|
45
|
+
<Span color="secondary">/category/{row.slug} · {row.products} products</Span></Span
|
|
43
46
|
>
|
|
44
47
|
<button class="underline" onclick={() => (editing = row)} type="button">Edit</button>
|
|
45
48
|
</li>
|
|
46
49
|
{:else}
|
|
47
|
-
<li class="px-4 py-6 text-[var(--
|
|
50
|
+
<li class="px-4 py-6 text-[var(--txs)]">No categories yet.</li>
|
|
48
51
|
{/each}
|
|
49
52
|
</ul>
|
|
50
53
|
{#snippet pending()}
|
|
51
|
-
<
|
|
54
|
+
<Text class="mt-6" color="secondary">Loading…</Text>
|
|
52
55
|
{/snippet}
|
|
53
56
|
</Boundary>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { saveCategoryForm } from '../admin.remote';
|
|
3
|
-
import { CategoryFormSchema } from '../schema';
|
|
4
2
|
import { Form, MessageField, NumberField, TextField } from '@zeyolabs/ui/form';
|
|
5
3
|
import Button from '@zeyolabs/ui/form/Button.svelte';
|
|
6
4
|
|
|
5
|
+
import { saveCategoryForm } from '../admin.remote';
|
|
6
|
+
import { CategoryFormSchema } from '../schema';
|
|
7
|
+
|
|
7
8
|
type Category = {
|
|
8
9
|
description: string;
|
|
9
10
|
id: number;
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
</script>
|
|
27
28
|
|
|
28
29
|
<Form
|
|
29
|
-
class="grid max-w-xl gap-3 rounded-xl border border-[var(--
|
|
30
|
+
class="grid max-w-xl gap-3 rounded-xl border border-[var(--bd)] bg-white p-5"
|
|
30
31
|
defaults={{
|
|
31
32
|
description: category?.description ?? '',
|
|
32
33
|
name: category?.name ?? '',
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { resolve } from '$app/paths';
|
|
3
|
+
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
4
|
+
import Text from '@zeyolabs/ui/text/Text.svelte';
|
|
5
|
+
import Title from '@zeyolabs/ui/text/Title.svelte';
|
|
6
|
+
|
|
3
7
|
import { getAdminProduct, getProductOptions } from '../admin.remote';
|
|
4
8
|
import ProductForm from './ProductForm.svelte';
|
|
5
|
-
import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
|
|
6
9
|
|
|
7
10
|
/** The product to edit; leave out for a new one. */
|
|
8
11
|
let { id }: { id?: number } = $props();
|
|
@@ -10,8 +13,8 @@
|
|
|
10
13
|
|
|
11
14
|
<svelte:head><title>{id ? 'Edit product' : 'New product'} · Admin</title></svelte:head>
|
|
12
15
|
|
|
13
|
-
<
|
|
14
|
-
<
|
|
16
|
+
<Text><a href={resolve('/products')}>← Products</a></Text>
|
|
17
|
+
<Title class="mt-2 mb-6" level={1} size="md">{id ? 'Edit product' : 'New product'}</Title>
|
|
15
18
|
|
|
16
19
|
<Boundary message="Could not load the product." statusMessages={{ 404: 'Product not found.' }}>
|
|
17
20
|
{let options = $derived(await getProductOptions())}
|
|
@@ -20,6 +23,6 @@
|
|
|
20
23
|
<ProductForm {options} {product} />
|
|
21
24
|
{/key}
|
|
22
25
|
{#snippet pending()}
|
|
23
|
-
<
|
|
26
|
+
<Text color="secondary">Loading…</Text>
|
|
24
27
|
{/snippet}
|
|
25
28
|
</Boundary>
|