@revenexx/cover 0.2.18 → 0.2.20

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/app/app.config.ts CHANGED
@@ -32,6 +32,27 @@ export default defineAppConfig({
32
32
  // crashed SearchInput with "Cannot read … 'autocompleteMinChars'").
33
33
  search: {
34
34
  autocompleteMinChars: 2,
35
+ // Which sorts the listing toolbar offers. A storefront switches off
36
+ // what its catalogue cannot honour — offering a control that silently
37
+ // does nothing is worse than not offering it, and a live search index
38
+ // that projects no price field can never sort by price.
39
+ //
40
+ // A MAP and not a list on purpose: app.config is merged with defu,
41
+ // which CONCATENATES arrays. A storefront overriding a list would
42
+ // append to the layer's five rather than replace them, and every
43
+ // option would stay on. Booleans merge key by key, so
44
+ // `sorts: { price_asc: false }` in a storefront means exactly that.
45
+ //
46
+ // Display order follows this declaration, not the override.
47
+ sorts: {
48
+ relevance: true,
49
+ price_asc: true,
50
+ price_desc: true,
51
+ name_asc: true,
52
+ name_desc: true,
53
+ sku_asc: true,
54
+ sku_desc: true,
55
+ },
35
56
  },
36
57
  ui: {
37
58
  icons: nuxtUiIcons(DEFAULT_ICON_WEIGHT),
@@ -5,7 +5,7 @@ const localePath = useLocalePath();
5
5
  </script>
6
6
 
7
7
  <template>
8
- <div class="border border-default py-6 px-8 rounded-lg flex flex-col self-start">
8
+ <div class="border border-default py-6 px-8 rounded-lg flex flex-col self-start lg:sticky lg:top-10">
9
9
  <h2 class="text-xl font-semibold text-highlighted">
10
10
  {{ t('auth.login.existingCustomer') }}
11
11
  </h2>
@@ -105,88 +105,82 @@ async function onSubmit(): Promise<void> {
105
105
 
106
106
  <template>
107
107
  <div class="bg-elevated py-6 px-6 sm:px-8 rounded-lg">
108
- <h2 class="text-xl font-semibold text-highlighted">
109
- {{ registrationEnabled ? t('auth.register.title') : t('auth.register.disabled.title') }}
110
- </h2>
108
+ <div class="rounded-lg bg-default shadow-sm p-6 mb-4">
109
+ <h2 class="text-xl font-semibold text-highlighted">
110
+ {{ registrationEnabled ? t('auth.register.title') : t('auth.register.disabled.title') }}
111
+ </h2>
111
112
 
112
- <!-- Registration closed by the tenant — no form, just a notice. -->
113
- <p
114
- v-if="!registrationEnabled"
115
- class="pt-6 text-sm text-muted"
116
- >
117
- {{ t('auth.register.disabled.description') }}
118
- </p>
113
+ <!-- Registration closed by the tenant — no form, just a notice. -->
114
+ <p
115
+ v-if="!registrationEnabled"
116
+ class="pt-6 text-sm text-muted"
117
+ >
118
+ {{ t('auth.register.disabled.description') }}
119
+ </p>
119
120
 
120
- <!-- Path selection (new vs. existing customer) -->
121
- <fieldset
122
- v-if="registrationEnabled"
123
- class="pt-6"
124
- >
125
- <legend class="text-sm font-medium text-highlighted">
126
- {{ t('auth.register.modes.title') }}
127
- </legend>
128
- <div class="mt-3 grid grid-cols-1 sm:grid-cols-2 gap-3">
129
- <button
130
- v-for="option in modes"
131
- :key="option.value"
132
- type="button"
133
- tabindex="0"
134
- class="text-left rounded-lg border p-4 transition-colors cursor-pointer"
135
- :class="state.mode === option.value
136
- ? 'border-(--ui-primary) bg-primary/5 ring-1 ring-(--ui-primary)'
137
- : 'border-(--ui-border) hover:border-(--ui-border-accented)'"
138
- :aria-pressed="state.mode === option.value"
139
- @click="state.mode = option.value"
140
- >
141
- <span class="flex items-center gap-2">
142
- <UIcon
143
- :name="icon(option.icon)"
144
- class="size-5"
145
- :class="state.mode === option.value ? 'text-primary' : 'text-muted'"
146
- />
147
- <span class="text-sm font-semibold text-highlighted">
148
- {{ t(`auth.register.modes.${option.value}.title`) }}
121
+ <!-- Path selection (new vs. existing customer) -->
122
+ <fieldset
123
+ v-if="registrationEnabled"
124
+ class="pt-6"
125
+ >
126
+ <legend class="text-sm font-medium text-highlighted">
127
+ {{ t('auth.register.modes.title') }}
128
+ </legend>
129
+ <div class="mt-3 grid grid-cols-1 sm:grid-cols-2 gap-3">
130
+ <button
131
+ v-for="option in modes"
132
+ :key="option.value"
133
+ type="button"
134
+ tabindex="0"
135
+ class="text-left rounded-lg border p-4 transition-colors cursor-pointer"
136
+ :class="state.mode === option.value
137
+ ? 'border-(--ui-primary) bg-primary/5 ring-1 ring-(--ui-primary)'
138
+ : 'border-(--ui-border) hover:border-(--ui-border-accented)'"
139
+ :aria-pressed="state.mode === option.value"
140
+ @click="state.mode = option.value"
141
+ >
142
+ <span class="flex items-center gap-2">
143
+ <UIcon
144
+ :name="icon(option.icon)"
145
+ class="size-5"
146
+ :class="state.mode === option.value ? 'text-primary' : 'text-muted'"
147
+ />
148
+ <span class="text-sm font-semibold text-highlighted">
149
+ {{ t(`auth.register.modes.${option.value}.title`) }}
150
+ </span>
151
+ </span>
152
+ <span class="mt-1.5 block text-xs text-muted">
153
+ {{ t(`auth.register.modes.${option.value}.description`) }}
149
154
  </span>
150
- </span>
151
- <span class="mt-1.5 block text-xs text-muted">
152
- {{ t(`auth.register.modes.${option.value}.description`) }}
153
- </span>
154
- </button>
155
- </div>
156
- </fieldset>
155
+ </button>
156
+ </div>
157
+ </fieldset>
158
+ </div>
157
159
 
158
160
  <FormKit
159
161
  v-if="registrationEnabled"
160
162
  type="form"
161
163
  :actions="false"
162
- class="space-y-7 pt-7"
163
164
  @submit="onSubmit"
164
165
  >
165
166
  <!-- Company -->
166
- <section class="space-y-4">
167
- <h3 class="text-xs font-semibold uppercase tracking-wide text-muted">
167
+ <section class="space-y-4 rounded-lg bg-default shadow-sm p-6">
168
+ <h3 class="text-xl font-semibold text-highlighted">
168
169
  {{ t('auth.register.sections.company') }}
169
170
  </h3>
170
- <FormKit
171
- v-model="state.company"
172
- type="text"
173
- :label="t('auth.register.fields.company')"
174
- name="company"
175
- validation="required|companyName"
176
- :validation-messages="{ companyName: t('validation.invalidCompanyName') }"
177
- :help="t('auth.register.companyRequiredHint')"
178
- autocomplete="organization"
179
- />
180
171
  <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
181
172
  <FormKit
182
- v-if="state.mode === 'existing'"
183
- v-model="state.customerNumber"
173
+ v-model="state.company"
184
174
  type="text"
185
- :label="t('auth.register.fields2.customerNumber')"
186
- name="customerNumber"
187
- validation="required"
188
- :help="t('auth.register.fields2.customerNumberHint')"
175
+ :label="t('auth.register.fields.company')"
176
+ name="company"
177
+ validation="required|companyName"
178
+ :validation-messages="{ companyName: t('validation.invalidCompanyName') }"
179
+ :help="t('auth.register.companyRequiredHint')"
180
+ autocomplete="organization"
189
181
  />
182
+ </div>
183
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
190
184
  <FormKit
191
185
  v-model="state.vatId"
192
186
  type="text"
@@ -196,15 +190,74 @@ async function onSubmit(): Promise<void> {
196
190
  :help="t('auth.register.fields2.vatIdHint')"
197
191
  placeholder="DE123456789"
198
192
  />
193
+ <FormKit
194
+ v-if="state.mode === 'existing'"
195
+ v-model="state.customerNumber"
196
+ type="text"
197
+ :label="t('auth.register.fields2.customerNumber')"
198
+ name="customerNumber"
199
+ validation="required"
200
+ :help="t('auth.register.fields2.customerNumberHint')"
201
+ />
202
+ </div>
203
+ </section>
204
+
205
+ <!-- Contact person -->
206
+ <section class="space-y-4 rounded-lg bg-default shadow-sm p-6">
207
+ <h3 class="text-xl font-semibold text-highlighted">
208
+ {{ t('auth.register.sections.contact') }}
209
+ </h3>
210
+ <div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
211
+ <FormKit
212
+ v-model="state.salutation"
213
+ type="select"
214
+ :label="t('auth.register.fields2.salutation')"
215
+ name="salutation"
216
+ :options="salutationItems"
217
+ />
218
+ <FormKit
219
+ v-model="state.firstName"
220
+ type="text"
221
+ :label="t('auth.register.fields.firstName')"
222
+ name="firstName"
223
+ validation="required"
224
+ autocomplete="given-name"
225
+ />
226
+ <FormKit
227
+ v-model="state.lastName"
228
+ type="text"
229
+ :label="t('auth.register.fields.lastName')"
230
+ name="lastName"
231
+ validation="required"
232
+ autocomplete="family-name"
233
+ />
234
+ </div>
235
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
236
+ <FormKit
237
+ v-model="state.jobTitle"
238
+ type="text"
239
+ :label="t('auth.register.fields2.jobTitle')"
240
+ name="jobTitle"
241
+ :help="t('auth.register.fields2.jobTitleHint')"
242
+ autocomplete="organization-title"
243
+ />
244
+ <FormKit
245
+ v-model="state.phone"
246
+ type="tel"
247
+ :label="t('auth.register.fields2.phone')"
248
+ name="phone"
249
+ :help="t('auth.register.fields2.phoneHint')"
250
+ autocomplete="tel"
251
+ />
199
252
  </div>
200
253
  </section>
201
254
 
202
255
  <!-- Billing address (new customers only) -->
203
256
  <section
204
257
  v-if="state.mode === 'new'"
205
- class="space-y-4"
258
+ class="space-y-4 rounded-lg bg-default shadow-sm p-6"
206
259
  >
207
- <h3 class="text-xs font-semibold uppercase tracking-wide text-muted">
260
+ <h3 class="text-xl font-semibold text-highlighted">
208
261
  {{ t('auth.register.sections.address') }}
209
262
  </h3>
210
263
  <div class="grid grid-cols-3 gap-4">
@@ -256,59 +309,9 @@ async function onSubmit(): Promise<void> {
256
309
  />
257
310
  </section>
258
311
 
259
- <!-- Contact person -->
260
- <section class="space-y-4">
261
- <h3 class="text-xs font-semibold uppercase tracking-wide text-muted">
262
- {{ t('auth.register.sections.contact') }}
263
- </h3>
264
- <div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
265
- <FormKit
266
- v-model="state.salutation"
267
- type="select"
268
- :label="t('auth.register.fields2.salutation')"
269
- name="salutation"
270
- :options="salutationItems"
271
- />
272
- <FormKit
273
- v-model="state.firstName"
274
- type="text"
275
- :label="t('auth.register.fields.firstName')"
276
- name="firstName"
277
- validation="required"
278
- autocomplete="given-name"
279
- />
280
- <FormKit
281
- v-model="state.lastName"
282
- type="text"
283
- :label="t('auth.register.fields.lastName')"
284
- name="lastName"
285
- validation="required"
286
- autocomplete="family-name"
287
- />
288
- </div>
289
- <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
290
- <FormKit
291
- v-model="state.jobTitle"
292
- type="text"
293
- :label="t('auth.register.fields2.jobTitle')"
294
- name="jobTitle"
295
- :help="t('auth.register.fields2.jobTitleHint')"
296
- autocomplete="organization-title"
297
- />
298
- <FormKit
299
- v-model="state.phone"
300
- type="tel"
301
- :label="t('auth.register.fields2.phone')"
302
- name="phone"
303
- :help="t('auth.register.fields2.phoneHint')"
304
- autocomplete="tel"
305
- />
306
- </div>
307
- </section>
308
-
309
312
  <!-- Account credentials -->
310
- <section class="space-y-4">
311
- <h3 class="text-xs font-semibold uppercase tracking-wide text-muted">
313
+ <section class="space-y-4 rounded-lg bg-default shadow-sm p-6">
314
+ <h3 class="text-xl font-semibold text-highlighted">
312
315
  {{ t('auth.register.sections.account') }}
313
316
  </h3>
314
317
  <FormKit
@@ -350,6 +353,7 @@ async function onSubmit(): Promise<void> {
350
353
  validation="accepted"
351
354
  :validation-messages="{ accepted: t('validation.termsRequired') }"
352
355
  :help="t('auth.register.fields.acceptTermsDescription')"
356
+ outer-class="rounded-lg bg-default shadow-sm p-6"
353
357
  />
354
358
 
355
359
  <UAlert
@@ -60,7 +60,7 @@ const availabilityColor = computed(() => {
60
60
  switch (availability.value?.state) {
61
61
  case "in-stock": return "bg-success";
62
62
  case "partial": return "bg-warning";
63
- default: return "bg-error";
63
+ default: return "bg-[oklch(0.88_0.2_98.38)]";
64
64
  }
65
65
  });
66
66
 
@@ -115,7 +115,7 @@ const hintColor = (type: string) =>
115
115
  />
116
116
  </div>
117
117
 
118
- <div class="flex items-start gap-3">
118
+ <div class="flex flex-wrap md:flex-nowrap items-start gap-3">
119
119
  <!-- Selector + drag handle -->
120
120
  <div
121
121
  v-if="!readonly"
@@ -178,6 +178,18 @@ const hintColor = (type: string) =>
178
178
  class="text-xs text-muted"
179
179
  >{{ item.name2 }}</span>
180
180
 
181
+ <!-- Delivery / availability -->
182
+ <span
183
+ v-if="availability"
184
+ class="inline-flex items-center gap-1.5 text-xs text-muted"
185
+ >
186
+ <span
187
+ class="size-2 rounded-full"
188
+ :class="availabilityColor"
189
+ />
190
+ {{ t(`cart.availability.${availability.state}`, { count: availability.availableQuantity, days: availability.deliveryDays ?? 0 }) }}
191
+ </span>
192
+
181
193
  <!-- Cost center: shown and edited right at the position -->
182
194
  <button
183
195
  v-if="showCostCenter && !readonly"
@@ -260,8 +272,14 @@ const hintColor = (type: string) =>
260
272
  </button>
261
273
  </div>
262
274
 
263
- <!-- Quantity + availability -->
264
- <div class="flex flex-col items-end gap-1.5 shrink-0">
275
+ <!-- Forces quantity/price/functions onto their own row below 768px -->
276
+ <div
277
+ class="basis-full md:hidden"
278
+ aria-hidden="true"
279
+ />
280
+
281
+ <!-- Quantity -->
282
+ <div class="flex items-center shrink-0">
265
283
  <div
266
284
  v-if="!readonly"
267
285
  class="flex items-center gap-1"
@@ -300,22 +318,13 @@ const hintColor = (type: string) =>
300
318
  <span
301
319
  v-else
302
320
  class="text-sm text-highlighted"
303
- >{{ line?.adjustedQuantity ?? item.quantity }}</span>
304
- <span class="text-xs text-muted">{{ item.unit ?? t('cart.position.defaultUnit') }}</span>
305
- <span
306
- v-if="availability"
307
- class="inline-flex items-center gap-1.5 text-xs text-muted"
308
321
  >
309
- <span
310
- class="size-2 rounded-full"
311
- :class="availabilityColor"
312
- />
313
- {{ t(`cart.availability.${availability.state}`, { count: availability.availableQuantity, days: availability.deliveryDays ?? 0 }) }}
322
+ {{ line?.adjustedQuantity ?? item.quantity }}
314
323
  </span>
315
324
  </div>
316
325
 
317
326
  <!-- Price block -->
318
- <div class="flex flex-col items-end gap-0.5 w-32 shrink-0">
327
+ <div class="flex flex-col items-end gap-0.5 w-44 shrink-0 ms-auto md:ms-0">
319
328
  <template v-if="line?.priceLabel">
320
329
  <UBadge
321
330
  color="neutral"
@@ -328,12 +337,12 @@ const hintColor = (type: string) =>
328
337
  {{ formatCurrency(line?.lineTotal ?? item.price * item.quantity) }}
329
338
  </span>
330
339
  <span class="text-xs text-muted">
331
- {{ t('cart.position.perUnit', { price: formatCurrency(line?.unitPrice ?? item.price) }) }}
340
+ {{ formatCurrency(line?.unitPrice ?? item.price) }} / {{ item.unit ?? t('cart.position.defaultUnit') }}
332
341
  </span>
333
342
  <span
334
343
  v-for="surcharge in line?.surcharges ?? []"
335
344
  :key="surcharge.name"
336
- class="text-xs text-dimmed"
345
+ class="text-xs text-muted text-right whitespace-nowrap"
337
346
  >
338
347
  + {{ surcharge.name }} {{ formatCurrency(surcharge.amountPerUnit) }}
339
348
  </span>
@@ -84,7 +84,7 @@ function add(suggestion: (typeof suggestions.value)[number]): void {
84
84
  <template>
85
85
  <section
86
86
  v-if="suggestions.length"
87
- class="print:hidden"
87
+ class="print:hidden mb-11"
88
88
  >
89
89
  <h2 class="flex items-center gap-2 text-sm font-semibold text-highlighted mb-3">
90
90
  <UIcon
@@ -93,16 +93,31 @@ function add(suggestion: (typeof suggestions.value)[number]): void {
93
93
  />
94
94
  {{ t('cart.boost.reorderTitle') }}
95
95
  </h2>
96
- <div class="flex gap-3 overflow-x-auto pb-2 -mx-1 px-1">
97
- <CartRecommendCard
98
- v-for="suggestion in suggestions"
99
- :key="suggestion.id"
100
- :name="suggestion.name"
101
- :image="suggestion.image"
102
- :sku="suggestion.sku"
103
- :price="suggestion.price"
104
- @add="add(suggestion)"
105
- />
106
- </div>
96
+ <UCarousel
97
+ :items="suggestions"
98
+ arrows
99
+ dots
100
+ align="start"
101
+ :ui="{
102
+ item: 'basis-auto',
103
+ dot: 'rounded-none bg-primary/30 data-[state=active]:bg-primary',
104
+ arrows: 'hidden md:block',
105
+ prev: 'size-11 justify-center start-2 sm:start-2 disabled:text-dimmed disabled:ring-default',
106
+ next: 'size-11 justify-center end-2 sm:end-2 disabled:text-dimmed disabled:ring-default',
107
+ }"
108
+ :prev="{ color: 'primary' }"
109
+ :next="{ color: 'primary' }"
110
+ class="px-0 md:px-16 pb-8"
111
+ >
112
+ <template #default="{ item }">
113
+ <CartRecommendCard
114
+ :name="item.name"
115
+ :image="item.image"
116
+ :sku="item.sku"
117
+ :price="item.price"
118
+ @add="add(item)"
119
+ />
120
+ </template>
121
+ </UCarousel>
107
122
  </section>
108
123
  </template>
@@ -36,7 +36,7 @@ onMounted(() => {
36
36
  hydrated.value = true;
37
37
  });
38
38
 
39
- const { items, requisitions, isEmpty, itemCount } = storeToRefs(cart);
39
+ const { items, requisitions, isEmpty } = storeToRefs(cart);
40
40
 
41
41
  const freeItems = computed(() => items.value.filter(i => !i.requisitionId));
42
42
  const itemsByRequisition = computed(() => {
@@ -54,10 +54,6 @@ const itemsByRequisition = computed(() => {
54
54
  // Keep the selection in sync when positions leave the cart.
55
55
  watch(items, () => selection.prune(), { deep: true });
56
56
 
57
- const cartItemCount = computed(() =>
58
- t("cart.page.itemCount", itemCount.value, { count: itemCount.value }),
59
- );
60
-
61
57
  const quickAddOpen = ref(false);
62
58
 
63
59
  /* ---- loadable requisitions (orderer side, spec: hinzufügen) -------- */
@@ -262,9 +258,6 @@ const messageColor = (severity: string) =>
262
258
  </section>
263
259
 
264
260
  <aside class="lg:col-span-4 lg:sticky lg:top-24">
265
- <p class="text-xs text-muted mb-2">
266
- {{ cartItemCount }}
267
- </p>
268
261
  <CartSummaryPanel />
269
262
  </aside>
270
263
  </div>
@@ -52,10 +52,12 @@ export const useCategoryListing = (options: CategoryListingOptions) => {
52
52
  ...(subcategorySlug.value ? { subcategorySlug: [subcategorySlug.value] } : {}),
53
53
  }),
54
54
  // The category itself is fixed; subcategories remain filterable on the
55
- // category root, manufacturers and availability everywhere.
56
- facetFields: subcategorySlug.value
55
+ // category root, manufacturers and availability everywhere. Passed as a
56
+ // getter so switching subcategory (route change or editor edit) updates
57
+ // the offered facets instead of freezing the first render's list.
58
+ facetFields: () => (subcategorySlug.value
57
59
  ? ["manufacturer", "available"]
58
- : ["subcategory", "manufacturer", "available"],
60
+ : ["subcategory", "manufacturer", "available"]),
59
61
  });
60
62
 
61
63
  const title = computed(() =>
@@ -13,14 +13,37 @@ import type {
13
13
  export const useProductDetail = (id: MaybeRefOrGetter<string>) => {
14
14
  const { public: { locale, taxIncludedPrices } } = useRuntimeConfig();
15
15
  const currency = useDisplayCurrency();
16
+ const { locale: activeLocale } = useI18n();
16
17
 
17
- const { data: detail, status, error, refresh } = useFetch<ProductDetail | null>(
18
+ // Kept as one object (rather than destructured straight away) so `ready()`
19
+ // below can await the AsyncData thenable — destructuring drops it, which is
20
+ // why a setup-time `error.value` check can never see a 404: SSR only awaits
21
+ // the request in onServerPrefetch, i.e. after setup has returned.
22
+ const detailRequest = useFetch<ProductDetail | null>(
18
23
  () => productApi.detail(toValue(id)),
19
24
  {
25
+ // The BFF resolves the locale from `x-locale` first. Without this
26
+ // header it falls through to the browser's Accept-Language, so a
27
+ // German browser saw German product text on the /en pages while the
28
+ // UI and <html lang> had already switched.
29
+ headers: computed(() => ({ "x-locale": activeLocale.value })),
30
+ // An explicit key: without one this fetch's result is not carried
31
+ // in the SSR payload, so the client refetches on hydration and
32
+ // renders "product not found" over a correctly server-rendered page
33
+ // until it resolves.
34
+ key: () => `product-detail:${toValue(id)}`,
20
35
  default: () => null,
36
+ // Without this guard an empty id requests `/api/product/`, which the
37
+ // BFF answers 400. Callers that can produce an empty id (a malformed
38
+ // product URL) render a not-found state instead of fetching. Safe as a
39
+ // one-time evaluation: Nuxt keys pages by the interpolated path, so a
40
+ // route change remounts the page and re-evaluates this.
41
+ immediate: Boolean(toValue(id)),
21
42
  },
22
43
  );
23
44
 
45
+ const { data: detail, status, error, refresh } = detailRequest;
46
+
24
47
  // Price + availability are the Offer domain — fetched on their own axis
25
48
  // (heavyweight ERP call in production), never blocking the detail render.
26
49
  const { loadOffers, useOffer } = useOffers();
@@ -92,8 +115,17 @@ export const useProductDetail = (id: MaybeRefOrGetter<string>) => {
92
115
  return imagesApi.detail(filename);
93
116
  };
94
117
 
118
+ /**
119
+ * Resolves once the initial detail request has settled — for pages that own
120
+ * the HTTP status and SEO tags and must know whether the product exists
121
+ * before they render. Never await this inside a block.
122
+ */
123
+ const ready = async (): Promise<void> => {
124
+ await detailRequest;
125
+ };
126
+
95
127
  return {
96
- detail, status, error, refresh,
128
+ detail, status, error, refresh, ready,
97
129
  productInfo, mainImages, longDescription,
98
130
  stocks, attributes, prices, taxRate, offerPending,
99
131
  productCategories, categorySlug, subcategorySlug,
@@ -13,13 +13,24 @@ export interface ProductListingOptions {
13
13
  */
14
14
  fixedFilters?: () => Record<string, string[]>;
15
15
  /** Facet fields offered to the user, in display order. */
16
- facetFields?: string[];
16
+ facetFields?: MaybeRefOrGetter<string[]>;
17
17
  /** Run the first request even with an empty query (category pages). */
18
18
  allowEmptyQuery?: boolean;
19
19
  }
20
20
 
21
21
  const DEFAULT_FACETS = ["category", "subcategory", "manufacturer", "available"];
22
22
 
23
+ /** Every sort the layer knows, and the i18n key that names it. */
24
+ const SORT_LABEL_KEYS = {
25
+ relevance: "search.sort.relevance",
26
+ price_asc: "search.sort.priceAsc",
27
+ price_desc: "search.sort.priceDesc",
28
+ name_asc: "search.sort.nameAsc",
29
+ name_desc: "search.sort.nameDesc",
30
+ sku_asc: "search.sort.skuAsc",
31
+ sku_desc: "search.sort.skuDesc",
32
+ } as const;
33
+
23
34
  export interface ListingResponse {
24
35
  products: ProductList[];
25
36
  facets: SearchFacet[];
@@ -36,17 +47,17 @@ export interface ListingResponse {
36
47
  export function useProductListing(options: ProductListingOptions) {
37
48
  const route = useRoute();
38
49
  const router = useRouter();
39
- const { t } = useI18n();
50
+ const { t, locale } = useI18n();
40
51
  const { productsPerPage } = useRuntimeConfig().public;
41
52
 
42
53
  // Static facets (configured by the calling page) plus dynamic
43
54
  // per-tenant `attrs.<code>` facets from the Products app's
44
55
  // `is_filterable` flags. The dynamic side reacts to the SSR-loaded
45
56
  // useFacetMeta payload — first render already includes them.
46
- const staticFacets = options.facetFields ?? DEFAULT_FACETS;
57
+ const staticFacets = computed(() => toValue(options.facetFields) ?? DEFAULT_FACETS);
47
58
  const facetMeta = useFacetMeta();
48
59
  const facetFields = computed(() => [
49
- ...staticFacets,
60
+ ...staticFacets.value,
50
61
  ...facetMeta.codes.value.map(c => `attrs.${c}`),
51
62
  ]);
52
63
  const query = computed(() => options.query?.() ?? "");
@@ -74,8 +85,30 @@ export function useProductListing(options: ProductListingOptions) {
74
85
  void router.replace({ query: next });
75
86
  }
76
87
 
88
+ // Which sorts this storefront offers (app.config `search.sortOptions`),
89
+ // in the configured order. Falls back to the full set so a storefront that
90
+ // configures nothing behaves as before.
91
+ const appConfig = useAppConfig();
92
+ const enabledSorts = computed<string[]>(() => {
93
+ const configured = appConfig.search?.sorts as Record<string, boolean> | undefined;
94
+ // Declaration order of SORT_LABEL_KEYS decides display order; the
95
+ // config only decides membership. An unset key stays enabled, so a
96
+ // storefront that configures nothing behaves exactly as before.
97
+ const enabled = Object.keys(SORT_LABEL_KEYS)
98
+ .filter(value => configured?.[value] !== false);
99
+ return enabled.length > 0 ? enabled : ["relevance"];
100
+ });
101
+
77
102
  const sort = computed({
78
- get: () => (route.query.sort as string) ?? "relevance",
103
+ // A disabled sort must not be reachable by hand-editing the URL — it
104
+ // would apply a sort the toolbar cannot show, and on a live index it
105
+ // could ask Typesense for a field that is not there.
106
+ get: () => {
107
+ const requested = (route.query.sort as string) ?? "relevance";
108
+ return enabledSorts.value.includes(requested)
109
+ ? requested
110
+ : (enabledSorts.value[0] ?? "relevance");
111
+ },
79
112
  set: (value: string) => updateUrl({ sort: value === "relevance" ? null : value }),
80
113
  });
81
114
 
@@ -135,23 +168,24 @@ export function useProductListing(options: ProductListingOptions) {
135
168
  key: `listing:${options.key}`,
136
169
  method: "POST",
137
170
  body: requestBody,
138
- immediate: false,
139
- watch: false,
140
- },
141
- );
142
-
143
- if (hasQuery.value) {
144
- // First load (SSR-capable), then re-fetch on every URL state change.
145
- void execute();
146
- }
147
- watch(
148
- () => [route.query, query.value],
149
- () => {
150
- if (hasQuery.value) {
151
- void execute();
152
- }
171
+ // Same reason as useProductDetail: the search route filters the
172
+ // index by locale, and without this header it uses the browser's
173
+ // Accept-Language instead of the locale the visitor selected.
174
+ headers: computed(() => ({ "x-locale": locale.value })),
175
+ // `immediate` is what registers Nuxt's onServerPrefetch, so it must be
176
+ // truthy for the first request to be AWAITED during SSR — with
177
+ // `immediate: false` the listing markup server-rendered empty and the
178
+ // in-flight fetch raced into payload.data (a hydration mismatch).
179
+ // An empty query has nothing to render, so it legitimately stays false;
180
+ // the watcher below still picks it up once a query arrives.
181
+ immediate: hasQuery.value,
182
+ // SSR awaits the request; on the client the fetch moves to onBeforeMount
183
+ // so a route change doesn't block navigation on the listing.
184
+ lazy: true,
185
+ // No explicit `watch`: Nuxt's default watches the reactive request
186
+ // options, and every URL-derived input (query, facets, price, sort,
187
+ // page) flows through `requestBody`.
153
188
  },
154
- { deep: true },
155
189
  );
156
190
 
157
191
  /* ---- derived view state -------------------------------------------- */
@@ -209,13 +243,10 @@ export function useProductListing(options: ProductListingOptions) {
209
243
  updateUrl(updates);
210
244
  }
211
245
 
212
- const sortOptions = computed(() => [
213
- { value: "relevance", label: t("search.sort.relevance") },
214
- { value: "price_asc", label: t("search.sort.priceAsc") },
215
- { value: "price_desc", label: t("search.sort.priceDesc") },
216
- { value: "name_asc", label: t("search.sort.nameAsc") },
217
- { value: "name_desc", label: t("search.sort.nameDesc") },
218
- ]);
246
+ const sortOptions = computed(() => enabledSorts.value.map(value => ({
247
+ value,
248
+ label: t(SORT_LABEL_KEYS[value as keyof typeof SORT_LABEL_KEYS]),
249
+ })));
219
250
 
220
251
  return {
221
252
  query, sort, sortOptions, page, activeFilters, priceRange,
@@ -1,8 +1,12 @@
1
1
  import { useDebounceFn } from "@vueuse/core";
2
2
 
3
3
  export interface SearchListingOptions {
4
- /** The full-text search value the listing searches for. */
5
- readonly query: () => string;
4
+ /**
5
+ * Fallback search value, used only when the URL carries no `?q` — the
6
+ * authored sample on the blokkli search page and in the editor canvas,
7
+ * which has no route query of its own.
8
+ */
9
+ readonly query?: () => string;
6
10
  }
7
11
 
8
12
  /**
@@ -11,6 +15,11 @@ export interface SearchListingOptions {
11
15
  * ListingContext) so the shared `listing_*` widgets work unchanged. There is no
12
16
  * category/subcategory here (those resolve to undefined). The locked `search`
13
17
  * wrapper block calls this once and provides the result.
18
+ *
19
+ * The term is read from `?q` FIRST and only falls back to `options.query` — that
20
+ * is what closes the loop with `pushQuery` below (which writes `?q`) and makes
21
+ * the in-page search box actually change the results. The fallback keeps the
22
+ * editor canvas rendering the authored sample, since it has no route query.
14
23
  */
15
24
  export const useSearchListing = (options: SearchListingOptions) => {
16
25
  const route = useRoute();
@@ -18,7 +27,11 @@ export const useSearchListing = (options: SearchListingOptions) => {
18
27
  const { t } = useI18n();
19
28
  const localePath = useLocalePath();
20
29
 
21
- const query = computed(() => options.query());
30
+ const routeQuery = computed(() => {
31
+ const q = route.query.q;
32
+ return Array.isArray(q) ? q[0] : q;
33
+ });
34
+ const query = computed(() => routeQuery.value ?? options.query?.() ?? "");
22
35
 
23
36
  // No category context on the search page — kept for shape parity with
24
37
  // useCategoryListing so the shared listing widgets (incl. the header) work.
@@ -27,8 +40,8 @@ export const useSearchListing = (options: SearchListingOptions) => {
27
40
  const categorySlug = computed(() => "");
28
41
  const subcategorySlug = computed(() => undefined);
29
42
 
30
- // Mirrors the in-category search box mechanics for parity with the header
31
- // widget; the listing query is prop-driven, so this only reflects the term.
43
+ // Mirrors the in-category search box mechanics: `pushQuery` writes `?q` and
44
+ // `query` above reads it back, so typing re-runs the search.
32
45
  const q = computed(() => query.value);
33
46
  const searchInput = ref(q.value);
34
47
  const pushQuery = useDebounceFn(() => {
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  const head = useLocaleHead({ seo: true });
3
- const { query: searchQuery } = useSearch();
3
+ const { navigateToSearch } = useSearch();
4
4
  const route = useRoute();
5
5
  const cart = useCartStore();
6
6
 
@@ -13,8 +13,7 @@ watch(isCartOrCheckoutPage, (isRestrictedPage) => {
13
13
  }, { immediate: true });
14
14
 
15
15
  async function handleSearch(q: string): Promise<void> {
16
- searchQuery.value = q;
17
- await navigateTo("/search");
16
+ await navigateToSearch(q);
18
17
  }
19
18
  </script>
20
19
 
@@ -15,7 +15,7 @@
15
15
  "passwordConfirmPlaceholder": "Passwort wiederholen",
16
16
  "firstName": "Vorname",
17
17
  "lastName": "Nachname",
18
- "company": "Unternehmen",
18
+ "company": "Firma",
19
19
  "companyHint": "Optional – Ihr Unternehmen oder Ihre Organisation",
20
20
  "acceptTerms": "Ich akzeptiere die AGB",
21
21
  "acceptTermsDescription": "Mit der Erstellung eines Kontos stimmen Sie unseren AGB und der Datenschutzerklärung zu. (Demo-Hinweis – es wird kein tatsächlicher Vertrag geschlossen.)"
@@ -21,7 +21,9 @@
21
21
  "priceAsc": "Preis aufsteigend",
22
22
  "priceDesc": "Preis absteigend",
23
23
  "nameAsc": "Name A–Z",
24
- "nameDesc": "Name Z–A"
24
+ "nameDesc": "Name Z–A",
25
+ "skuAsc": "Art.-Nr. A–Z",
26
+ "skuDesc": "Art.-Nr. Z–A"
25
27
  },
26
28
  "filters": {
27
29
  "title": "Filter",
@@ -21,7 +21,9 @@
21
21
  "priceAsc": "Price: Low to High",
22
22
  "priceDesc": "Price: High to Low",
23
23
  "nameAsc": "Name A–Z",
24
- "nameDesc": "Name Z–A"
24
+ "nameDesc": "Name Z–A",
25
+ "skuAsc": "SKU A–Z",
26
+ "skuDesc": "SKU Z–A"
25
27
  },
26
28
  "filters": {
27
29
  "title": "Filters",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenexx/cover",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "Cover \u2014 revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -16,7 +16,20 @@ function isMissingFacetFieldError(err: unknown): boolean {
16
16
  return /Could not find a facet field named/i.test(msg);
17
17
  }
18
18
 
19
- type SortOption = "relevance" | "price_asc" | "price_desc" | "name_asc" | "name_desc";
19
+ /**
20
+ * Same shape, for sorting: a collection provisioned before `name` was declared
21
+ * `sort: true` answers 404 "Could not find a field named `name` in the schema
22
+ * for sorting." Sorting is a nicety; the listing is not. Retry unsorted rather
23
+ * than fail the page, and let it start working by itself once the tenant's
24
+ * collection carries the field.
25
+ */
26
+ function isMissingSortFieldError(err: unknown): boolean {
27
+ if (!err) return false;
28
+ const msg = err instanceof Error ? err.message : String(err);
29
+ return /Could not find a field named .* in the schema for sorting/i.test(msg);
30
+ }
31
+
32
+ type SortOption = "relevance" | "price_asc" | "price_desc" | "name_asc" | "name_desc" | "sku_asc" | "sku_desc";
20
33
 
21
34
  const SORT_MAP: Record<SortOption, string> = {
22
35
  relevance: "_text_match:desc",
@@ -24,6 +37,8 @@ const SORT_MAP: Record<SortOption, string> = {
24
37
  price_desc: "price:desc",
25
38
  name_asc: "name:asc",
26
39
  name_desc: "name:desc",
40
+ sku_asc: "sku:asc",
41
+ sku_desc: "sku:desc",
27
42
  };
28
43
 
29
44
  interface SearchBody {
@@ -122,19 +137,36 @@ export default defineEventHandler(async (event) => {
122
137
  // Retry once without dynamic facets so the storefront keeps
123
138
  // rendering with spine facets only; the meta cache repairs on
124
139
  // its next refresh.
125
- const runSearch = async (facetBy: string) => searchLiveProducts({
140
+ // The sort the visitor picked was computed and then never sent: the
141
+ // dropdown has been inert in live mode. Only the sorts the live
142
+ // collection can actually carry are passed on — it projects no `price`
143
+ // field, so a price sort would 404; "relevance" is the absence of
144
+ // sort_by, which is what Typesense does by itself.
145
+ //
146
+ // `name` and `sku` are STRINGS, and Typesense only sorts a string field
147
+ // that was declared `sort: true` at schema time. A catalogue whose
148
+ // search.json predates that is handled below: the request is retried
149
+ // unsorted rather than failing the listing.
150
+ const LIVE_SORTABLE: readonly SortOption[] = ["name_asc", "name_desc", "sku_asc", "sku_desc"];
151
+ const liveSortBy = LIVE_SORTABLE.includes(sort)
152
+ ? SORT_MAP[sort]
153
+ : undefined;
154
+
155
+ const runSearch = async (facetBy: string, sortBy?: string) => searchLiveProducts({
126
156
  q,
127
157
  queryBy: "name,sku,description,manufacturer",
128
158
  filterBy: liveFilterParts.join(" && "),
129
159
  facetBy,
160
+ ...(sortBy ? { sortBy } : {}),
130
161
  page,
131
162
  perPage,
132
163
  });
133
164
 
134
- try {
135
- let results;
165
+ // Two independent degradations, each retried once: a dynamic facet the
166
+ // tenant's schema no longer has, and a sort field it never had.
167
+ const searchWithFallbacks = async (sortBy?: string) => {
136
168
  try {
137
- results = await runSearch(liveFacetBy);
169
+ return await runSearch(liveFacetBy, sortBy);
138
170
  }
139
171
  catch (err) {
140
172
  if (dynamicFacets.length > 0 && isMissingFacetFieldError(err)) {
@@ -142,7 +174,24 @@ export default defineEventHandler(async (event) => {
142
174
  "search: dynamic facet missing in Typesense, retrying with spine facets only",
143
175
  toErrorContext(err),
144
176
  );
145
- results = await runSearch(spineFacetBy);
177
+ return await runSearch(spineFacetBy, sortBy);
178
+ }
179
+ throw err;
180
+ }
181
+ };
182
+
183
+ try {
184
+ let results;
185
+ try {
186
+ results = await searchWithFallbacks(liveSortBy);
187
+ }
188
+ catch (err) {
189
+ if (liveSortBy && isMissingSortFieldError(err)) {
190
+ getLogService().warn(
191
+ "search: collection has no sortable field for this sort, retrying unsorted",
192
+ toErrorContext(err),
193
+ );
194
+ results = await searchWithFallbacks(undefined);
146
195
  }
147
196
  else {
148
197
  throw err;
@@ -1,3 +1,10 @@
1
1
  export interface ILogService {
2
2
  error(message: string, context?: Record<string, unknown>): void;
3
+ /**
4
+ * A degradation the request survived — a retry that worked, a feature
5
+ * switched off because its data was missing. Distinct from `error` so a
6
+ * log full of graceful fallbacks does not read like a log full of
7
+ * failures.
8
+ */
9
+ warn(message: string, context?: Record<string, unknown>): void;
3
10
  }
@@ -48,6 +48,9 @@ export class ApiProductService implements IProductService {
48
48
 
49
49
  async getProductDetail(id: string, locale: Locale = "de"): Promise<ProductDetail | null> {
50
50
  const doc = await getLiveProductDoc(id, locale);
51
- return doc ? mapLiveDocToDetail(doc) : null;
51
+ // The locale selects the document AND the labels: mapLiveDocToDetail
52
+ // resolves every attribute name and select-option value through it.
53
+ // Dropping it here left the spec table German on an English page.
54
+ return doc ? mapLiveDocToDetail(doc, locale) : null;
52
55
  }
53
56
  }
@@ -12,8 +12,16 @@ export class LogService implements ILogService {
12
12
  }
13
13
 
14
14
  error(message: string, context?: Record<string, unknown>): void {
15
+ this.write("error", message, context);
16
+ }
17
+
18
+ warn(message: string, context?: Record<string, unknown>): void {
19
+ this.write("warn", message, context);
20
+ }
21
+
22
+ private write(level: string, message: string, context?: Record<string, unknown>): void {
15
23
  const entry = JSON.stringify({
16
- level: "error",
24
+ level,
17
25
  timestamp: new Date().toISOString(),
18
26
  message,
19
27
  ...context,