@revenexx/cover 0.2.41 → 0.2.43

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.
@@ -2,6 +2,7 @@
2
2
  import CartApprovalsPanel from "./CartApprovalsPanel.vue";
3
3
  import CartWorkflowPickerModal from "../actions/CartWorkflowPickerModal.vue";
4
4
  import PunchoutTransferAction from "../../punchout/action/PunchoutTransferAction.vue";
5
+ import CartQuoteRequestModal from "../quote/CartQuoteRequestModal.vue";
5
6
 
6
7
  /**
7
8
  * Cart summary 2.0: the calculated totals block in document order, the
@@ -40,6 +41,12 @@ const totals = computed(() =>
40
41
  const isRequester = computed(() => role.value === "requester");
41
42
  const orderable = computed(() => calculation.value?.orderable ?? true);
42
43
 
44
+ // A cart the shop cannot order as it is, but can quote (RX-783): the checkout
45
+ // button becomes the quotation request, because that is the one way on.
46
+ const quoteMessage = computed(() =>
47
+ (calculation.value?.messages ?? []).find(message => message.action === "request-quote") ?? null);
48
+ const quoteOpen = ref(false);
49
+
43
50
  /* ---- CTA (spec 5 / 5a) -------------------------------------------- */
44
51
  const workflowModalOpen = ref(false);
45
52
  const noWorkflowModalOpen = ref(false);
@@ -228,6 +235,26 @@ const trustItems = computed(() => {
228
235
  <CartApprovalsPanel :limits="calculation?.approvalLimits ?? []" />
229
236
 
230
237
  <PunchoutTransferAction v-if="isPunchout" />
238
+ <template v-else-if="quoteMessage">
239
+ <UButton
240
+ color="primary"
241
+ variant="solid"
242
+ size="lg"
243
+ class="w-full justify-center mt-2"
244
+ :icon="icon('file')"
245
+ :loading="pending"
246
+ :label="t('cart.quote.action')"
247
+ tabindex="0"
248
+ @click="quoteOpen = true"
249
+ />
250
+ <p class="text-xs text-muted text-center">
251
+ {{ t('cart.quote.ctaHint') }}
252
+ </p>
253
+ <CartQuoteRequestModal
254
+ v-model:open="quoteOpen"
255
+ :reason="quoteMessage.code"
256
+ />
257
+ </template>
231
258
  <template v-else>
232
259
  <UButton
233
260
  color="primary"
@@ -218,6 +218,7 @@
218
218
  },
219
219
  "quote": {
220
220
  "action": "Angebot anfordern",
221
+ "ctaHint": "Versand auf Anfrage – wir kalkulieren die Fracht, bestellt wird anschließend aus Ihrem Kundenkonto.",
221
222
  "title": "Angebot anfordern",
222
223
  "description": "Wir kalkulieren die Fracht für Ihre Sendung und schicken Ihnen ein Angebot.",
223
224
  "shippingAddress": "Lieferadresse",
@@ -218,6 +218,7 @@
218
218
  },
219
219
  "quote": {
220
220
  "action": "Request a quote",
221
+ "ctaHint": "Shipping on request – we price the carriage, you order from your account afterwards.",
221
222
  "title": "Request a quote",
222
223
  "description": "We price the carriage for your consignment and send you a quote.",
223
224
  "shippingAddress": "Shipping address",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenexx/cover",
3
- "version": "0.2.41",
3
+ "version": "0.2.43",
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",
@@ -52,9 +52,10 @@ function toAccountAddress(row: ApiAddressRow): AccountAddress {
52
52
  }
53
53
 
54
54
  /**
55
- * Live address book: the signed-in contact's addresses in the customers
56
- * app. The contact comes from the session cookie; guests have no address
57
- * book. The customers schema requires ISO 3166-1 alpha-2 countries.
55
+ * Live address book: the signed-in buyer's addresses in the customers app —
56
+ * their own AND their company's, because in B2B the delivery addresses belong
57
+ * to the company. Both references come from the session cookie; guests have no
58
+ * address book. The customers schema requires ISO 3166-1 alpha-2 countries.
58
59
  */
59
60
  export class ApiAddressBookService implements IAddressBookService {
60
61
  private contactRef(event: H3Event): { contact_id?: string; organization_id?: string } {
@@ -69,19 +70,49 @@ export class ApiAddressBookService implements IAddressBookService {
69
70
  return contact_id;
70
71
  }
71
72
 
73
+ /**
74
+ * The addresses this buyer may ship and bill to: their own, plus their
75
+ * company's.
76
+ *
77
+ * The company half is not a nicety. In B2B the delivery addresses are the
78
+ * COMPANY's — that is how they arrive from an ERP, hung on the
79
+ * organisation with no person attached — and a buyer read by contact alone
80
+ * then signs in to "no address available" while the merchant is looking at
81
+ * four of them in the Cockpit. Nobody can order, and nothing in the shop
82
+ * explains why.
83
+ *
84
+ * Two calls rather than one because the list filter is an AND: there is no
85
+ * way to ask for "mine or my company's" in a single query. They are
86
+ * merged by id, personal first, so a buyer's own entry stays the one a
87
+ * checkout adopts when neither is marked default.
88
+ */
72
89
  async list(event: H3Event): Promise<AccountAddress[]> {
73
- const { contact_id } = this.contactRef(event);
74
- if (!contact_id) {
90
+ const { contact_id, organization_id } = this.contactRef(event);
91
+ if (!contact_id && !organization_id) {
75
92
  return [];
76
93
  }
77
94
  try {
78
95
  // Typed list filter (customers.addresses.list declares its query
79
96
  // params — @revenexx/sdk >= 0.0.11).
80
- const { items } = await useRevenexxSdk().customers.customersAddressesList({
81
- contactId: contact_id,
82
- limit: 200,
83
- }) as unknown as { items: ApiAddressRow[] };
84
- return items.map(toAccountAddress);
97
+ const sdk = useRevenexxSdk();
98
+ const [own, company] = await Promise.all([
99
+ contact_id
100
+ ? sdk.customers.customersAddressesList({ contactId: contact_id, limit: 200 }) as unknown as Promise<{ items: ApiAddressRow[] }>
101
+ : Promise.resolve({ items: [] as ApiAddressRow[] }),
102
+ organization_id
103
+ ? sdk.customers.customersAddressesList({ organizationId: organization_id, limit: 200 }) as unknown as Promise<{ items: ApiAddressRow[] }>
104
+ : Promise.resolve({ items: [] as ApiAddressRow[] }),
105
+ ]);
106
+ const seen = new Set<string>();
107
+ return [...(own.items ?? []), ...(company.items ?? [])]
108
+ .filter((row) => {
109
+ if (seen.has(row.id)) {
110
+ return false;
111
+ }
112
+ seen.add(row.id);
113
+ return true;
114
+ })
115
+ .map(toAccountAddress);
85
116
  }
86
117
  catch (err) {
87
118
  getLogService().error("API request failed: addresses/list", apiErrorContext(err));