@thefittingroom/shop-ui 1.1.7 → 1.1.9
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 +2 -1
- package/dist/esm/index.js +204 -158
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +117 -117
- package/package.json +2 -2
|
@@ -12,6 +12,7 @@ export declare class SizeRecComponent {
|
|
|
12
12
|
private readonly onSignInClick;
|
|
13
13
|
private readonly onSignOutClick;
|
|
14
14
|
private _sku;
|
|
15
|
+
private isLoggedIn;
|
|
15
16
|
private tfrSizeRecTitle;
|
|
16
17
|
private tfrSizeRecSubtitle;
|
|
17
18
|
private tfrSizeRecActionLogin;
|
|
@@ -30,7 +31,7 @@ export declare class SizeRecComponent {
|
|
|
30
31
|
setLoading(isLoading: boolean): void;
|
|
31
32
|
setGarmentLocations(locations: string[]): void;
|
|
32
33
|
setRecommendedSize({ recommended, sizes }: RecommendedSize): void;
|
|
33
|
-
setError(
|
|
34
|
+
setError(): void;
|
|
34
35
|
private init;
|
|
35
36
|
private setElements;
|
|
36
37
|
private bindEvents;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* thefittingroom v1.1.
|
|
2
|
+
* thefittingroom v1.1.9 (2024-05-17T00:01:17.423Z)
|
|
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.
|
|
50
|
+
* thefittingroom v1.1.7 (2024-05-16T23:59:30.970Z)
|
|
51
51
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
52
52
|
*/
|
|
53
53
|
|
|
@@ -22903,6 +22903,172 @@ const getFirebaseError = (e) => {
|
|
|
22903
22903
|
}
|
|
22904
22904
|
};
|
|
22905
22905
|
|
|
22906
|
+
class Fetcher {
|
|
22907
|
+
static get endpoint() {
|
|
22908
|
+
const api = Config.getInstance().api;
|
|
22909
|
+
return api.url;
|
|
22910
|
+
}
|
|
22911
|
+
static async Fetch({ user, endpointPath, method, body, useToken = true }) {
|
|
22912
|
+
const url = this.getUrl(endpointPath, useToken);
|
|
22913
|
+
const headers = await this.getHeaders(user, useToken);
|
|
22914
|
+
const config = { method, headers, credentials: 'include' };
|
|
22915
|
+
if (body)
|
|
22916
|
+
config.body = JSON.stringify(body);
|
|
22917
|
+
const res = await fetch(url, config);
|
|
22918
|
+
if (res.ok)
|
|
22919
|
+
return res;
|
|
22920
|
+
if (res.status === 500)
|
|
22921
|
+
throw new Error(res.statusText);
|
|
22922
|
+
const json = await res.json();
|
|
22923
|
+
return Promise.reject(json);
|
|
22924
|
+
}
|
|
22925
|
+
static getUrl(endpointPath, useToken) {
|
|
22926
|
+
return useToken ? `${this.endpoint}/v1${endpointPath}` : this.endpoint + endpointPath;
|
|
22927
|
+
}
|
|
22928
|
+
static async getHeaders(user, useToken) {
|
|
22929
|
+
if (!useToken)
|
|
22930
|
+
return { 'Content-Type': 'application/json' };
|
|
22931
|
+
const token = await user.getToken();
|
|
22932
|
+
return {
|
|
22933
|
+
'Content-Type': 'application/json',
|
|
22934
|
+
Authorization: `Bearer ${token}`,
|
|
22935
|
+
};
|
|
22936
|
+
}
|
|
22937
|
+
static Get(user, endpointPath, useToken) {
|
|
22938
|
+
return this.Fetch({ user, endpointPath, method: 'GET', body: null, useToken });
|
|
22939
|
+
}
|
|
22940
|
+
static Post(user, endpointPath, body = null, useToken) {
|
|
22941
|
+
return this.Fetch({ user, endpointPath, method: 'POST', body, useToken });
|
|
22942
|
+
}
|
|
22943
|
+
static Put(user, endpointPath, body, useToken) {
|
|
22944
|
+
return this.Fetch({ user, endpointPath, method: 'PUT', body, useToken });
|
|
22945
|
+
}
|
|
22946
|
+
static Patch(user, endpointPath, body, useToken) {
|
|
22947
|
+
return this.Fetch({ user, endpointPath, method: 'PATCH', body, useToken });
|
|
22948
|
+
}
|
|
22949
|
+
static Delete(user, endpointPath, body, useToken) {
|
|
22950
|
+
return this.Fetch({ user, endpointPath, method: 'DELETE', body, useToken });
|
|
22951
|
+
}
|
|
22952
|
+
}
|
|
22953
|
+
|
|
22954
|
+
class TfrShop {
|
|
22955
|
+
constructor(brandId, firebase) {
|
|
22956
|
+
this.brandId = brandId;
|
|
22957
|
+
this.firebase = firebase;
|
|
22958
|
+
this.measurementLocations = new Map();
|
|
22959
|
+
}
|
|
22960
|
+
get user() {
|
|
22961
|
+
return this.firebase.user;
|
|
22962
|
+
}
|
|
22963
|
+
get isLoggedIn() {
|
|
22964
|
+
return !this.firebase || Boolean(this.user.id);
|
|
22965
|
+
}
|
|
22966
|
+
async onInit() {
|
|
22967
|
+
await this.getMeasurementLocations();
|
|
22968
|
+
return this.firebase.onInit();
|
|
22969
|
+
}
|
|
22970
|
+
async getRecommendedSizes(styleId) {
|
|
22971
|
+
var _a, _b;
|
|
22972
|
+
if (!this.isLoggedIn)
|
|
22973
|
+
throw new UserNotLoggedInError();
|
|
22974
|
+
try {
|
|
22975
|
+
const res = await Fetcher.Get(this.user, `/styles/${styleId}/recommendation`);
|
|
22976
|
+
const data = (await res.json());
|
|
22977
|
+
if (!((_a = data === null || data === void 0 ? void 0 : data.fits) === null || _a === void 0 ? void 0 : _a.length) || !((_b = data === null || data === void 0 ? void 0 : data.recommended_size) === null || _b === void 0 ? void 0 : _b.id))
|
|
22978
|
+
return null;
|
|
22979
|
+
return data;
|
|
22980
|
+
}
|
|
22981
|
+
catch (error) {
|
|
22982
|
+
if ((error === null || error === void 0 ? void 0 : error.error) === AvatarNotCreated)
|
|
22983
|
+
throw new AvatarNotCreatedError();
|
|
22984
|
+
throw error;
|
|
22985
|
+
}
|
|
22986
|
+
}
|
|
22987
|
+
async submitTelephoneNumber(tel) {
|
|
22988
|
+
const sanitizedTel = tel.replace(/[^\+0-9]/g, '');
|
|
22989
|
+
const res = await Fetcher.Post(this.user, '/ios-app-link', { phone_number: sanitizedTel }, false);
|
|
22990
|
+
console.log(res);
|
|
22991
|
+
}
|
|
22992
|
+
async getColorwaySizeAssetFromSku(colorwaySizeAssetSku) {
|
|
22993
|
+
const assets = await this.getColorwaySizeAssets(null, [colorwaySizeAssetSku]);
|
|
22994
|
+
if (!(assets === null || assets === void 0 ? void 0 : assets.size))
|
|
22995
|
+
throw new NoColorwaySizeAssetsFoundError();
|
|
22996
|
+
return Array.from(assets.values())[0];
|
|
22997
|
+
}
|
|
22998
|
+
async getMeasurementLocationsFromSku(sku) {
|
|
22999
|
+
const asset = await this.getColorwaySizeAssetFromSku(sku);
|
|
23000
|
+
if (!asset)
|
|
23001
|
+
throw new Error('No colorway size asset found for sku');
|
|
23002
|
+
const styleCategory = await this.getStyleCategory(asset.style_id);
|
|
23003
|
+
if (!styleCategory)
|
|
23004
|
+
throw new Error('Style category not found for style id');
|
|
23005
|
+
const taxonomy = await this.getGetTaxonomy(styleCategory.style_garment_category_id);
|
|
23006
|
+
if (!taxonomy)
|
|
23007
|
+
throw new Error('Taxonomy not found for style garment category id');
|
|
23008
|
+
return taxonomy.garment_measurement_locations.female.map((location) => {
|
|
23009
|
+
return this.measurementLocations.has(location) ? this.measurementLocations.get(location) : location;
|
|
23010
|
+
});
|
|
23011
|
+
}
|
|
23012
|
+
async getColorwaySizeAssets(styleId, skus) {
|
|
23013
|
+
const constraints = [rl('brand_id', '==', this.brandId)];
|
|
23014
|
+
if (styleId)
|
|
23015
|
+
constraints.push(rl('style_id', '==', styleId));
|
|
23016
|
+
if ((skus === null || skus === void 0 ? void 0 : skus.length) > 0)
|
|
23017
|
+
constraints.push(rl('sku', 'in', skus));
|
|
23018
|
+
try {
|
|
23019
|
+
const querySnapshot = await this.firebase.getDocs('colorway_size_assets', constraints);
|
|
23020
|
+
const colorwaySizeAssets = new Map();
|
|
23021
|
+
querySnapshot.forEach((doc) => {
|
|
23022
|
+
const colorwaySizeAsset = doc.data();
|
|
23023
|
+
colorwaySizeAssets.set(colorwaySizeAsset.id, colorwaySizeAsset);
|
|
23024
|
+
});
|
|
23025
|
+
return colorwaySizeAssets;
|
|
23026
|
+
}
|
|
23027
|
+
catch (error) {
|
|
23028
|
+
return getFirebaseError(error);
|
|
23029
|
+
}
|
|
23030
|
+
}
|
|
23031
|
+
async getStyleCategory(styleId) {
|
|
23032
|
+
try {
|
|
23033
|
+
const doc = await this.firebase.getDoc('styles', String(styleId));
|
|
23034
|
+
return doc;
|
|
23035
|
+
}
|
|
23036
|
+
catch (error) {
|
|
23037
|
+
return getFirebaseError(error);
|
|
23038
|
+
}
|
|
23039
|
+
}
|
|
23040
|
+
async getGetTaxonomy(styleId) {
|
|
23041
|
+
try {
|
|
23042
|
+
const doc = await this.firebase.getDoc('style_garment_categories', String(styleId));
|
|
23043
|
+
return doc;
|
|
23044
|
+
}
|
|
23045
|
+
catch (error) {
|
|
23046
|
+
return getFirebaseError(error);
|
|
23047
|
+
}
|
|
23048
|
+
}
|
|
23049
|
+
async getMeasurementLocations() {
|
|
23050
|
+
const locations = await this.fetchMeasurementLocations();
|
|
23051
|
+
locations.forEach((location) => {
|
|
23052
|
+
this.measurementLocations.set(location.name, location.label);
|
|
23053
|
+
});
|
|
23054
|
+
}
|
|
23055
|
+
async fetchMeasurementLocations() {
|
|
23056
|
+
try {
|
|
23057
|
+
const docs = await this.firebase.getDocs('garment_measurement_locations', []);
|
|
23058
|
+
return docs.docs.map((doc) => doc.data());
|
|
23059
|
+
}
|
|
23060
|
+
catch (error) {
|
|
23061
|
+
return getFirebaseError(error);
|
|
23062
|
+
}
|
|
23063
|
+
}
|
|
23064
|
+
}
|
|
23065
|
+
const initShop = (brandId, env = 'dev') => {
|
|
23066
|
+
if (env === 'dev' || env === 'development')
|
|
23067
|
+
console.warn('TfrShop is in development mode');
|
|
23068
|
+
Config.getInstance().setEnv(env);
|
|
23069
|
+
return new TfrShop(brandId, new Firebase());
|
|
23070
|
+
};
|
|
23071
|
+
|
|
22906
23072
|
var MeasurementLocation;
|
|
22907
23073
|
(function (MeasurementLocation) {
|
|
22908
23074
|
MeasurementLocation["ACROSS_BACK"] = "across_back";
|
|
@@ -23257,6 +23423,12 @@ var Fit;
|
|
|
23257
23423
|
Fit["SLIGHTLY_LOOSE"] = "slightly_loose";
|
|
23258
23424
|
Fit["LOOSE"] = "loose";
|
|
23259
23425
|
Fit["OVERSIZED"] = "oversized";
|
|
23426
|
+
Fit["TOO_SHORT"] = "too_short";
|
|
23427
|
+
Fit["SHORT"] = "short";
|
|
23428
|
+
Fit["SLIGHTLY_SHORT"] = "slightly_short";
|
|
23429
|
+
Fit["SLIGHTLY_LONG"] = "slightly_long";
|
|
23430
|
+
Fit["LONG"] = "long";
|
|
23431
|
+
Fit["TOO_LONG"] = "too_long";
|
|
23260
23432
|
})(Fit || (Fit = {}));
|
|
23261
23433
|
const FitNames = {
|
|
23262
23434
|
[Fit.TOO_TIGHT]: 'Too Tight',
|
|
@@ -23266,151 +23438,12 @@ const FitNames = {
|
|
|
23266
23438
|
[Fit.SLIGHTLY_LOOSE]: 'Slightly Loose',
|
|
23267
23439
|
[Fit.LOOSE]: 'Loose',
|
|
23268
23440
|
[Fit.OVERSIZED]: 'Oversized',
|
|
23269
|
-
|
|
23270
|
-
|
|
23271
|
-
|
|
23272
|
-
|
|
23273
|
-
|
|
23274
|
-
|
|
23275
|
-
}
|
|
23276
|
-
static async Fetch({ user, endpointPath, method, body, useToken = true }) {
|
|
23277
|
-
const url = this.getUrl(endpointPath, useToken);
|
|
23278
|
-
const headers = await this.getHeaders(user, useToken);
|
|
23279
|
-
const config = { method, headers, credentials: 'include' };
|
|
23280
|
-
if (body)
|
|
23281
|
-
config.body = JSON.stringify(body);
|
|
23282
|
-
const res = await fetch(url, config);
|
|
23283
|
-
if (res.ok)
|
|
23284
|
-
return res;
|
|
23285
|
-
if (res.status === 500)
|
|
23286
|
-
throw new Error(res.statusText);
|
|
23287
|
-
const json = await res.json();
|
|
23288
|
-
return Promise.reject(json);
|
|
23289
|
-
}
|
|
23290
|
-
static getUrl(endpointPath, useToken) {
|
|
23291
|
-
return useToken ? `${this.endpoint}/v1${endpointPath}` : this.endpoint + endpointPath;
|
|
23292
|
-
}
|
|
23293
|
-
static async getHeaders(user, useToken) {
|
|
23294
|
-
if (!useToken)
|
|
23295
|
-
return { 'Content-Type': 'application/json' };
|
|
23296
|
-
const token = await user.getToken();
|
|
23297
|
-
return {
|
|
23298
|
-
'Content-Type': 'application/json',
|
|
23299
|
-
Authorization: `Bearer ${token}`,
|
|
23300
|
-
};
|
|
23301
|
-
}
|
|
23302
|
-
static Get(user, endpointPath, useToken) {
|
|
23303
|
-
return this.Fetch({ user, endpointPath, method: 'GET', body: null, useToken });
|
|
23304
|
-
}
|
|
23305
|
-
static Post(user, endpointPath, body = null, useToken) {
|
|
23306
|
-
return this.Fetch({ user, endpointPath, method: 'POST', body, useToken });
|
|
23307
|
-
}
|
|
23308
|
-
static Put(user, endpointPath, body, useToken) {
|
|
23309
|
-
return this.Fetch({ user, endpointPath, method: 'PUT', body, useToken });
|
|
23310
|
-
}
|
|
23311
|
-
static Patch(user, endpointPath, body, useToken) {
|
|
23312
|
-
return this.Fetch({ user, endpointPath, method: 'PATCH', body, useToken });
|
|
23313
|
-
}
|
|
23314
|
-
static Delete(user, endpointPath, body, useToken) {
|
|
23315
|
-
return this.Fetch({ user, endpointPath, method: 'DELETE', body, useToken });
|
|
23316
|
-
}
|
|
23317
|
-
}
|
|
23318
|
-
|
|
23319
|
-
class TfrShop {
|
|
23320
|
-
constructor(brandId, firebase) {
|
|
23321
|
-
this.brandId = brandId;
|
|
23322
|
-
this.firebase = firebase;
|
|
23323
|
-
}
|
|
23324
|
-
get user() {
|
|
23325
|
-
return this.firebase.user;
|
|
23326
|
-
}
|
|
23327
|
-
get isLoggedIn() {
|
|
23328
|
-
return !this.firebase || Boolean(this.user.id);
|
|
23329
|
-
}
|
|
23330
|
-
onInit() {
|
|
23331
|
-
return this.firebase.onInit();
|
|
23332
|
-
}
|
|
23333
|
-
async getRecommendedSizes(styleId) {
|
|
23334
|
-
var _a, _b;
|
|
23335
|
-
if (!this.isLoggedIn)
|
|
23336
|
-
throw new UserNotLoggedInError();
|
|
23337
|
-
try {
|
|
23338
|
-
const res = await Fetcher.Get(this.user, `/styles/${styleId}/recommendation`);
|
|
23339
|
-
const data = (await res.json());
|
|
23340
|
-
if (!((_a = data === null || data === void 0 ? void 0 : data.fits) === null || _a === void 0 ? void 0 : _a.length) || !((_b = data === null || data === void 0 ? void 0 : data.recommended_size) === null || _b === void 0 ? void 0 : _b.id))
|
|
23341
|
-
return null;
|
|
23342
|
-
return data;
|
|
23343
|
-
}
|
|
23344
|
-
catch (error) {
|
|
23345
|
-
if ((error === null || error === void 0 ? void 0 : error.error) === AvatarNotCreated)
|
|
23346
|
-
throw new AvatarNotCreatedError();
|
|
23347
|
-
throw error;
|
|
23348
|
-
}
|
|
23349
|
-
}
|
|
23350
|
-
async submitTelephoneNumber(tel) {
|
|
23351
|
-
const sanitizedTel = tel.replace(/[^\+0-9]/g, '');
|
|
23352
|
-
const res = await Fetcher.Post(this.user, '/ios-app-link', { phone_number: sanitizedTel }, false);
|
|
23353
|
-
console.log(res);
|
|
23354
|
-
}
|
|
23355
|
-
async getColorwaySizeAssetFromSku(colorwaySizeAssetSku) {
|
|
23356
|
-
const assets = await this.getColorwaySizeAssets(null, [colorwaySizeAssetSku]);
|
|
23357
|
-
if (!(assets === null || assets === void 0 ? void 0 : assets.size))
|
|
23358
|
-
throw new NoColorwaySizeAssetsFoundError();
|
|
23359
|
-
return Array.from(assets.values())[0];
|
|
23360
|
-
}
|
|
23361
|
-
async getMeasurementLocationsFromSku(sku) {
|
|
23362
|
-
var _a;
|
|
23363
|
-
const asset = await this.getColorwaySizeAssetFromSku(sku);
|
|
23364
|
-
const styleCategory = await this.getStyleCategory(asset.style_id);
|
|
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;
|
|
23367
|
-
return classificationLocation
|
|
23368
|
-
? ClassificationLocations[classificationLocation].map((location) => MeasurementLocationName[location])
|
|
23369
|
-
: null;
|
|
23370
|
-
}
|
|
23371
|
-
async getColorwaySizeAssets(styleId, skus) {
|
|
23372
|
-
const constraints = [rl('brand_id', '==', this.brandId)];
|
|
23373
|
-
if (styleId)
|
|
23374
|
-
constraints.push(rl('style_id', '==', styleId));
|
|
23375
|
-
if ((skus === null || skus === void 0 ? void 0 : skus.length) > 0)
|
|
23376
|
-
constraints.push(rl('sku', 'in', skus));
|
|
23377
|
-
try {
|
|
23378
|
-
const querySnapshot = await this.firebase.getDocs('colorway_size_assets', constraints);
|
|
23379
|
-
const colorwaySizeAssets = new Map();
|
|
23380
|
-
querySnapshot.forEach((doc) => {
|
|
23381
|
-
const colorwaySizeAsset = doc.data();
|
|
23382
|
-
colorwaySizeAssets.set(colorwaySizeAsset.id, colorwaySizeAsset);
|
|
23383
|
-
});
|
|
23384
|
-
return colorwaySizeAssets;
|
|
23385
|
-
}
|
|
23386
|
-
catch (error) {
|
|
23387
|
-
return getFirebaseError(error);
|
|
23388
|
-
}
|
|
23389
|
-
}
|
|
23390
|
-
async getStyleCategory(styleId) {
|
|
23391
|
-
try {
|
|
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));
|
|
23402
|
-
return doc;
|
|
23403
|
-
}
|
|
23404
|
-
catch (error) {
|
|
23405
|
-
return getFirebaseError(error);
|
|
23406
|
-
}
|
|
23407
|
-
}
|
|
23408
|
-
}
|
|
23409
|
-
const initShop = (brandId, env = 'dev') => {
|
|
23410
|
-
if (env === 'dev' || env === 'development')
|
|
23411
|
-
console.warn('TfrShop is in development mode');
|
|
23412
|
-
Config.getInstance().setEnv(env);
|
|
23413
|
-
return new TfrShop(brandId, new Firebase());
|
|
23441
|
+
[Fit.TOO_SHORT]: 'Too Short',
|
|
23442
|
+
[Fit.SHORT]: 'Short',
|
|
23443
|
+
[Fit.SLIGHTLY_SHORT]: 'Slightly Short',
|
|
23444
|
+
[Fit.SLIGHTLY_LONG]: 'Slightly Long',
|
|
23445
|
+
[Fit.LONG]: 'Long',
|
|
23446
|
+
[Fit.TOO_LONG]: 'Too Long',
|
|
23414
23447
|
};
|
|
23415
23448
|
|
|
23416
23449
|
var AvatarState$1;
|
|
@@ -23504,7 +23537,7 @@ n(css$5,{});
|
|
|
23504
23537
|
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}}";
|
|
23505
23538
|
n(css$4,{});
|
|
23506
23539
|
|
|
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}";
|
|
23540
|
+
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{display:inline-block}#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}";
|
|
23508
23541
|
n(css$3,{});
|
|
23509
23542
|
|
|
23510
23543
|
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%}";
|
|
@@ -36439,6 +36472,7 @@ class SizeRecComponent {
|
|
|
36439
36472
|
this.onSignInClick = onSignInClick;
|
|
36440
36473
|
this.onSignOutClick = onSignOutClick;
|
|
36441
36474
|
this._sku = '';
|
|
36475
|
+
this.isLoggedIn = false;
|
|
36442
36476
|
this.redraw = null;
|
|
36443
36477
|
this.init(sizeRecMainDivId);
|
|
36444
36478
|
}
|
|
@@ -36449,9 +36483,12 @@ class SizeRecComponent {
|
|
|
36449
36483
|
this._sku = sku;
|
|
36450
36484
|
}
|
|
36451
36485
|
setIsLoggedIn(isLoggedIn) {
|
|
36486
|
+
this.isLoggedIn = isLoggedIn;
|
|
36452
36487
|
if (isLoggedIn) {
|
|
36453
36488
|
this.tfrSizeRecActionLogin.style.display = 'none';
|
|
36454
36489
|
this.tfrSizeRecActionLogout.style.display = 'block';
|
|
36490
|
+
this.tfrSizeRecTitle.style.display = 'block';
|
|
36491
|
+
this.tfrSizeRecSubtitle.style.display = 'block';
|
|
36455
36492
|
}
|
|
36456
36493
|
else {
|
|
36457
36494
|
this.tfrSizeRecActionLogin.style.display = 'block';
|
|
@@ -36469,6 +36506,11 @@ class SizeRecComponent {
|
|
|
36469
36506
|
}
|
|
36470
36507
|
}
|
|
36471
36508
|
setGarmentLocations(locations) {
|
|
36509
|
+
if (!locations || !locations.length) {
|
|
36510
|
+
this.tfrSizeRecTitle.style.display = 'none';
|
|
36511
|
+
this.tfrSizeRecSubtitle.style.display = 'none';
|
|
36512
|
+
return;
|
|
36513
|
+
}
|
|
36472
36514
|
this.renderGarmentLocations(locations);
|
|
36473
36515
|
this.tfrSizeRecSelect.style.display = 'none';
|
|
36474
36516
|
}
|
|
@@ -36476,11 +36518,13 @@ class SizeRecComponent {
|
|
|
36476
36518
|
this.renderSizeRec(recommended, sizes);
|
|
36477
36519
|
this.tfrSizeRecSelect.style.display = 'flex';
|
|
36478
36520
|
}
|
|
36479
|
-
setError(
|
|
36521
|
+
setError() {
|
|
36480
36522
|
this.tfrSizeRecTitle.style.display = 'none';
|
|
36481
36523
|
this.tfrSizeRecSubtitle.style.display = 'none';
|
|
36524
|
+
if (!this.isLoggedIn)
|
|
36525
|
+
return;
|
|
36482
36526
|
this.tfrSizeRecommendationError.style.display = 'block';
|
|
36483
|
-
this.tfrSizeRecommendationError.innerHTML =
|
|
36527
|
+
this.tfrSizeRecommendationError.innerHTML = 'No recommended size found.';
|
|
36484
36528
|
}
|
|
36485
36529
|
init(sizeRecMainDivId) {
|
|
36486
36530
|
const sizeRecMainDiv = document.getElementById(sizeRecMainDivId);
|
|
@@ -36624,17 +36668,17 @@ class TfrSizeRec {
|
|
|
36624
36668
|
async setGarmentLocations() {
|
|
36625
36669
|
this.sizeRecComponent.setLoading(true);
|
|
36626
36670
|
const locations = await this.getGarmentLocations();
|
|
36627
|
-
|
|
36628
|
-
|
|
36629
|
-
this.sizeRecComponent.setGarmentLocations(locations);
|
|
36671
|
+
console.debug('locations', locations);
|
|
36672
|
+
this.sizeRecComponent.setGarmentLocations(locations || []);
|
|
36630
36673
|
this.sizeRecComponent.setLoading(false);
|
|
36631
36674
|
}
|
|
36632
36675
|
async setRecommendedSize() {
|
|
36633
36676
|
this.sizeRecComponent.setLoading(true);
|
|
36634
36677
|
const sizes = await this.getRecommenedSize();
|
|
36635
36678
|
if (!sizes) {
|
|
36679
|
+
console.error('No sizes found for sku');
|
|
36636
36680
|
this.sizeRecComponent.setLoading(false);
|
|
36637
|
-
this.sizeRecComponent.setError(
|
|
36681
|
+
this.sizeRecComponent.setError();
|
|
36638
36682
|
return;
|
|
36639
36683
|
}
|
|
36640
36684
|
this.sizeRecComponent.setRecommendedSize(sizes);
|
|
@@ -36646,7 +36690,8 @@ class TfrSizeRec {
|
|
|
36646
36690
|
return locations;
|
|
36647
36691
|
}
|
|
36648
36692
|
catch (error) {
|
|
36649
|
-
|
|
36693
|
+
console.error(error);
|
|
36694
|
+
this.sizeRecComponent.setError();
|
|
36650
36695
|
return null;
|
|
36651
36696
|
}
|
|
36652
36697
|
}
|
|
@@ -36657,7 +36702,8 @@ class TfrSizeRec {
|
|
|
36657
36702
|
return sizes;
|
|
36658
36703
|
}
|
|
36659
36704
|
catch (error) {
|
|
36660
|
-
|
|
36705
|
+
console.error(error);
|
|
36706
|
+
this.sizeRecComponent.setError();
|
|
36661
36707
|
return null;
|
|
36662
36708
|
}
|
|
36663
36709
|
}
|
|
@@ -36666,10 +36712,10 @@ class TfrSizeRec {
|
|
|
36666
36712
|
if (!sizeRec)
|
|
36667
36713
|
return null;
|
|
36668
36714
|
return {
|
|
36669
|
-
recommended: sizeRec.recommended_size.
|
|
36715
|
+
recommended: sizeRec.recommended_size.label,
|
|
36670
36716
|
sizes: sizeRec.fits.map((fit) => {
|
|
36671
36717
|
return {
|
|
36672
|
-
size: sizeRec.available_sizes.find((size) => size.id === fit.size_id).
|
|
36718
|
+
size: sizeRec.available_sizes.find((size) => size.id === fit.size_id).label,
|
|
36673
36719
|
locations: fit.measurement_location_fits.map((locationFit) => {
|
|
36674
36720
|
return {
|
|
36675
36721
|
fit: index.FitNames[locationFit.fit],
|