@zeyolabs/shopping 2026.11.37 → 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.
Files changed (46) hide show
  1. package/basket/client.remote.ts +16 -2
  2. package/basket/cookies.server.ts +13 -1
  3. package/basket/library.ts +58 -0
  4. package/basket/pages/Basket.svelte +80 -30
  5. package/basket/service.server.ts +139 -6
  6. package/bundles/admin/BundleEditPage.svelte +7 -4
  7. package/bundles/admin/BundleForm.svelte +50 -11
  8. package/bundles/admin/BundlesPage.svelte +14 -10
  9. package/bundles/client.remote.ts +18 -6
  10. package/bundles/library.ts +51 -0
  11. package/bundles/pages/Bundle.svelte +233 -68
  12. package/bundles/schema.ts +13 -2
  13. package/bundles/service.server.ts +185 -33
  14. package/catalogue/admin/CategoriesPage.svelte +13 -10
  15. package/catalogue/admin/CategoryForm.svelte +4 -3
  16. package/catalogue/admin/ProductEditPage.svelte +7 -4
  17. package/catalogue/admin/ProductForm.svelte +31 -29
  18. package/catalogue/admin/ProductsPage.svelte +16 -14
  19. package/catalogue/client.remote.ts +23 -9
  20. package/catalogue/components/ProductCard.svelte +22 -14
  21. package/catalogue/library.ts +91 -0
  22. package/catalogue/loads.server.ts +8 -4
  23. package/catalogue/pages/Category.svelte +15 -6
  24. package/catalogue/pages/Product.svelte +164 -45
  25. package/catalogue/pages/Search.svelte +12 -7
  26. package/catalogue/pages/Shop.svelte +12 -12
  27. package/catalogue/service.server.ts +44 -9
  28. package/checkout/manager.server.ts +68 -16
  29. package/checkout/pages/CheckoutSuccess.svelte +10 -8
  30. package/customers/pages/Account.svelte +19 -15
  31. package/db/schema.ts +27 -3
  32. package/fulfilment/admin/OrderPage.svelte +60 -56
  33. package/fulfilment/admin/OrdersPage.svelte +26 -22
  34. package/orders/manager.server.ts +45 -11
  35. package/orders/pages/Order.svelte +35 -29
  36. package/orders/service.server.ts +25 -3
  37. package/package.json +5 -4
  38. package/reviews/admin/ReviewsPage.svelte +23 -19
  39. package/reviews/components/ReviewForm.svelte +3 -2
  40. package/reviews/components/Reviews.svelte +17 -13
  41. package/stock/admin/StockPage.svelte +12 -9
  42. package/stock/admin/StockRow.svelte +3 -2
  43. package/stock/service.server.ts +6 -1
  44. package/ui/PageLinks.svelte +45 -0
  45. package/ui/PageTitle.svelte +20 -4
  46. package/ui/Stars.svelte +3 -1
@@ -1,4 +1,4 @@
1
- import { and, asc, desc, eq, sql } from 'drizzle-orm';
1
+ import { and, asc, count, desc, eq, inArray, sql } from 'drizzle-orm';
2
2
 
3
3
  import type { ShopDb } from '../db/index';
4
4
 
@@ -10,9 +10,9 @@ import {
10
10
  products,
11
11
  productSlugAliases,
12
12
  } from '../db/schema';
13
- import { StockService } from '../stock/service.server';
13
+ import { sellableSql, StockService } from '../stock/service.server';
14
14
  import { CoverService } from './covers.server';
15
- import { Search } from './library';
15
+ import { Paging, Search } from './library';
16
16
 
17
17
  type Product = typeof products.$inferSelect;
18
18
 
@@ -66,6 +66,36 @@ export class CatalogueService {
66
66
  return { options, product, variationName: product.variationGroup?.name };
67
67
  }
68
68
 
