@zeyolabs/shopping 2026.11.39 → 2026.11.41

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.
@@ -0,0 +1,51 @@
1
+ import { logger } from '@zeyolabs/kit/server/logger';
2
+
3
+ import { ShopClients } from '../clients/shop.server';
4
+ import { StripeClient } from '../clients/stripe';
5
+ import { secret } from '../config';
6
+ import { OrderManager } from '../orders/manager.server';
7
+
8
+ const FULFIL_ON = new Set([
9
+ 'checkout.session.async_payment_succeeded',
10
+ 'checkout.session.completed',
11
+ ]);
12
+
13
+ /**
14
+ * Stripe's webhook, independent of any framework: the shop's SvelteKit route and the standalone
15
+ * payments Worker both answer with it. Runs inside `runWithContext`.
16
+ */
17
+ export const StripeWebhook = {
18
+ /**
19
+ * Unsigned or mis-signed requests get a 400 before any work. A paid Checkout session is
20
+ * fulfilled; a failed fulfilment answers 500 so Stripe retries (fulfilment is idempotent).
21
+ * Every other event is acknowledged and ignored.
22
+ */
23
+ async handle(request: Request): Promise<Response> {
24
+ const signature = request.headers.get('stripe-signature');
25
+ if (!signature) return new Response('Missing signature', { status: 400 });
26
+
27
+ let event;
28
+ try {
29
+ event = await ShopClients.stripe().webhooks.constructEventAsync(
30
+ await request.text(),
31
+ signature,
32
+ secret('stripeWebhookSecret'),
33
+ undefined,
34
+ StripeClient.webhookCrypto
35
+ );
36
+ } catch {
37
+ return new Response('Invalid signature', { status: 400 });
38
+ }
39
+
40
+ if (FULFIL_ON.has(event.type)) {
41
+ const session = event.data.object as { id: string };
42
+ try {
43
+ await OrderManager.fulfil(session.id);
44
+ } catch (err) {
45
+ logger.error(err, { eventId: event.id, op: 'stripeWebhook' });
46
+ return new Response('Fulfilment failed', { status: 500 });
47
+ }
48
+ }
49
+ return Response.json({ received: true });
50
+ },
51
+ };
@@ -2,6 +2,7 @@
2
2
  import type { Snippet } from 'svelte';
3
3
 
4
4
  import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
5
+ import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
5
6
  import SkeletonCard from '@zeyolabs/ui/skeleton/SkeletonCard.svelte';
6
7
  import Span from '@zeyolabs/ui/text/Span.svelte';
7
8
  import Text from '@zeyolabs/ui/text/Text.svelte';
@@ -48,20 +49,22 @@
48
49
  {:else}
49
50
  <ul class="mt-2 divide-y divide-[var(--bd)] border-y border-[var(--bd)]">
