@thefittingroom/shop-ui 5.0.10 → 5.0.11

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.
Files changed (2) hide show
  1. package/dist/index.js +82 -71
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -41951,8 +41951,7 @@ function VtoSingleOverlay() {
41951
41951
  logger$2.timerStart("fetchInitialData_2_getStyleData");
41952
41952
  const styleRec = await getStyleByExternalId(brandId, currentProduct.externalId);
41953
41953
  if (!styleRec) {
41954
- logger$2.logError(`Style not found for externalId: ${currentProduct.externalId}`);
41955
- return;
41954
+ throw new Error(`Style not found for externalId: ${currentProduct.externalId}`);
41956
41955
  }
41957
41956
  const styleGarmentCategoryRec = await getStyleGarmentCategoryById(styleRec.style_garment_category_id);
41958
41957
  const styleCategoryLabel = styleGarmentCategoryRec?.style_category_label ?? null;
@@ -41964,77 +41963,84 @@ function VtoSingleOverlay() {
41964
41963
  {
41965
41964
  const recommendedSizeId = sizeRecommendationRecord.recommended_size.id || null;
41966
41965
  const recommendedSizeLabel = getSizeLabelFromSize(sizeRecommendationRecord.recommended_size);
41967
- if (recommendedSizeId != null && recommendedSizeLabel != null) {
41968
- let productData;
41969
- {
41970
- const fitClassification = sizeRecommendationRecord.fit_classification;
41971
- const sizes = [];
41972
- for (const sizeRec of sizeRecommendationRecord.available_sizes) {
41973
- const sizeId = sizeRec.id;
41974
- const sizeLabel = getSizeLabelFromSize(sizeRec) || null;
41975
- if (!sizeLabel) {
41976
- continue;
41977
- }
41978
- const isRecommended = sizeRec.id === recommendedSizeId;
41979
- const fit = sizeRecommendationRecord.fits.find((f) => f.size_id === sizeRec.id);
41980
- if (!fit) {
41966
+ if (recommendedSizeId == null || recommendedSizeLabel == null) {
41967
+ throw new Error(`No recommended size found for externalId: ${currentProduct.externalId}`);
41968
+ }
41969
+ let productData;
41970
+ {
41971
+ const fitClassification = sizeRecommendationRecord.fit_classification;
41972
+ const sizes = [];
41973
+ for (const sizeRec of sizeRecommendationRecord.available_sizes) {
41974
+ const sizeId = sizeRec.id;
41975
+ const sizeLabel = getSizeLabelFromSize(sizeRec) || null;
41976
+ if (!sizeLabel) {
41977
+ continue;
41978
+ }
41979
+ const isRecommended = sizeRec.id === recommendedSizeId;
41980
+ const fit = sizeRecommendationRecord.fits.find((f) => f.size_id === sizeRec.id);
41981
+ if (!fit) {
41982
+ continue;
41983
+ }
41984
+ const colors = [];
41985
+ for (const csaRec of sizeRec.colorway_size_assets) {
41986
+ const colorwaySizeAssetId = csaRec.id;
41987
+ const sku = csaRec.sku;
41988
+ const variant = variants.find((v) => v.sku === sku);
41989
+ if (!variant) {
41990
+ logger$2.logWarn(`Variant not found for externalId: ${currentProduct.externalId} sizeId: ${sizeId} sku: ${sku}`);
41981
41991
  continue;
41982
41992
  }
41983
- const colors = [];
41984
- for (const csaRec of sizeRec.colorway_size_assets) {
41985
- const colorwaySizeAssetId = csaRec.id;
41986
- const sku = csaRec.sku;
41987
- const variant = variants.find((v) => v.sku === sku);
41988
- if (!variant) {
41989
- continue;
41990
- }
41991
- const colorLabel = variant.color || null;
41992
- if (!colorLabel) {
41993
- continue;
41994
- }
41995
- const priceFormatted = variant.priceFormatted;
41996
- colors.push({
41997
- colorwaySizeAssetId,
41998
- colorLabel,
41999
- sku,
42000
- priceFormatted
42001
- });
42002
- }
42003
- sizes.push({
42004
- sizeId,
42005
- sizeLabel,
42006
- isRecommended,
42007
- fit,
42008
- colors
41993
+ const colorLabel = variant.color || null;
41994
+ const priceFormatted = variant.priceFormatted;
41995
+ colors.push({
41996
+ colorwaySizeAssetId,
41997
+ colorLabel,
41998
+ sku,
41999
+ priceFormatted
42009
42000
  });
42010
42001
  }
42011
- productData = {
42012
- productName,
42013
- productDescriptionHtml,
42014
- fitClassification,
42015
- recommendedSizeId,
42016
- recommendedSizeLabel,
42017
- sizes,
42018
- styleCategoryLabel
42019
- };
42020
- }
42021
- let recommendedColorLabel;
42022
- {
42023
- const recommendedSizeRecord = productData.sizes.find((s) => s.isRecommended);
42024
- if (!recommendedSizeRecord) {
42025
- throw new Error("Recommended size record not found");
42002
+ if (!colors.length) {
42003
+ logger$2.logWarn(`No valid colorways found for externalId: ${currentProduct.externalId} sizeId: ${sizeId}`);
42004
+ continue;
42026
42005
  }
42027
- const recommendedSizeColorRecord = recommendedSizeRecord.colors.find((c) => {
42028
- return c.colorLabel === selectedColor;
42029
- }) || recommendedSizeRecord.colors[0];
42030
- recommendedColorLabel = recommendedSizeColorRecord.colorLabel;
42006
+ sizes.push({
42007
+ sizeId,
42008
+ sizeLabel,
42009
+ isRecommended,
42010
+ fit,
42011
+ colors
42012
+ });
42031
42013
  }
42032
- setLoadedProductData(productData);
42033
- setSelectedSizeLabel(recommendedSizeLabel);
42034
- setSelectedColorLabel(recommendedColorLabel);
42035
- } else {
42036
- setLoadedProductData(false);
42014
+ if (!sizes.length) {
42015
+ throw new Error(`No valid sizes found for externalId: ${currentProduct.externalId}`);
42016
+ }
42017
+ productData = {
42018
+ productName,
42019
+ productDescriptionHtml,
42020
+ fitClassification,
42021
+ recommendedSizeId,
42022
+ recommendedSizeLabel,
42023
+ sizes,
42024
+ styleCategoryLabel
42025
+ };
42026
+ }
42027
+ let recommendedColorLabel = null;
42028
+ {
42029
+ const recommendedSizeRecord = productData.sizes.find((s) => s.isRecommended);
42030
+ if (!recommendedSizeRecord) {
42031
+ throw new Error("Recommended size record not found");
42032
+ }
42033
+ if (!recommendedSizeRecord.colors.length) {
42034
+ throw new Error("No colorways found for recommended size record");
42035
+ }
42036
+ const recommendedSizeColorRecord = recommendedSizeRecord.colors.find((c) => {
42037
+ return c.colorLabel === selectedColor;
42038
+ }) || recommendedSizeRecord.colors[0];
42039
+ recommendedColorLabel = recommendedSizeColorRecord?.colorLabel ?? null;
42037
42040
  }
42041
+ setLoadedProductData(productData);
42042
+ setSelectedSizeLabel(recommendedSizeLabel);
42043
+ setSelectedColorLabel(recommendedColorLabel);
42038
42044
  }
42039
42045
  for (const sku in userProfile?.vto?.[brandId] ?? {}) {
42040
42046
  fetchedVtoSkus.current.add(sku);
@@ -42047,6 +42053,9 @@ function VtoSingleOverlay() {
42047
42053
  logger$2.logError("Error fetching initial data:", {
42048
42054
  error
42049
42055
  });
42056
+ setLoadedProductData(false);
42057
+ setSelectedSizeLabel(null);
42058
+ setSelectedColorLabel(null);
42050
42059
  }
42051
42060
  }
42052
42061
  if (userIsLoggedIn && userHasAvatar && userProfile && loadedProductData == null) {
@@ -42071,7 +42080,7 @@ function VtoSingleOverlay() {
42071
42080
  };
42072
42081
  }
42073
42082
  const sizeColorRecord = sizeRecord.colors.find((c) => c.colorLabel === selectedColorLabel) ?? sizeRecord.colors[0];
42074
- const availableColorLabels2 = sizeRecord.colors.map((c) => c.colorLabel);
42083
+ const availableColorLabels2 = sizeRecord.colors.map((c) => c.colorLabel).filter((label) => !!label);
42075
42084
  return {
42076
42085
  sizeColorRecord,
42077
42086
  availableColorLabels: availableColorLabels2
@@ -42104,7 +42113,9 @@ function VtoSingleOverlay() {
42104
42113
  }
42105
42114
  for (const sizeRecord of loadedProductData.sizes) {
42106
42115
  const sizeColorRecord = sizeRecord.colors.find((c) => c.colorLabel === selectedColorLabel) ?? sizeRecord.colors[0];
42107
- requestVto(sizeColorRecord);
42116
+ if (sizeColorRecord) {
42117
+ requestVto(sizeColorRecord);
42118
+ }
42108
42119
  }
42109
42120
  }, [requestVto, loadedProductData, selectedColorLabel]);
42110
42121
  const vtoData = reactExports.useMemo(() => {
@@ -43435,9 +43446,9 @@ const SHARED_CONFIG = {
43435
43446
  appGooglePlayUrl: "https://play.google.com/store/apps/details?id=com.thefittingroom.marketplace"
43436
43447
  },
43437
43448
  build: {
43438
- version: `${"5.0.10"}`,
43439
- commitHash: `${"0058a65"}`,
43440
- date: `${"2026-02-01T18:44:35.278Z"}`
43449
+ version: `${"5.0.11"}`,
43450
+ commitHash: `${"77ac921"}`,
43451
+ date: `${"2026-02-02T01:20:02.888Z"}`
43441
43452
  }
43442
43453
  };
43443
43454
  const CONFIGS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thefittingroom/shop-ui",
3
- "version": "5.0.10",
3
+ "version": "5.0.11",
4
4
  "description": "the fitting room UI library",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",