basklee-nuxt 0.9.4 → 0.9.6

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 (35) hide show
  1. package/README.md +4 -0
  2. package/package.json +2 -2
  3. package/templates/app/components/basklee/account/StorefrontLogout.README.md +2 -0
  4. package/templates/app/components/basklee/blog/BlogArticle.README.md +2 -0
  5. package/templates/app/components/basklee/blog/BlogArticle.vue +21 -1
  6. package/templates/app/components/basklee/orders/OrderDetails.README.md +2 -0
  7. package/templates/app/components/basklee/orders/OrderDetails.vue +5 -0
  8. package/templates/app/components/basklee/storefront/StorefrontFooter.README.md +6 -0
  9. package/templates/app/components/basklee/storefront/StorefrontFooter.vue +21 -4
  10. package/templates/app/components/basklee/stores/StorefrontStores.README.md +2 -0
  11. package/templates/app/components/basklee/stores/StorefrontStores.vue +2 -1
  12. package/templates/app/composables/useBaskleeCart.ts +356 -2
  13. package/templates/app/layouts/default.vue +2 -1
  14. package/templates/app/pages/browse.vue +2 -2
  15. package/templates/app/utils/basklee/activityLabels.ts +15 -0
  16. package/templates/app/utils/basklee/blogMediaFallback.ts +322 -0
  17. package/templates/app/utils/basklee/browseLabels.ts +12 -0
  18. package/templates/app/utils/basklee/cartLabels.ts +125 -1
  19. package/templates/app/utils/basklee/cartMemory.ts +614 -0
  20. package/templates/app/utils/basklee/contactLabels.ts +13 -1
  21. package/templates/app/utils/basklee/directoryLabels.ts +3 -0
  22. package/templates/app/utils/basklee/featureLabels.ts +12 -0
  23. package/templates/app/utils/basklee/footerLabels.ts +3 -0
  24. package/templates/app/utils/basklee/headerLabels.ts +1 -1
  25. package/templates/app/utils/basklee/photoDetail.ts +59 -0
  26. package/templates/app/utils/basklee/productActions.ts +8 -0
  27. package/templates/app/utils/basklee/profile.ts +52 -0
  28. package/templates/app/utils/basklee/profileLabels.ts +15 -0
  29. package/templates/app/utils/basklee/reviewLabels.ts +6 -0
  30. package/templates/app/utils/basklee/sellerDirectory.ts +112 -0
  31. package/templates/app/utils/basklee/sessionLabels.ts +6 -6
  32. package/templates/app/utils/basklee/storeDirectory.ts +26 -0
  33. package/templates/app/utils/basklee/subscriptionLabels.ts +3 -0
  34. package/templates/app/utils/basklee/tabLocation.ts +37 -0
  35. package/templates/app/utils/basklee/ticketDraft.ts +56 -0
package/README.md CHANGED
@@ -1170,3 +1170,7 @@ See [`templates/basklee/COMPONENTS.md`](templates/basklee/COMPONENTS.md)
1170
1170
  for the maintained route/component/endpoint table. Components use the named
1171
1171
  API client, confirmed mutation results and English/Russian/Spanish labels. Customer
1172
1172
  source bundles include transitive dependencies and installation guidance.