69
+ /**
70
+ * One page of active products (all of them, or one category's): those that can be bought first,
71
+ * then by sort order and name. `page` is 1-based; `pages` is at least 1.
72
+ */
73
+ async productPage(page: number, categoryId?: number) {
74
+ const where = and(
75
+ eq(products.active, true),
76
+ categoryId === undefined
77
+ ? undefined
78
+ : inArray(
79
+ products.id,
80
+ this.db
81
+ .select({ id: productCategories.productId })
82
+ .from(productCategories)
83
+ .where(eq(productCategories.categoryId, categoryId))
84
+ )
85
+ );
86
+ const [[{ total }], list] = await Promise.all([
87
+ this.db.select({ total: count() }).from(products).where(where),
88
+ this.db
89
+ .select()
90
+ .from(products)
91
+ .where(where)
92
+ .orderBy(desc(sellableSql), asc(products.sortOrder), asc(products.name))
93
+ .limit(Paging.PER_PAGE)
94
+ .offset((page - 1) * Paging.PER_PAGE),
95
+ ]);
96
+ return { page, pages: Paging.pages(total), products: await this.withCovers(list), total };
97
+ }
98
+
69
99
  /** Every active product, each with its cover image. */
70
100
  async products() {
71
101
  const list = await this.db
@@ -125,17 +155,22 @@ export class CatalogueService {
125
155
  };
126
156
  }
127
157
 
128
- /** Adds each product's cover image (lowest position). `stock` becomes what can be sold now. */
158
+ /**
159
+ * Adds each product's cover image (lowest position). `stock` becomes what can be sold now, and
160
+ * products that can be bought come first; within each half the order is unchanged.
161
+ */
129
162
  private async withCovers(list: Product[]) {
130
163
  if (list.length === 0) return [];
131
164
  const ids = list.map((p) => p.id);
132
165
  const covers = new CoverService(this.db);
133
166
  const stock = new StockService(this.db);
134
167
  const [cover, sellable] = await Promise.all([covers.covers(ids), stock.availableMany(ids)]);
135
- return list.map((product) => ({
136
- ...product,
137
- cover: cover.get(product.id),
138
- stock: sellable.get(product.id) ?? 0,
139
- }));
168
+ return list
169
+ .map((product) => ({
170
+ ...product,
171
+ cover: cover.get(product.id),
172
+ stock: sellable.get(product.id) ?? 0,
173
+ }))
174
+ .toSorted((a, b) => Number(b.stock > 0) - Number(a.stock > 0));
140
175
  }
141
176
  }
@@ -6,6 +6,7 @@ import { Error400 } from '@zeyolabs/kit/utils/errors';
6
6
 
7
7
  import { BasketCookies } from '../basket/cookies.server';
8
8
  import { BasketService, type BasketSummary } from '../basket/service.server';
9
+ import { BundleParts } from '../bundles/library';
9
10
  import { ShopClients } from '../clients/shop.server';
10
11
  import { shopping } from '../config';
11
12
  import { CustomerService } from '../customers/service.server';
@@ -30,10 +31,17 @@ export const CheckoutManager = {
30
31
  const summary = await basket.summarise(
31
32
  BasketCookies.read(cookies),
32
33
  BasketCookies.readShipTo(cookies, config.shipping.defaultCountry),
33
- config.shipping
34
+ config.shipping,
35
+ BasketCookies.readBundles(cookies)
34
36
  );
35
37
 
36
- if (summary.lines.length === 0) throw Error400('Your basket is empty.');
38
+ if (summary.lines.length === 0 && summary.bundles.length === 0) {
39
+ throw Error400('Your basket is empty.');
40
+ }
41
+ const brokenBundle = summary.bundles.find((b) => !b.available);
42
+ if (brokenBundle) {
43
+ throw Error400(`${brokenBundle.name}: ${brokenBundle.problem} Please remove it to continue.`);
44
+ }
37
45
  const unavailable = summary.lines.find((line) => line.available < 1);
38
46
  if (unavailable)
39
47
  throw Error400(`${unavailable.name} is out of stock. Please remove it to continue.`);
@@ -86,20 +94,11 @@ function sessionParams(
86
94
  },
87
95
  }
88
96
  : undefined,
89
- line_items: summary.lines.map((line) => ({
90
- price_data: {
91
- currency: 'gbp',
92
- product_data: {
93
- images: line.cover
94
- ? [new URL(Images.url(imageBaseUrl, line.cover.src), origin).href]
95
- : undefined,
96
- metadata: { productId: String(line.id), sku: line.sku },
97
- name: line.name,
98
- },
99
- unit_amount: line.pricePence,
100
- },
101
- quantity: line.available,
102
- })),
97
+ line_items: [
98
+ ...summary.lines.map((line) => productItem(line, imageBaseUrl, origin)),
99
+ ...summary.bundles.map((bundle) => bundleItem(bundle, imageBaseUrl, origin)),
100
+ ],
101
+
103
102
  metadata: {
104
103
  country: summary.country,
105
104
  shippingService: summary.shipping.service,
@@ -125,3 +124,56 @@ function sessionParams(
125
124
  success_url: `${origin}/checkout/complete?session_id={CHECKOUT_SESSION_ID}`,
126
125
  };
127
126
  }
