rerobe-js-orm 3.3.5 → 3.3.7

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.
@@ -18,7 +18,7 @@ export default class Product extends Base {
18
18
  autoCreateDescriptionHTML(t?: (text: string) => string, additionalSections?: {
19
19
  title: string;
20
20
  attributes: string[];
21
- }[]): string;
21
+ }[], currency?: string, locale?: string): string;
22
22
  autoCreateMetaDescription(): string;
23
23
  generateSchemaForTypesense(name?: string): {
24
24
  default_sorting_field: string;
@@ -454,10 +454,10 @@ class Product extends Base_1.default {
454
454
  }
455
455
  return this.utilities.capitalizeString(result).trim();
456
456
  }
457
- autoCreateDescriptionHTML(t = (str) => str, additionalSections = []) {
457
+ autoCreateDescriptionHTML(t = (str) => str, additionalSections = [], currency = 'SEK', locale = 'sv-SE') {
458
458
  var _a;
459
459
  const { compareAtPrice } = this.attributes;
460
- const { color, productCategory, productType, productStyle, condition, size, gender } = this.filterAttributes;
460
+ const { color, productCategory, productType, productStyle, condition, gender } = this.filterAttributes;
461
461
  const { productRemarks, conditionRemarks, purchasePrice, yearPurchased, sizeComment, majorDefects, minorDefects } = this.consignmentAttributes;
462
462
  const measurements = this.measurementsJoinedString(this.filterAttributes.measurements);
463
463
  const materials = this.materialCompJoinedString();
@@ -465,15 +465,25 @@ class Product extends Base_1.default {
465
465
  const joinedProductStyle = productStyle.join(', ');
466
466
  const joinedMajorDefects = majorDefects.join(', ');
467
467
  const joinedMinorDefects = minorDefects.join(', ');
468
+ const numberFormatter = new Intl.NumberFormat(locale, {
469
+ style: 'currency',
470
+ currency,
471
+ });
472
+ const formatCurrency = (value) => {
473
+ if (value === undefined)
474
+ return '';
475
+ // Parse the string as a float and format it as currency
476
+ const num = parseFloat(value);
477
+ return isNaN(num) ? value : numberFormatter.format(num);
478
+ };
468
479
  // Group the base attributes
469
480
  const baseAttributeSections = [
470
481
  {
471
482
  title: 'Product Details',
472
483
  attributes: [
484
+ gender && `${t('Primary segment')}: ${t(gender)}`,
473
485
  productCategory && `${t('Category')}: ${t(productCategory)}`,
474
486
  productType && `${t('Type')}: ${t(productType)}`,
475
- size && `${t('Size')}: ${t(size)}`,
476
- gender && `${t('Gender')}: ${t(gender)}`,
477
487
  ].filter(Boolean),
478
488
  },
479
489
  {
@@ -494,10 +504,10 @@ class Product extends Base_1.default {
494
504
  ].filter(Boolean),
495
505
  },
496
506
  {
497
- title: 'Purchase Details',
507
+ title: 'Extra Details',
498
508
  attributes: [
499
- compareAtPrice && `${t('Original price')}: ${t(purchasePrice)}`,
500
- purchasePrice && `${t('Purchase price')}: ${t(purchasePrice)}`,
509
+ compareAtPrice && `${t('Price new')}: ${t(formatCurrency(compareAtPrice))}`,
510
+ purchasePrice && `${t('Purchase price')}: ${t(formatCurrency(purchasePrice))}`,
501
511
  yearPurchased && `${t('Year purchased')}: ${t(yearPurchased)}`,
502
512
  ].filter(Boolean),
503
513
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.3.5",
3
+ "version": "3.3.7",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",