@propeller-commerce/propeller-v2-react-ui 0.4.23 → 0.4.25

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/dist/pure.d.cts CHANGED
@@ -315,6 +315,19 @@ interface OrderSummaryProps {
315
315
  formatDate?: (dateString: string) => string;
316
316
  /** Labels for the component */
317
317
  labels?: Record<string, string>;
318
+ /**
319
+ * Localized order/quote status labels, keyed by the raw backend status
320
+ * (e.g. `{ NEW: 'Nieuw', REQUEST: 'Aangevraagd' }`). Unknown → raw value.
321
+ */
322
+ statusLabels?: Record<string, string>;
323
+ /**
324
+ * Localized payment-method names, keyed by the raw method value LOWER-CASED
325
+ * (e.g. `{ rekening: 'Op rekening', account: 'Op rekening' }`). The backend
326
+ * sends different raw values on the order vs quote path (REKENING / ACCOUNT),
327
+ * so mapping both here makes the same method render identically. Unknown →
328
+ * raw value.
329
+ */
330
+ paymethodLabels?: Record<string, string>;
318
331
  /** List of countries for resolving codes to names [{code: 'NL', name: 'Netherlands'}, ...] */
319
332
  countries?: {
320
333
  code: string;
package/dist/pure.d.ts CHANGED
@@ -315,6 +315,19 @@ interface OrderSummaryProps {
315
315
  formatDate?: (dateString: string) => string;
316
316
  /** Labels for the component */
317
317
  labels?: Record<string, string>;
318
+ /**
319
+ * Localized order/quote status labels, keyed by the raw backend status
320
+ * (e.g. `{ NEW: 'Nieuw', REQUEST: 'Aangevraagd' }`). Unknown → raw value.
321
+ */
322
+ statusLabels?: Record<string, string>;
323
+ /**
324
+ * Localized payment-method names, keyed by the raw method value LOWER-CASED
325
+ * (e.g. `{ rekening: 'Op rekening', account: 'Op rekening' }`). The backend
326
+ * sends different raw values on the order vs quote path (REKENING / ACCOUNT),
327
+ * so mapping both here makes the same method render identically. Unknown →
328
+ * raw value.
329
+ */
330
+ paymethodLabels?: Record<string, string>;
318
331
  /** List of countries for resolving codes to names [{code: 'NL', name: 'Netherlands'}, ...] */
319
332
  countries?: {
320
333
  code: string;
package/dist/pure.js CHANGED
@@ -411,11 +411,13 @@ function OrderSummary(props) {
411
411
  const showRemarks = props.showRemarks !== void 0 ? props.showRemarks : true;
412
412
  const orderNumber = order?.id || "";
413
413
  const orderDate = order?.createdAt || "";
414
- const orderStatus = order?.status || "";
414
+ const rawStatus = order?.status || "";
415
+ const orderStatus = rawStatus ? props.statusLabels?.[rawStatus] || rawStatus : "";
415
416
  const orderTotal = Number(order?.total?.net || 0);
416
417
  const orderReference = order?.reference || "";
417
418
  const orderRemarks = order?.remarks || "";
418
- const paymentMethod = order?.paymentData?.method || "";
419
+ const rawPaymentMethod = order?.paymentData?.method || "";
420
+ const paymentMethod = rawPaymentMethod ? props.paymethodLabels?.[rawPaymentMethod.toLowerCase()] || rawPaymentMethod : "";
419
421
  const carrierName = order?.postageData?.carrier || "";
420
422
  const addresses = order?.addresses || [];
421
423
  const invoiceAddress = addresses.find((a) => a.type === "invoice") || null;
@@ -426,15 +428,18 @@ function OrderSummary(props) {
426
428
  }
427
429
  return formatPrice(price || 0, { symbol: props.currency ?? "\u20AC" });
428
430
  }
431
+ function numericDate(dateString) {
432
+ const d = new Date(dateString);
433
+ if (isNaN(d.getTime())) return dateString;
434
+ const day = String(d.getDate()).padStart(2, "0");
435
+ const month = String(d.getMonth() + 1).padStart(2, "0");
436
+ return `${day}-${month}-${d.getFullYear()}`;
437
+ }
429
438
  function formatOrderDate(dateString) {
430
439
  if (props.formatDate) {
431
440
  return props.formatDate(dateString);
432
441
  }
433
- try {
434
- return new Date(dateString).toLocaleDateString("en-US");
435
- } catch {
436
- return dateString;
437
- }
442
+ return numericDate(dateString);
438
443
  }
439
444
  const requestDateRaw = order?.postageData?.requestDate;
440
445
  let requestDate = "";
@@ -442,11 +447,7 @@ function OrderSummary(props) {
442
447
  if (props.formatDate) {
443
448
  requestDate = props.formatDate(requestDateRaw);
444
449
  } else {
445
- try {
446
- requestDate = new Date(requestDateRaw).toLocaleDateString("en-US");
447
- } catch {
448
- requestDate = requestDateRaw;
449
- }
450
+ requestDate = numericDate(requestDateRaw);
450
451
  }
451
452
  }
452
453
  const getCountryName$1 = (code) => getCountryName(code, props.countries);