127
+
128
+ type LineItem = Stripe.Checkout.SessionCreateParams.LineItem;
129
+
130
+ function productItem(
131
+ line: BasketSummary['lines'][number],
132
+ imageBaseUrl: string,
133
+ origin: string
134
+ ): LineItem {
135
+ return {
136
+ price_data: {
137
+ currency: 'gbp',
138
+ product_data: {
139
+ images: line.cover
140
+ ? [new URL(Images.url(imageBaseUrl, line.cover.src), origin).href]
141
+ : undefined,
142
+ metadata: { productId: String(line.id), sku: line.sku },
143
+ name: line.name,
144
+ },
145
+ unit_amount: line.pricePence,
146
+ },
147
+ quantity: line.available,
148
+ };
149
+ }
150
+
151
+ /**
152
+ * A kit or discounted bundle as one Checkout line at its price. Its parts travel in the metadata
153
+ * (`BundleParts`) so the order can record them and take their stock once paid.
154
+ */
155
+ function bundleItem(
156
+ bundle: BasketSummary['bundles'][number],
157
+ imageBaseUrl: string,
158
+ origin: string
159
+ ): LineItem {
160
+ return {
161
+ price_data: {
162
+ currency: 'gbp',
163
+ product_data: {
164
+ description: bundle.details.join(', ').slice(0, 500) || undefined,
165
+ images: bundle.cover
166
+ ? [new URL(Images.url(imageBaseUrl, bundle.cover.src), origin).href]
167
+ : undefined,
168
+ metadata: {
169
+ bundleId: String(bundle.bundleId),
170
+ bundleParts: BundleParts.encode(bundle.parts),
171
+ sku: `BUNDLE-${bundle.bundleId}`,
172
+ },
173
+ name: bundle.name,
174
+ },
175
+ unit_amount: bundle.pricePence,
176
+ },
177
+ quantity: 1,
178
+ };
179
+ }
@@ -1,10 +1,12 @@
1
1
  <script lang="ts">
2
2
  import { resolve } from '$app/paths';
3
3
  import { page } from '$app/state';
4
- import PageTitle from '../../ui/PageTitle.svelte';
5
- import { getCheckoutOrder } from '../../orders/client.remote';
6
4
  import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
7
5
  import SkeletonText from '@zeyolabs/ui/skeleton/SkeletonText.svelte';
6
+ import Text from '@zeyolabs/ui/text/Text.svelte';
7
+
8
+ import { getCheckoutOrder } from '../../orders/client.remote';
9
+ import PageTitle from '../../ui/PageTitle.svelte';
8
10
 
9
11
  const sessionId = page.url.searchParams.get('session_id') ?? '';
10
12
  </script>
@@ -15,22 +17,22 @@
15
17
  <!-- `/checkout/complete` has already fulfilled the order and emptied the basket on the server. -->
16
18
  {const order = $derived(sessionId ? await getCheckoutOrder(sessionId) : null)}
