@thefittingroom/shop-ui 1.0.0 → 1.1.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/components/SizeRec.d.ts +45 -0
- package/dist/esm/index.js +334 -88
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +170 -170
- package/dist/esm/init.d.ts +1 -1
- package/dist/esm/styles/index.d.ts +2 -0
- package/dist/esm/{tfr-nav.d.ts → tfr-modal.d.ts} +1 -4
- package/dist/esm/tfr-size-rec.d.ts +16 -0
- package/dist/esm/tfr.d.ts +12 -15
- package/package.json +2 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { TfrShop } from '@thefittingroom/sdk';
|
|
2
|
+
export type RecommendedSize = {
|
|
3
|
+
recommended: string;
|
|
4
|
+
sizes: {
|
|
5
|
+
size: string;
|
|
6
|
+
locations: {
|
|
7
|
+
fit: string;
|
|
8
|
+
location: string;
|
|
9
|
+
}[];
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
export declare class SizeRecComponent {
|
|
13
|
+
private readonly tfrShop;
|
|
14
|
+
private readonly onSignInClick;
|
|
15
|
+
private readonly onSignOutClick;
|
|
16
|
+
private _sku;
|
|
17
|
+
private tfrSizeRecActionLogin;
|
|
18
|
+
private tfrSizeRecActionLogout;
|
|
19
|
+
private tfrSizeRecLoading;
|
|
20
|
+
private tfrSizeRecommendationError;
|
|
21
|
+
private tfrSizeRecommendationsContainer;
|
|
22
|
+
private tfrSizeRecSelect;
|
|
23
|
+
private tfrSizeRecSize;
|
|
24
|
+
private tfrSizeRecTable;
|
|
25
|
+
private redraw;
|
|
26
|
+
constructor(sizeRecMainDivId: string, tfrShop: TfrShop, onSignInClick: () => void, onSignOutClick: () => void);
|
|
27
|
+
get sku(): string;
|
|
28
|
+
setSku(sku: string): void;
|
|
29
|
+
setIsLoggedIn(isLoggedIn: boolean): void;
|
|
30
|
+
setLoading(isLoading: boolean): void;
|
|
31
|
+
setGarmentLocations(locations: string[]): void;
|
|
32
|
+
setRecommendedSize({ recommended, sizes }: RecommendedSize): void;
|
|
33
|
+
setError(error: string): void;
|
|
34
|
+
private init;
|
|
35
|
+
private setElements;
|
|
36
|
+
private bindEvents;
|
|
37
|
+
private onSizeRecSelectClick;
|
|
38
|
+
private renderSizeRec;
|
|
39
|
+
private renderSizeRecTable;
|
|
40
|
+
private renderSizeRecSelect;
|
|
41
|
+
private renderSizeRecTableRow;
|
|
42
|
+
private renderLoginCta;
|
|
43
|
+
private renderGarmentLocations;
|
|
44
|
+
private render;
|
|
45
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* thefittingroom v1.
|
|
2
|
+
* thefittingroom v1.1.0 (2024-02-27T19:18:33.918Z)
|
|
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.0
|
|
50
|
+
* thefittingroom v1.1.0 (2024-02-16T20:34:26.286Z)
|
|
51
51
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
52
52
|
*/
|
|
53
53
|
|
|
@@ -22834,19 +22834,11 @@ class FirebaseUser {
|
|
|
22834
22834
|
const userProfile = await Ol(Aa(this.firestore, 'users', this.id));
|
|
22835
22835
|
return userProfile.data();
|
|
22836
22836
|
}
|
|
22837
|
-
watchUserProfileForChanges(
|
|
22837
|
+
watchUserProfileForChanges(callback) {
|
|
22838
22838
|
let unsub;
|
|
22839
22839
|
const q = sl(Ta(this.firestore, 'users'), rl(Eh(), '==', this.id));
|
|
22840
|
-
|
|
22841
|
-
return
|
|
22842
|
-
unsub = jl(q, async (snapshot) => {
|
|
22843
|
-
if (!(await predicate(snapshot)))
|
|
22844
|
-
return;
|
|
22845
|
-
clearTimeout(cancel);
|
|
22846
|
-
unsub();
|
|
22847
|
-
resolve(snapshot.docs[0].data());
|
|
22848
|
-
});
|
|
22849
|
-
});
|
|
22840
|
+
unsub = jl(q, (snapshot) => callback(snapshot.docs[0].data()));
|
|
22841
|
+
return () => unsub();
|
|
22850
22842
|
}
|
|
22851
22843
|
async login(username, password) {
|
|
22852
22844
|
if (this.auth.currentUser)
|
|
@@ -23487,16 +23479,22 @@ const validatePassword = (password) => {
|
|
|
23487
23479
|
|
|
23488
23480
|
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
23489
23481
|
|
|
23490
|
-
var css$
|
|
23482
|
+
var css$8 = ".tfr-bg-aquamarina-strong{background-color:#209da7}.tfr-c-white{color:#fff}.tfr-c-brand{color:#209da7}.tfr-c-dark{color:#000}.tfr-c-dark-o5{color:rgba(0,0,0,.5)}.tfr-c-red{color:red}";
|
|
23483
|
+
n(css$8,{});
|
|
23484
|
+
|
|
23485
|
+
var css$7 = ".tfr-home-button-container{display:flex;flex-wrap:wrap;margin:20px}.tfr-home-button-container>button{border:0;cursor:pointer;height:60px;margin:20px;width:200px}.tfr-home-button-container>button:hover{background-color:#e6e6e6}[data-tfr=hidden]{display:none}.tfr-modal{background-color:rgba(0,0,0,.53);display:flex;height:100%;left:0;position:fixed;top:0;width:100%;z-index:10000}.tfr-modal-content{margin:auto;text-align:center;width:90%}.tfr-modal-content-flex{align-items:center;display:flex}.tfr-modal-content-container{background-color:#fff;border:1px solid #434343;border-radius:0;box-shadow:0 6px 6px #00000029;line-height:normal;margin:auto;max-height:100vh;max-width:709px;overflow:auto;width:100%}.tfr-close-container{text-align:end}.tfr-close{color:#aaa;font-size:28px;font-weight:700;height:50px;width:50px}.tfr-close:focus,.tfr-close:hover{color:#000;text-decoration:none}.tfr-cursor:hover{cursor:pointer}.tfr-underline{text-decoration:underline}.tfr-standard-button{border:0;border-radius:3px;color:#fff;height:43px;width:138px}.tfr-logo-container{align-items:center;display:flex}.tfr-modal-title-logo-container{align-items:center;display:flex;justify-content:center}.tfr-girl-clothes{display:inline-block;height:316px;width:253px}.tfr-t-a-center{text-align:center}.tfr-w-70-p{width:70%}.tfr-w-80-p{width:80%}.tfr-w-85-p{width:85%}.tfr-w-150{width:150px}.tfr-h-150{height:150px}.tfr-d-none{display:none}.tfr-d-block{display:block}.tfr-d-flex{display:flex}.tfr-how-it-works-item{align-items:center;display:flex;justify-items:center}.tfr-try-on-content{margin-left:60px}#tfr-tryon-image{max-width:30vw}.progress-bar{background-color:#fff;border:1px solid #bdbdbd;height:10px;margin:15px auto 0;width:55%}.progress-bar-fill{animation-duration:120s;animation-name:progress;background-color:#209da7;color:#fff;display:block;font-size:16px;height:100%;text-align:center;transition:width .6s linear}#tfr-video{height:100%;max-height:390px;max-width:390px}.tfr-logo-box{aspect-ratio:1;margin:auto;max-height:430px;max-width:430px;padding:20px}.tfr-flex,.tfr-logo-box{align-items:center;display:flex;justify-content:center}";
|
|
23486
|
+
n(css$7,{});
|
|
23487
|
+
|
|
23488
|
+
var css$6 = "input{border:none;box-shadow:none!important;width:100%}input:focus,select:focus,textarea:focus{border:none;outline:none}.tfr-fieldset{margin-left:auto;margin-right:auto;width:65%}.tfr-fieldset,.tfr-fieldset-inline{border-color:rgba(0,0,0,.5);border-radius:10px;border-width:1px;padding:5px 10px 10px;text-align:left}.tfr-fieldset-inline{margin-right:10px;width:250px}.tfr-fieldset-err{border-color:red}";
|
|
23491
23489
|
n(css$6,{});
|
|
23492
23490
|
|
|
23493
|
-
var css$5 = ".
|
|
23491
|
+
var css$5 = ".lds-ellipsis{display:inline-block;height:80px;position:relative;width:80px}.lds-ellipsis div{animation-timing-function:cubic-bezier(0,1,1,0);background:#209da7;border-radius:50%;display:block;height:13px;position:absolute;top:33px;width:13px}.lds-ellipsis div:first-child{animation:lds-ellipsis1 .6s infinite;left:8px}.lds-ellipsis div:nth-child(2){animation:lds-ellipsis2 .6s infinite;left:8px}.lds-ellipsis div:nth-child(3){animation:lds-ellipsis2 .6s infinite;left:32px}.lds-ellipsis div:nth-child(4){animation:lds-ellipsis3 .6s infinite;left:56px}@keyframes lds-ellipsis1{0%{transform:scale(0)}to{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}to{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0)}to{transform:translate(24px)}}";
|
|
23494
23492
|
n(css$5,{});
|
|
23495
23493
|
|
|
23496
|
-
var css$4 = "
|
|
23494
|
+
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}}";
|
|
23497
23495
|
n(css$4,{});
|
|
23498
23496
|
|
|
23499
|
-
var css$3 = "
|
|
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}";
|
|
23500
23498
|
n(css$3,{});
|
|
23501
23499
|
|
|
23502
23500
|
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%}";
|
|
@@ -36349,19 +36347,13 @@ const TryOnModal = (props) => {
|
|
|
36349
36347
|
};
|
|
36350
36348
|
};
|
|
36351
36349
|
|
|
36352
|
-
class
|
|
36350
|
+
class TfrModal {
|
|
36353
36351
|
constructor(modalDivId, signIn, forgotPassword, submitTel) {
|
|
36354
36352
|
this.signIn = signIn;
|
|
36355
36353
|
this.forgotPassword = forgotPassword;
|
|
36356
36354
|
this.submitTel = submitTel;
|
|
36357
36355
|
this.manager = InitModalManager(modalDivId);
|
|
36358
36356
|
}
|
|
36359
|
-
get sku() {
|
|
36360
|
-
return this._sku;
|
|
36361
|
-
}
|
|
36362
|
-
setSku(sku) {
|
|
36363
|
-
this._sku = sku;
|
|
36364
|
-
}
|
|
36365
36357
|
close() {
|
|
36366
36358
|
this.manager.close();
|
|
36367
36359
|
}
|
|
@@ -36425,6 +36417,241 @@ class FittingRoomNav {
|
|
|
36425
36417
|
}
|
|
36426
36418
|
}
|
|
36427
36419
|
|
|
36420
|
+
const svgSrc = '';
|
|
36421
|
+
class SizeRecComponent {
|
|
36422
|
+
constructor(sizeRecMainDivId, tfrShop, onSignInClick, onSignOutClick) {
|
|
36423
|
+
this.tfrShop = tfrShop;
|
|
36424
|
+
this.onSignInClick = onSignInClick;
|
|
36425
|
+
this.onSignOutClick = onSignOutClick;
|
|
36426
|
+
this._sku = '';
|
|
36427
|
+
this.redraw = null;
|
|
36428
|
+
this.init(sizeRecMainDivId);
|
|
36429
|
+
}
|
|
36430
|
+
get sku() {
|
|
36431
|
+
return this._sku;
|
|
36432
|
+
}
|
|
36433
|
+
setSku(sku) {
|
|
36434
|
+
this._sku = sku;
|
|
36435
|
+
}
|
|
36436
|
+
setIsLoggedIn(isLoggedIn) {
|
|
36437
|
+
if (isLoggedIn) {
|
|
36438
|
+
this.tfrSizeRecActionLogin.style.display = 'none';
|
|
36439
|
+
this.tfrSizeRecActionLogout.style.display = 'block';
|
|
36440
|
+
}
|
|
36441
|
+
else {
|
|
36442
|
+
this.tfrSizeRecActionLogin.style.display = 'block';
|
|
36443
|
+
this.tfrSizeRecActionLogout.style.display = 'none';
|
|
36444
|
+
}
|
|
36445
|
+
}
|
|
36446
|
+
setLoading(isLoading) {
|
|
36447
|
+
if (isLoading) {
|
|
36448
|
+
this.tfrSizeRecLoading.style.display = 'block';
|
|
36449
|
+
this.tfrSizeRecommendationsContainer.style.display = 'none';
|
|
36450
|
+
}
|
|
36451
|
+
else {
|
|
36452
|
+
this.tfrSizeRecLoading.style.display = 'none';
|
|
36453
|
+
this.tfrSizeRecommendationsContainer.style.display = 'flex';
|
|
36454
|
+
}
|
|
36455
|
+
}
|
|
36456
|
+
setGarmentLocations(locations) {
|
|
36457
|
+
this.renderGarmentLocations(locations);
|
|
36458
|
+
this.tfrSizeRecSelect.style.display = 'none';
|
|
36459
|
+
}
|
|
36460
|
+
setRecommendedSize({ recommended, sizes }) {
|
|
36461
|
+
this.renderSizeRec(recommended, sizes);
|
|
36462
|
+
this.tfrSizeRecSelect.style.display = 'flex';
|
|
36463
|
+
}
|
|
36464
|
+
setError(error) {
|
|
36465
|
+
this.tfrSizeRecommendationError.innerHTML = error;
|
|
36466
|
+
}
|
|
36467
|
+
init(sizeRecMainDivId) {
|
|
36468
|
+
const sizeRecMainDiv = document.getElementById(sizeRecMainDivId);
|
|
36469
|
+
if (!sizeRecMainDiv)
|
|
36470
|
+
throw new Error('Size rec main div not found');
|
|
36471
|
+
this.render(sizeRecMainDiv);
|
|
36472
|
+
this.setElements();
|
|
36473
|
+
this.bindEvents();
|
|
36474
|
+
}
|
|
36475
|
+
setElements() {
|
|
36476
|
+
this.tfrSizeRecActionLogin = document.getElementById('tfr-size-rec-action-login');
|
|
36477
|
+
this.tfrSizeRecActionLogout = document.getElementById('tfr-size-rec-action-logout');
|
|
36478
|
+
this.tfrSizeRecTable = document.getElementById('tfr-size-rec-table');
|
|
36479
|
+
this.tfrSizeRecommendationError = document.getElementById('tfr-size-recommendation-error');
|
|
36480
|
+
this.tfrSizeRecSize = document.getElementById('tfr-size-rec-size');
|
|
36481
|
+
this.tfrSizeRecSelect = document.getElementById('tfr-size-rec-select');
|
|
36482
|
+
this.tfrSizeRecLoading = document.getElementById('tfr-size-rec-loading');
|
|
36483
|
+
this.tfrSizeRecommendationsContainer = document.getElementById('tfr-size-recommendations-container');
|
|
36484
|
+
}
|
|
36485
|
+
bindEvents() {
|
|
36486
|
+
this.tfrSizeRecActionLogin.addEventListener('click', this.onSignInClick);
|
|
36487
|
+
this.tfrSizeRecActionLogout.addEventListener('click', this.onSignOutClick);
|
|
36488
|
+
this.tfrSizeRecSelect.addEventListener('click', this.onSizeRecSelectClick.bind(this));
|
|
36489
|
+
}
|
|
36490
|
+
onSizeRecSelectClick(e) {
|
|
36491
|
+
const target = e.target;
|
|
36492
|
+
if (!target.classList.contains('tfr-size-rec-select-button'))
|
|
36493
|
+
return;
|
|
36494
|
+
e.preventDefault();
|
|
36495
|
+
const selectedIndex = Number(target.getAttribute('data-index'));
|
|
36496
|
+
if (Number.isNaN(selectedIndex))
|
|
36497
|
+
return;
|
|
36498
|
+
const allButtons = document.querySelectorAll('.tfr-size-rec-select-button');
|
|
36499
|
+
allButtons.forEach((button) => button.classList.remove('active'));
|
|
36500
|
+
allButtons.item(selectedIndex).classList.add('active');
|
|
36501
|
+
this.redraw(selectedIndex);
|
|
36502
|
+
}
|
|
36503
|
+
renderSizeRec(recommended, sizes) {
|
|
36504
|
+
this.tfrSizeRecSize.innerHTML = ` ${recommended}`;
|
|
36505
|
+
const selectedSizeIndex = sizes.findIndex(({ size }) => size === recommended);
|
|
36506
|
+
this.redraw = (index) => this.renderSizeRecTable(sizes, index);
|
|
36507
|
+
this.redraw(selectedSizeIndex);
|
|
36508
|
+
this.renderSizeRecSelect(sizes, selectedSizeIndex);
|
|
36509
|
+
}
|
|
36510
|
+
renderSizeRecTable(sizes, index) {
|
|
36511
|
+
const { locations } = sizes[index];
|
|
36512
|
+
const html = locations
|
|
36513
|
+
.sort(({ location: a }, { location: b }) => (a < b ? -1 : 1))
|
|
36514
|
+
.map(({ location, fit }) => this.renderSizeRecTableRow(location, fit))
|
|
36515
|
+
.join('');
|
|
36516
|
+
this.tfrSizeRecTable.innerHTML = html;
|
|
36517
|
+
}
|
|
36518
|
+
renderSizeRecSelect(sizes, index) {
|
|
36519
|
+
const sizeNames = sizes.map(({ size }) => size);
|
|
36520
|
+
const html = sizeNames
|
|
36521
|
+
.map((name, i) => `<div class="tfr-size-rec-select-button ${i === index ? 'active' : ''}" data-index="${i}">${name}</div>`)
|
|
36522
|
+
.join('');
|
|
36523
|
+
this.tfrSizeRecSelect.innerHTML = html;
|
|
36524
|
+
}
|
|
36525
|
+
renderSizeRecTableRow(location, fit) {
|
|
36526
|
+
return `<div class="tfr-size-rec-table-row">
|
|
36527
|
+
<div class="tfr-size-rec-table-cell-left">${location}</div>
|
|
36528
|
+
<div class="tfr-size-rec-table-cell-right ${fit === 'Perfect Fit' ? 'perfect' : ''}">
|
|
36529
|
+
${fit}
|
|
36530
|
+
</div>
|
|
36531
|
+
</div>`;
|
|
36532
|
+
}
|
|
36533
|
+
renderLoginCta() {
|
|
36534
|
+
return `<div class="tfr-size-rec-login-cta"><img src="${svgSrc}" /> Login to view</div>`;
|
|
36535
|
+
}
|
|
36536
|
+
renderGarmentLocations(locations) {
|
|
36537
|
+
const html = locations
|
|
36538
|
+
.sort()
|
|
36539
|
+
.map((location) => this.renderSizeRecTableRow(location, this.renderLoginCta()))
|
|
36540
|
+
.join('');
|
|
36541
|
+
this.tfrSizeRecTable.innerHTML = html;
|
|
36542
|
+
this.tfrSizeRecSize.innerHTML = this.renderLoginCta();
|
|
36543
|
+
}
|
|
36544
|
+
render(sizeRecMainDiv) {
|
|
36545
|
+
const body = `<div id="tfr-size-recommendations">
|
|
36546
|
+
<div id="tfr-size-rec-loading">
|
|
36547
|
+
<div class="lds-ellipsis">
|
|
36548
|
+
<div></div>
|
|
36549
|
+
<div></div>
|
|
36550
|
+
<div></div>
|
|
36551
|
+
<div></div>
|
|
36552
|
+
</div>
|
|
36553
|
+
</div>
|
|
36554
|
+
<div id="tfr-size-recommendations-container">
|
|
36555
|
+
<img id="tfr-size-rec-login-svg" src="{{ 'login-icon.svg' | asset_url }}" />
|
|
36556
|
+
<div id="tfr-size-rec-title">
|
|
36557
|
+
Recommend Size:
|
|
36558
|
+
<div id="tfr-size-rec-size">
|
|
36559
|
+
<div class="tfr-size-rec-login-cta">
|
|
36560
|
+
<img src="{{ 'login-icon.svg' | asset_url }}" /> Login to view
|
|
36561
|
+
</div>
|
|
36562
|
+
</div>
|
|
36563
|
+
</div>
|
|
36564
|
+
|
|
36565
|
+
<div id="tfr-size-rec-select"></div>
|
|
36566
|
+
|
|
36567
|
+
<div id="tfr-size-rec-subtitle">How it fits</div>
|
|
36568
|
+
|
|
36569
|
+
<div id="tfr-size-rec-table"></div>
|
|
36570
|
+
|
|
36571
|
+
<div id="tfr-size-rec-action">
|
|
36572
|
+
<div id="tfr-size-rec-action-login">Login to see your recommended size</div>
|
|
36573
|
+
<div id="tfr-size-rec-action-logout">Sign out of the Fitting Room</div>
|
|
36574
|
+
</div>
|
|
36575
|
+
</div>
|
|
36576
|
+
</div>`;
|
|
36577
|
+
sizeRecMainDiv.innerHTML = body;
|
|
36578
|
+
}
|
|
36579
|
+
}
|
|
36580
|
+
|
|
36581
|
+
class TfrSizeRec {
|
|
36582
|
+
constructor(sizeRecMainDivId, tfrShop, onSignInClick, onSignOutClick) {
|
|
36583
|
+
this.tfrShop = tfrShop;
|
|
36584
|
+
this.onSignInClick = onSignInClick;
|
|
36585
|
+
this.onSignOutClick = onSignOutClick;
|
|
36586
|
+
this.sizeRecComponent = new SizeRecComponent(sizeRecMainDivId, this.tfrShop, this.onSignInClick, this.onSignOutClick);
|
|
36587
|
+
}
|
|
36588
|
+
get sku() {
|
|
36589
|
+
return this.sizeRecComponent.sku;
|
|
36590
|
+
}
|
|
36591
|
+
setSku(sku) {
|
|
36592
|
+
this.sizeRecComponent.setSku(sku);
|
|
36593
|
+
}
|
|
36594
|
+
setIsLoggedIn(isLoggedIn) {
|
|
36595
|
+
this.sizeRecComponent.setIsLoggedIn(isLoggedIn);
|
|
36596
|
+
}
|
|
36597
|
+
async setGarmentLocations() {
|
|
36598
|
+
this.sizeRecComponent.setLoading(true);
|
|
36599
|
+
const locations = await this.getGarmentLocations();
|
|
36600
|
+
if (!locations)
|
|
36601
|
+
return;
|
|
36602
|
+
this.sizeRecComponent.setGarmentLocations(locations);
|
|
36603
|
+
this.sizeRecComponent.setLoading(false);
|
|
36604
|
+
}
|
|
36605
|
+
async setRecommendedSize() {
|
|
36606
|
+
this.sizeRecComponent.setLoading(true);
|
|
36607
|
+
const sizes = await this.getRecommenedSize();
|
|
36608
|
+
if (!sizes)
|
|
36609
|
+
return;
|
|
36610
|
+
this.sizeRecComponent.setRecommendedSize(sizes);
|
|
36611
|
+
this.sizeRecComponent.setLoading(false);
|
|
36612
|
+
}
|
|
36613
|
+
async getGarmentLocations() {
|
|
36614
|
+
try {
|
|
36615
|
+
const locations = await this.tfrShop.getMeasurementLocationsFromSku(this.sku);
|
|
36616
|
+
return locations;
|
|
36617
|
+
}
|
|
36618
|
+
catch (error) {
|
|
36619
|
+
this.sizeRecComponent.setError(error.message);
|
|
36620
|
+
return null;
|
|
36621
|
+
}
|
|
36622
|
+
}
|
|
36623
|
+
async getRecommenedSize() {
|
|
36624
|
+
try {
|
|
36625
|
+
const colorwaySizeAsset = await this.tfrShop.getColorwaySizeAssetFromSku(this.sku);
|
|
36626
|
+
const sizes = await this.getRecommendedSizes(String(colorwaySizeAsset.style_id));
|
|
36627
|
+
return sizes;
|
|
36628
|
+
}
|
|
36629
|
+
catch (error) {
|
|
36630
|
+
this.sizeRecComponent.setError(error.message);
|
|
36631
|
+
return null;
|
|
36632
|
+
}
|
|
36633
|
+
}
|
|
36634
|
+
async getRecommendedSizes(styleId) {
|
|
36635
|
+
const sizeRec = await this.tfrShop.getRecommendedSizes(styleId);
|
|
36636
|
+
if (!sizeRec)
|
|
36637
|
+
return null;
|
|
36638
|
+
return {
|
|
36639
|
+
recommended: sizeRec.recommended_size.size_value.size,
|
|
36640
|
+
sizes: sizeRec.fits.map((fit) => {
|
|
36641
|
+
return {
|
|
36642
|
+
size: sizeRec.available_sizes.find((size) => size.id === fit.size_id).size_value.size,
|
|
36643
|
+
locations: fit.measurement_location_fits.map((locationFit) => {
|
|
36644
|
+
return {
|
|
36645
|
+
fit: index.FitNames[locationFit.fit],
|
|
36646
|
+
location: index.MeasurementLocationName[locationFit.measurement_location],
|
|
36647
|
+
};
|
|
36648
|
+
}),
|
|
36649
|
+
};
|
|
36650
|
+
}),
|
|
36651
|
+
};
|
|
36652
|
+
}
|
|
36653
|
+
}
|
|
36654
|
+
|
|
36428
36655
|
var AvatarState;
|
|
36429
36656
|
(function (AvatarState) {
|
|
36430
36657
|
AvatarState["NOT_CREATED"] = "NOT_CREATED";
|
|
@@ -36433,44 +36660,65 @@ var AvatarState;
|
|
|
36433
36660
|
})(AvatarState || (AvatarState = {}));
|
|
36434
36661
|
|
|
36435
36662
|
class FittingRoom {
|
|
36436
|
-
constructor(shopId, modalDivId, hooks = {}, _env) {
|
|
36663
|
+
constructor(shopId, modalDivId, sizeRecMainDivId, hooks = {}, _env) {
|
|
36437
36664
|
this.shopId = shopId;
|
|
36438
36665
|
this.hooks = hooks;
|
|
36666
|
+
this.isLoggedIn = false;
|
|
36667
|
+
this.unsub = null;
|
|
36439
36668
|
// prettier-ignore
|
|
36440
36669
|
const env = _env
|
|
36441
36670
|
? _env
|
|
36442
36671
|
: typeof process !== 'undefined'
|
|
36443
36672
|
? process.env.NODE_ENV
|
|
36444
36673
|
: 'dev';
|
|
36445
|
-
this.
|
|
36674
|
+
this.tfrModal = new TfrModal(modalDivId, this.signIn.bind(this), this.forgotPassword.bind(this), this.submitTel.bind(this));
|
|
36446
36675
|
this.tfrShop = initShop(Number(this.shopId), env);
|
|
36447
|
-
|
|
36448
|
-
get sku() {
|
|
36449
|
-
return this.nav.sku;
|
|
36676
|
+
this.tfrSizeRec = new TfrSizeRec(sizeRecMainDivId, this.tfrShop, this.onSignInClick.bind(this), this.signOut.bind(this));
|
|
36450
36677
|
}
|
|
36451
36678
|
get shop() {
|
|
36452
36679
|
return this.tfrShop;
|
|
36453
36680
|
}
|
|
36454
|
-
|
|
36455
|
-
|
|
36456
|
-
if (loggedIn && this.hooks.onLogin)
|
|
36457
|
-
this.hooks.onLogin();
|
|
36458
|
-
if (!loggedIn && this.hooks.onLogout)
|
|
36459
|
-
this.hooks.onLogout();
|
|
36460
|
-
return loggedIn;
|
|
36681
|
+
get sku() {
|
|
36682
|
+
return this.tfrSizeRec.sku;
|
|
36461
36683
|
}
|
|
36462
36684
|
setSku(sku) {
|
|
36463
|
-
this.
|
|
36685
|
+
this.tfrSizeRec.setSku(sku);
|
|
36686
|
+
if (this.isLoggedIn)
|
|
36687
|
+
this.tfrSizeRec.setRecommendedSize();
|
|
36688
|
+
else
|
|
36689
|
+
this.tfrSizeRec.setGarmentLocations();
|
|
36690
|
+
}
|
|
36691
|
+
async onInit() {
|
|
36692
|
+
var _a, _b;
|
|
36693
|
+
this.isLoggedIn = await this.tfrShop.onInit();
|
|
36694
|
+
this.tfrSizeRec.setIsLoggedIn(this.isLoggedIn);
|
|
36695
|
+
if (this.isLoggedIn) {
|
|
36696
|
+
if ((_a = this.hooks) === null || _a === void 0 ? void 0 : _a.onLogin)
|
|
36697
|
+
this.hooks.onLogin();
|
|
36698
|
+
this.subscribeToProfileChanges();
|
|
36699
|
+
}
|
|
36700
|
+
else {
|
|
36701
|
+
if ((_b = this.hooks) === null || _b === void 0 ? void 0 : _b.onLogout)
|
|
36702
|
+
this.hooks.onLogout();
|
|
36703
|
+
this.unsubscribeFromProfileChanges();
|
|
36704
|
+
}
|
|
36705
|
+
return this.isLoggedIn;
|
|
36464
36706
|
}
|
|
36465
36707
|
close() {
|
|
36466
|
-
this.
|
|
36708
|
+
this.tfrModal.close();
|
|
36467
36709
|
}
|
|
36468
36710
|
async signOut() {
|
|
36711
|
+
var _a;
|
|
36469
36712
|
await this.tfrShop.user.logout();
|
|
36470
|
-
if (this.hooks.onLogout)
|
|
36713
|
+
if ((_a = this.hooks) === null || _a === void 0 ? void 0 : _a.onLogout)
|
|
36471
36714
|
this.hooks.onLogout();
|
|
36715
|
+
this.isLoggedIn = false;
|
|
36716
|
+
this.tfrSizeRec.setIsLoggedIn(false);
|
|
36717
|
+
this.tfrSizeRec.setGarmentLocations();
|
|
36718
|
+
this.unsubscribeFromProfileChanges();
|
|
36472
36719
|
}
|
|
36473
36720
|
async signIn(username, password, validationError) {
|
|
36721
|
+
var _a;
|
|
36474
36722
|
if (username.length == 0 || password.length == 0)
|
|
36475
36723
|
return validationError(L.UsernameOrPasswordEmpty);
|
|
36476
36724
|
if (!validateEmail(username))
|
|
@@ -36479,34 +36727,17 @@ class FittingRoom {
|
|
|
36479
36727
|
return validationError(L.PasswordError);
|
|
36480
36728
|
try {
|
|
36481
36729
|
await this.tfrShop.user.login(username, password);
|
|
36730
|
+
if ((_a = this.hooks) === null || _a === void 0 ? void 0 : _a.onLogin)
|
|
36731
|
+
this.hooks.onLogin();
|
|
36732
|
+
this.tfrModal.close();
|
|
36733
|
+
this.isLoggedIn = true;
|
|
36734
|
+
this.tfrSizeRec.setIsLoggedIn(true);
|
|
36735
|
+
this.tfrSizeRec.setRecommendedSize();
|
|
36736
|
+
this.subscribeToProfileChanges();
|
|
36482
36737
|
}
|
|
36483
36738
|
catch (e) {
|
|
36484
36739
|
return validationError(L.UsernameOrPasswordIncorrect);
|
|
36485
36740
|
}
|
|
36486
|
-
if (this.hooks.onLogin)
|
|
36487
|
-
this.hooks.onLogin();
|
|
36488
|
-
this.nav.close();
|
|
36489
|
-
try {
|
|
36490
|
-
const userProfile = await this.tfrShop.user.getUserProfile();
|
|
36491
|
-
switch (userProfile.avatar_status) {
|
|
36492
|
-
case AvatarState.NOT_CREATED:
|
|
36493
|
-
this.nav.onNotCreated();
|
|
36494
|
-
break;
|
|
36495
|
-
case AvatarState.PENDING:
|
|
36496
|
-
if (this.hooks.onLoading)
|
|
36497
|
-
this.hooks.onLoading();
|
|
36498
|
-
break;
|
|
36499
|
-
case AvatarState.CREATED:
|
|
36500
|
-
console.debug('avatar_state: created');
|
|
36501
|
-
break;
|
|
36502
|
-
default:
|
|
36503
|
-
this.nav.onError(L.SomethingWentWrong);
|
|
36504
|
-
break;
|
|
36505
|
-
}
|
|
36506
|
-
}
|
|
36507
|
-
catch (_a) {
|
|
36508
|
-
this.nav.onError(L.SomethingWentWrong);
|
|
36509
|
-
}
|
|
36510
36741
|
}
|
|
36511
36742
|
setBrandUserId(brandUserId) {
|
|
36512
36743
|
this.tfrShop.user.setBrandUserId(brandUserId);
|
|
@@ -36514,49 +36745,64 @@ class FittingRoom {
|
|
|
36514
36745
|
async submitTel(tel) {
|
|
36515
36746
|
try {
|
|
36516
36747
|
await this.tfrShop.submitTelephoneNumber(tel);
|
|
36517
|
-
this.
|
|
36748
|
+
this.tfrModal.toSignIn();
|
|
36518
36749
|
}
|
|
36519
36750
|
catch (_a) {
|
|
36520
|
-
this.
|
|
36751
|
+
this.tfrModal.onError(L.SomethingWentWrong);
|
|
36521
36752
|
}
|
|
36522
36753
|
}
|
|
36523
36754
|
async forgotPassword(email) {
|
|
36524
36755
|
await this.tfrShop.user.sendPasswordResetEmail(email);
|
|
36525
|
-
this.
|
|
36756
|
+
this.tfrModal.toSignIn();
|
|
36526
36757
|
}
|
|
36527
36758
|
async passwordReset(code, newPassword) {
|
|
36528
36759
|
await this.tfrShop.user.confirmPasswordReset(code, newPassword);
|
|
36529
|
-
this.
|
|
36760
|
+
this.tfrModal.toPasswordReset();
|
|
36530
36761
|
}
|
|
36531
36762
|
async getMeasurementLocationsFromSku(sku) {
|
|
36532
36763
|
return this.tfrShop.getMeasurementLocationsFromSku(sku);
|
|
36533
36764
|
}
|
|
36534
36765
|
onSignInClick() {
|
|
36535
|
-
this.
|
|
36766
|
+
this.tfrModal.toScan();
|
|
36767
|
+
}
|
|
36768
|
+
onUserProfileChange(userProfile) {
|
|
36769
|
+
var _a, _b, _c, _d;
|
|
36770
|
+
switch (userProfile.avatar_status) {
|
|
36771
|
+
case AvatarState.NOT_CREATED:
|
|
36772
|
+
if ((_a = this.hooks) === null || _a === void 0 ? void 0 : _a.onError)
|
|
36773
|
+
this.hooks.onError(L.DontHaveAvatar);
|
|
36774
|
+
this.tfrModal.onNotCreated();
|
|
36775
|
+
break;
|
|
36776
|
+
case AvatarState.PENDING:
|
|
36777
|
+
if ((_b = this.hooks) === null || _b === void 0 ? void 0 : _b.onLoading)
|
|
36778
|
+
this.hooks.onLoading();
|
|
36779
|
+
break;
|
|
36780
|
+
case AvatarState.CREATED:
|
|
36781
|
+
if ((_c = this.hooks) === null || _c === void 0 ? void 0 : _c.onLoadingComplete)
|
|
36782
|
+
this.hooks.onLoadingComplete();
|
|
36783
|
+
break;
|
|
36784
|
+
default:
|
|
36785
|
+
if ((_d = this.hooks) === null || _d === void 0 ? void 0 : _d.onError)
|
|
36786
|
+
this.hooks.onError(L.SomethingWentWrong);
|
|
36787
|
+
this.tfrModal.onError(L.SomethingWentWrong);
|
|
36788
|
+
break;
|
|
36789
|
+
}
|
|
36536
36790
|
}
|
|
36537
|
-
|
|
36538
|
-
|
|
36539
|
-
|
|
36540
|
-
|
|
36541
|
-
|
|
36542
|
-
|
|
36543
|
-
|
|
36544
|
-
|
|
36545
|
-
|
|
36546
|
-
|
|
36547
|
-
return {
|
|
36548
|
-
fit: index.FitNames[locationFit.fit],
|
|
36549
|
-
location: index.MeasurementLocationName[locationFit.measurement_location],
|
|
36550
|
-
};
|
|
36551
|
-
}),
|
|
36552
|
-
};
|
|
36553
|
-
}),
|
|
36554
|
-
};
|
|
36791
|
+
subscribeToProfileChanges() {
|
|
36792
|
+
if (this.unsub)
|
|
36793
|
+
return;
|
|
36794
|
+
this.unsub = this.tfrShop.user.watchUserProfileForChanges((userProfile) => this.onUserProfileChange(userProfile));
|
|
36795
|
+
}
|
|
36796
|
+
unsubscribeFromProfileChanges() {
|
|
36797
|
+
if (!this.unsub)
|
|
36798
|
+
return;
|
|
36799
|
+
this.unsub();
|
|
36800
|
+
this.unsub = null;
|
|
36555
36801
|
}
|
|
36556
36802
|
}
|
|
36557
36803
|
|
|
36558
|
-
const initFittingRoom = async (shopId, modalDivId, hooks, env = 'dev') => {
|
|
36559
|
-
const tfr = new FittingRoom(shopId, modalDivId, hooks, env);
|
|
36804
|
+
const initFittingRoom = async (shopId, modalDivId, sizeRecMainDivId, hooks, env = 'dev') => {
|
|
36805
|
+
const tfr = new FittingRoom(shopId, modalDivId, sizeRecMainDivId, hooks, env);
|
|
36560
36806
|
await tfr.onInit();
|
|
36561
36807
|
return tfr;
|
|
36562
36808
|
};
|