@revenexx/cover 0.7.0 → 0.10.1

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 (101) hide show
  1. package/app/api/forms.ts +1 -0
  2. package/app/app.config.ts +17 -12
  3. package/app/components/RevenexxForm.vue +80 -12
  4. package/app/components/account/AccountShell.vue +18 -0
  5. package/app/components/account/approvals/AccountPendingApprovals.vue +178 -0
  6. package/app/components/account/orderlists/AccountOrderListDetail.vue +47 -4
  7. package/app/components/account/orders/AccountOrderDetail.vue +186 -1
  8. package/app/components/account/payments/AccountPayments.vue +129 -0
  9. package/app/components/account/quotes/AccountQuoteDetail.vue +48 -16
  10. package/app/components/auth/AuthLoginPanel.vue +131 -15
  11. package/app/components/auth/AuthMagicLinkPanel.vue +70 -0
  12. package/app/components/cart/view/CartSummaryPanel.vue +54 -0
  13. package/app/components/checkout/onepage/CheckoutDeliverySection.vue +13 -1
  14. package/app/components/checkout/onepage/CheckoutGate.vue +8 -7
  15. package/app/components/form/FormPage.vue +40 -0
  16. package/app/components/layout/header/AppBar.vue +7 -1
  17. package/app/components/layout/header/MainNav.vue +23 -1
  18. package/app/components/layout/header/MobileMenu.vue +12 -0
  19. package/app/components/product/detail/ProductDetailPriceRequest.vue +39 -0
  20. package/app/components/product/detail/ProductDetailView.vue +57 -0
  21. package/app/composables/useAccountHold.ts +45 -0
  22. package/app/composables/useAccountPayments.ts +21 -0
  23. package/app/composables/useAccountQuotes.ts +15 -2
  24. package/app/composables/useAuthStore.ts +82 -2
  25. package/app/composables/useAuthoredForms.ts +26 -0
  26. package/app/composables/useAvailableOffers.ts +42 -0
  27. package/app/composables/useGuestOrdering.ts +28 -0
  28. package/app/composables/useMasterDataEditable.ts +22 -7
  29. package/app/composables/useOrderListRules.ts +21 -1
  30. package/app/composables/usePendingApprovals.ts +37 -0
  31. package/app/config/icons.ts +2 -0
  32. package/app/config/navigation.ts +2 -2
  33. package/app/formkit.config.ts +14 -0
  34. package/app/interfaces/account/approvals.ts +37 -0
  35. package/app/interfaces/account/order-list.ts +29 -0
  36. package/app/interfaces/account/order-lists.ts +9 -0
  37. package/app/interfaces/account/payments.ts +48 -0
  38. package/app/interfaces/auth.ts +11 -0
  39. package/app/interfaces/b2b.ts +8 -8
  40. package/app/interfaces/offers.ts +35 -0
  41. package/app/interfaces/shopSettings.ts +77 -0
  42. package/app/plugins/account-hold.client.ts +20 -0
  43. package/app/plugins/shop-settings.ts +27 -12
  44. package/i18n/locales/de/account.json +80 -0
  45. package/i18n/locales/de/auth.json +29 -0
  46. package/i18n/locales/de/cart.json +7 -0
  47. package/i18n/locales/de/checkout.json +2 -1
  48. package/i18n/locales/de/common.json +4 -2
  49. package/i18n/locales/de/forms.json +27 -0
  50. package/i18n/locales/en/account.json +80 -0
  51. package/i18n/locales/en/auth.json +29 -0
  52. package/i18n/locales/en/cart.json +7 -0
  53. package/i18n/locales/en/checkout.json +2 -1
  54. package/i18n/locales/en/common.json +2 -0
  55. package/i18n/locales/en/forms.json +27 -0
  56. package/package.json +2 -1
  57. package/server/api/account/address/[id].delete.ts +1 -1
  58. package/server/api/account/address/[id].put.ts +1 -1
  59. package/server/api/account/address/index.post.ts +1 -1
  60. package/server/api/account/order-lists/[id].get.ts +37 -3
  61. package/server/api/account/orders/[id]/cancel.post.ts +54 -0
  62. package/server/api/account/orders/[id]/messages.get.ts +63 -0
  63. package/server/api/account/orders/[id]/messages.post.ts +44 -0
  64. package/server/api/account/organization.put.ts +1 -1
  65. package/server/api/account/payments.get.ts +54 -0
  66. package/server/api/account/pending-approvals/[id]/approve.post.ts +10 -0
  67. package/server/api/account/pending-approvals/[id]/decline.post.ts +10 -0
  68. package/server/api/account/pending-approvals/index.get.ts +25 -0
  69. package/server/api/account/profile.put.ts +1 -1
  70. package/server/api/account/quotes/[id]/decline.post.ts +35 -6
  71. package/server/api/account/team/[id].put.ts +1 -1
  72. package/server/api/account/team.post.ts +1 -1
  73. package/server/api/auth/magic-link.post.ts +32 -0
  74. package/server/api/auth/magic-link.put.ts +30 -0
  75. package/server/api/auth/otp.post.ts +33 -0
  76. package/server/api/auth/otp.put.ts +28 -0
  77. package/server/api/checkout/profile.get.ts +6 -3
  78. package/server/api/forms/[slug]/submit.post.ts +27 -16
  79. package/server/api/forms/[slug].get.ts +9 -1
  80. package/server/api/forms/index.get.ts +23 -0
  81. package/server/api/orders/index.post.ts +8 -0
  82. package/server/api/promotions/available.post.ts +37 -0
  83. package/server/config/account/organization.json +0 -4
  84. package/server/config/shop/app-settings.json +4 -0
  85. package/server/data/forms/authored.json +337 -0
  86. package/server/interfaces/forms.ts +51 -0
  87. package/server/services/ApiAuthService.ts +10 -0
  88. package/server/services/ApiFormsService.ts +56 -0
  89. package/server/services/MockB2BContextService.ts +1 -5
  90. package/server/services/MockFormsService.ts +63 -0
  91. package/server/utils/accountPayments.ts +45 -0
  92. package/server/utils/appSettings.ts +69 -4
  93. package/server/utils/forms.ts +62 -14
  94. package/server/utils/formsService.ts +29 -0
  95. package/server/utils/liveOrders.ts +26 -0
  96. package/server/utils/masterData.ts +31 -11
  97. package/server/utils/passwordlessSignIn.ts +73 -0
  98. package/server/utils/pendingApprovals.ts +153 -0
  99. package/server/utils/promotionsService.ts +90 -0
  100. package/server/utils/quotesService.ts +15 -0
  101. package/server/utils/shopSettings.ts +35 -4
