basklee-react 0.9.14 → 0.9.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "basklee-react",
3
- "version": "0.9.14",
3
+ "version": "0.9.15",
4
4
  "description": "Next.js 16 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",
@@ -11,6 +11,7 @@ import type {
11
11
  } from '@/interfaces/basklee/accounts/IStorefrontProfile';
12
12
  import { featureLabels } from '@/lib/basklee/featureLabels';
13
13
  import { profileLabels } from '@/lib/basklee/profileLabels';
14
+ import { phoneForDisplay } from '@/lib/basklee/phone';
14
15
  import { ProfileAvatar } from './ProfileAvatar';
15
16
  import { ProfileDetailsForm } from './ProfileDetailsForm';
16
17
  import { ProfileEmailSettings } from './ProfileEmailSettings';
@@ -125,7 +126,7 @@ export function StorefrontProfile({
125
126
  >
126
127
  <path d="M8 3h8v18H8zM11 18h2" />
127
128
  </svg>
128
- {profile.phone}
129
+ {phoneForDisplay(profile.phone)}
129
130
  </li>
130
131
  ) : null}
131
132
  {profile?.email ? (
@@ -21,6 +21,7 @@ import {
21
21
  matchCartAddress,
22
22
  } from '@/lib/basklee/cartAddress';
23
23
  import { cartLabels } from '@/lib/basklee/cartLabels';
24
+ import { phoneForDisplay } from '@/lib/basklee/phone';
24
25
  import { featureLabels } from '@/lib/basklee/featureLabels';
25
26
  import { phoneWithCountryCode } from '@/lib/basklee/phone';
26
27
  import {
@@ -295,7 +296,7 @@ export function CartCheckoutDetails({
295
296
  <h2>{labels.recipient}</h2>
296
297
  <p className={styles.recipient}>
297
298
  {summary?.contact.receiver?.full_name || ''} ·{' '}
298
- {summary?.contact.receiver?.phone || ''}
299
+ {phoneForDisplay(summary?.contact.receiver?.phone)}
299
300
  </p>
300
301
  <div className={styles.actions}>
301
302
  <button
@@ -16,6 +16,7 @@ import type {
16
16
  import type { IProduct } from '@/interfaces/basklee/products/IProduct';
17
17
  import { formatCurrency } from '@/lib/basklee/currency';
18
18
  import { orderLabels } from '@/lib/basklee/orderLabels';
19
+ import { phoneForDisplay } from '@/lib/basklee/phone';
19
20
  import {
20
21
  hasOrderAmount,
21
22
  orderAmount,
@@ -120,7 +121,7 @@ export function OrderDetails({
120
121
  const shipments = order.delivery_froms ?? [];
121
122
  const recipient = {
122
123
  name: order.contact.reciever_name || order.contact.full_name,
123
- phone: order.contact.reciever_phone || order.contact.phone,
124
+ phone: phoneForDisplay(order.contact.reciever_phone || order.contact.phone),
124
125
  email: order.contact.email,
125
126
  };
126
127
  const method = getAvailableNestedValueFromObject(
@@ -1,3 +1,5 @@
1
+ import { parsePhoneNumberFromString } from 'libphonenumber-js';
2
+
1
3
  /**
2
4
  * A phone number typed without «+» on the Russian storefront, as people in
3
5
  * Russia usually type it: «8 900 555-01-72» (the domestic prefix 8) or
@@ -20,3 +22,19 @@ export function phoneWithCountryCode(value: string, locale: string): string {
20
22
  }
21
23
  return value;
22
24
  }
25
+
26
+ /**
27
+ * A stored phone as people read it: «+12125550161» becomes «+1 212 555 0161»,
28
+ * «+74955550162» becomes «+7 495 555 01 62». The backend keeps numbers in the
29
+ * international format without spaces; a number the library cannot read is
30
+ * shown as stored.
31
+ */
32
+ export function phoneForDisplay(value: string | null | undefined): string {
33
+ const text = (value ?? '').trim();
34
+
35
+ if (!text) {
36
+ return '';
37
+ }
38
+
39
+ return parsePhoneNumberFromString(text)?.formatInternational() ?? text;
40
+ }