17
19
  {#if order}
18
- <p>
20
+ <Text>
19
21
  Your order number is <strong>{order.number}</strong>. A confirmation email is on its way.
20
- </p>
22
+ </Text>
21
23
  {#if order.orderPath}
22
24
  <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- token path built server-side -->
23
- <p class="mt-4"><a class="btn default" href={order.orderPath}>View your order</a></p>
25
+ <Text class="mt-4"><a class="btn default" href={order.orderPath}>View your order</a></Text>
24
26
  {/if}
25
27
  {:else}
26
- <p>
28
+ <Text>
27
29
  Thank you. Your payment is being confirmed and your order number will be emailed to you
28
30
  shortly.
29
- </p>
31
+ </Text>
30
32
  {/if}
31
33
 
32
34
  {#snippet pending()}
33
35
  <SkeletonText lines={2} />
34
36
  {/snippet}
35
37
  </Boundary>
36
- <p class="mt-6"><a class="underline" href={resolve('/')}>Back to the shop</a></p>
38
+ <Text class="mt-6"><a class="underline" href={resolve('/')}>Back to the shop</a></Text>
@@ -1,11 +1,15 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
3
 
4
- import PageTitle from '../../ui/PageTitle.svelte';
5
- import { getMyOrders } from '../client.remote';
6
- import { Money } from '../../utils/money';
7
4
  import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
8
5
  import SkeletonCard from '@zeyolabs/ui/skeleton/SkeletonCard.svelte';
6
+ import Span from '@zeyolabs/ui/text/Span.svelte';
7
+ import Text from '@zeyolabs/ui/text/Text.svelte';
8
+ import Title from '@zeyolabs/ui/text/Title.svelte';
9
+
10
+ import PageTitle from '../../ui/PageTitle.svelte';
11
+ import { Money } from '../../utils/money';
12
+ import { getMyOrders } from '../client.remote';
9
13
 
10
14
  let {
11
15
  children,
@@ -32,32 +36,32 @@
32
36
 
33
37
  <Boundary message="Could not load your orders.">
34
38
  {let data = $derived(await getMyOrders())}
35
- <p class="text-[var(--txs)]">
39
+ <Text color="secondary">
36
40
  Signed in as <strong class="text-[var(--tx)]">{data.email}</strong>
37
- </p>
41
+ </Text>
38
42
 
39
- <h2 class="mt-8 text-lg font-semibold">Orders</h2>
43
+ <Title class="mt-8" level={2} size="sm">Orders</Title>
40
44
  {#if data.orders.length === 0}
41
- <p class="mt-2 text-[var(--txs)]">
45
+ <Text class="mt-2" color="secondary">
42
46
  No orders yet. Orders placed with this email address, signed in or not, show here.
43
- </p>
47
+ </Text>
44
48
  {:else}
45
49
  <ul class="mt-2 divide-y divide-[var(--bd)] border-y border-[var(--bd)]">
46
50
  {#each data.orders as order (order.number)}
47
51
  <li class="flex flex-wrap items-center justify-between gap-2 py-3">
48
- <span>
52
+ <Span>
49
53
  {#if order.path}
50
54
  <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- the order's private path -->
51
55
  <a class="font-medium underline" href={order.path}>{order.number}</a>
52
56
  {:else}
53
- <span class="font-medium">{order.number}</span>
57
+ <Span bold>{order.number}</Span>
54
58
  {/if}
55
- <span class="text-[var(--txs)]"> · {date.format(order.createdAt)}</span>
56
- </span>
57
- <span>
58
- <span class="text-[var(--txs)]">{STATUS[order.status] ?? order.status}</span>
59
+ <Span color="secondary">· {date.format(order.createdAt)}</Span>
60
+ </Span>
61
+ <Span>
62
+ <Span color="secondary">{STATUS[order.status] ?? order.status}</Span>
59
63
  · {Money.format(order.totalPence)}
60
- </span>
64
+ </Span>
61
65
  </li>
62
66
  {/each}
63
67
  </ul>
package/db/schema.ts CHANGED
@@ -260,6 +260,11 @@ export const orderItems = sqliteTable(
260
260
  .references(() => orders.id, { onDelete: 'cascade' }),
261
261
  productId: integer('product_id').references(() => products.id, { onDelete: 'set null' }),
262
262
  quantity: integer('quantity').notNull(),
263
+ /**
264
+ * True for a kit's parts: `quantity` is single units (16 switches), not purchases (packs), so
265
+ * paying takes exactly that many from stock.
266
+ */
267
+ singleUnits: integer('single_units', { mode: 'boolean' }).notNull().default(false),
263
268
  sku: text('sku').notNull(),
264
269
  unitPricePence: integer('unit_price_pence').notNull(),
265
270
  },
@@ -314,14 +319,17 @@ export const reviews = sqliteTable(
314
319
  );
315
320
 
316
321
  /**
317
- * A bundle is built in steps: at each step the customer picks from that step's products. Adding a
318
- * bundle to the basket adds the chosen products as ordinary lines at their own prices, so stock,
319
- * shipping and orders work unchanged.
322
+ * A bundle is built in steps: at each step the customer picks from that step's products. A plain
323
+ * bundle adds the chosen products to the basket as ordinary lines at their own prices. A bundle with
324
+ * a discount, or a kit (it has a `base` step), goes in the basket as one line: a discounted bundle
325
+ * costs its products' prices less `discountPercent`, a kit costs its base's price.
320
326
  */
321
327
  export const bundles = sqliteTable('bundles', {
322
328
  active: integer('active', { mode: 'boolean' }).notNull().default(true),
323
329
  createdAt: integer('created_at').notNull(),
324
330
  description: text('description').notNull().default(''),
331
+ /** Off the products' total when bought as this bundle, 0 to 90. Not applied to kits. */
332
+ discountPercent: integer('discount_percent').notNull().default(0),
325
333
  id: integer('id').primaryKey({ autoIncrement: true }),
326
334
  /** File name in the product image bucket, shown on the bundle page. */
327
335
  image: text('image'),
@@ -330,6 +338,15 @@ export const bundles = sqliteTable('bundles', {
330
338
  sortOrder: integer('sort_order').notNull().default(0),
331
339
  });
332
340
 
341
+ /**
342
+ * How a step is chosen. `pick`: between `minChoices` and `maxChoices` different products. A kit's
343
+ * steps: `base`, one product whose `slots` sets the kit's size and whose price is the kit's price;
344
+ * `fill`, fill every slot with single units, repeats allowed up to `maxPerChoice` each; `cover`, one
345
+ * product, a single unit per slot (e.g. keycaps for every switch).
346
+ */
347
+ export const BUNDLE_STEP_ROLES = ['pick', 'base', 'fill', 'cover'] as const;
348
+ export type BundleStepRole = (typeof BUNDLE_STEP_ROLES)[number];
349
+
333
350
  /** One step of a bundle: pick between `minChoices` and `maxChoices` of its products. */
334
351
  export const bundleSteps = sqliteTable(
335
352
  'bundle_steps',
@@ -340,9 +357,12 @@ export const bundleSteps = sqliteTable(
340
357
  description: text('description').notNull().default(''),
341
358
  id: integer('id').primaryKey({ autoIncrement: true }),
342
359
  maxChoices: integer('max_choices').notNull().default(1),
360
+ /** A `fill` step: the most slots one product may take. Null: no limit. */
361
+ maxPerChoice: integer('max_per_choice'),
343
362
  /** 0 makes the step optional. */
344
363
  minChoices: integer('min_choices').notNull().default(1),
345
364
  position: integer('position').notNull().default(0),
365
+ role: text('role', { enum: BUNDLE_STEP_ROLES }).notNull().default('pick'),
346
366
  title: text('title').notNull(),
347
367
  },
348
368
  (t) => [index('bundle_steps_bundle_idx').on(t.bundleId, t.position)]
@@ -353,9 +373,13 @@ export const bundleStepProducts = sqliteTable(
353
373
  'bundle_step_products',
354
374
  {
355
375
  position: integer('position').notNull().default(0),
376
+ /** A kit's `base` option: the kit's price when not the product's own (a case sold alone for less). */
377
+ pricePence: integer('price_pence'),
356
378
  productId: integer('product_id')
357
379
  .notNull()
358
380
  .references(() => products.id, { onDelete: 'cascade' }),
381
+ /** A kit's `base` option: how many slots it holds (a 4x4 tester holds 16). */
382
+ slots: integer('slots'),
359
383
  stepId: integer('step_id')
360
384
  .notNull()
361
385
  .references(() => bundleSteps.id, { onDelete: 'cascade' }),
@@ -1,7 +1,20 @@
1
1
  <script lang="ts">
2
- import { ErrorMessage } from '../../utils/errors';
3
2
  import { resolve } from '$app/paths';
4
3
  import { page } from '$app/state';
4
+ import Badge from '@zeyolabs/ui/badge/Badge.svelte';
5
+ import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
6
+ import { CheckboxField, Form, NumberField, SelectField, TextField } from '@zeyolabs/ui/form';
7
+ import Button from '@zeyolabs/ui/form/Button.svelte';
8
+ import Span from '@zeyolabs/ui/text/Span.svelte';
9
+ import Text from '@zeyolabs/ui/text/Text.svelte';
10
+ import Title from '@zeyolabs/ui/text/Title.svelte';
11
+ import { toast } from 'svelte-sonner';
12
+
13
+ import { PACKAGE_FORMATS } from '../../db/schema';
14
+ import { Orders } from '../../orders/library';
15
+ import { ErrorMessage } from '../../utils/errors';
16
+ import { FormInput } from '../../utils/form-input';
17
+ import { Money } from '../../utils/money';
5
18
  import {
6
19
  createOrderLabel,
7
20
  detailsForm,
@@ -12,6 +25,7 @@
12
25
  shipForm,
13
26
  updateOrderForm,
14
27
  } from '../admin.remote';
28
+ import { Packing } from '../library';
15
29
  import {
16
30
  OrderDetailsSchema,
17
31
  OrderStepSchema,
@@ -19,16 +33,6 @@
19
33
  RefundSchema,
20
34
  ShipSchema,
21
35
  } from '../schema';
22
- import { Money } from '../../utils/money';
23
- import { FormInput } from '../../utils/form-input';
24
- import { Orders } from '../../orders/library';
25
- import { toast } from 'svelte-sonner';
26
- import { PACKAGE_FORMATS } from '../../db/schema';
27
- import { Packing } from '../library';
28
- import Badge from '@zeyolabs/ui/badge/Badge.svelte';
29
- import Boundary from '@zeyolabs/ui/boundary/Boundary.svelte';
30
- import { CheckboxField, Form, NumberField, SelectField, TextField } from '@zeyolabs/ui/form';
31
- import Button from '@zeyolabs/ui/form/Button.svelte';
32
36
 
33
37
  const number = $derived(page.params.number ?? '');
34
38
 
@@ -56,12 +60,12 @@
56
60
 
57
61
  <svelte:head><title>{number} · Admin</title></svelte:head>
58
62
 
59
- <p><a href={resolve('/orders')}>← Orders</a></p>
63
+ <Text><a href={resolve('/orders')}>← Orders</a></Text>
60
64
 
61
65
  <Boundary message="Could not load this order." statusMessages={{ 404: 'Order not found.' }}>
62
66
  {let order = $derived(await getOrder(number))}
63
67
  <div class="mt-4 flex flex-wrap items-center gap-3">
64
- <h1 class="text-2xl font-semibold">{order.number}</h1>
68
+ <Title level={1} size="md">{order.number}</Title>
65
69
  <Badge
66
70
  color={order.status === 'paid'
67
71
  ? 'warning'
@@ -72,15 +76,15 @@
72
76
  {order.status === 'paid' ? 'To ship' : order.status}
73
77
  </Badge>
74
78
  </div>
75
- <p class="mt-1 text-sm text-[var(--ink-muted)]">
79
+ <Text class="mt-1" color="secondary">
76
80
  Placed {date.format(order.createdAt)}{order.paidAt
77
81
  ? ` · paid ${date.format(order.paidAt)}`
78
82
  : ''}
79
- </p>
83
+ </Text>
80
84
 
81
85
  <div class="mt-6 grid gap-6 md:grid-cols-2">
82
- <section class="rounded-xl border border-[var(--line)] bg-white p-5">
83
- <h2 class="font-semibold">Ship to</h2>
86
+ <section class="rounded-xl border border-[var(--bd)] bg-white p-5">
87
+ <Title level={2} size="sm">Ship to</Title>
84
88
  <address class="mt-2 not-italic select-all">
85
89
  {order.address.name}<br />
86
90
  {order.address.line1}<br />
@@ -89,24 +93,24 @@
89
93
  {order.address.postcode}<br />
90
94
  {order.address.country}
91
95
  </address>
92
- <p class="mt-3 text-sm">
96
+ <Text class="mt-3">
93
97
  <a href="mailto:{order.email}">{order.email}</a>{order.address.phone
94
98
  ? ` · ${order.address.phone}`
95
99
  : ''}
96
- </p>
97
- <p class="mt-3 text-sm text-[var(--ink-muted)]">
100
+ </Text>
101
+ <Text class="mt-3" color="secondary">
98
102
  Service: {order.shippingService ?? 'n/a'}
99
103
  {#if order.royalMailOrderId}· Click &amp; Drop order {order.royalMailOrderId}{/if}
100
- </p>
104
+ </Text>
101
105
  </section>
102
106
 
103
- <section class="rounded-xl border border-[var(--line)] bg-white p-5">
104
- <h2 class="font-semibold">Items</h2>
105
- <ul class="mt-2 divide-y divide-[var(--line)]">
107
+ <section class="rounded-xl border border-[var(--bd)] bg-white p-5">
108
+ <Title level={2} size="sm">Items</Title>
109
+ <ul class="mt-2 divide-y divide-[var(--bd)]">
106
110
  {#each order.items as item (item.id)}
107
111
  <li class="flex justify-between gap-4 py-2">
108
- <span>{item.name} <span class="text-[var(--ink-muted)]">× {item.quantity}</span></span>
109
- <span>{Money.format(item.quantity * item.unitPricePence)}</span>
112
+ <Span>{item.name} <Span color="secondary">× {item.quantity}</Span></Span>
113
+ <Span>{Money.format(item.quantity * item.unitPricePence)}</Span>
110
114
  </li>
111
115
  {/each}
112
116
  </ul>
@@ -141,17 +145,17 @@
141
145
 
142
146
  {#if order.status === 'paid'}
143
147
  {let stage = $derived(Packing.stage(order))}
144
- <section class="mt-6 max-w-xl rounded-xl border border-[var(--line)] bg-white p-5">
148
+ <section class="mt-6 max-w-xl rounded-xl border border-[var(--bd)] bg-white p-5">
145
149
  <div class="flex flex-wrap items-center gap-3">
146
- <h2 class="font-semibold">Packing</h2>
150
+ <Title level={2} size="sm">Packing</Title>
147
151
  <Badge color={Packing.STAGE_COLORS[stage]}>{Packing.STAGE_LABELS[stage]}</Badge>
148
152
  </div>
149
- <p class="mt-1 text-sm text-[var(--ink-muted)]">
153
+ <Text class="mt-1" color="secondary">
150
154
  {#if order.heldAt}On hold since {date.format(order.heldAt)}.{/if}
151
155
  {#if order.packingStartedAt}Packing started {date.format(order.packingStartedAt)}.{/if}
152
156
  {#if order.packedAt}Packed {date.format(order.packedAt)}.{/if}
153
157
  {#if order.labelCreatedAt}Label created {date.format(order.labelCreatedAt)}.{/if}
154
- </p>
158
+ </Text>
155
159
  <Form
156
160
  class="mt-4 flex flex-wrap gap-2"
157
161
  form={updateOrderForm}
@@ -194,18 +198,18 @@
194
198
  {/if}
195
199
  </Form>
196
200
 
197
- <p class="mt-3 text-sm text-[var(--ink-muted)]">
201
+ <Text class="mt-3" color="secondary">
198
202
  Printing the label sends the saved parcel details to Royal Mail and marks the order packed.
199
203
  {#if order.labelCreatedAt}A label is already made, so later parcel changes will not change
200
204
  it.{/if}
201
- </p>
205
+ </Text>
202
206
 
203
- <h3 class="mt-6 font-medium">Parcel</h3>
204
- <p class="mt-1 text-sm text-[var(--ink-muted)]">
207
+ <Title class="mt-6" level={3} size="sm">Parcel</Title>
208
+ <Text class="mt-1" color="secondary">
205
209
  {order.weightGrams === null
206
210
  ? `Estimated ${order.estimatedWeightGrams} g from the items. Weigh the parcel and correct it.`
207
211
  : 'Weight and size go on the Royal Mail label.'}
208
- </p>
212
+ </Text>
209
213
  <Form
210
214
  class="mt-3 grid gap-4"
211
215
  defaults={{
@@ -248,14 +252,14 @@
248
252
 
249
253
  {#if order.status === 'paid' || order.status === 'shipped'}
250
254
  {let services = $derived(await getShippingServices())}
251
- <section class="mt-6 max-w-xl rounded-xl border border-[var(--line)] bg-white p-5">
255
+ <section class="mt-6 max-w-xl rounded-xl border border-[var(--bd)] bg-white p-5">
252
256
  <details>
253
257
  <summary class="cursor-pointer font-semibold">Edit contact, address and postage</summary>
254
- <p class="mt-2 text-sm text-[var(--ink-muted)]">
258
+ <Text class="mt-2" color="secondary">
255
259
  For fixing a typo or a customer's request. If you change the country, check the postage
256
260
  service still fits. {#if order.status === 'paid' && order.labelCreatedAt}The label is
257
261
  already made, so after a change you need to print it again.{/if}
258
- </p>
262
+ </Text>
259
263
  <Form
260
264
  class="mt-4 grid gap-4"
261
265
  defaults={{
@@ -312,13 +316,13 @@
312
316
 
313
317
  {#if (order.status === 'paid' || order.status === 'shipped') && order.stripePaymentIntentId && order.refundedPence < order.totalPence}
314
318
  {let left = $derived(order.totalPence - order.refundedPence)}
315
- <section class="mt-6 max-w-xl rounded-xl border border-[var(--line)] bg-white p-5">
316
- <h2 class="font-semibold">Refund</h2>
317
- <p class="mt-1 text-sm text-[var(--ink-muted)]">
319
+ <section class="mt-6 max-w-xl rounded-xl border border-[var(--bd)] bg-white p-5">
320
+ <Title level={2} size="sm">Refund</Title>
321
+ <Text class="mt-1" color="secondary">
318
322
  Up to {Money.format(left)} can be refunded to the customer's card through Stripe. A full refund
319
323
  marks the order refunded, even if it had shipped, and does not cancel a Royal Mail label. Stock
320
324
  is not put back; do that on the stock page if the goods come back.
321
- </p>
325
+ </Text>
322
326
  <Form
323
327
  class="mt-4 grid gap-4"
324
328
  defaults={{ amount: FormInput.penceToPounds(left) }}
@@ -333,23 +337,23 @@
333
337
  </section>
334
338
  {/if}
335
339
 
336
- <section class="mt-6 max-w-xl rounded-xl border border-[var(--line)] bg-white p-5">
337
- <h2 class="font-semibold">Dispatch</h2>
340
+ <section class="mt-6 max-w-xl rounded-xl border border-[var(--bd)] bg-white p-5">
341
+ <Title level={2} size="sm">Dispatch</Title>
338
342
  {#if order.status === 'paid' || order.status === 'shipped'}
339
343
  {#if order.shippedAt}
340
- <p class="mt-1 text-sm text-[var(--ink-muted)]">
344
+ <Text class="mt-1" color="secondary">
341
345
  Dispatched {date.format(order.shippedAt)}.
342
346
  {#if order.dispatchEmailedAt}
343
347
  Customer emailed {date.format(order.dispatchEmailedAt)}.
344
348
  {:else}
345
349
  The customer has <strong>not</strong> been emailed.
346
350
  {/if}
347
- </p>
351
+ </Text>
348
352
  {:else}
349
- <p class="mt-1 text-sm text-[var(--ink-muted)]">
353
+ <Text class="mt-1" color="secondary">
350
354
  Enter the Royal Mail tracking number (leave blank if untracked), then mark it dispatched.
351
355
  The customer is emailed straight away and their order page updates.
352
- </p>
356
+ </Text>
353
357
  {/if}
354
358
  <Form
355
359
  class="mt-4 grid gap-4"
@@ -370,31 +374,31 @@
370
374
  </div>
371
375
  </Form>
372
376
  {:else}
373
- <p class="mt-1 text-sm">This order is {order.status}, so it cannot be dispatched.</p>
377
+ <Text class="mt-1">This order is {order.status}, so it cannot be dispatched.</Text>
374
378
  {/if}
375
379
 
376
380
  {#if order.trackingNumber}
377
- <p class="mt-4 text-sm">
381
+ <Text class="mt-4">
378
382
  <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- external Royal Mail URL -->
379
383
  <a href={Orders.trackingUrl(order.trackingNumber)} rel="noopener" target="_blank"
380
384
  >Track {order.trackingNumber} on Royal Mail</a
381
385
  >
382
- </p>
386
+ </Text>
383
387
  {/if}
384
388
  {#if order.stripeInvoiceId}
385
- <p class="mt-2 text-sm">
389
+ <Text class="mt-2">
386
390
  <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- server route, opens Stripe's PDF -->
387
391
  <a href="/orders/{order.number}/invoice" rel="external" target="_blank">Invoice (PDF)</a>
388
- </p>
392
+ </Text>
389
393
  {/if}
390
394
  {#if order.customerUrl}
391
- <p class="mt-2 text-sm">
395
+ <Text class="mt-2">
392
396
  <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -- absolute URL on the shop domain -->
393
397
  <a href={order.customerUrl} rel="noopener" target="_blank">Customer's order page</a>
394
- </p>
398
+ </Text>
395
399
  {/if}
396
400
  </section>
397
401
  {#snippet pending()}
398
- <p class="mt-6 text-[var(--ink-muted)]">Loading…</p>
402
+ <Text class="mt-6" color="secondary">Loading…</Text>
399
403
  {/snippet}
400
404
  </Boundary>