@thefittingroom/shop-ui 4.3.2 → 4.3.4
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/index.js +76 -28
- package/dist/index.umd.cjs +76 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20423,7 +20423,7 @@ class FittingRoomAPI {
|
|
|
20423
20423
|
return cachedAsset;
|
|
20424
20424
|
}
|
|
20425
20425
|
}
|
|
20426
|
-
console.debug("
|
|
20426
|
+
console.debug("colorwaySizeAsset sku not found in cache:", colorwaySizeAssetSku, Array.from(this.cachedColorwaySizeAssets.keys()));
|
|
20427
20427
|
const constraints = [
|
|
20428
20428
|
where("brand_id", "==", this.BrandID),
|
|
20429
20429
|
where("sku", "==", colorwaySizeAssetSku)
|
|
@@ -20605,12 +20605,22 @@ class FittingRoomAPI {
|
|
|
20605
20605
|
}
|
|
20606
20606
|
console.debug("checking user for vto frames", colorwaySizeAssetSKU);
|
|
20607
20607
|
const firestoreUser = data;
|
|
20608
|
-
const
|
|
20609
|
-
if (!
|
|
20608
|
+
const colorwaySizeAssetEntry = firestoreUser.vto?.[this.BrandID]?.[colorwaySizeAssetSKU];
|
|
20609
|
+
if (!colorwaySizeAssetEntry) {
|
|
20610
|
+
console.debug("no vto entry for SKU, continue watching:", colorwaySizeAssetSKU);
|
|
20611
|
+
return false;
|
|
20612
|
+
}
|
|
20613
|
+
if (colorwaySizeAssetEntry.error) {
|
|
20614
|
+
console.error("VTO error found for SKU:", colorwaySizeAssetSKU, colorwaySizeAssetEntry.error);
|
|
20610
20615
|
throw NoFramesFoundError;
|
|
20611
20616
|
}
|
|
20612
|
-
console.debug("
|
|
20613
|
-
const
|
|
20617
|
+
console.debug("cololrwaySizeAssetEntry", colorwaySizeAssetEntry);
|
|
20618
|
+
const frames = this.getVTOFramesFromUser(firestoreUser, colorwaySizeAssetSKU);
|
|
20619
|
+
if (!frames?.length) {
|
|
20620
|
+
throw NoFramesFoundError;
|
|
20621
|
+
}
|
|
20622
|
+
console.debug("testing first frame for SKU:", colorwaySizeAssetSKU, frames[0]);
|
|
20623
|
+
const tested = await testImage(frames[0]);
|
|
20614
20624
|
if (!tested) {
|
|
20615
20625
|
console.error("image test failed for SKU:", colorwaySizeAssetSKU);
|
|
20616
20626
|
throw NoFramesFoundError;
|
|
@@ -20641,12 +20651,12 @@ class FittingRoomAPI {
|
|
|
20641
20651
|
console.error(`Error watching for try-on frames for SKU: ${colorwaySizeAssetSKU}`, error);
|
|
20642
20652
|
throw error;
|
|
20643
20653
|
}
|
|
20644
|
-
const
|
|
20645
|
-
if (!
|
|
20654
|
+
const frames = this.getVTOFramesFromUser(firestoreUser, colorwaySizeAssetSKU);
|
|
20655
|
+
if (!frames) {
|
|
20646
20656
|
console.error(`Frames not found on final user object for SKU: ${colorwaySizeAssetSKU}`, firestoreUser);
|
|
20647
20657
|
throw NoFramesFoundError;
|
|
20648
20658
|
}
|
|
20649
|
-
return
|
|
20659
|
+
return frames;
|
|
20650
20660
|
}
|
|
20651
20661
|
async GetCachedOrRequestUserColorwaySizeAssetFrames(firestoreUserController, colorwaySizeAssetSKU, skipCache) {
|
|
20652
20662
|
console.debug("GetCachedOrRequestUserColorwaySizeAssetFrames", colorwaySizeAssetSKU, "skipCache:", skipCache);
|
|
@@ -20683,7 +20693,6 @@ class FittingRoomAPI {
|
|
|
20683
20693
|
framesPromise = this.watchForTryOnFrames(firestoreUserController, colorwaySizeAssetSKU, true);
|
|
20684
20694
|
}
|
|
20685
20695
|
this.vtoFramesPromiseCache.set(colorwaySizeAssetSKU, framesPromise);
|
|
20686
|
-
console.debug("retrieved frames", frames);
|
|
20687
20696
|
return await framesPromise;
|
|
20688
20697
|
}
|
|
20689
20698
|
}
|
|
@@ -21338,10 +21347,10 @@ class TFRModal {
|
|
|
21338
21347
|
}
|
|
21339
21348
|
toPasswordReset() {
|
|
21340
21349
|
}
|
|
21341
|
-
onTryOn(
|
|
21350
|
+
onTryOn(frames) {
|
|
21342
21351
|
this.manager.open(
|
|
21343
21352
|
TryOnModal({
|
|
21344
|
-
frames
|
|
21353
|
+
frames,
|
|
21345
21354
|
onClose: () => this.close(),
|
|
21346
21355
|
onNavBack: () => this.navBack()
|
|
21347
21356
|
})
|
|
@@ -21479,6 +21488,17 @@ class SizeRecComponent {
|
|
|
21479
21488
|
this.tfrTryOnButton.classList.remove("loading");
|
|
21480
21489
|
}
|
|
21481
21490
|
}
|
|
21491
|
+
ShowSizeRecommendationError(message) {
|
|
21492
|
+
console.debug("ShowSizeRecommendationError", message);
|
|
21493
|
+
this.tfrSizeRecommendationError.innerHTML = message;
|
|
21494
|
+
this.tfrSizeRecommendationError.classList.remove("hide");
|
|
21495
|
+
this.tfrSizeRecommendationsContainer.classList.add("hide");
|
|
21496
|
+
}
|
|
21497
|
+
HideSizeRecommendationError() {
|
|
21498
|
+
console.debug("HideSizeRecommendationError");
|
|
21499
|
+
this.tfrSizeRecommendationError.classList.add("hide");
|
|
21500
|
+
this.tfrSizeRecommendationsContainer.classList.remove("hide");
|
|
21501
|
+
}
|
|
21482
21502
|
SetStyleMeasurementLocations(garmentMeasurementLocations) {
|
|
21483
21503
|
if (!garmentMeasurementLocations || !garmentMeasurementLocations.length) {
|
|
21484
21504
|
this.tfrSizeRecTitle.classList.add("hide");
|
|
@@ -21502,6 +21522,9 @@ class SizeRecComponent {
|
|
|
21502
21522
|
showTryOnButton() {
|
|
21503
21523
|
this.tfrTryOnButton.classList.remove("hide");
|
|
21504
21524
|
}
|
|
21525
|
+
hideTryOnButton() {
|
|
21526
|
+
this.tfrTryOnButton.classList.add("hide");
|
|
21527
|
+
}
|
|
21505
21528
|
disableTryOnButton(message) {
|
|
21506
21529
|
this.tfrTryOnButton.disabled = true;
|
|
21507
21530
|
this.tfrTryOnButton.title = message;
|
|
@@ -21611,7 +21634,8 @@ class SizeRecComponent {
|
|
|
21611
21634
|
}
|
|
21612
21635
|
renderSizeRec(sizeMeasurementLocationFits) {
|
|
21613
21636
|
const selectedSizeIndex = sizeMeasurementLocationFits.findIndex((size) => size.isRecommended);
|
|
21614
|
-
const
|
|
21637
|
+
const selectedSize = sizeMeasurementLocationFits[selectedSizeIndex];
|
|
21638
|
+
const selectedSizeLabel = selectedSize.label || selectedSize.size_value?.name || selectedSize.id;
|
|
21615
21639
|
this.tfrSizeRecSize.innerHTML = ` ${selectedSizeLabel}`;
|
|
21616
21640
|
this.availableSizes = sizeMeasurementLocationFits;
|
|
21617
21641
|
this.redraw = (index) => this.renderSizeRecTable(sizeMeasurementLocationFits, index);
|
|
@@ -21624,7 +21648,7 @@ class SizeRecComponent {
|
|
|
21624
21648
|
}
|
|
21625
21649
|
renderSizeRecSelect(sizeMeasurementLocationFits, index) {
|
|
21626
21650
|
const html = sizeMeasurementLocationFits.map(
|
|
21627
|
-
(size, i) => `<div class="tfr-size-rec-select-button ${i === index ? "active" : ""}" data-index="${i}">${size.label}</div>`
|
|
21651
|
+
(size, i) => `<div class="tfr-size-rec-select-button ${i === index ? "active" : ""}" data-index="${i}">${size.label || size.size_value?.name || size.id}</div>`
|
|
21628
21652
|
).join("");
|
|
21629
21653
|
this.tfrSizeRecSelect.innerHTML = html;
|
|
21630
21654
|
}
|
|
@@ -21793,7 +21817,7 @@ class SizeRecommendationController {
|
|
|
21793
21817
|
);
|
|
21794
21818
|
}
|
|
21795
21819
|
setLoggedOutStyleMeasurementLocations(garmentMeasurementLocations = []) {
|
|
21796
|
-
if (garmentMeasurementLocations.length
|
|
21820
|
+
if (garmentMeasurementLocations.length === 0) {
|
|
21797
21821
|
throw new Error("filteredLocations passed to setGarmentLocations is 0");
|
|
21798
21822
|
}
|
|
21799
21823
|
console.debug("filledLocations", garmentMeasurementLocations);
|
|
@@ -21810,7 +21834,14 @@ class SizeRecommendationController {
|
|
|
21810
21834
|
try {
|
|
21811
21835
|
this.Show();
|
|
21812
21836
|
this.SetSizeRecommendationLoading(true);
|
|
21813
|
-
|
|
21837
|
+
this.sizeFitRecommendationPromise = this.fittingRoomAPI.GetRecommendedSizes(styleId);
|
|
21838
|
+
const sizeFitRecommendation = await this.sizeFitRecommendationPromise;
|
|
21839
|
+
if (!sizeFitRecommendation?.recommended_size) {
|
|
21840
|
+
this.sizeRecComponent.ShowLoggedIn();
|
|
21841
|
+
this.sizeRecComponent.Show();
|
|
21842
|
+
this.sizeRecComponent.ShowSizeRecommendationError("No sizes were recommended.");
|
|
21843
|
+
return;
|
|
21844
|
+
}
|
|
21814
21845
|
const sizeMeasurementLocationFits = sizeFitRecommendation.available_sizes.map((size) => {
|
|
21815
21846
|
const sizeMeasurementLocationFit = {
|
|
21816
21847
|
isRecommended: size.id === sizeFitRecommendation.recommended_size.id,
|
|
@@ -21830,6 +21861,7 @@ class SizeRecommendationController {
|
|
|
21830
21861
|
}).sort((a, b) => (a.size_value?.id || 0) - (b.size_value?.id || 0));
|
|
21831
21862
|
this.sizeRecComponent.ShowLoggedIn();
|
|
21832
21863
|
this.sizeRecComponent.Show();
|
|
21864
|
+
this.sizeRecComponent.HideSizeRecommendationError();
|
|
21833
21865
|
this.sizeRecComponent.SetRecommendedSize(sizeMeasurementLocationFits);
|
|
21834
21866
|
} catch (e) {
|
|
21835
21867
|
console.error("error in get size recommendation", e);
|
|
@@ -21855,7 +21887,7 @@ class SizeRecommendationController {
|
|
|
21855
21887
|
ShowTryOnButton() {
|
|
21856
21888
|
this.sizeRecComponent.showTryOnButton();
|
|
21857
21889
|
}
|
|
21858
|
-
|
|
21890
|
+
DisableTryOnButton(message) {
|
|
21859
21891
|
this.sizeRecComponent.disableTryOnButton(message);
|
|
21860
21892
|
}
|
|
21861
21893
|
EnableTryOnButton() {
|
|
@@ -21869,6 +21901,9 @@ class SizeRecommendationController {
|
|
|
21869
21901
|
console.debug("SetVTOLoading", isLoading);
|
|
21870
21902
|
this.sizeRecComponent.SetVTOLoading(isLoading);
|
|
21871
21903
|
}
|
|
21904
|
+
CurrentSizeRecommendation() {
|
|
21905
|
+
return this.sizeFitRecommendationPromise;
|
|
21906
|
+
}
|
|
21872
21907
|
setCssVariables(sizeRecMainDiv, cssVariables) {
|
|
21873
21908
|
const toKebabCase = (str) => str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
21874
21909
|
for (const [key, value] of Object.entries(cssVariables)) {
|
|
@@ -21917,21 +21952,21 @@ class VTOController {
|
|
|
21917
21952
|
this.sliderElement = null;
|
|
21918
21953
|
this.isShown = false;
|
|
21919
21954
|
}
|
|
21920
|
-
onNewFramesReady(
|
|
21921
|
-
console.debug("onNewFramesReady",
|
|
21955
|
+
onNewFramesReady(frames) {
|
|
21956
|
+
console.debug("onNewFramesReady", frames);
|
|
21922
21957
|
if (!this.isShown) {
|
|
21923
21958
|
this.show();
|
|
21924
21959
|
}
|
|
21925
|
-
if (Array.isArray(
|
|
21926
|
-
const boundedValue = Math.min(this.currentSliderValue,
|
|
21927
|
-
const e = this.slider.Load(
|
|
21960
|
+
if (Array.isArray(frames) && frames.length > 0) {
|
|
21961
|
+
const boundedValue = Math.min(this.currentSliderValue, frames.length - 1);
|
|
21962
|
+
const e = this.slider.Load(frames, boundedValue);
|
|
21928
21963
|
if (e instanceof Error) {
|
|
21929
21964
|
console.error(e);
|
|
21930
21965
|
return;
|
|
21931
21966
|
}
|
|
21932
|
-
if (this.sliderElement && this.currentSliderValue <
|
|
21967
|
+
if (this.sliderElement && this.currentSliderValue < frames.length) {
|
|
21933
21968
|
this.sliderElement.value = this.currentSliderValue.toString();
|
|
21934
|
-
this.tryOnImage.src =
|
|
21969
|
+
this.tryOnImage.src = frames[this.currentSliderValue];
|
|
21935
21970
|
}
|
|
21936
21971
|
}
|
|
21937
21972
|
}
|
|
@@ -22044,20 +22079,32 @@ class FittingRoomController {
|
|
|
22044
22079
|
}
|
|
22045
22080
|
}
|
|
22046
22081
|
async SetColorwaySizeAssetBySKU(activeSku, skipCache = false) {
|
|
22082
|
+
if (!this.style?.is_vto) {
|
|
22083
|
+
console.warn("skipping SetColorwaySizeAssetBySKU due to disabled vto");
|
|
22084
|
+
return;
|
|
22085
|
+
}
|
|
22047
22086
|
if (this.cacheColorwaySizeAssetsPromise) {
|
|
22048
22087
|
await this.cacheColorwaySizeAssetsPromise;
|
|
22049
22088
|
}
|
|
22050
|
-
|
|
22051
|
-
if (!
|
|
22052
|
-
console.warn("skipping SetColorwaySizeAssetBySKU due to
|
|
22089
|
+
const currentSizeRec = this.SizeRecommendationController.CurrentSizeRecommendation();
|
|
22090
|
+
if (!currentSizeRec) {
|
|
22091
|
+
console.warn("skipping SetColorwaySizeAssetBySKU due to no size recommendation promise");
|
|
22053
22092
|
return;
|
|
22054
22093
|
}
|
|
22094
|
+
const sizeFitRecommendation = await currentSizeRec;
|
|
22095
|
+
console.debug("SetColorwaySizeAssetBySKU: SizeFitRecommendation", sizeFitRecommendation);
|
|
22096
|
+
if (!sizeFitRecommendation?.recommended_size?.id) {
|
|
22097
|
+
console.warn("skipping SetColorwaySizeAssetBySKU due to no size recommendation");
|
|
22098
|
+
return;
|
|
22099
|
+
}
|
|
22100
|
+
console.debug("SetColorwaySizeAssetBySKU", activeSku, skipCache);
|
|
22055
22101
|
try {
|
|
22056
22102
|
this.selectedColorwaySizeAsset = await this.API.GetCachedColorwaySizeAssetFromSku(activeSku, skipCache);
|
|
22057
22103
|
} catch (e) {
|
|
22058
22104
|
this.SizeRecommendationController.Hide();
|
|
22059
22105
|
throw e;
|
|
22060
22106
|
}
|
|
22107
|
+
this.SizeRecommendationController.Show();
|
|
22061
22108
|
this.SizeRecommendationController.ShowTryOnButton();
|
|
22062
22109
|
}
|
|
22063
22110
|
close() {
|
|
@@ -22143,6 +22190,7 @@ class FittingRoomController {
|
|
|
22143
22190
|
const availableAssets = allCachedAssets.filter(
|
|
22144
22191
|
(asset) => availableSizeIDs.includes(asset.size_id) && asset.colorway_id === this.selectedColorwaySizeAsset.colorway_id
|
|
22145
22192
|
);
|
|
22193
|
+
console.debug("availableAssets", availableAssets);
|
|
22146
22194
|
const availableColorwaySizeAssetSKUs = availableAssets.map((asset) => asset.sku);
|
|
22147
22195
|
const batchResult = await this.API.PriorityTryOnWithMultiRequestCache(
|
|
22148
22196
|
this.firestoreUserController,
|
|
@@ -22185,7 +22233,7 @@ class FittingRoomController {
|
|
|
22185
22233
|
case AvatarStatusPending:
|
|
22186
22234
|
if (this.hooks?.onLoading) this.hooks.onLoading();
|
|
22187
22235
|
console.log("calling DisableTryOnButton - avatar not ready");
|
|
22188
|
-
this.SizeRecommendationController.
|
|
22236
|
+
this.SizeRecommendationController.DisableTryOnButton("Your avatar is not ready yet");
|
|
22189
22237
|
break;
|
|
22190
22238
|
case AvatarStatusCreated:
|
|
22191
22239
|
if (this.hooks?.onLoadingComplete) this.hooks.onLoadingComplete();
|
|
@@ -22194,7 +22242,7 @@ class FittingRoomController {
|
|
|
22194
22242
|
break;
|
|
22195
22243
|
default:
|
|
22196
22244
|
console.log("calling DisableTryOnButton - fitting room unavailable");
|
|
22197
|
-
this.SizeRecommendationController.
|
|
22245
|
+
this.SizeRecommendationController.DisableTryOnButton("The Fitting Room is currently unavailable.");
|
|
22198
22246
|
throw new Error("no avatar status");
|
|
22199
22247
|
}
|
|
22200
22248
|
}
|
package/dist/index.umd.cjs
CHANGED
|
@@ -20427,7 +20427,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
20427
20427
|
return cachedAsset;
|
|
20428
20428
|
}
|
|
20429
20429
|
}
|
|
20430
|
-
console.debug("
|
|
20430
|
+
console.debug("colorwaySizeAsset sku not found in cache:", colorwaySizeAssetSku, Array.from(this.cachedColorwaySizeAssets.keys()));
|
|
20431
20431
|
const constraints = [
|
|
20432
20432
|
where("brand_id", "==", this.BrandID),
|
|
20433
20433
|
where("sku", "==", colorwaySizeAssetSku)
|
|
@@ -20609,12 +20609,22 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
20609
20609
|
}
|
|
20610
20610
|
console.debug("checking user for vto frames", colorwaySizeAssetSKU);
|
|
20611
20611
|
const firestoreUser = data;
|
|
20612
|
-
const
|
|
20613
|
-
if (!
|
|
20612
|
+
const colorwaySizeAssetEntry = firestoreUser.vto?.[this.BrandID]?.[colorwaySizeAssetSKU];
|
|
20613
|
+
if (!colorwaySizeAssetEntry) {
|
|
20614
|
+
console.debug("no vto entry for SKU, continue watching:", colorwaySizeAssetSKU);
|
|
20615
|
+
return false;
|
|
20616
|
+
}
|
|
20617
|
+
if (colorwaySizeAssetEntry.error) {
|
|
20618
|
+
console.error("VTO error found for SKU:", colorwaySizeAssetSKU, colorwaySizeAssetEntry.error);
|
|
20614
20619
|
throw NoFramesFoundError;
|
|
20615
20620
|
}
|
|
20616
|
-
console.debug("
|
|
20617
|
-
const
|
|
20621
|
+
console.debug("cololrwaySizeAssetEntry", colorwaySizeAssetEntry);
|
|
20622
|
+
const frames = this.getVTOFramesFromUser(firestoreUser, colorwaySizeAssetSKU);
|
|
20623
|
+
if (!frames?.length) {
|
|
20624
|
+
throw NoFramesFoundError;
|
|
20625
|
+
}
|
|
20626
|
+
console.debug("testing first frame for SKU:", colorwaySizeAssetSKU, frames[0]);
|
|
20627
|
+
const tested = await testImage(frames[0]);
|
|
20618
20628
|
if (!tested) {
|
|
20619
20629
|
console.error("image test failed for SKU:", colorwaySizeAssetSKU);
|
|
20620
20630
|
throw NoFramesFoundError;
|
|
@@ -20645,12 +20655,12 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
20645
20655
|
console.error(`Error watching for try-on frames for SKU: ${colorwaySizeAssetSKU}`, error);
|
|
20646
20656
|
throw error;
|
|
20647
20657
|
}
|
|
20648
|
-
const
|
|
20649
|
-
if (!
|
|
20658
|
+
const frames = this.getVTOFramesFromUser(firestoreUser, colorwaySizeAssetSKU);
|
|
20659
|
+
if (!frames) {
|
|
20650
20660
|
console.error(`Frames not found on final user object for SKU: ${colorwaySizeAssetSKU}`, firestoreUser);
|
|
20651
20661
|
throw NoFramesFoundError;
|
|
20652
20662
|
}
|
|
20653
|
-
return
|
|
20663
|
+
return frames;
|
|
20654
20664
|
}
|
|
20655
20665
|
async GetCachedOrRequestUserColorwaySizeAssetFrames(firestoreUserController, colorwaySizeAssetSKU, skipCache) {
|
|
20656
20666
|
console.debug("GetCachedOrRequestUserColorwaySizeAssetFrames", colorwaySizeAssetSKU, "skipCache:", skipCache);
|
|
@@ -20687,7 +20697,6 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
20687
20697
|
framesPromise = this.watchForTryOnFrames(firestoreUserController, colorwaySizeAssetSKU, true);
|
|
20688
20698
|
}
|
|
20689
20699
|
this.vtoFramesPromiseCache.set(colorwaySizeAssetSKU, framesPromise);
|
|
20690
|
-
console.debug("retrieved frames", frames);
|
|
20691
20700
|
return await framesPromise;
|
|
20692
20701
|
}
|
|
20693
20702
|
}
|
|
@@ -21342,10 +21351,10 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21342
21351
|
}
|
|
21343
21352
|
toPasswordReset() {
|
|
21344
21353
|
}
|
|
21345
|
-
onTryOn(
|
|
21354
|
+
onTryOn(frames) {
|
|
21346
21355
|
this.manager.open(
|
|
21347
21356
|
TryOnModal({
|
|
21348
|
-
frames
|
|
21357
|
+
frames,
|
|
21349
21358
|
onClose: () => this.close(),
|
|
21350
21359
|
onNavBack: () => this.navBack()
|
|
21351
21360
|
})
|
|
@@ -21483,6 +21492,17 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21483
21492
|
this.tfrTryOnButton.classList.remove("loading");
|
|
21484
21493
|
}
|
|
21485
21494
|
}
|
|
21495
|
+
ShowSizeRecommendationError(message) {
|
|
21496
|
+
console.debug("ShowSizeRecommendationError", message);
|
|
21497
|
+
this.tfrSizeRecommendationError.innerHTML = message;
|
|
21498
|
+
this.tfrSizeRecommendationError.classList.remove("hide");
|
|
21499
|
+
this.tfrSizeRecommendationsContainer.classList.add("hide");
|
|
21500
|
+
}
|
|
21501
|
+
HideSizeRecommendationError() {
|
|
21502
|
+
console.debug("HideSizeRecommendationError");
|
|
21503
|
+
this.tfrSizeRecommendationError.classList.add("hide");
|
|
21504
|
+
this.tfrSizeRecommendationsContainer.classList.remove("hide");
|
|
21505
|
+
}
|
|
21486
21506
|
SetStyleMeasurementLocations(garmentMeasurementLocations) {
|
|
21487
21507
|
if (!garmentMeasurementLocations || !garmentMeasurementLocations.length) {
|
|
21488
21508
|
this.tfrSizeRecTitle.classList.add("hide");
|
|
@@ -21506,6 +21526,9 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21506
21526
|
showTryOnButton() {
|
|
21507
21527
|
this.tfrTryOnButton.classList.remove("hide");
|
|
21508
21528
|
}
|
|
21529
|
+
hideTryOnButton() {
|
|
21530
|
+
this.tfrTryOnButton.classList.add("hide");
|
|
21531
|
+
}
|
|
21509
21532
|
disableTryOnButton(message) {
|
|
21510
21533
|
this.tfrTryOnButton.disabled = true;
|
|
21511
21534
|
this.tfrTryOnButton.title = message;
|
|
@@ -21615,7 +21638,8 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21615
21638
|
}
|
|
21616
21639
|
renderSizeRec(sizeMeasurementLocationFits) {
|
|
21617
21640
|
const selectedSizeIndex = sizeMeasurementLocationFits.findIndex((size) => size.isRecommended);
|
|
21618
|
-
const
|
|
21641
|
+
const selectedSize = sizeMeasurementLocationFits[selectedSizeIndex];
|
|
21642
|
+
const selectedSizeLabel = selectedSize.label || selectedSize.size_value?.name || selectedSize.id;
|
|
21619
21643
|
this.tfrSizeRecSize.innerHTML = ` ${selectedSizeLabel}`;
|
|
21620
21644
|
this.availableSizes = sizeMeasurementLocationFits;
|
|
21621
21645
|
this.redraw = (index) => this.renderSizeRecTable(sizeMeasurementLocationFits, index);
|
|
@@ -21628,7 +21652,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21628
21652
|
}
|
|
21629
21653
|
renderSizeRecSelect(sizeMeasurementLocationFits, index) {
|
|
21630
21654
|
const html = sizeMeasurementLocationFits.map(
|
|
21631
|
-
(size, i) => `<div class="tfr-size-rec-select-button ${i === index ? "active" : ""}" data-index="${i}">${size.label}</div>`
|
|
21655
|
+
(size, i) => `<div class="tfr-size-rec-select-button ${i === index ? "active" : ""}" data-index="${i}">${size.label || size.size_value?.name || size.id}</div>`
|
|
21632
21656
|
).join("");
|
|
21633
21657
|
this.tfrSizeRecSelect.innerHTML = html;
|
|
21634
21658
|
}
|
|
@@ -21797,7 +21821,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21797
21821
|
);
|
|
21798
21822
|
}
|
|
21799
21823
|
setLoggedOutStyleMeasurementLocations(garmentMeasurementLocations = []) {
|
|
21800
|
-
if (garmentMeasurementLocations.length
|
|
21824
|
+
if (garmentMeasurementLocations.length === 0) {
|
|
21801
21825
|
throw new Error("filteredLocations passed to setGarmentLocations is 0");
|
|
21802
21826
|
}
|
|
21803
21827
|
console.debug("filledLocations", garmentMeasurementLocations);
|
|
@@ -21814,7 +21838,14 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21814
21838
|
try {
|
|
21815
21839
|
this.Show();
|
|
21816
21840
|
this.SetSizeRecommendationLoading(true);
|
|
21817
|
-
|
|
21841
|
+
this.sizeFitRecommendationPromise = this.fittingRoomAPI.GetRecommendedSizes(styleId);
|
|
21842
|
+
const sizeFitRecommendation = await this.sizeFitRecommendationPromise;
|
|
21843
|
+
if (!sizeFitRecommendation?.recommended_size) {
|
|
21844
|
+
this.sizeRecComponent.ShowLoggedIn();
|
|
21845
|
+
this.sizeRecComponent.Show();
|
|
21846
|
+
this.sizeRecComponent.ShowSizeRecommendationError("No sizes were recommended.");
|
|
21847
|
+
return;
|
|
21848
|
+
}
|
|
21818
21849
|
const sizeMeasurementLocationFits = sizeFitRecommendation.available_sizes.map((size) => {
|
|
21819
21850
|
const sizeMeasurementLocationFit = {
|
|
21820
21851
|
isRecommended: size.id === sizeFitRecommendation.recommended_size.id,
|
|
@@ -21834,6 +21865,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21834
21865
|
}).sort((a, b) => (a.size_value?.id || 0) - (b.size_value?.id || 0));
|
|
21835
21866
|
this.sizeRecComponent.ShowLoggedIn();
|
|
21836
21867
|
this.sizeRecComponent.Show();
|
|
21868
|
+
this.sizeRecComponent.HideSizeRecommendationError();
|
|
21837
21869
|
this.sizeRecComponent.SetRecommendedSize(sizeMeasurementLocationFits);
|
|
21838
21870
|
} catch (e) {
|
|
21839
21871
|
console.error("error in get size recommendation", e);
|
|
@@ -21859,7 +21891,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21859
21891
|
ShowTryOnButton() {
|
|
21860
21892
|
this.sizeRecComponent.showTryOnButton();
|
|
21861
21893
|
}
|
|
21862
|
-
|
|
21894
|
+
DisableTryOnButton(message) {
|
|
21863
21895
|
this.sizeRecComponent.disableTryOnButton(message);
|
|
21864
21896
|
}
|
|
21865
21897
|
EnableTryOnButton() {
|
|
@@ -21873,6 +21905,9 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21873
21905
|
console.debug("SetVTOLoading", isLoading);
|
|
21874
21906
|
this.sizeRecComponent.SetVTOLoading(isLoading);
|
|
21875
21907
|
}
|
|
21908
|
+
CurrentSizeRecommendation() {
|
|
21909
|
+
return this.sizeFitRecommendationPromise;
|
|
21910
|
+
}
|
|
21876
21911
|
setCssVariables(sizeRecMainDiv, cssVariables) {
|
|
21877
21912
|
const toKebabCase = (str) => str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
21878
21913
|
for (const [key, value] of Object.entries(cssVariables)) {
|
|
@@ -21921,21 +21956,21 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
21921
21956
|
this.sliderElement = null;
|
|
21922
21957
|
this.isShown = false;
|
|
21923
21958
|
}
|
|
21924
|
-
onNewFramesReady(
|
|
21925
|
-
console.debug("onNewFramesReady",
|
|
21959
|
+
onNewFramesReady(frames) {
|
|
21960
|
+
console.debug("onNewFramesReady", frames);
|
|
21926
21961
|
if (!this.isShown) {
|
|
21927
21962
|
this.show();
|
|
21928
21963
|
}
|
|
21929
|
-
if (Array.isArray(
|
|
21930
|
-
const boundedValue = Math.min(this.currentSliderValue,
|
|
21931
|
-
const e = this.slider.Load(
|
|
21964
|
+
if (Array.isArray(frames) && frames.length > 0) {
|
|
21965
|
+
const boundedValue = Math.min(this.currentSliderValue, frames.length - 1);
|
|
21966
|
+
const e = this.slider.Load(frames, boundedValue);
|
|
21932
21967
|
if (e instanceof Error) {
|
|
21933
21968
|
console.error(e);
|
|
21934
21969
|
return;
|
|
21935
21970
|
}
|
|
21936
|
-
if (this.sliderElement && this.currentSliderValue <
|
|
21971
|
+
if (this.sliderElement && this.currentSliderValue < frames.length) {
|
|
21937
21972
|
this.sliderElement.value = this.currentSliderValue.toString();
|
|
21938
|
-
this.tryOnImage.src =
|
|
21973
|
+
this.tryOnImage.src = frames[this.currentSliderValue];
|
|
21939
21974
|
}
|
|
21940
21975
|
}
|
|
21941
21976
|
}
|
|
@@ -22048,20 +22083,32 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
22048
22083
|
}
|
|
22049
22084
|
}
|
|
22050
22085
|
async SetColorwaySizeAssetBySKU(activeSku, skipCache = false) {
|
|
22086
|
+
if (!this.style?.is_vto) {
|
|
22087
|
+
console.warn("skipping SetColorwaySizeAssetBySKU due to disabled vto");
|
|
22088
|
+
return;
|
|
22089
|
+
}
|
|
22051
22090
|
if (this.cacheColorwaySizeAssetsPromise) {
|
|
22052
22091
|
await this.cacheColorwaySizeAssetsPromise;
|
|
22053
22092
|
}
|
|
22054
|
-
|
|
22055
|
-
if (!
|
|
22056
|
-
console.warn("skipping SetColorwaySizeAssetBySKU due to
|
|
22093
|
+
const currentSizeRec = this.SizeRecommendationController.CurrentSizeRecommendation();
|
|
22094
|
+
if (!currentSizeRec) {
|
|
22095
|
+
console.warn("skipping SetColorwaySizeAssetBySKU due to no size recommendation promise");
|
|
22057
22096
|
return;
|
|
22058
22097
|
}
|
|
22098
|
+
const sizeFitRecommendation = await currentSizeRec;
|
|
22099
|
+
console.debug("SetColorwaySizeAssetBySKU: SizeFitRecommendation", sizeFitRecommendation);
|
|
22100
|
+
if (!sizeFitRecommendation?.recommended_size?.id) {
|
|
22101
|
+
console.warn("skipping SetColorwaySizeAssetBySKU due to no size recommendation");
|
|
22102
|
+
return;
|
|
22103
|
+
}
|
|
22104
|
+
console.debug("SetColorwaySizeAssetBySKU", activeSku, skipCache);
|
|
22059
22105
|
try {
|
|
22060
22106
|
this.selectedColorwaySizeAsset = await this.API.GetCachedColorwaySizeAssetFromSku(activeSku, skipCache);
|
|
22061
22107
|
} catch (e) {
|
|
22062
22108
|
this.SizeRecommendationController.Hide();
|
|
22063
22109
|
throw e;
|
|
22064
22110
|
}
|
|
22111
|
+
this.SizeRecommendationController.Show();
|
|
22065
22112
|
this.SizeRecommendationController.ShowTryOnButton();
|
|
22066
22113
|
}
|
|
22067
22114
|
close() {
|
|
@@ -22147,6 +22194,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
22147
22194
|
const availableAssets = allCachedAssets.filter(
|
|
22148
22195
|
(asset) => availableSizeIDs.includes(asset.size_id) && asset.colorway_id === this.selectedColorwaySizeAsset.colorway_id
|
|
22149
22196
|
);
|
|
22197
|
+
console.debug("availableAssets", availableAssets);
|
|
22150
22198
|
const availableColorwaySizeAssetSKUs = availableAssets.map((asset) => asset.sku);
|
|
22151
22199
|
const batchResult = await this.API.PriorityTryOnWithMultiRequestCache(
|
|
22152
22200
|
this.firestoreUserController,
|
|
@@ -22189,7 +22237,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
22189
22237
|
case AvatarStatusPending:
|
|
22190
22238
|
if (this.hooks?.onLoading) this.hooks.onLoading();
|
|
22191
22239
|
console.log("calling DisableTryOnButton - avatar not ready");
|
|
22192
|
-
this.SizeRecommendationController.
|
|
22240
|
+
this.SizeRecommendationController.DisableTryOnButton("Your avatar is not ready yet");
|
|
22193
22241
|
break;
|
|
22194
22242
|
case AvatarStatusCreated:
|
|
22195
22243
|
if (this.hooks?.onLoadingComplete) this.hooks.onLoadingComplete();
|
|
@@ -22198,7 +22246,7 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
22198
22246
|
break;
|
|
22199
22247
|
default:
|
|
22200
22248
|
console.log("calling DisableTryOnButton - fitting room unavailable");
|
|
22201
|
-
this.SizeRecommendationController.
|
|
22249
|
+
this.SizeRecommendationController.DisableTryOnButton("The Fitting Room is currently unavailable.");
|
|
22202
22250
|
throw new Error("no avatar status");
|
|
22203
22251
|
}
|
|
22204
22252
|
}
|