50
51
  {#each data.orders as order (order.number)}
51
- <li class="flex flex-wrap items-center justify-between gap-2 py-3">
52
- <Span>
53
- {#if order.path}
54
- <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- the order's private path -->
55
- <a class="font-medium underline" href={order.path}>{order.number}</a>
56
- {:else}
57
- <Span bold>{order.number}</Span>
58
- {/if}
59
- <Span color="secondary">· {date.format(order.createdAt)}</Span>
60
- </Span>
61
- <Span>
62
- <Span color="secondary">{STATUS[order.status] ?? order.status}</Span>
63
- · {Money.format(order.totalPence)}
64
- </Span>
52
+ <li class="py-3">
53
+ <Cluster gap="xs" justify="between">
54
+ <Span>
55
+ {#if order.path}
56
+ <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- the order's private path -->
57
+ <a class="underline" href={order.path}><Span bold>{order.number}</Span></a>
58
+ {:else}
59
+ <Span bold>{order.number}</Span>
60
+ {/if}
61
+ <Span color="secondary">· {date.format(order.createdAt)}</Span>
62
+ </Span>
63
+ <Span>
64
+ <Span color="secondary">{STATUS[order.status] ?? order.status}</Span>
65
+ · {Money.format(order.totalPence)}
66
+ </Span>
67
+ </Cluster>
65
68
  </li>
66
69
  {/each}
67
70
  </ul>
@@ -5,6 +5,7 @@
5
5
  import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
6
6
  import { CheckboxField, Form, NumberField, SelectField, TextField } from '@zeyolabs/ui/form';
7
7
  import Button from '@zeyolabs/ui/form/Button.svelte';
8
+ import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
8
9
  import Span from '@zeyolabs/ui/text/Span.svelte';
9
10
  import Text from '@zeyolabs/ui/text/Text.svelte';
10
11
  import Title from '@zeyolabs/ui/text/Title.svelte';
@@ -64,7 +65,7 @@
64
65
 
65
66
  <Boundary message="Could not load this order." statusMessages={{ 404: 'Order not found.' }}>
66
67
  {let order = $derived(await getOrder(number))}
67
- <div class="mt-4 flex flex-wrap items-center gap-3">
68
+ <Cluster class="mt-4" gap="sm">
68
69
  <Title level={1} size="md">{order.number}</Title>
69
70
  <Badge
70
71
  color={order.status === 'paid'
@@ -75,7 +76,7 @@
75
76
  >
76
77
  {order.status === 'paid' ? 'To ship' : order.status}
77
78
  </Badge>
78
- </div>
79
+ </Cluster>
79
80
  <Text class="mt-1" color="secondary">
80
81
  Placed {date.format(order.createdAt)}{order.paidAt
81
82
  ? ` · paid ${date.format(order.paidAt)}`
@@ -108,35 +109,41 @@
108
109
  <Title level={2} size="sm">Items</Title>
109
110
  <ul class="mt-2 divide-y divide-[var(--bd)]">
110
111
  {#each order.items as item (item.id)}
111
- <li class="flex justify-between gap-4 py-2">
112
- <Span>{item.name} <Span color="secondary">× {item.quantity}</Span></Span>
113
- <Span>{Money.format(item.quantity * item.unitPricePence)}</Span>
112
+ <li class="py-2">
113
+ <Cluster gap="sm" justify="between" nowrap>
114
+ <Span>{item.name} <Span color="secondary">× {item.quantity}</Span></Span>
115
+ <Span>{Money.format(item.quantity * item.unitPricePence)}</Span>
116
+ </Cluster>
114
117
  </li>
115
118
  {/each}
116
119
  </ul>
117
- <dl class="mt-3 space-y-1 text-sm">
120
+ <dl class="mt-3 space-y-1">
118
121
  <div class="flex justify-between">
119
- <dt>Subtotal</dt>
120
- <dd>{Money.format(order.subtotalPence)}</dd>
122
+ <dt><Span size="sm">Subtotal</Span></dt>
123
+ <dd><Span size="sm">{Money.format(order.subtotalPence)}</Span></dd>
121
124
  </div>
122
125
  {#if order.discountPence > 0}
123
126
  <div class="flex justify-between">
124
- <dt>Discount</dt>
125
- <dd>-{Money.format(order.discountPence)}</dd>
127
+ <dt><Span size="sm">Discount</Span></dt>
128
+ <dd><Span size="sm">-{Money.format(order.discountPence)}</Span></dd>
126
129
  </div>
127
130
  {/if}
128
131
  <div class="flex justify-between">
129
- <dt>Delivery</dt>
130
- <dd>{order.shippingPence === 0 ? 'Free' : Money.format(order.shippingPence)}</dd>
132
+ <dt><Span size="sm">Delivery</Span></dt>
133
+ <dd>
134
+ <Span size="sm"
135
+ >{order.shippingPence === 0 ? 'Free' : Money.format(order.shippingPence)}</Span
136
+ >
137
+ </dd>
131
138
  </div>
132
- <div class="flex justify-between font-semibold">
133
- <dt>Total</dt>
134
- <dd>{Money.format(order.totalPence)}</dd>
139
+ <div class="flex justify-between">
140
+ <dt><Span bold size="sm">Total</Span></dt>
141
+ <dd><Span bold size="sm">{Money.format(order.totalPence)}</Span></dd>
135
142
  </div>
136
143
  {#if order.refundedPence > 0}
137
144
  <div class="flex justify-between">
138
- <dt>Refunded</dt>
139
- <dd>-{Money.format(order.refundedPence)}</dd>
145
+ <dt><Span size="sm">Refunded</Span></dt>
146
+ <dd><Span size="sm">-{Money.format(order.refundedPence)}</Span></dd>
140
147
  </div>
141
148
  {/if}
142
149
  </dl>
@@ -146,10 +153,10 @@
146
153
  {#if order.status === 'paid'}
147
154
  {let stage = $derived(Packing.stage(order))}
148
155
  <section class="mt-6 max-w-xl rounded-xl border border-[var(--bd)] bg-white p-5">
149
- <div class="flex flex-wrap items-center gap-3">
156
+ <Cluster gap="sm">
150
157
  <Title level={2} size="sm">Packing</Title>
151
158
  <Badge color={Packing.STAGE_COLORS[stage]}>{Packing.STAGE_LABELS[stage]}</Badge>
152
- </div>
159
+ </Cluster>
153
160
  <Text class="mt-1" color="secondary">
154
161
  {#if order.heldAt}On hold since {date.format(order.heldAt)}.{/if}
155
162
  {#if order.packingStartedAt}Packing started {date.format(order.packingStartedAt)}.{/if}
@@ -157,45 +164,47 @@
157
164
  {#if order.labelCreatedAt}Label created {date.format(order.labelCreatedAt)}.{/if}
158
165
  </Text>
159
166
  <Form
160
- class="mt-4 flex flex-wrap gap-2"
167
+ class="mt-4"
161
168
  form={updateOrderForm}
162
169
  hidden={{ number: order.number }}
163
170
  schema={OrderStepSchema}
164
171
  >
165
- {#if stage === 'new'}
166
- <Button {...updateOrderForm.fields.step.as('submit', 'start')} form={updateOrderForm}
167
- >Start packing</Button
168
- >
169
- {:else if stage === 'packing'}
170
- <Button
171
- {...updateOrderForm.fields.step.as('submit', 'pack')}
172
- form={updateOrderForm}
173
- variant="secondary"
174
- >
175
- Mark packed
176
- </Button>
177
- {:else if stage === 'packed' || stage === 'label'}
178
- <Button disabled={printing} onclick={() => printLabel(order.number)}>
179
- {order.labelCreatedAt ? 'Reprint label' : 'Print label'}
180
- </Button>
181
- {/if}
182
- {#if stage === 'held'}
183
- <Button
184
- {...updateOrderForm.fields.step.as('submit', 'release')}
185
- form={updateOrderForm}
186
- variant="secondary"
187
- >
188
- Release hold
189
- </Button>
190
- {:else if stage !== 'label'}
191
- <Button
192
- {...updateOrderForm.fields.step.as('submit', 'hold')}
193
- form={updateOrderForm}
194
- variant="secondary"
195
- >
196
- Put on hold
197
- </Button>
198
- {/if}
172
+ <Cluster gap="xs">
173
+ {#if stage === 'new'}
174
+ <Button {...updateOrderForm.fields.step.as('submit', 'start')} form={updateOrderForm}
175
+ >Start packing</Button
176
+ >
177
+ {:else if stage === 'packing'}
178
+ <Button
179
+ {...updateOrderForm.fields.step.as('submit', 'pack')}
180
+ form={updateOrderForm}
181
+ variant="secondary"
182
+ >
183
+ Mark packed
184
+ </Button>
185
+ {:else if stage === 'packed' || stage === 'label'}
186
+ <Button disabled={printing} onclick={() => printLabel(order.number)}>
187
+ {order.labelCreatedAt ? 'Reprint label' : 'Print label'}
188
+ </Button>
189
+ {/if}
190
+ {#if stage === 'held'}
191
+ <Button
192
+ {...updateOrderForm.fields.step.as('submit', 'release')}
193
+ form={updateOrderForm}
194
+ variant="secondary"
195
+ >
196
+ Release hold
197
+ </Button>
198
+ {:else if stage !== 'label'}
199
+ <Button
200
+ {...updateOrderForm.fields.step.as('submit', 'hold')}
201
+ form={updateOrderForm}
202
+ variant="secondary"
203
+ >
204
+ Put on hold
205
+ </Button>
206
+ {/if}
207
+ </Cluster>
199
208
  </Form>
200
209
 
201
210
  <Text class="mt-3" color="secondary">
@@ -254,7 +263,8 @@
254
263
  {let services = $derived(await getShippingServices())}
255
264
  <section class="mt-6 max-w-xl rounded-xl border border-[var(--bd)] bg-white p-5">
256
265
  <details>
257
- <summary class="cursor-pointer font-semibold">Edit contact, address and postage</summary>
266
+ <summary class="cursor-pointer"><Span bold>Edit contact, address and postage</Span></summary
267
+ >
258
268
  <Text class="mt-2" color="secondary">
259
269
  For fixing a typo or a customer's request. If you change the country, check the postage
260
270
  service still fits. {#if order.status === 'paid' && order.labelCreatedAt}The label is
@@ -5,6 +5,7 @@
5
5
  import Badge from '@zeyolabs/ui/badge/Badge.svelte';
6
6
  import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
7
7
  import Button from '@zeyolabs/ui/form/Button.svelte';
8
+ import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
8
9
  import Span from '@zeyolabs/ui/text/Span.svelte';
9
10
  import Text from '@zeyolabs/ui/text/Text.svelte';
10
11
  import Title from '@zeyolabs/ui/text/Title.svelte';
@@ -86,45 +87,46 @@
86
87
 
87
88
  <Title level={1} size="md">Orders</Title>
88
89
 
89
- <nav class="mt-4 flex flex-wrap items-center gap-2" aria-label="Order filter">
90
- {#each ORDER_FILTERS as f (f)}
91
- <!-- eslint-disable svelte/no-navigation-without-resolve -- href() resolves the path -->
92
- <a
93
- class="rounded-full border px-3 py-1 text-sm no-underline {f === filter
94
- ? 'border-[var(--acc)] bg-[var(--acc)] text-white'
95
- : 'border-[var(--bd)] bg-white text-[var(--tx)]'}"
96
- aria-current={f === filter ? 'page' : undefined}
97
- href={href({ filter: f })}
98
- >
99
- {FILTER_LABELS[f]}
100
- ({(await getOrderCounts())[f]})
101
- </a>
102
- <!-- eslint-enable svelte/no-navigation-without-resolve -->
103
- {/each}
104
- <Boundary message="Could not load ready counts.">
105
- {#each Object.entries(await getReadyByService()) as [service, n] (service)}
106
- <Span color="secondary">{service}: {n} ready</Span>
90
+ <nav class="mt-4" aria-label="Order filter">
91
+ <Cluster gap="xs">
92
+ {#each ORDER_FILTERS as f (f)}
93
+ <!-- eslint-disable svelte/no-navigation-without-resolve -- href() resolves the path -->
94
+ <a
95
+ class="rounded-full border px-3 py-1 no-underline {f === filter
96
+ ? 'border-[var(--acc)] bg-[var(--acc)] text-white'
97
+ : 'border-[var(--bd)] bg-white text-[var(--tx)]'}"
98
+ aria-current={f === filter ? 'page' : undefined}
99
+ href={href({ filter: f })}
100
+ >
101
+ <Span size="sm">{FILTER_LABELS[f]} ({(await getOrderCounts())[f]})</Span>
102
+ </a>
103
+ <!-- eslint-enable svelte/no-navigation-without-resolve -->
107
104
  {/each}
105
+ <Boundary message="Could not load ready counts.">
106
+ {#each Object.entries(await getReadyByService()) as [service, n] (service)}
107
+ <Span color="secondary">{service}: {n} ready</Span>
108
+ {/each}
108
109
 
109
- {#snippet pending()}{/snippet}
110
- </Boundary>
111
- <form
112
- class="ml-auto"
113
- onsubmit={(event) => {
114
- event.preventDefault();
115
- const input = new FormData(event.currentTarget).get('q');
116
- // eslint-disable-next-line svelte/no-navigation-without-resolve -- href() already resolves the path
117
- goto(href({ q: typeof input === 'string' ? input.trim() : '' }));
118
- }}
119
- >
120
- <input
121
- name="q"
122
- class="w-56 rounded-md border border-[var(--bd)] px-3 py-1.5 text-sm"
123
- placeholder="Order, email or name"
124
- type="search"
125
- value={q}
126
- />
127
- </form>
110
+ {#snippet pending()}{/snippet}
111
+ </Boundary>
112
+ <form
113
+ class="ml-auto"
114
+ onsubmit={(event) => {
115
+ event.preventDefault();
116
+ const input = new FormData(event.currentTarget).get('q');
117
+ // eslint-disable-next-line svelte/no-navigation-without-resolve -- href() already resolves the path
118
+ goto(href({ q: typeof input === 'string' ? input.trim() : '' }));
119
+ }}
120
+ >
121
+ <input
122
+ name="q"
123
+ class="w-56 rounded-md border border-[var(--bd)] px-3 py-1.5"
124
+ placeholder="Order, email or name"
125
+ type="search"
126
+ value={q}
127
+ />
128
+ </form>
129
+ </Cluster>
128
130
  </nav>
129
131
 
130
132
  <Boundary message="Could not load orders.">
@@ -137,9 +139,10 @@
137
139
  </Text>
138
140
  {:else}
139
141
  {#if filter === 'ready'}
140
- <div class="mt-4 flex flex-wrap items-center gap-4 text-sm">
141
- <label class="flex items-center gap-2">
142
+ <Cluster class="mt-4" gap="md">
143
+ <Cluster gap="xs" nowrap>
142
144
  <input
145
+ id="select-ready"
143
146
  checked={rows.length > 0 &&
144
147
  chosen.length === Math.min(rows.length, BULK_DISPATCH_LIMIT)}
145
148
  onchange={(event) => {
@@ -149,30 +152,32 @@
149
152
  }}
150
153
  type="checkbox"
151
154
  />
152
- Select {Math.min(rows.length, BULK_DISPATCH_LIMIT)}
153
- </label>
154
- <label class="flex items-center gap-2">
155
- <input type="checkbox" bind:checked={sendEmail} />
156
- Email the customers
157
- </label>
155
+ <label for="select-ready"
156
+ ><Span size="sm">Select {Math.min(rows.length, BULK_DISPATCH_LIMIT)}</Span></label
157
+ >
158
+ </Cluster>
159
+ <Cluster gap="xs" nowrap>
160
+ <input id="email-customers" type="checkbox" bind:checked={sendEmail} />
161
+ <label for="email-customers"><Span size="sm">Email the customers</Span></label>
162
+ </Cluster>
158
163
  <Button
159
164
  disabled={chosen.length === 0 || dispatching}
160
165
  onclick={() => dispatchSelected(chosen)}
161
166
  >
162
167
  Dispatch {chosen.length} order{chosen.length === 1 ? '' : 's'}
163
168
  </Button>
164
- </div>
169
+ </Cluster>
165
170
  {/if}
166
171
  <div class="mt-4 overflow-x-auto rounded-xl border border-[var(--bd)] bg-white">
167
- <table class="w-full text-left text-sm">
172
+ <table class="w-full text-left">
168
173
  <thead class="border-b border-[var(--bd)] text-[var(--txs)]">
169
174
  <tr>
170
175
  {#if filter === 'ready'}<th class="w-8 px-4 py-2"></th>{/if}
171
- <th class="px-4 py-2 font-medium">Order</th>
172
- <th class="px-4 py-2 font-medium">Placed</th>
173
- <th class="px-4 py-2 font-medium">Customer</th>
174
- <th class="px-4 py-2 text-right font-medium">Total</th>
175
- <th class="px-4 py-2 font-medium">Status</th>
176
+ <th class="px-4 py-2"><Span bold size="sm">Order</Span></th>
177
+ <th class="px-4 py-2"><Span bold size="sm">Placed</Span></th>
178
+ <th class="px-4 py-2"><Span bold size="sm">Customer</Span></th>
179
+ <th class="px-4 py-2 text-right"><Span bold size="sm">Total</Span></th>
180
+ <th class="px-4 py-2"><Span bold size="sm">Status</Span></th>
176
181
  </tr>
177
182
  </thead>
178
183
  <tbody class="divide-y divide-[var(--bd)]">
@@ -192,15 +197,21 @@
192
197
  />
193
198
  </td>
194
199
  {/if}
195
- <td class="px-4 py-2 font-medium">
196
- <a href={resolve('/orders/[number]', { number: row.number })}>{row.number}</a>
200
+ <td class="px-4 py-2">
201
+ <a href={resolve('/orders/[number]', { number: row.number })}
202
+ ><Span bold size="sm">{row.number}</Span></a
203
+ >
197
204
  </td>
198
- <td class="px-4 py-2 whitespace-nowrap">{date.format(row.createdAt)}</td>
205
+ <td class="px-4 py-2 whitespace-nowrap"
206
+ ><Span size="sm">{date.format(row.createdAt)}</Span></td
207
+ >
199
208
  <td class="px-4 py-2">
200
- {row.name}
201
- <Span class="block" color="secondary" size="sm">{row.email} · {row.country}</Span>
209
+ <Span size="sm">{row.name}</Span>
210
+ <Span class="block" color="secondary" size="xs">{row.email} · {row.country}</Span>
202
211
  </td>
203
- <td class="px-4 py-2 text-right whitespace-nowrap">{Money.format(row.totalPence)}</td>
212
+ <td class="px-4 py-2 text-right whitespace-nowrap"
213
+ ><Span size="sm">{Money.format(row.totalPence)}</Span></td
214
+ >
204
215
  <td class="px-4 py-2">
205
216
  {#if row.status === 'paid' || row.status === 'shipped'}
206
217
  {let stage = $derived(Packing.stage(row))}
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { page } from '$app/state';
3
3
  import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
4
+ import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
4
5
  import SkeletonCard from '@zeyolabs/ui/skeleton/SkeletonCard.svelte';
5
6
  import Span from '@zeyolabs/ui/text/Span.svelte';
6
7
  import Text from '@zeyolabs/ui/text/Text.svelte';
@@ -47,18 +48,20 @@
47
48
  {:else}
48
49
  <ol class="mt-6 space-y-3">
49
50
  {#each steps as step (step.label)}
50
- <li class="flex items-center gap-3">
51
- <div
52
- class="grid size-6 place-items-center rounded-full text-xs {step.done
53
- ? 'bg-[var(--primary-strong)] text-white'
54
- : 'border border-[var(--bd)] text-[var(--txs)]'}"
55
- aria-hidden="true"
56
- >
57
- {step.done ? '✓' : ''}
58
- </div>
59
- <Span bold={step.done} color={step.done ? undefined : 'secondary'}>
60
- {step.label}{step.done && step.when ? `: ${date.format(step.when)}` : ''}
61
- </Span>
51
+ <li>
52
+ <Cluster gap="sm" nowrap>
53
+ <div
54
+ class="grid size-6 place-items-center rounded-full {step.done
55
+ ? 'bg-[var(--primary-strong)] text-white'
56
+ : 'border border-[var(--bd)] text-[var(--txs)]'}"
57
+ aria-hidden="true"
58
+ >
59
+ <Span size="xs">{step.done ? '✓' : ''}</Span>
60
+ </div>
61
+ <Span bold={step.done} color={step.done ? undefined : 'secondary'}>
62
+ {step.label}{step.done && step.when ? `: ${date.format(step.when)}` : ''}
63
+ </Span>
64
+ </Cluster>
62
65
  </li>
63
66
  {/each}
64
67
  </ol>
@@ -83,9 +86,11 @@
83
86
  <Title class="mt-8" level={2} size="sm">Items</Title>
84
87
  <ul class="mt-2 divide-y divide-[var(--bd)] border-y border-[var(--bd)]">
85
88
  {#each data.items as item (item.name)}
86
- <li class="flex justify-between gap-4 py-3">
87
- <Span>{item.name} <Span color="secondary">× {item.quantity}</Span></Span>
88
- <Span>{Money.format(item.quantity * item.unitPricePence)}</Span>
89
+ <li class="py-3">
90
+ <Cluster gap="sm" justify="between" nowrap>
91
+ <Span>{item.name} <Span color="secondary">× {item.quantity}</Span></Span>
92
+ <Span>{Money.format(item.quantity * item.unitPricePence)}</Span>
93
+ </Cluster>
89
94
  </li>
90
95
  {/each}
91
96
  </ul>
@@ -105,9 +110,9 @@
105
110
  <dt>Delivery</dt>
106
111
  <dd>{order.shippingPence === 0 ? 'Free' : Money.format(order.shippingPence)}</dd>
107
112
  </div>
108
- <div class="flex justify-between font-semibold">
109
- <dt>Total</dt>
110
- <dd>{Money.format(order.totalPence)}</dd>
113
+ <div class="flex justify-between">
114
+ <dt><Span bold>Total</Span></dt>
115
+ <dd><Span bold>{Money.format(order.totalPence)}</Span></dd>
111
116
  </div>
112
117
  </dl>
113
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeyolabs/shopping",
3
- "version": "2026.11.39",
3
+ "version": "2026.11.41",
4
4
  "description": "Shop and order fulfilment for SvelteKit 3 on Cloudflare: catalogue, basket, Stripe Checkout, orders, Royal Mail Click & Drop, order emails, packing, pages and admin.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -67,8 +67,8 @@
67
67
  "@eslint/compat": "2.1.1",
68
68
  "@eslint/js": "10.0.1",
69
69
  "@sveltejs/kit": "3.2.0",
70
- "@zeyolabs/kit": "2026.11.36",
71
- "@zeyolabs/ui": "2026.11.32",
70
+ "@zeyolabs/kit": "2026.11.38",
71
+ "@zeyolabs/ui": "2026.11.37",
72
72
  "drizzle-orm": "0.45.4",
73
73
  "eslint": "10.15.0",
74
74
  "eslint-config-prettier": "10.1.8",
@@ -4,11 +4,14 @@
4
4
  import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
5
5
  import { Form } from '@zeyolabs/ui/form';
6
6
  import Button from '@zeyolabs/ui/form/Button.svelte';
7
+ import Cluster from '@zeyolabs/ui/layout/Cluster.svelte';
8
+ import Span from '@zeyolabs/ui/text/Span.svelte';
7
9
  import Text from '@zeyolabs/ui/text/Text.svelte';
8
10
  import Title from '@zeyolabs/ui/text/Title.svelte';
9
11
 
10
12
  import { shopContext } from '../../context';
11
13
  import { REVIEW_STATUSES, type ReviewStatus } from '../../db/schema';
14
+ import Stars from '../../ui/Stars.svelte';
12
15
  import { getReviews, moderateReviewForm } from '../admin.remote';
13
16
  import { ModerateReviewSchema } from '../schema';
14
17
 
@@ -32,16 +35,18 @@
32
35
  Customers review items from their order page. A review shows on the product page once approved.
33
36
  </Text>
34
37
 
35
- <nav class="mt-4 flex gap-2" aria-label="Review status">
36
- {#each REVIEW_STATUSES as s (s)}
37
- <a
38
- class="rounded-full border px-3 py-1 text-sm no-underline {s === status
39
- ? 'border-[var(--acc)] bg-[var(--acc)] text-white'
40
- : 'border-[var(--bd)] bg-white text-[var(--tx)]'}"
41
- aria-current={s === status ? 'page' : undefined}
42
- href="{resolve('/reviews')}?status={s}">{LABELS[s]}</a
43
- >
44
- {/each}
38
+ <nav class="mt-4" aria-label="Review status">
39
+ <Cluster gap="xs">
40
+ {#each REVIEW_STATUSES as s (s)}
41
+ <a
42
+ class="rounded-full border px-3 py-1 no-underline {s === status
43
+ ? 'border-[var(--acc)] bg-[var(--acc)] text-white'
44
+ : 'border-[var(--bd)] bg-white text-[var(--tx)]'}"
45
+ aria-current={s === status ? 'page' : undefined}
46
+ href="{resolve('/reviews')}?status={s}"><Span size="sm">{LABELS[s]}</Span></a
47
+ >
48
+ {/each}
49
+ </Cluster>
45
50
  </nav>
46
51
 
47
52
  <Boundary message="Could not load reviews.">
@@ -64,30 +69,29 @@
64
69
  >
65
70
  · {review.email} · {date.format(review.createdAt)}
66
71
  </Text>
67
- <Text class="mt-2">
68
- <!-- eslint-disable-next-line svelte/no-restricted-html-elements -- star glyphs with an aria-label, which Span does not take -->
69
- <span class="text-[var(--acc)]" aria-label="{review.rating} out of 5"
70
- >{'★'.repeat(review.rating)}{'☆'.repeat(5 - review.rating)}</span
71
- >
72
- {#if review.title}<strong class="ml-2">{review.title}</strong>{/if}
73
- </Text>
72
+ <Cluster class="mt-2" gap="xs">
73
+ <Stars rating={review.rating} size="sm" />
74
+ {#if review.title}<Text bold>{review.title}</Text>{/if}
75
+ </Cluster>
74
76
  <Text class="mt-2 whitespace-pre-line">{review.body}</Text>
75
77
  <Text class="mt-2">by {review.name}</Text>
76
78
  <Form
77
- class="mt-3 flex gap-2"
79
+ class="mt-3"
78
80
  {form}
79
81
  hidden={{ id: review.id }}
80
82
  reset={false}
81
83
  schema={ModerateReviewSchema}
82
84
  >
83
- {#if review.status !== 'approved'}
84
- <Button {...form.fields.status.as('submit', 'approved')} {form}>Approve</Button>
85
- {/if}
86
- {#if review.status !== 'rejected'}
87
- <Button {...form.fields.status.as('submit', 'rejected')} {form} variant="secondary"
88
- >Reject</Button
89
- >
90
- {/if}
85
+ <Cluster gap="xs">
86
+ {#if review.status !== 'approved'}
87
+ <Button {...form.fields.status.as('submit', 'approved')} {form}>Approve</Button>
88
+ {/if}
89
+ {#if review.status !== 'rejected'}
90
+ <Button {...form.fields.status.as('submit', 'rejected')} {form} variant="secondary"
91
+ >Reject</Button
92
+ >
93
+ {/if}
94
+ </Cluster>
91
95
  </Form>
92
96
  </li>
93
97
  {/each}