@thefittingroom/shop-ui 1.4.40 → 1.5.0

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/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * thefittingroom v1.4.40 (2024-08-29T22:15:34.046Z)
2
+ * thefittingroom v1.5.0 (2024-09-01T16:53:36.094Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
5
  function loadImageRecursive(imageURL, imageURLs) {
@@ -47,7 +47,7 @@ const InitImageSlider = (sliderID, onChange) => {
47
47
  };
48
48
 
49
49
  /*!
50
- * thefittingroom v1.4.3 (2024-08-27T23:39:34.070Z)
50
+ * thefittingroom v1.5.0 (2024-09-01T16:52:25.366Z)
51
51
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
52
52
  */
53
53
 
@@ -25459,9 +25459,14 @@ class TfrShop {
25459
25459
  const filteredLocations = !filledLocations.length
25460
25460
  ? taxonomy.measurement_locations.female
25461
25461
  : taxonomy.measurement_locations.female.filter((location) => filledLocations.includes(location));
25462
- return filteredLocations.map((location) => {
25463
- return this.measurementLocations.has(location) ? this.measurementLocations.get(location) : location;
25462
+ const locationsWithSortOrder = filteredLocations.map((location) => {
25463
+ return this.measurementLocations.has(location)
25464
+ ? this.measurementLocations.get(location)
25465
+ : { name: location, sort_order: Infinity };
25464
25466
  });
25467
+ return locationsWithSortOrder
25468
+ .sort((a, b) => (a.sort_order < b.sort_order ? -1 : 0))
25469
+ .map((location) => location.name);
25465
25470
  }
25466
25471
  async getMeasurementLocationsFromBrandStyleId(brandStyleId, filledLocations = []) {
25467
25472
  const asset = await this.getColorwaySizeAssetFromBrandStyleId(brandStyleId);
@@ -25476,9 +25481,14 @@ class TfrShop {
25476
25481
  const filteredLocations = !filledLocations.length
25477
25482
  ? taxonomy.measurement_locations.female
25478
25483
  : taxonomy.measurement_locations.female.filter((location) => filledLocations.includes(location));
25479
- return filteredLocations.map((location) => {
25480
- return this.measurementLocations.has(location) ? this.measurementLocations.get(location) : location;
25484
+ const locationsWithSortOrder = filteredLocations.map((location) => {
25485
+ return this.measurementLocations.has(location)
25486
+ ? this.measurementLocations.get(location)
25487
+ : { name: location, sort_order: Infinity };
25481
25488
  });
25489
+ return locationsWithSortOrder
25490
+ .sort((a, b) => (a.sort_order < b.sort_order ? -1 : 0))
25491
+ .map((location) => location.name);
25482
25492
  }
25483
25493
  async getStyleByBrandStyleId(brandStyleId) {
25484
25494
  var _a, _b;
@@ -25521,7 +25531,10 @@ class TfrShop {
25521
25531
  }
25522
25532
  }
25523
25533
  getMeasurementLocationName(location) {
25524
- return this.measurementLocations.has(location) ? this.measurementLocations.get(location) : location;
25534
+ return this.measurementLocations.has(location) ? this.measurementLocations.get(location).name : location;
25535
+ }
25536
+ getMeasurementLocationSortOrder(location) {
25537
+ return this.measurementLocations.has(location) ? this.measurementLocations.get(location).sort_order : Infinity;
25525
25538
  }
25526
25539
  async getGetTaxonomy(styleId) {
25527
25540
  try {
@@ -25535,7 +25548,7 @@ class TfrShop {
25535
25548
  async getMeasurementLocations() {
25536
25549
  const locations = await this.fetchMeasurementLocations();
25537
25550
  locations.forEach((location) => {
25538
- this.measurementLocations.set(location.name, location.garment_label);
25551
+ this.measurementLocations.set(location.name, { name: location.garment_label, sort_order: location.sort_order });
25539
25552
  });
25540
25553
  }
25541
25554
  async fetchMeasurementLocations() {
@@ -26930,13 +26943,16 @@ class TfrSizeRec {
26930
26943
  sizes: sizeRec.fits.map((fit) => {
26931
26944
  return {
26932
26945
  size: sizeRec.available_sizes.find((size) => size.id === fit.size_id).label,
26933
- locations: fit.measurement_location_fits.map((locationFit) => {
26946
+ locations: fit.measurement_location_fits
26947
+ .map((locationFit) => {
26934
26948
  return {
26935
26949
  fit: index.FitNames[locationFit.fit],
26936
26950
  isPerfect: this.perfectFits.includes(locationFit.fit),
26937
26951
  location: this.tfrShop.getMeasurementLocationName(locationFit.measurement_location),
26952
+ sortOrder: this.tfrShop.getMeasurementLocationSortOrder(locationFit.measurement_location),
26938
26953
  };
26939
- }),
26954
+ })
26955
+ .sort((a, b) => (a.sortOrder < b.sortOrder ? -1 : 1)),
26940
26956
  };
26941
26957
  }),
26942
26958
  };