1173
+
1174
+ ---
1175
+
1176
+ Powered by [Basklee](https://basklee.com).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "basklee-nuxt",
3
- "version": "0.9.4",
4
- "description": "Nuxt 4 storefront for your Basklee marketplace: setup CLI, server API gateway, typed store and ready-made catalog, cart, checkout and account components in English, Russian and Spanish, plus an Android app build.",
3
+ "version": "0.9.6",
4
+ "description": "Nuxt 4 storefront for your Basklee marketplace: setup CLI, server API gateway, typed store and ready-made catalog, cart, checkout and account components in English, Russian and Spanish, plus an Android app build. Powered by Basklee: https://basklee.com",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Basklee",
@@ -10,6 +10,8 @@ after successful logout retries only AppLoad, without repeating the mutation.
10
10
  The presentation component emits `retry` and `selectHome`; its documentation
11
11
  preview never signs out the reader.
12
12
 
13
+ The progress and success messages say that the session is ended on all devices: `profile_logout` signs the customer out everywhere, and the page says so.
14
+
13
15
  ## Related components
14
16
 
15
17
  [Profile menu](https://docs.basklee.com/en/sandbox/components/nuxt/profile-menu), [Header](https://docs.basklee.com/en/sandbox/components/nuxt/header).
@@ -22,6 +22,8 @@ When `has_full_access` is false, the article shows its preview and an access pan
22
22
 
23
23
  The first preview image is shown above the text, in an area that keeps its proportions. A post without a preview image, or with an image that fails to load, shows no cover. The cover and the images of the text open larger: a click, `Enter` or `Space` on one opens `ProductReviewImageViewer` at that image, with the article's other images a step away and each image's caption (its `figcaption`, else its `title`, else its `alt`) under it. The images get `role="button"`, a keyboard stop and an «Open image» name; a zoom-in cursor marks them. Images inside a link, a button or a product placement keep their own action. The helper is `app/utils/basklee/blogImageViewer.ts`. Article videos are shown with their poster image; their addresses may be backend paths (`/ps3/...`). In an Android app build the backend's own media paths (`/ps3/...`: cover, article videos, images and videos inside the text) load from the storefront address.
24
24
 
25
+ A picture, video or YouTube player of the text that does not load is replaced by a placeholder in the text's own colours: «The image could not be loaded» with the picture's `alt`, or «The video could not be loaded» with a link to the video file or to the video on YouTube. A blocked YouTube gives no error, so the article checks once per page whether YouTube's image server answers within 8 seconds; the players stay when it does. Pictures of product cards keep the card's own placeholder. The helper is `app/utils/basklee/blogMediaFallback.ts`.
26
+
25
27
  When the first successful `blog_posts_get` response has no article with this ID, the server render of the supplied page answers HTTP 404; after client-side navigation the component emits `missing`. The backend returns an empty list for an unknown ID, an unpublished article and a subscription-only article that the current visitor cannot open. An article returned with `has_full_access = false` keeps its preview and the access panel with the Plans link. An article that disappears after sign-out keeps the “This article is unavailable” state on the page. A failed request is not a missing article: the error notice keeps its Refresh button. The supplied `app/pages/journal/[id].vue` opens the storefront 404 page on `missing` through `useBaskleeMissingPage()`.
26
28
 
27
29
  The guide describes its inputs and events. Source is maintained in
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, defineComponent, h, nextTick, onMounted, ref, shallowRef, watch } from 'vue';
2
+ import { computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue';
3
3
  import type { PropType, VNode } from 'vue';
4
4
  import { useRuntimeConfig } from '#imports';
5
5
  import { useBaskleeStore } from '@/stores/basklee';
@@ -30,6 +30,10 @@
30
30
  nativeAppOrigin,
31
31
  } from '@/utils/basklee/nativeApp';
32
32
  import { requestBlogPost } from '@/utils/basklee/blogLayout';
33
+ import {
34
+ blogMediaFallbackLabels,
35
+ guardBlogMedia,
36
+ } from '@/utils/basklee/blogMediaFallback';
33
37
  import {
34
38
  blogPlacementProductIds,
35
39
  blogPlacementRequests,
@@ -367,6 +371,22 @@
367
371
  { flush: 'post' },
368
372
  );
369
373
 
374
+ // Pictures, videos and YouTube players of the text that do not load get a placeholder.
375
+ let stopMediaGuard = () => {};
376
+ watch(
377
+ [html, mounted, article, () => selectionStore.localeCode],
378
+ () => {
379
+ void nextTick(() => {
380
+ stopMediaGuard();
381
+ stopMediaGuard = mounted.value
382
+ ? guardBlogMedia(article.value, blogMediaFallbackLabels(selectionStore.localeCode))
383
+ : () => {};
384
+ });
385
+ },
386
+ { flush: 'post' },
387
+ );
388
+ onBeforeUnmount(() => stopMediaGuard());
389
+
370
390
  function openViewer(event: Event) {
371
391
  const images = openableImages();
372
392
  const index = blogViewerIndex(event.target, images);
@@ -32,6 +32,8 @@ describes dependencies, theme and consumer configuration. Standalone file
32
32
  copying requires the same dependencies. Links to storefront routes use the
33
33
  pages supplied by the full starter.
34
34
 
35
+ While nothing has left yet, the first step of the rail carries the order's own status word, Processing, in place of Placed: the status card and the rail name one stage, not two.
36
+
35
37
  ## Endpoint coverage
36
38
 
37
39
  - `orders_optiongroup_file_get`
@@ -151,6 +151,11 @@
151
151
  if (step.state === 'partial' && step.key === 'delivered') {
152
152
  return statuses.partlyDelivered;
153
153
  }
154
+ // While nothing has left, the first step carries the order's own status
155
+ // word («Processing»): the card and the rail name one stage, not two.
156
+ if (step.key === 'placed' && step.current) {
157
+ return statuses.processing;
158
+ }
154
159
 
155
160
  return labels.value.steps[step.key];
156
161
  }
@@ -24,3 +24,9 @@ When Application Load reports `init.visual_settings.single_seller_mode: true`, S
24
24
  Navigation omits categories with `exclude_from_tree: true` and all their descendants. The full published catalog remains available for product main-category names, links and breadcrumbs.
25
25
 
26
26
  В навигации скрываются категории с `exclude_from_tree: true` и все их подкатегории. Полный каталог опубликованных категорий сохраняется для названий, ссылок и цепочек основной категории товара.
27
+
28
+ ## Powered by Basklee
29
+
30
+ The bottom line of the footer ends with a small link, «Powered by Basklee»: an `<a href="https://basklee.com">` that opens in a new tab and is marked `data-footer-part="PoweredBy"`. Its text is the `powered` label of `footerLabels` (English, Russian, Spanish). The link is external, so the navigation callback is not called for it.
31
+
32
+ Нижняя строка футера заканчивается маленькой ссылкой «Работает на Basklee»: это `<a href="https://basklee.com">`, она открывается в новой вкладке и отмечена `data-footer-part="PoweredBy"`. Её текст — подпись `powered` из `footerLabels` (английский, русский, испанский). Ссылка внешняя, поэтому обработчик навигации для неё не вызывается.
@@ -221,16 +221,33 @@
221
221
  </a>
222
222
  </nav>
223
223
  </div>
224
- <p
224
+ <div
225
225
  class="
226
- m-0 pt-6
226
+ flex flex-wrap items-baseline justify-between gap-x-6 gap-y-1
227
+ pt-6
227
228
  border-0 border-t border-solid border-basklee-inverse-text/15
228
229
  text-xs uppercase leading-6 tracking-[0.08em]
229
230
  text-basklee-inverse-muted
230
231
  "
231
232
  >
232
- © {{ props.year }} {{ company }} · {{ copy.rights }}
233
- </p>
233
+ <p class="m-0">
234
+ © {{ props.year }} {{ company }} · {{ copy.rights }}
235
+ </p>
236
+ <a
237
+ href="https://basklee.com"
238
+ target="_blank"
239
+ rel="noopener"
240
+ class="
241
+ text-basklee-inverse-muted no-underline
242
+ outline-none
243
+ hover:text-basklee-inverse-text
244
+ focus-visible:text-basklee-inverse-text
245
+ "
246
+ data-footer-part="PoweredBy"
247
+ >
248
+ {{ copy.powered }}
249
+ </a>
250
+ </div>
234
251
  </div>
235
252
  </footer>
236
253
  </template>
@@ -36,6 +36,8 @@ describes dependencies, theme and consumer configuration. Standalone file
36
36
  copying requires the same dependencies. Links to storefront routes use the
37
37
  pages supplied by the full starter.
38
38
 
39
+ A phone number is shown as people read it: a number typed with its own spaces, brackets or dashes stays as typed, and a bare run of digits is grouped from the end (`+78120000078` reads `+7 812 000 00 78`). The dial link keeps the digits only.
40
+
39
41
  ## Endpoint coverage
40
42
 
41
43
  - `stores_get`
@@ -20,6 +20,7 @@
20
20
  storeMapMarkers,
21
21
  storeMarkerId,
22
22
  storePhoneLink,
23
+ storePhoneText,
23
24
  } from '@/utils/basklee/storeDirectory';
