@thefittingroom/shop-ui 0.0.15 → 0.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/README.md +7 -1
- package/dist/esm/components/locale.d.ts +1 -0
- package/dist/esm/index.js +33 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +3 -3
- package/dist/esm/tfr.d.ts +4 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ const hooks: TfrHooks = {
|
|
|
27
27
|
onLoading: () => {},
|
|
28
28
|
onLoadingComplete: () => {},
|
|
29
29
|
onVtoReady: (frames: string[]) => {},
|
|
30
|
-
onError: () => {},
|
|
30
|
+
onError: (error: string) => {},
|
|
31
31
|
onLogin: () => {},
|
|
32
32
|
onLogout: () => {},
|
|
33
33
|
}
|
|
@@ -39,8 +39,14 @@ const modalDivId: string = 'tfr-modal'
|
|
|
39
39
|
const tfr = await initFittingRoom(shopId, modalDivId, hooks)
|
|
40
40
|
|
|
41
41
|
// on page nav to new product
|
|
42
|
+
// * Required for VTO
|
|
42
43
|
tfr.setSku(sku)
|
|
43
44
|
|
|
45
|
+
// on user login to brand site
|
|
46
|
+
// * Required for VTO
|
|
47
|
+
// e.g. uuid, email address, username, internal database Id
|
|
48
|
+
tft.setBrandUserId(brandUserId)
|
|
49
|
+
|
|
44
50
|
// close the modal
|
|
45
51
|
tfr.close()
|
|
46
52
|
```
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* thefittingroom v0.0.
|
|
2
|
+
* thefittingroom v0.0.16 (2023-11-20T17:29:10.547Z)
|
|
3
3
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/*!
|
|
6
|
-
* thefittingroom v0.0.
|
|
6
|
+
* thefittingroom v0.0.11 (2023-09-04T22:52:56.755Z)
|
|
7
7
|
* Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
@@ -22772,6 +22772,12 @@ class RecommendedAvailableSizesError extends Error {
|
|
|
22772
22772
|
this.available_sizes = available_sizes;
|
|
22773
22773
|
}
|
|
22774
22774
|
}
|
|
22775
|
+
class BrandUserIdNotSetError extends Error {
|
|
22776
|
+
constructor() {
|
|
22777
|
+
super('brand user id not set');
|
|
22778
|
+
this.name = 'BrandUserIdNotSetError';
|
|
22779
|
+
}
|
|
22780
|
+
}
|
|
22775
22781
|
// Backend responses
|
|
22776
22782
|
const AvatarNotCreated = 'avatar not created';
|
|
22777
22783
|
|
|
@@ -22784,12 +22790,14 @@ var errors = /*#__PURE__*/Object.freeze({
|
|
|
22784
22790
|
NoColorwaySizeAssetsFoundError: NoColorwaySizeAssetsFoundError,
|
|
22785
22791
|
NoStylesFoundError: NoStylesFoundError,
|
|
22786
22792
|
RecommendedAvailableSizesError: RecommendedAvailableSizesError,
|
|
22793
|
+
BrandUserIdNotSetError: BrandUserIdNotSetError,
|
|
22787
22794
|
AvatarNotCreated: AvatarNotCreated
|
|
22788
22795
|
});
|
|
22789
22796
|
|
|
22790
22797
|
class FirebaseUser {
|
|
22791
22798
|
constructor(firestore, app) {
|
|
22792
22799
|
this.firestore = firestore;
|
|
22800
|
+
this.brandUserId = null;
|
|
22793
22801
|
this.auth = getAuth(app);
|
|
22794
22802
|
this.auth.setPersistence(browserLocalPersistence);
|
|
22795
22803
|
}
|
|
@@ -22809,6 +22817,9 @@ class FirebaseUser {
|
|
|
22809
22817
|
setUser(user) {
|
|
22810
22818
|
this.user = user;
|
|
22811
22819
|
}
|
|
22820
|
+
setBrandUserId(brandUserId) {
|
|
22821
|
+
this.brandUserId = brandUserId;
|
|
22822
|
+
}
|
|
22812
22823
|
async getToken() {
|
|
22813
22824
|
var _a;
|
|
22814
22825
|
if (!((_a = this.user) === null || _a === void 0 ? void 0 : _a.uid))
|
|
@@ -23112,7 +23123,11 @@ class TfrShop {
|
|
|
23112
23123
|
async requestColorwaySizeAssetFrames(colorwaySizeAssetId) {
|
|
23113
23124
|
if (!this.isLoggedIn)
|
|
23114
23125
|
throw new UserNotLoggedInError();
|
|
23115
|
-
|
|
23126
|
+
if (!this.user.brandUserId)
|
|
23127
|
+
throw new BrandUserIdNotSetError();
|
|
23128
|
+
await Fetcher.Post(this.user, `/colorway-size-assets/${colorwaySizeAssetId}/frames`, {
|
|
23129
|
+
brand_user_id: String(this.user.brandUserId),
|
|
23130
|
+
});
|
|
23116
23131
|
}
|
|
23117
23132
|
async getColorwaySizeAssetFrames(colorwaySizeAssetSKU) {
|
|
23118
23133
|
var _a, _b, _c;
|
|
@@ -23191,6 +23206,7 @@ const InitImageSlider = (sliderID, onChange) => {
|
|
|
23191
23206
|
var L = {
|
|
23192
23207
|
AssociatedEmail: 'If there is an account associated with that email, We have sent a link to reset your password.',
|
|
23193
23208
|
BackToSignIn: 'Back to sign in',
|
|
23209
|
+
BrandUserIdNotSet: 'User not logged in to brand site.',
|
|
23194
23210
|
CreateAvatarSc: 'Scan the QR code/click link to download our app and create an avatar:',
|
|
23195
23211
|
DontHaveAcc: "Don't have an account?",
|
|
23196
23212
|
DontHaveAvatar: "Whoops! Looks like you don't have an avatar yet.",
|
|
@@ -36205,9 +36221,10 @@ var AvatarState;
|
|
|
36205
36221
|
})(AvatarState || (AvatarState = {}));
|
|
36206
36222
|
|
|
36207
36223
|
class FittingRoom {
|
|
36208
|
-
constructor(shopId, modalDivId, hooks = {}, _env) {
|
|
36224
|
+
constructor(shopId, modalDivId, hooks = {}, tryOnEnabled = false, _env) {
|
|
36209
36225
|
this.shopId = shopId;
|
|
36210
36226
|
this.hooks = hooks;
|
|
36227
|
+
this.tryOnEnabled = tryOnEnabled;
|
|
36211
36228
|
// prettier-ignore
|
|
36212
36229
|
const env = _env
|
|
36213
36230
|
? _env
|
|
@@ -36270,7 +36287,8 @@ class FittingRoom {
|
|
|
36270
36287
|
break;
|
|
36271
36288
|
case AvatarState.CREATED:
|
|
36272
36289
|
console.debug('avatar_state: created');
|
|
36273
|
-
this.
|
|
36290
|
+
if (this.tryOnEnabled)
|
|
36291
|
+
this.tryOn();
|
|
36274
36292
|
break;
|
|
36275
36293
|
default:
|
|
36276
36294
|
this.nav.onError(L.SomethingWentWrong);
|
|
@@ -36281,6 +36299,9 @@ class FittingRoom {
|
|
|
36281
36299
|
this.nav.onError(L.SomethingWentWrong);
|
|
36282
36300
|
}
|
|
36283
36301
|
}
|
|
36302
|
+
setBrandUserId(brandUserId) {
|
|
36303
|
+
this.tfrShop.user.setBrandUserId(brandUserId);
|
|
36304
|
+
}
|
|
36284
36305
|
async submitTel(tel) {
|
|
36285
36306
|
try {
|
|
36286
36307
|
await this.tfrShop.submitTelephoneNumber(tel);
|
|
@@ -36307,9 +36328,14 @@ class FittingRoom {
|
|
|
36307
36328
|
const trySizes = availableSizeLabels.length > 1 ? `${tryFirstSizes} ${L.OrSize} ${lastSize}` : tryFirstSizes;
|
|
36308
36329
|
return `${trySizes}. ${L.WeRecommendSize} ${recommendedSizeLabel}.`;
|
|
36309
36330
|
}
|
|
36331
|
+
onSignInClick() {
|
|
36332
|
+
this.nav.toScan();
|
|
36333
|
+
}
|
|
36310
36334
|
async tryOn() {
|
|
36311
36335
|
if (!this.shop.isLoggedIn)
|
|
36312
36336
|
return this.nav.toScan();
|
|
36337
|
+
if (!this.tryOnEnabled)
|
|
36338
|
+
return;
|
|
36313
36339
|
try {
|
|
36314
36340
|
if (this.hooks.onLoading)
|
|
36315
36341
|
this.hooks.onLoading();
|
|
@@ -36319,6 +36345,8 @@ class FittingRoom {
|
|
|
36319
36345
|
this.hooks.onVtoReady(frames);
|
|
36320
36346
|
}
|
|
36321
36347
|
catch (error) {
|
|
36348
|
+
if (error instanceof errors.BrandUserIdNotSetError)
|
|
36349
|
+
return this.nav.onError(L.BrandUserIdNotSet);
|
|
36322
36350
|
if (error instanceof errors.AvatarNotCreatedError)
|
|
36323
36351
|
return this.nav.onError(L.DontHaveAvatar);
|
|
36324
36352
|
if (error instanceof errors.RecommendedAvailableSizesError)
|