@@ -1,12 +1,17 @@
1
1
  <script setup lang="ts">
2
2
  import { accountApi } from "../../../api/account";
3
- import type { AccountOrder, AccountOrderStatus, AccountOrderPaymentStatus } from "../../../interfaces/account/order-list";
3
+ import type { AccountOrder, AccountOrderMessage, AccountOrderStatus, AccountOrderPaymentStatus } from "../../../interfaces/account/order-list";
4
4
 
5
5
  /**
6
6
  * Detail page content of one order (account pattern: detail = own page):
7
7
  * head facts, fulfillment progress with carrier tracking, positions and
8
8
  * the delivery/billing/payment block — everything a buyer needs to answer
9
9
  * "where is my order?" without contacting support.
10
+ *
11
+ * And the two things they previously had to telephone about: calling the order off
12
+ * while nothing has shipped, and saying something about it. The orders app has
13
+ * taken both all along — a comment thread with a customer-visible half, and a
14
+ * cancellation it refuses once goods are with a carrier.
10
15
  */
11
16
  const props = defineProps<{
12
17
  orderId: string;
@@ -24,6 +29,79 @@ const { data: order, status, error, refresh } = useFetch<AccountOrder>(
24
29
  { key: `account-order:${props.orderId}` },
25
30
  );
26
31
 
32
+ /* ---- talking about this order ------------------------------------------ */
33
+
34
+ /**
35
+ * What has been said, both ways.
36
+ *
37
+ * Only the customer-visible half reaches this: the desk keeps its own notes about
38
+ * a customer beside them and those are not part of a conversation with the buyer.
39
+ */
40
+ const { data: messageData, refresh: refreshMessages } = useFetch<{ messages: AccountOrderMessage[] }>(
41
+ `/api/account/orders/${props.orderId}/messages`,
42
+ { key: `account-order-messages:${props.orderId}`, default: () => ({ messages: [] }) },
43
+ );
44
+ const messages = computed(() => messageData.value?.messages ?? []);
45
+
46
+ const draft = ref("");
47
+ const sending = ref(false);
48
+
49
+ async function sendMessage(): Promise<void> {
50
+ const body = draft.value.trim();
51
+ if (!body) {
52
+ return;
53
+ }
54
+ sending.value = true;
55
+ try {
56
+ await $fetch(`/api/account/orders/${props.orderId}/messages`, { method: "POST", body: { body } });
57
+ draft.value = "";
58
+ await refreshMessages();
59
+ }
60
+ catch (err) {
61
+ toast.add({
62
+ title: t("orders.messages.failed"),
63
+ description: (err as { data?: { message?: string } })?.data?.message,
64
+ color: "error",
65
+ icon: icon("error"),
66
+ });
67
+ }
68
+ finally {
69
+ sending.value = false;
70
+ }
71
+ }
72
+
73
+ /* ---- calling it off ---------------------------------------------------- */
74
+
75
+ const cancelOpen = ref(false);
76
+ const cancelReason = ref("");
77
+ const cancelling = ref(false);
78
+
79
+ async function submitCancel(): Promise<void> {
80
+ cancelling.value = true;
81
+ try {
82
+ await $fetch(`/api/account/orders/${props.orderId}/cancel`, {
83
+ method: "POST",
84
+ body: cancelReason.value.trim() ? { reason: cancelReason.value.trim() } : {},
85
+ });
86
+ cancelOpen.value = false;
87
+ await refresh();
88
+ toast.add({ title: t("orders.cancel.done"), color: "success", icon: icon("success") });
89
+ }
90
+ catch (err) {
91
+ // The merchant requiring a reason, or the order having moved on since the
92
+ // page was drawn. Both are the buyer's to read.
93
+ toast.add({
94
+ title: t("orders.cancel.failed"),
95
+ description: (err as { data?: { message?: string } })?.data?.message,
96
+ color: "error",
97
+ icon: icon("error"),
98
+ });
99
+ }
100
+ finally {
101
+ cancelling.value = false;
102
+ }
103
+ }
104
+
27
105
  const statusColors: Record<AccountOrderStatus, "info" | "warning" | "primary" | "success" | "error"> = {
28
106
  "processing": "info",
29
107
  "approval-pending": "warning",
@@ -512,6 +590,18 @@ async function submitReturn(): Promise<void> {
512
590
  :label="t('orders.returns.requestReturn')"
513
591
  @click="openReturn"
514
592
  />
593
+ <!-- Calling it off, while nothing has shipped. The orders app answers
594
+ that question and this button follows it rather than guessing:
595
+ one that produced an error would be worse than none. -->
596
+ <UButton
597
+ v-if="order.cancellable"
598
+ color="error"
599
+ variant="outline"
600
+ tabindex="0"
601
+ :icon="icon('close')"
602
+ :label="t('orders.cancel.action')"
603
+ @click="cancelOpen = true"
604
+ />
515
605
  <UButton
516
606
  v-if="order.status !== 'cancelled'"
517
607
  color="primary"
@@ -523,6 +613,101 @@ async function submitReturn(): Promise<void> {
523
613
  />
524
614
  </div>
525
615
 
616
+ <!-- Saying something about this order. The desk's own notes about a
617
+ customer are not in here: a trail is a record of a conversation WITH
618
+ the buyer, and only the customer-visible half reaches this page. -->
619
+ <section class="border border-(--ui-border) rounded-xl overflow-hidden">
620
+ <h2 class="px-4 sm:px-5 py-3 text-sm font-semibold text-highlighted bg-elevated/60 border-b border-(--ui-border)">
621
+ {{ t('orders.messages.title') }}
622
+ </h2>
623
+
624
+ <ul
625
+ v-if="messages.length"
626
+ class="divide-y divide-(--ui-border)"
627
+ >
628
+ <li
629
+ v-for="message in messages"
630
+ :key="message.id"
631
+ class="px-4 sm:px-5 py-3"
632
+ >
633
+ <div class="flex items-baseline justify-between gap-3">
634
+ <span class="text-xs font-medium text-highlighted">
635
+ {{ message.fromBuyer ? t('orders.messages.you') : t('orders.messages.merchant') }}
636
+ </span>
637
+ <span class="text-xs text-muted">
638
+ {{ message.at ? d(new Date(message.at), { dateStyle: 'medium' }) : '' }}
639
+ </span>
640
+ </div>
641
+ <p class="text-sm text-default mt-1 whitespace-pre-line">
642
+ {{ message.body }}
643
+ </p>
644
+ </li>
645
+ </ul>
646
+ <p
647
+ v-else
648
+ class="px-4 sm:px-5 py-3 text-sm text-muted"
649
+ >
650
+ {{ t('orders.messages.empty') }}
651
+ </p>
652
+
653
+ <div class="px-4 sm:px-5 py-3 border-t border-(--ui-border) space-y-2">
654
+ <UTextarea
655
+ v-model="draft"
656
+ class="w-full"
657
+ :rows="2"
658
+ :placeholder="t('orders.messages.placeholder')"
659
+ />
660
+ <UButton
661
+ size="sm"
662
+ color="primary"
663
+ :disabled="!draft.trim() || sending"
664
+ :loading="sending"
665
+ :label="t('orders.messages.send')"
666
+ @click="sendMessage"
667
+ />
668
+ </div>
669
+ </section>
670
+
671
+ <!-- Cancel modal. The reason is asked for up front because the merchant
672
+ may require it, and a form that could have said so beats an error
673
+ that has to. -->
674
+ <UModal
675
+ v-model:open="cancelOpen"
676
+ :title="t('orders.cancel.title', { number: order.id })"
677
+ >
678
+ <template #body>
679
+ <div class="space-y-4">
680
+ <p class="text-sm text-default">
681
+ {{ t('orders.cancel.intro') }}
682
+ </p>
683
+ <UFormField :label="t('orders.cancel.reason')">
684
+ <UTextarea
685
+ v-model="cancelReason"
686
+ class="w-full"
687
+ :rows="2"
688
+ :placeholder="t('orders.cancel.reasonPlaceholder')"
689
+ />
690
+ </UFormField>
691
+ </div>
692
+ </template>
693
+ <template #footer>
694
+ <div class="flex items-center justify-end gap-2 w-full">
695
+ <UButton
696
+ color="neutral"
697
+ variant="ghost"
698
+ :label="t('cart.item.cancel')"
699
+ @click="cancelOpen = false"
700
+ />
701
+ <UButton
702
+ color="error"
703
+ :loading="cancelling"
704
+ :label="t('orders.cancel.confirm')"
705
+ @click="submitCancel"
706
+ />
707
+ </div>
708
+ </template>
709
+ </UModal>
710
+
526
711
  <!-- Request return modal -->
527
712
  <UModal
528
713
  v-model:open="returnOpen"
@@ -0,0 +1,129 @@
1
+ <script setup lang="ts">
2
+ import type { TableColumn } from "@nuxt/ui";
3
+
4
+ import type { AccountPayment } from "../../../interfaces/account/payments";
5
+
6
+ /**
7
+ * What the buyer owes and what they have settled.
8
+ *
9
+ * Overdue first, because that is the row somebody in their accounts department is
10
+ * asking them about. The outstanding total is stated per currency and never as one
11
+ * figure: a buyer trading in two has two answers, and adding them would produce a
12
+ * third that is true of nothing.
13
+ */
14
+ const { t, d } = useI18n();
15
+ const { icon } = useIcons();
16
+ const { payments, outstanding, overdue, status } = useAccountPayments();
17
+ const { formatCurrency } = useCartSummaryFormatting();
18
+
19
+ const STATE_COLOR: Record<AccountPayment["state"], "success" | "warning" | "error" | "neutral" | "info"> = {
20
+ paid: "success",
21
+ partially_paid: "warning",
22
+ authorized: "info",
23
+ pending: "info",
24
+ open: "neutral",
25
+ refunded: "neutral",
26
+ failed: "error",
27
+ };
28
+
29
+ /** Overdue first, then what is still open, then the settled ones by date. */
30
+ const rows = computed(() => [...payments.value].sort((a, b) => {
31
+ if (a.overdue !== b.overdue) {
32
+ return a.overdue ? -1 : 1;
33
+ }
34
+ const aSettled = a.state === "paid" || a.state === "refunded";
35
+ const bSettled = b.state === "paid" || b.state === "refunded";
36
+ if (aSettled !== bSettled) {
37
+ return aSettled ? 1 : -1;
38
+ }
39
+ return (b.dueAt ?? b.paidAt ?? "").localeCompare(a.dueAt ?? a.paidAt ?? "");
40
+ }));
41
+
42
+ const columns: TableColumn<AccountPayment>[] = [
43
+ { accessorKey: "orderNumber", header: t("payments.columns.order") },
44
+ { accessorKey: "amount", header: t("payments.columns.amount") },
45
+ { accessorKey: "state", header: t("payments.columns.state") },
46
+ { accessorKey: "dueAt", header: t("payments.columns.due") },
47
+ ];
48
+
49
+ const date = (value: string | null) => (value ? d(new Date(value), { dateStyle: "medium" }) : "–");
50
+ </script>
51
+
52
+ <template>
53
+ <div class="space-y-6">
54
+ <div>
55
+ <h1 class="text-2xl font-semibold text-highlighted">
56
+ {{ t('payments.title') }}
57
+ </h1>
58
+ <p class="text-muted">
59
+ {{ t('payments.description') }}
60
+ </p>
61
+ </div>
62
+
63
+ <!-- What is still owed, per currency. A buyer trading in two has two
64
+ answers, and one figure across both would be true of neither. -->
65
+ <div
66
+ v-if="outstanding.length"
67
+ class="flex flex-wrap gap-3"
68
+ >
69
+ <div
70
+ v-for="sum in outstanding"
71
+ :key="sum.currency"
72
+ class="rounded-xl border border-(--ui-border) px-4 py-3"
73
+ >
74
+ <p class="text-xs text-muted">
75
+ {{ t('payments.outstanding') }}
76
+ </p>
77
+ <p class="text-lg font-semibold text-highlighted tabular-nums">
78
+ {{ sum.amount.toLocaleString(undefined, { style: 'currency', currency: sum.currency }) }}
79
+ </p>
80
+ </div>
81
+ </div>
82
+
83
+ <UAlert
84
+ v-if="overdue.length"
85
+ color="warning"
86
+ variant="subtle"
87
+ :icon="icon('warning')"
88
+ :title="t('payments.overdueTitle', { count: overdue.length })"
89
+ :description="t('payments.overdueDescription')"
90
+ />
91
+
92
+ <UTable
93
+ :data="rows"
94
+ :columns="columns"
95
+ :loading="status === 'pending'"
96
+ >
97
+ <template #orderNumber-cell="{ row }">
98
+ <span class="text-sm font-medium text-highlighted">
99
+ {{ row.original.orderNumber ?? '–' }}
100
+ </span>
101
+ </template>
102
+ <template #amount-cell="{ row }">
103
+ <span class="text-sm tabular-nums">{{ formatCurrency(row.original.amount) }}</span>
104
+ </template>
105
+ <template #state-cell="{ row }">
106
+ <UBadge
107
+ size="sm"
108
+ variant="subtle"
109
+ :color="row.original.overdue ? 'error' : STATE_COLOR[row.original.state]"
110
+ :label="row.original.overdue
111
+ ? t('payments.states.overdue')
112
+ : t(`payments.states.${row.original.state}`)"
113
+ />
114
+ </template>
115
+ <template #dueAt-cell="{ row }">
116
+ <span class="text-sm text-muted">
117
+ {{ row.original.state === 'paid' ? date(row.original.paidAt) : date(row.original.dueAt) }}
118
+ </span>
119
+ </template>
120
+ <template #empty>
121
+ <UiFeedbackEmptyState
122
+ :icon="icon('payment')"
123
+ :title="t('payments.empty.title')"
124
+ :description="t('payments.empty.description')"
125
+ />
126
+ </template>
127
+ </UTable>
128
+ </div>
129
+ </template>
@@ -91,25 +91,39 @@ const openLines = computed(() => quote.value?.lines.filter(line => line.decision
91
91
  const selectable = computed(() =>
92
92
  Boolean(quote.value?.partialAcceptance) && quote.value?.canOrder === true && openLines.value.length > 1,
93
93
  );
94
- const selected = ref<string[]>([]);
94
+ /**
95
+ * What the buyer decided per open position: order it, refuse it, or leave it be.
96
+ *
97
+ * Three states and not a checkbox, because leaving a position open and refusing it
98
+ * are different answers with different consequences — one can be ordered next
99
+ * week, the other closes. The platform takes both through the same call.
100
+ */
101
+ type LineChoice = "order" | "decline" | "open";
102
+ const choices = ref<Record<string, LineChoice>>({});
95
103
 
96
- // Everything open, until the buyer says otherwise. Starting empty would show a
97
- // total of nothing and an order button that does nothing.
104
+ // Everything to order, until the buyer says otherwise. Starting on "open" would
105
+ // show a total of nothing and an order button that does nothing.
98
106
  watch(openLines, (lines) => {
99
- selected.value = lines.map(line => line.id);
107
+ choices.value = Object.fromEntries(lines.map(line => [line.id, "order" as LineChoice]));
100
108
  }, { immediate: true });
101
109
 
102
- const isSelected = (id: string) => selected.value.includes(id);
103
- function toggleLine(id: string): void {
104
- selected.value = isSelected(id)
105
- ? selected.value.filter(lineId => lineId !== id)
106
- : [...selected.value, id];
110
+ const choiceOf = (id: string): LineChoice => choices.value[id] ?? "order";
111
+ const isSelected = (id: string) => choiceOf(id) === "order";
112
+ function setChoice(id: string, choice: LineChoice): void {
113
+ choices.value = { ...choices.value, [id]: choice };
107
114
  }
108
115
 
116
+ const selected = computed(() => openLines.value.filter(line => choiceOf(line.id) === "order").map(line => line.id));
117
+ const refused = computed(() => openLines.value.filter(line => choiceOf(line.id) === "decline").map(line => line.id));
118
+
109
119
  /** A partial pick: some of what is open, not all of it. */
110
120
  const partialPick = computed(() =>
111
121
  selectable.value && selected.value.length > 0 && selected.value.length < openLines.value.length,
112
122
  );
123
+ /** Some positions refused, but not every open one — that would be a plain no. */
124
+ const partialRefusal = computed(() =>
125
+ selectable.value && refused.value.length > 0 && refused.value.length < openLines.value.length,
126
+ );
113
127
 
114
128
  /** What the buyer is about to order — their pick, or the whole quote. */
115
129
  const selectedTotal = computed(() => {
@@ -155,7 +169,12 @@ const declineReason = ref("");
155
169
 
156
170
  async function submitDecline(): Promise<void> {
157
171
  try {
158
- await decline(declineReason.value.trim() || undefined);
172
+ // Only a real subset travels: refusing every open position is a refusal of
173
+ // the offer, and the whole-quote path says that more plainly.
174
+ await decline(
175
+ declineReason.value.trim() || undefined,
176
+ partialRefusal.value ? refused.value : undefined,
177
+ );
159
178
  declineOpen.value = false;
160
179
  toast.add({ title: t("quotes.decline.success"), color: "neutral", icon: icon("success") });
161
180
  }
@@ -254,12 +273,23 @@ async function submitDecline(): Promise<void> {
254
273
  class="px-4 sm:px-5 py-3 flex flex-wrap items-center gap-x-4 gap-y-1"
255
274
  :class="selectable && line.decision === 'open' && !isSelected(line.id) ? 'opacity-55' : ''"
256
275
  >
257
- <UCheckbox
276
+ <div
258
277
  v-if="selectable && line.decision === 'open'"
259
- :model-value="isSelected(line.id)"
260
- :aria-label="t('quotes.detail.selectPosition', { name: line.name })"
261
- @update:model-value="toggleLine(line.id)"
262
- />
278
+ class="flex shrink-0 gap-1"
279
+ >
280
+ <UButton
281
+ v-for="option in (['order', 'decline', 'open'] as const)"
282
+ :key="option"
283
+ size="xs"
284
+ :color="choiceOf(line.id) === option ? (option === 'decline' ? 'error' : 'primary') : 'neutral'"
285
+ :variant="choiceOf(line.id) === option ? 'solid' : 'outline'"
286
+ tabindex="0"
287
+ :title="t(`quotes.detail.choice.${option}`)"
288
+ :aria-label="t(`quotes.detail.choice.${option}`) + ': ' + line.name"
289
+ :icon="icon(option === 'order' ? 'cart' : option === 'decline' ? 'close' : 'clock')"
290
+ @click="setChoice(line.id, option)"
291
+ />
292
+ </div>
263
293
  <div class="min-w-0 flex-1">
264
294
  <p class="text-sm font-medium text-highlighted">
265
295
  {{ line.name }}
@@ -393,7 +423,9 @@ async function submitDecline(): Promise<void> {
393
423
  v-if="quote.canDecline"
394
424
  color="neutral"
395
425
  variant="outline"
396
- :label="t('quotes.actions.decline')"
426
+ :label="partialRefusal
427
+ ? t('quotes.actions.declineSelected', { count: refused.length })
428
+ : t('quotes.actions.decline')"
397
429
  @click="declineOpen = true"
398
430
  />
399
431
  <UButton
@@ -18,19 +18,63 @@ const { loading, error } = storeToRefs(auth);
18
18
  /**
19
19
  * How this merchant lets a buyer sign in, as the customers app decides.
20
20
  *
21
- * Only the password is built here. Where the merchant has switched it off and
22
- * put a mailed link or a mailed code in its place, this form cannot sign anybody
23
- * in — so it says how to get in instead of offering a field whose submission
24
- * the app refuses. Building those two ways in is its own work (RX-798).
21
+ * Three ways, and the shop offers exactly the ones switched on — the app refuses
22
+ * the rest, so offering one would be a field whose submission fails. A merchant
23
+ * who has taken the password away and put a mailed link in its place gets a panel
24
+ * that asks for an address and nothing else.
25
25
  */
26
26
  const { signIn } = useShopSettings();
27
27
  const passwordOffered = computed(() => signIn.value?.password ?? true);
28
- const mailedWayIn = computed(() => {
29
- if (signIn.value?.magicLink) {
30
- return "magicLink" as const;
28
+ const magicLinkOffered = computed(() => signIn.value?.magicLink === true);
29
+ const otpOffered = computed(() => signIn.value?.emailOtp === true);
30
+ const anyMailedWay = computed(() => magicLinkOffered.value || otpOffered.value);
31
+
32
+ /* ---- signing in by mail ------------------------------------------------ */
33
+
34
+ /** Which mailed way the buyer is in the middle of, and how far. */
35
+ const mailedKind = ref<"magic-link" | "otp" | null>(null);
36
+ const mailSent = ref(false);
37
+ /** The id the code's confirmation needs; absent for an address nobody holds. */
38
+ const otpUserId = ref<string | null>(null);
39
+ const otpCode = ref("");
40
+
41
+ async function requestMail(kind: "magic-link" | "otp"): Promise<void> {
42
+ if (!state.email.trim()) {
43
+ return;
31
44
  }
32
- return signIn.value?.emailOtp ? "emailOtp" as const : null;
33
- });
45
+ mailedKind.value = kind;
46
+ try {
47
+ otpUserId.value = await auth.requestSignInMail(kind, state.email.trim());
48
+ mailSent.value = true;
49
+ }
50
+ catch {
51
+ // error is set on the store and rendered by UAlert
52
+ }
53
+ }
54
+
55
+ async function confirmCode(): Promise<void> {
56
+ // Without an id there is nothing to confirm against — which is what an address
57
+ // nobody holds looks like. The message is the same one a wrong code gets, so
58
+ // the form never reveals which of the two happened.
59
+ if (!otpCode.value.trim() || !otpUserId.value) {
60
+ auth.error = "auth.login.mailed.codeRejected";
61
+ return;
62
+ }
63
+ try {
64
+ await auth.confirmSignInMail("otp", { userId: otpUserId.value, secret: otpCode.value.trim() });
65
+ emit("success");
66
+ }
67
+ catch {
68
+ // error is set on the store and rendered by UAlert
69
+ }
70
+ }
71
+
72
+ function startOver(): void {
73
+ mailedKind.value = null;
74
+ mailSent.value = false;
75
+ otpUserId.value = null;
76
+ otpCode.value = "";
77
+ }
34
78
 
35
79
  const state = reactive<LoginFormState>({
36
80
  email: "",
@@ -57,19 +101,91 @@ async function onSubmit(): Promise<void> {
57
101
  {{ t('auth.login.existingCustomer') }}
58
102
  </h2>
59
103
 
60
- <!-- The merchant signs buyers in some other way. Saying so beats a
61
- password field that cannot work. -->
104
+ <!-- The merchant offers no password and no mailed way either: nothing this
105
+ form can do, so it says whom to ask instead. -->
62
106
  <UAlert
63
- v-if="!passwordOffered"
107
+ v-if="!passwordOffered && !anyMailedWay"
64
108
  class="mt-6"
65
109
  color="info"
66
110
  variant="soft"
67
111
  :title="t('auth.login.passwordDisabled.title')"
68
- :description="mailedWayIn
69
- ? t(`auth.login.passwordDisabled.${mailedWayIn}`)
70
- : t('auth.login.passwordDisabled.contact')"
112
+ :description="t('auth.login.passwordDisabled.contact')"
71
113
  />
72
114
 
115
+ <!-- Signing in by mail. Where the password is gone this is the whole panel;
116
+ beside a password it is the alternative under it. -->
117
+ <div
118
+ v-if="anyMailedWay"
119
+ :class="passwordOffered ? 'mt-6 pt-6 border-t border-(--ui-border) space-y-3' : 'mt-6 space-y-3'"
120
+ >
121
+ <template v-if="!mailSent">
122
+ <p class="text-sm text-muted">
123
+ {{ t(passwordOffered ? 'auth.login.mailed.alternative' : 'auth.login.mailed.only') }}
124
+ </p>
125
+ <UInput
126
+ v-if="!passwordOffered"
127
+ v-model="state.email"
128
+ type="email"
129
+ class="w-full"
130
+ autocomplete="email"
131
+ :placeholder="t('auth.login.fields.emailPlaceholder')"
132
+ />
133
+ <div class="flex flex-wrap gap-2">
134
+ <UButton
135
+ v-if="magicLinkOffered"
136
+ color="neutral"
137
+ :variant="passwordOffered ? 'outline' : 'solid'"
138
+ :disabled="!state.email.trim() || loading"
139
+ :label="t('auth.login.mailed.requestLink')"
140
+ @click="requestMail('magic-link')"
141
+ />
142
+ <UButton
143
+ v-if="otpOffered"
144
+ color="neutral"
145
+ :variant="passwordOffered ? 'outline' : 'solid'"
146
+ :disabled="!state.email.trim() || loading"
147
+ :label="t('auth.login.mailed.requestCode')"
148
+ @click="requestMail('otp')"
149
+ />
150
+ </div>
151
+ </template>
152
+
153
+ <template v-else>
154
+ <UAlert
155
+ color="success"
156
+ variant="soft"
157
+ :title="t('auth.login.mailed.sentTitle')"
158
+ :description="t(mailedKind === 'otp' ? 'auth.login.mailed.sentCode' : 'auth.login.mailed.sentLink', { email: state.email })"
159
+ />
160
+ <!-- The code is typed back here; a link is followed instead. -->
161
+ <div
162
+ v-if="mailedKind === 'otp'"
163
+ class="flex gap-2"
164
+ >
165
+ <UInput
166
+ v-model="otpCode"
167
+ class="flex-1"
168
+ autocomplete="one-time-code"
169
+ :placeholder="t('auth.login.mailed.codePlaceholder')"
170
+ @keyup.enter="confirmCode"
171
+ />
172
+ <UButton
173
+ color="primary"
174
+ :disabled="!otpCode.trim() || loading"
175
+ :label="t('auth.login.mailed.confirmCode')"
176
+ @click="confirmCode"
177
+ />
178
+ </div>
179
+ <UButton
180
+ color="neutral"
181
+ variant="ghost"
182
+ size="xs"
183
+ :label="t('auth.login.mailed.startOver')"
184
+ @click="startOver"
185
+ />
186
+ </template>
187
+ </div>
188
+
73
189
  <FormKit
74
190
  v-if="passwordOffered"
75
191
  type="form"