24
25
  import type { IApiPagination } from '@/interfaces/basklee/accounts/IProfileData';
25
26
  import type {
@@ -298,7 +299,7 @@
298
299
  class="op-feature-link self-start"
299
300
  :href="storePhoneLink(item.phone_number)"
300
301
  >
301
- {{ item.phone_number }}
302
+ {{ storePhoneText(item.phone_number) }}
302
303
  </a>
303
304
  <details v-if="item.working_hours">
304
305
  <summary
@@ -1,6 +1,7 @@
1
1
  import { computed, inject, onMounted, provide, ref, watch } from 'vue';
2
2
  import type { InjectionKey } from 'vue';
3
3
  import { useBaskleeStore } from '@/stores/basklee';
4
+ import { useBaskleeSelectionsStore } from '@/stores/baskleeSelections';
4
5
  import {
5
6
  useBaskleeFeatureApi,
6
7
  useBaskleeTask,
@@ -9,25 +10,75 @@ import { BaskleeApiError } from '@/utils/basklee/api';
9
10
  import { cartSnapshotProducts } from '@/utils/basklee/cartSnapshot';
10
11
  import { cartPromoRefusal } from '@/utils/basklee/cartPromo';
11
12
  import { cartRequiredOptionsFilled } from '@/utils/basklee/cartOptions';
13
+ import {
14
+ cartChoiceChanges,
15
+ cartMemory,
16
+ cartMemoryHasChoices,
17
+ cartRestorePlan,
18
+ keepCartMemory,
19
+ readCartMemory,
20
+ } from '@/utils/basklee/cartMemory';
21
+ import type {
22
+ ICartLostChoice,
23
+ ICartMemory,
24
+ ICartRestoreReport,
25
+ ICartRestoreStep,
26
+ } from '@/utils/basklee/cartMemory';
12
27
  import type { ICartPromoRefusal } from '@/utils/basklee/cartPromo';
13
28
  import type { BaskleeApiData } from '@/utils/basklee/api';
14
29
  import { ECartState } from '@/interfaces/basklee/cart/ICartActions';
15
30
  import type {
31
+ ICartAddress,
32
+ ICartCheckoutProduct,
16
33
  ICartDelivery,
17
34
  ICartGetResponse,
35
+ ICurrencyAmounts,
36
+ IPaymentMethod,
18
37
  } from '@/interfaces/basklee/cart/ICartData';
38
+ import type { IProduct } from '@/interfaces/basklee/products/IProduct';
19
39
  import type {
20
40
  IOrderCreated,
21
41
  IOrderCreateFailure,
22
42
  } from '@/interfaces/basklee/orders/IOrderActions';
23
43
 
24
44
  type CartData = NonNullable<ICartGetResponse['page_data']>;
45
+
46
+ /** A line just removed from the cart, kept so that «Undo» can put it back. */
47
+ export interface ICartRemovedLine {
48
+ product: number;
49
+ quantity: number;
50
+ name: IProduct['locale'];
51
+ /** Where the line stood in the list. */
52
+ index: number;
53
+ /** «Undo» was pressed and the line is back. */
54
+ restored: boolean;
55
+ }
56
+
57
+ /** What the order was placed with: shown on the receipt, the cart is gone by then. */
58
+ export interface ICartReceipt {
59
+ total: ICurrencyAmounts | undefined;
60
+ payment: IPaymentMethod | undefined;
61
+ address: ICartAddress | null;
62
+ shipments: ICartMemory['shipments'];
63
+ }
25
64
  const cartKey: InjectionKey<ReturnType<typeof useBaskleeCart>> =
26
65
  Symbol('cart');
27
66
 
28
- export function useBaskleeCart() {
67
+ export interface IBaskleeCartOptions {
68
+ /**
69
+ * Keep what the customer chose during checkout (delivery, extras) and ask
70
+ * for it again when the backend rebuilds the checkout: after «Back» to the
71
+ * cart and after «Cart was modified» at the order. A page that turns this
72
+ * on shows `restored`, the report of what was kept, lost or priced anew.
73
+ * Off by default: the checkout then starts anew, as the backend returns it.
74
+ */
75
+ rememberChoices?: boolean;
76
+ }
77
+
78
+ export function useBaskleeCart(options: IBaskleeCartOptions = {}) {
29
79
  const api = useBaskleeFeatureApi();
30
80
  const store = useBaskleeStore();
81
+ const selections = useBaskleeSelectionsStore();
31
82
  const task = useBaskleeTask();
32
83
  const data = ref<CartData>();
33
84
  const loaded = ref(false);
@@ -37,6 +88,52 @@ export function useBaskleeCart() {
37
88
  const orderUncertain = ref(false);
38
89
  // Why the last promo code was refused; the next cart answer replaces it.
39
90
  const promoRefusal = ref<ICartPromoRefusal>();
91
+ // What the customer chose during checkout (utils/basklee/cartMemory): asked
92
+ // for again when the backend rebuilt the checkout — after «Back» to the
93
+ // cart, and after «Cart was modified» at the order. `restored` tells what
94
+ // came of it until the customer's next action.
95
+ const restored = ref<ICartRestoreReport>();
96
+ let memory: ICartMemory | undefined;
97
+ let restoreReason: ICartRestoreReport['reason'] | undefined;
98
+ let seenState: ECartState | undefined;
99
+ // The delivery price each method was last quoted at in this checkout, by
100
+ // `<shipment id>:<method id>`: the list of methods shows it beside a method
101
+ // the customer already tried.
102
+ const quotes = ref<Record<string, ICurrencyAmounts>>({});
103
+ // The line removed last and where an undone line goes back to.
104
+ const removed = ref<ICartRemovedLine>();
105
+ let placement: { product: number; index: number } | undefined;
106
+ // The checkout choices held when a line was removed: an emptied cart
107
+ // forgets them, and «Undo» brings them back with the line.
108
+ let removedMemory: ICartMemory | undefined;
109
+ const receipt = ref<ICartReceipt>();
110
+ // The backend refused the order because the wallet holds too little: the
111
+ // page then offers to top it up or to pay another way.
112
+ const walletRefused = ref(false);
113
+ // The wallet, when it is the chosen way to pay (audit 14): what it holds
114
+ // and how much it lacks for this order, in the shown currency. The page
115
+ // says both at the payment choice; the backend still decides at the order.
116
+ const walletState = computed(() => {
117
+ const summary = data.value?.cart;
118
+ const method = Object.values(summary?.payment_methods ?? {}).find(
119
+ (item) => item.id === summary?.selected_payment,
120
+ );
121
+ const currency = String(selections.currencyId);
122
+ const have = Number(store.init?.wallet?.[currency]?.transform_value);
123
+ const need = Number(
124
+ summary?.prices?.summary_price?.[currency]?.transform_value,
125
+ );
126
+
127
+ if (!method?.is_from_balance_payment || !Number.isFinite(have)) {
128
+ return undefined;
129
+ }
130
+ return {
131
+ balance: have,
132
+ short: Number.isFinite(need) && need > have ? need - have : 0,
133
+ };
134
+ });
135
+ const walletBalance = computed(() => walletState.value?.balance);
136
+ const walletShort = computed(() => walletState.value?.short ?? 0);
40
137
  const checkout = computed(
41
138
  () => data.value?.cart.state === ECartState.STATE_CHECKOUT,
42
139
  );
@@ -62,8 +159,140 @@ export function useBaskleeCart() {
62
159
  () => busy.value || needsRefresh.value || orderUncertain.value,
63
160
  );
64
161
 
162
+ function restoreBody(step: ICartRestoreStep): BaskleeApiData {
163
+ if (step.endpoint !== 'cart_customer_option_add_additional') {
164
+ return step.input;
165
+ }
166
+ const body = new FormData();
167
+
168
+ body.append('data', JSON.stringify(step.input));
169
+ return body;
170
+ }
171
+
172
+ // A rebuilt checkout gets the remembered choices back through the ordinary
173
+ // calls, one by one; a refused call is reported, never retried.
174
+ async function restoreChoices(result: CartData, signal: AbortSignal) {
175
+ if (!options.rememberChoices) {
176
+ return result;
177
+ }
178
+
179
+ const inCheckout = result.cart.state === ECartState.STATE_CHECKOUT;
180
+ const reason =
181
+ restoreReason ??
182
+ (seenState !== ECartState.STATE_CHECKOUT ? 'back' : undefined);
183
+
184
+ restoreReason = undefined;
185
+ seenState = result.cart.state;
186
+ if (!inCheckout) {
187
+ return result;
188
+ }
189
+ memory ??= readCartMemory(result.cart.id);
190
+ if (!reason || !memory || !cartMemoryHasChoices(memory)) {
191
+ return result;
192
+ }
193
+
194
+ const plan = cartRestorePlan(
195
+ memory,
196
+ result.cart,
197
+ result.cart_data as ICartDelivery[],
198
+ );
199
+
200
+ if (!plan.steps.length && !plan.lost.length && reason === 'back') {
201
+ return result;
202
+ }
203
+
204
+ const lost: ICartLostChoice[] = [...plan.lost];
205
+ let kept = 0;
206
+
207
+ for (const step of plan.steps) {
208
+ try {
209
+ await api.request(step.endpoint, restoreBody(step), signal, step.params);
210
+ kept += 1;
211
+ } catch (error) {
212
+ if (signal.aborted) {
213
+ throw error;
214
+ }
215
+ lost.push({
216
+ ...step.lost,
217
+ message: error instanceof BaskleeApiError ? error.message : undefined,
218
+ });
219
+ }
220
+ }
221
+
222
+ const after = plan.steps.length
223
+ ? await api.request<CartData>('cart_guest_get', {}, signal)
224
+ : result;
225
+
226
+ seenState = after.cart.state;
227
+ restored.value = {
228
+ reason,
229
+ kept,
230
+ lost,
231
+ changes:
232
+ reason === 'requote' && after.cart.state === ECartState.STATE_CHECKOUT
233
+ ? cartChoiceChanges(
234
+ memory,
235
+ after.cart,
236
+ after.cart_data as ICartDelivery[],
237
+ selections.currencyId,
238
+ )
239
+ : [],
240
+ };
241
+ return after;
242
+ }
243
+
244
+ // Remembers the checkout as it stands and each method's last quote.
245
+ function remember(result: CartData) {
246
+ if (result.cart.state !== ECartState.STATE_CHECKOUT) {
247
+ if (!result.cart.c_cart_positions) {
248
+ memory = undefined;
249
+ keepCartMemory(result.cart.id, undefined);
250
+ }
251
+ return;
252
+ }
253
+
254
+ const deliveries = result.cart_data as ICartDelivery[];
255
+ const known = { ...quotes.value };
256
+
257
+ for (const delivery of deliveries) {
258
+ if (delivery.delivery_data.method) {
259
+ known[`${delivery.delivery_from_id}:${delivery.delivery_data.method}`] =
260
+ delivery.prices?.delivery_price_after_promo;
261
+ }
262
+ }
263
+ quotes.value = known;
264
+ if (!options.rememberChoices) {
265
+ return;
266
+ }
267
+ memory = cartMemory(result.cart, deliveries);
268
+ keepCartMemory(result.cart.id, memory);
269
+ }
270
+
271
+ // An undone removal goes back to where the line stood (the backend lists a
272
+ // product added again last). For this page's life only.
273
+ function place(result: CartData) {
274
+ if (!placement || result.cart.state !== ECartState.STATE_CART) {
275
+ return;
276
+ }
277
+
278
+ const lines = result.cart_data as IProduct[];
279
+ const from = lines.findIndex((line) => line.id === placement!.product);
280
+
281
+ if (from < 0) {
282
+ placement = undefined;
283
+ return;
284
+ }
285
+ lines.splice(Math.min(placement.index, lines.length - 1), 0, ...lines.splice(from, 1));
286
+ }
287
+
65
288
  async function fetchCart(signal: AbortSignal) {
66
- const result = await api.request<CartData>('cart_guest_get', {}, signal);
289
+ const result = await restoreChoices(
290
+ await api.request<CartData>('cart_guest_get', {}, signal),
291
+ signal,
292
+ );
293
+
294
+ place(result);
295
+ remember(result);
67
296
  data.value = result;
68
297
  loaded.value = true;
69
298
  needsRefresh.value = false;
@@ -89,6 +318,10 @@ export function useBaskleeCart() {
89
318
  if (disabled.value) {
90
319
  return Promise.resolve(false);
91
320
  }
321
+ // The customer acts again: the last report and the offer to undo are over.
322
+ restored.value = undefined;
323
+ removed.value = undefined;
324
+ walletRefused.value = false;
92
325
  return task.run(endpoint, async (signal) => {
93
326
  await api.request(endpoint, input, signal, params);
94
327
  // A confirmed mutation must never be repeated to retry its refresh.
@@ -130,12 +363,98 @@ export function useBaskleeCart() {
130
363
  });
131
364
  }
132
365
 
366
+ /**
367
+ * Removes one line and keeps what is needed to put it back: the page shows
368
+ * «Removed … Undo» in its place (`removed`) until the next action.
369
+ */
370
+ function removeLine(product: IProduct | ICartCheckoutProduct) {
371
+ if (disabled.value) {
372
+ return Promise.resolve(false);
373
+ }
374
+
375
+ const shipment = 'dlf_id' in product ? product : undefined;
376
+ const cartItem = product.cart_counts?.cart_id;
377
+
378
+ if (!shipment && !cartItem) {
379
+ return Promise.resolve(false);
380
+ }
381
+
382
+ const lines = checkout.value
383
+ ? (data.value?.cart_data as ICartDelivery[]).flatMap(
384
+ (delivery) => delivery.product_items,
385
+ )
386
+ : ((data.value?.cart_data as IProduct[]) ?? []);
387
+ const gone = {
388
+ product: product.id,
389
+ quantity: shipment?.dlf_count ?? product.cart_counts?.quantity ?? 1,
390
+ name: product.locale,
391
+ index: Math.max(0, lines.findIndex((line) => line?.id === product.id)),
392
+ restored: false,
393
+ };
394
+
395
+ restored.value = undefined;
396
+ removed.value = undefined;
397
+ placement = undefined;
398
+ removedMemory = memory ?? readCartMemory(data.value?.cart.id);
399
+ return task.run('remove', async (signal) => {
400
+ await (shipment
401
+ ? api.request(
402
+ 'cart_customer_remove_by_dlf_item',
403
+ {},
404
+ signal,
405
+ { dlf_item_id: shipment.dlf_id },
406
+ )
407
+ : api.request(
408
+ 'cart_guest_remove_by_cart_item',
409
+ {},
410
+ signal,
411
+ { cart_item_id: cartItem! },
412
+ ));
413
+ needsRefresh.value = true;
414
+ await fetchCart(signal);
415
+ removed.value = gone;
416
+ return true;
417
+ });
418
+ }
419
+
420
+ /** Puts the removed line back: the same product, quantity and place. */
421
+ function undoRemove() {
422
+ const gone = removed.value;
423
+
424
+ if (!gone || gone.restored || disabled.value) {
425
+ return Promise.resolve(false);
426
+ }
427
+ return task.run('undo', async (signal) => {
428
+ await api.request(
429
+ 'cart_guest_first_set',
430
+ { product: gone.product, quantity: gone.quantity },
431
+ signal,
432
+ );
433
+ needsRefresh.value = true;
434
+ placement = { product: gone.product, index: gone.index };
435
+ await fetchCart(signal);
436
+ // The cart that came back empty lost its checkout choices: the next
437
+ // checkout asks for them again, as after «Back».
438
+ if (!memory && removedMemory) {
439
+ memory = removedMemory;
440
+ keepCartMemory(data.value?.cart.id, memory);
441
+ }
442
+ removedMemory = undefined;
443
+ removed.value = { ...gone, restored: true };
444
+ return true;
445
+ });
446
+ }
447
+
133
448
  function clear() {
134
449
  if (disabled.value) {
135
450
  return;
136
451
  }
452
+ restored.value = undefined;
453
+ removed.value = undefined;
137
454
  return task.run('clear', async (signal) => {
138
455
  await api.request('cart_guest_clean', {}, signal);
456
+ keepCartMemory(data.value?.cart.id, undefined);
457
+ memory = undefined;
139
458
  data.value = undefined;
140
459
  loaded.value = true;
141
460
  store.setProductCounters({ c_cart_positions: 0 });
@@ -147,6 +466,7 @@ export function useBaskleeCart() {
147
466
  if (disabled.value || !orderReady.value || created.value) {
148
467
  return;
149
468
  }
469
+ walletRefused.value = false;
150
470
  return task.run('order', async (signal) => {
151
471
  try {
152
472
  const result = await api.request<IOrderCreated>(
@@ -158,6 +478,20 @@ export function useBaskleeCart() {
158
478
  orderUncertain.value = true;
159
479
  throw new BaskleeApiError('failed');
160
480
  }
481
+ // The receipt names what was ordered with: the cart is gone now.
482
+ const summary = data.value?.cart;
483
+
484
+ receipt.value = {
485
+ total: summary?.prices?.summary_price,
486
+ payment: Object.values(summary?.payment_methods ?? {}).find(
487
+ (method) => method.id === summary?.selected_payment,
488
+ ),
489
+ address: summary?.cart_address ?? null,
490
+ shipments: memory?.shipments ?? [],
491
+ };
492
+ keepCartMemory(summary?.id, undefined);
493
+ memory = undefined;
494
+ removed.value = undefined;
161
495
  created.value = result;
162
496
  data.value = undefined;
163
497
  store.setProductCounters({ c_cart_positions: 0 });
@@ -168,8 +502,13 @@ export function useBaskleeCart() {
168
502
  Object.keys(error.fields).length
169
503
  ) {
170
504
  const details = error.data as IOrderCreateFailure | undefined;
505
+
506
+ walletRefused.value = details?.balance_usd !== undefined;
171
507
  if (details?.reboot) {
508
+ // The backend rebuilt the checkout: the remembered delivery and
509
+ // extras are asked for again, and the customer is told what changed.
172
510
  needsRefresh.value = true;
511
+ restoreReason = 'requote';
173
512
  await fetchCart(signal);
174
513
  }
175
514
  } else {
@@ -187,6 +526,12 @@ export function useBaskleeCart() {
187
526
  task.cancel();
188
527
  data.value = undefined;
189
528
  created.value = undefined;
529
+ receipt.value = undefined;
530
+ restored.value = undefined;
531
+ removed.value = undefined;
532
+ memory = undefined;
533
+ seenState = undefined;
534
+ quotes.value = {};
190
535
  orderUncertain.value = false;
191
536
  promoRefusal.value = undefined;
192
537
  void load();
@@ -207,8 +552,17 @@ export function useBaskleeCart() {
207
552
  created,
208
553
  orderUncertain,
209
554
  promoRefusal,
555
+ restored,
556
+ quotes,
557
+ removed,
558
+ receipt,
559
+ walletBalance,
560
+ walletShort,
561
+ walletRefused,
210
562
  load,
211
563
  change,
564
+ removeLine,
565
+ undoRemove,
212
566
  applyPromo,
213
567
  clear,
214
568
  placeOrder,
@@ -26,6 +26,7 @@
26
26
  import '@/components/basklee/shared/features.css';
27
27
  import { useBaskleeCartPreview } from '@/composables/useBaskleeCartPreview';
28
28
  import { useBaskleeSignIn } from '@/composables/useBaskleeSignIn';
29
+ import { PRODUCT_NOTICE_TIME } from '@/utils/basklee/productActions';
29
30
  import { useBaskleeSearchHistory } from '@/composables/useBaskleeSearchHistory';
30
31
  import MainSearch from '@/components/basklee/search/MainSearch.vue';
31
32
  const CartPreview = defineAsyncComponent(
@@ -165,7 +166,7 @@
165
166
  }
166
167
  const timer = setTimeout(() => {
167
168
  actions.success.value = false;
168
- }, 4000);
169
+ }, PRODUCT_NOTICE_TIME);
169
170
  cleanup(() => clearTimeout(timer));
170
171
  },
171
172
  );
@@ -12,7 +12,7 @@
12
12
  import { useBaskleeSearchScopeNames } from '@/composables/useBaskleeSearchScopeNames';
13
13
  import { useBaskleeStorefront } from '@/composables/useBaskleeStorefront';
14
14
  import { directoryLabels } from '@/utils/basklee/directoryLabels';
15
- import { storeAddress, storePhoneLink } from '@/utils/basklee/storeDirectory';
15
+ import { storeAddress, storePhoneLink, storePhoneText } from '@/utils/basklee/storeDirectory';
16
16
  import { browseLabels } from '@/utils/basklee/browseLabels';
17
17
  import { productListLocationFromQuery } from '@/utils/basklee/productListLocation';
18
18
  import {
@@ -189,7 +189,7 @@
189
189
  :href="storePhoneLink(names.storeDetails.phone_number)"
190
190
  class="w-fit text-inherit no-underline focus-visible:outline"
191
191
  >
192
- {{ names.storeDetails.phone_number }}
192
+ {{ storePhoneText(names.storeDetails.phone_number) }}
193
193
  </a>
194
194
  <details v-if="names.storeDetails.working_hours">
195
195
  <summary>{{ directory.hours }}</summary>