@thefittingroom/shop-ui 1.1.5 → 1.1.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.
@@ -1,4 +1,3 @@
1
- import { TfrShop } from '@thefittingroom/sdk';
2
1
  export type RecommendedSize = {
3
2
  recommended: string;
4
3
  sizes: {
@@ -10,10 +9,11 @@ export type RecommendedSize = {
10
9
  }[];
11
10
  };
12
11
  export declare class SizeRecComponent {
13
- private readonly tfrShop;
14
12
  private readonly onSignInClick;
15
13
  private readonly onSignOutClick;
16
14
  private _sku;
15
+ private tfrSizeRecTitle;
16
+ private tfrSizeRecSubtitle;
17
17
  private tfrSizeRecActionLogin;
18
18
  private tfrSizeRecActionLogout;
19
19
  private tfrSizeRecLoading;
@@ -23,7 +23,7 @@ export declare class SizeRecComponent {
23
23
  private tfrSizeRecSize;
24
24
  private tfrSizeRecTable;
25
25
  private redraw;
26
- constructor(sizeRecMainDivId: string, tfrShop: TfrShop, onSignInClick: () => void, onSignOutClick: () => void);
26
+ constructor(sizeRecMainDivId: string, onSignInClick: () => void, onSignOutClick: () => void);
27
27
  get sku(): string;
28
28
  setSku(sku: string): void;
29
29
  setIsLoggedIn(isLoggedIn: boolean): void;
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * thefittingroom v1.1.5 (2024-04-05T19:10:10.348Z)
2
+ * thefittingroom v1.1.7 (2024-05-16T02:29:04.341Z)
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.1.0 (2024-02-16T20:34:26.286Z)
50
+ * thefittingroom v1.1.5 (2024-05-16T02:24:56.143Z)
51
51
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
52
52
  */
53
53
 
@@ -23362,7 +23362,8 @@ class TfrShop {
23362
23362
  var _a;
23363
23363
  const asset = await this.getColorwaySizeAssetFromSku(sku);
23364
23364
  const styleCategory = await this.getStyleCategory(asset.style_id);
23365
- const classificationLocation = ((_a = Taxonomy[styleCategory.category]) === null || _a === void 0 ? void 0 : _a[styleCategory.sub_category]) || null;
23365
+ const taxonomy = await this.getGetTaxonomy(styleCategory.style_garment_category_id);
23366
+ const classificationLocation = ((_a = Taxonomy[taxonomy.style_category]) === null || _a === void 0 ? void 0 : _a[taxonomy.garment_category]) || null;
23366
23367
  return classificationLocation
23367
23368
  ? ClassificationLocations[classificationLocation].map((location) => MeasurementLocationName[location])
23368
23369
  : null;
@@ -23388,7 +23389,16 @@ class TfrShop {
23388
23389
  }
23389
23390
  async getStyleCategory(styleId) {
23390
23391
  try {
23391
- const doc = await this.firebase.getDoc('style_categories', String(styleId));
23392
+ const doc = await this.firebase.getDoc('styles', String(styleId));
23393
+ return doc;
23394
+ }
23395
+ catch (error) {
23396
+ return getFirebaseError(error);
23397
+ }
23398
+ }
23399
+ async getGetTaxonomy(styleId) {
23400
+ try {
23401
+ const doc = await this.firebase.getDoc('style_garment_categories', String(styleId));
23392
23402
  return doc;
23393
23403
  }
23394
23404
  catch (error) {
@@ -23494,7 +23504,7 @@ n(css$5,{});
23494
23504
  var css$4 = "@media screen and (max-width:702px){.tfr-modal-title-logo-container{display:flex;flex-direction:column}}@media screen and (min-width:600px){.tfr-modal-content-container{border-radius:10px;height:auto}}@media screen and (max-width:599px){.tfr-mobile-hidden{display:none}.tfr-modal-content-container{min-height:100vh}.trf-logo-title{margin-bottom:10px}.tfr-modal-content-flex{height:calc(100vh - 76px)}}@media screen and (max-width:500px){.tfr-fieldset{width:90%}.tfr-how-it-works-item{flex-direction:column}.tfr-try-on-content{margin-left:0;margin-top:20px}}";
23495
23505
  n(css$4,{});
23496
23506
 
23497
- var css$3 = "#tfr-size-recommendations{border:1px solid hsla(0,0%,7%,.55);color:#121212;display:flex;padding:14px 20px;width:440px}#tfr-size-recommendations,#tfr-size-recommendations-container{align-items:center;flex-direction:column;justify-content:center}#tfr-size-recommendations-container{display:none;width:100%}#tfr-size-rec-login-svg{display:none}#tfr-size-rec-title{align-items:center;display:flex;margin-bottom:8px}#tfr-size-rec-subtitle{margin-bottom:6px}#tfr-size-rec-subtitle,#tfr-size-rec-title{font-size:16px;font-weight:700}#tfr-size-rec-table{display:flex;flex-direction:column;font-size:12px;width:100%}.tfr-size-rec-table-row:first-of-type{border-top-width:2px}.tfr-size-rec-table-row{align-items:center;border-top:1px solid hsla(0,0%,7%,.55);display:flex;height:40px;justify-content:center}.tfr-size-rec-table-cell-left,.tfr-size-rec-table-cell-right{flex:1 1 0px}.tfr-size-rec-table-cell-left{font-weight:700;margin-right:70px;text-align:right}.tfr-size-rec-table-cell-right{margin-left:16px}.tfr-size-rec-table-cell-right.perfect{color:#209da7}#tfr-size-rec-size>.tfr-size-rec-login-cta{font-weight:500;margin-left:10px}.tfr-size-rec-login-cta,.tfr-size-rec-table-cell-right{font-size:12px}.tfr-size-rec-login-cta{color:#a7a7a7;display:flex}#tfr-size-rec-action-login,#tfr-size-rec-action-logout{display:none}#tfr-size-rec-action{cursor:pointer;font-size:16px;margin-top:14px;text-decoration:underline}#tfr-size-rec-select{background-color:#878787;border-radius:8px;box-shadow:0 4px 4px 0 rgba(0,0,0,.3);color:#fff;display:none;font-size:14px;margin-bottom:20px;margin-top:10px}#tfr-size-rec-select,.tfr-size-rec-select-button{align-items:center;height:35px;justify-content:center}.tfr-size-rec-select-button{cursor:pointer;display:flex;transition:all .15s ease-in;width:80px}.tfr-size-rec-select-button:hover:not(.active){background-color:hsla(0,0%,100%,.3);opacity:.7}.tfr-size-rec-select-button.active{background-color:#212121;height:45px}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:first-of-type{border-bottom-left-radius:8px;border-top-left-radius:8px}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:last-of-type{border-bottom-right-radius:8px;border-top-right-radius:8px}.tfr-powered-by{align-items:center;display:flex;font-size:10px;margin-top:10px}.tfr-powered-by-logo{margin:0 4px}.tfr-powered-by-logo,.tfr-powered-by-logo img{height:24px}.tfr-powered-by-text-bold{font-weight:700}";
23507
+ var css$3 = "#tfr-size-recommendations{border:1px solid hsla(0,0%,7%,.55);color:#121212;display:flex;padding:14px 20px;width:440px}#tfr-size-recommendations,#tfr-size-recommendations-container{align-items:center;flex-direction:column;justify-content:center}#tfr-size-recommendations-container{display:none;width:100%}#tfr-size-rec-login-svg{display:none}#tfr-size-rec-title{align-items:center;display:flex;margin-bottom:8px}#tfr-size-rec-subtitle{margin-bottom:6px}#tfr-size-rec-subtitle,#tfr-size-rec-title{font-size:16px;font-weight:700}#tfr-size-rec-table{display:flex;flex-direction:column;font-size:12px;width:100%}.tfr-size-rec-table-row:first-of-type{border-top-width:2px}.tfr-size-rec-table-row{align-items:center;border-top:1px solid hsla(0,0%,7%,.55);display:flex;height:40px;justify-content:center}.tfr-size-rec-table-cell-left,.tfr-size-rec-table-cell-right{flex:1 1 0px}.tfr-size-rec-table-cell-left{font-weight:700;margin-right:70px;text-align:right}.tfr-size-rec-table-cell-right{margin-left:16px}.tfr-size-rec-table-cell-right.perfect{color:#209da7}#tfr-size-rec-size>.tfr-size-rec-login-cta{font-weight:500;margin-left:10px}.tfr-size-rec-login-cta,.tfr-size-rec-table-cell-right{font-size:12px}.tfr-size-rec-login-cta{color:#a7a7a7;display:flex}#tfr-size-rec-action-login,#tfr-size-rec-action-logout{display:none}#tfr-size-rec-action{cursor:pointer;font-size:16px;margin-top:14px;text-decoration:underline}#tfr-size-rec-select{background-color:#878787;border-radius:8px;box-shadow:0 4px 4px 0 rgba(0,0,0,.3);color:#fff;display:none;font-size:14px;margin-bottom:20px;margin-top:10px}#tfr-size-rec-select,.tfr-size-rec-select-button{align-items:center;height:35px;justify-content:center}.tfr-size-rec-select-button{cursor:pointer;display:flex;transition:all .15s ease-in;width:80px}.tfr-size-rec-select-button:hover:not(.active){background-color:hsla(0,0%,100%,.3);opacity:.7}.tfr-size-rec-select-button.active{background-color:#212121;height:45px}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:first-of-type{border-bottom-left-radius:8px;border-top-left-radius:8px}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:last-of-type{border-bottom-right-radius:8px;border-top-right-radius:8px}.tfr-powered-by{align-items:center;display:flex;font-size:10px;margin-top:10px}.tfr-powered-by-logo{margin:0 4px}.tfr-powered-by-logo,.tfr-powered-by-logo img{height:24px}.tfr-powered-by-text-bold{font-weight:700}#tfr-size-recommendation-error{color:#8d0000;display:none}";
23498
23508
  n(css$3,{});
23499
23509
 
23500
23510
  var css$2 = ".tfr-mt-10{margin-top:10px}.tfr-mt-20{margin-top:20px}.tfr-mt-15{margin-top:15px}.tfr-mt-30{margin-top:30px}.mt-40{margin-top:40px}.tfr-mb-40{margin-bottom:40px}.tfr-mb-20{margin-bottom:20px}.tfr-mr-10{margin-right:10px}.tfr-mr-15{margin-right:15px}.tfr-mt-50{margin-top:50px}.tfr-mt-60{margin-top:60px}.tfr-mb-60{margin-bottom:60px}.tfr-mr-20{margin-right:20px}.tfr-mt-15-p{margin-top:15%}.tfr-mb-13-p{margin-bottom:13%}.tfr-m-h-auto{margin-left:auto;margin-right:auto}.tfr-pt-20{padding-top:20px}.tfr-pb-50{padding-bottom:50px}.tfr-p-20{padding:20px}.tfr-pr-20{padding-right:20px}.tfr-pl-20{padding-left:20px}.tfr-pb-7-p{padding-bottom:7%}";
@@ -36425,8 +36435,7 @@ class TfrModal {
36425
36435
  const loginIconSrc = 'https://assets.dev.thefittingroom.xyz/shop-sdk/assets/login-icon.svg';
36426
36436
  const doorLogoSrc = 'https://assets.dev.thefittingroom.xyz/shop-sdk/assets/tfr-door-brand.svg';
36427
36437
  class SizeRecComponent {
36428
- constructor(sizeRecMainDivId, tfrShop, onSignInClick, onSignOutClick) {
36429
- this.tfrShop = tfrShop;
36438
+ constructor(sizeRecMainDivId, onSignInClick, onSignOutClick) {
36430
36439
  this.onSignInClick = onSignInClick;
36431
36440
  this.onSignOutClick = onSignOutClick;
36432
36441
  this._sku = '';
@@ -36468,6 +36477,9 @@ class SizeRecComponent {
36468
36477
  this.tfrSizeRecSelect.style.display = 'flex';
36469
36478
  }
36470
36479
  setError(error) {
36480
+ this.tfrSizeRecTitle.style.display = 'none';
36481
+ this.tfrSizeRecSubtitle.style.display = 'none';
36482
+ this.tfrSizeRecommendationError.style.display = 'block';
36471
36483
  this.tfrSizeRecommendationError.innerHTML = error;
36472
36484
  }
36473
36485
  init(sizeRecMainDivId) {
@@ -36479,6 +36491,8 @@ class SizeRecComponent {
36479
36491
  this.bindEvents();
36480
36492
  }
36481
36493
  setElements() {
36494
+ this.tfrSizeRecTitle = document.getElementById('tfr-size-rec-title');
36495
+ this.tfrSizeRecSubtitle = document.getElementById('tfr-size-rec-subtitle');
36482
36496
  this.tfrSizeRecActionLogin = document.getElementById('tfr-size-rec-action-login');
36483
36497
  this.tfrSizeRecActionLogout = document.getElementById('tfr-size-rec-action-logout');
36484
36498
  this.tfrSizeRecTable = document.getElementById('tfr-size-rec-table');
@@ -36558,12 +36572,12 @@ class SizeRecComponent {
36558
36572
  </div>
36559
36573
  </div>
36560
36574
  <div id="tfr-size-recommendations-container">
36561
- <img id="tfr-size-rec-login-svg" src="{{ 'login-icon.svg' | asset_url }}" />
36575
+ <img id="tfr-size-rec-login-svg" src="${loginIconSrc}" />
36562
36576
  <div id="tfr-size-rec-title">
36563
36577
  Recommended Size:
36564
36578
  <div id="tfr-size-rec-size">
36565
36579
  <div class="tfr-size-rec-login-cta">
36566
- <img src="{{ 'login-icon.svg' | asset_url }}" /> Login to view
36580
+ <img src="${loginIconSrc}" /> Login to view
36567
36581
  </div>
36568
36582
  </div>
36569
36583
  </div>
@@ -36585,7 +36599,8 @@ class SizeRecComponent {
36585
36599
  <div class="tfr-powered-by-text-bold">The Fitting Room</div>
36586
36600
  </div>
36587
36601
  </div>
36588
- </div>`;
36602
+ </div>
36603
+ <div id="tfr-size-recommendation-error"></div>`;
36589
36604
  sizeRecMainDiv.innerHTML = body;
36590
36605
  }
36591
36606
  }
@@ -36595,7 +36610,7 @@ class TfrSizeRec {
36595
36610
  this.tfrShop = tfrShop;
36596
36611
  this.onSignInClick = onSignInClick;
36597
36612
  this.onSignOutClick = onSignOutClick;
36598
- this.sizeRecComponent = new SizeRecComponent(sizeRecMainDivId, this.tfrShop, this.onSignInClick, this.onSignOutClick);
36613
+ this.sizeRecComponent = new SizeRecComponent(sizeRecMainDivId, this.onSignInClick, this.onSignOutClick);
36599
36614
  }
36600
36615
  get sku() {
36601
36616
  return this.sizeRecComponent.sku;
@@ -36610,15 +36625,18 @@ class TfrSizeRec {
36610
36625
  this.sizeRecComponent.setLoading(true);
36611
36626
  const locations = await this.getGarmentLocations();
36612
36627
  if (!locations)
36613
- return;
36628
+ return this.sizeRecComponent.setLoading(false);
36614
36629
  this.sizeRecComponent.setGarmentLocations(locations);
36615
36630
  this.sizeRecComponent.setLoading(false);
36616
36631
  }
36617
36632
  async setRecommendedSize() {
36618
36633
  this.sizeRecComponent.setLoading(true);
36619
36634
  const sizes = await this.getRecommenedSize();
36620
- if (!sizes)
36635
+ if (!sizes) {
36636
+ this.sizeRecComponent.setLoading(false);
36637
+ this.sizeRecComponent.setError('No recommended size found.');
36621
36638
  return;
36639
+ }
36622
36640
  this.sizeRecComponent.setRecommendedSize(sizes);
36623
36641
  this.sizeRecComponent.setLoading(false);
36624
36642
  }
@@ -36628,7 +36646,7 @@ class TfrSizeRec {
36628
36646
  return locations;
36629
36647
  }
36630
36648
  catch (error) {
36631
- this.sizeRecComponent.setError(error.message);
36649
+ this.sizeRecComponent.setError(error.message || error.error);
36632
36650
  return null;
36633
36651
  }
36634
36652
  }
@@ -36639,7 +36657,7 @@ class TfrSizeRec {
36639
36657
  return sizes;
36640
36658
  }
36641
36659
  catch (error) {
36642
- this.sizeRecComponent.setError(error.message);
36660
+ this.sizeRecComponent.setError(error.message || error.error);
36643
36661
  return null;
36644
36662
  }
36645
36663
  }