zakeke-configurator-react 0.0.114 → 0.0.116
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.
|
@@ -17,6 +17,11 @@ interface ThemeCompositions {
|
|
|
17
17
|
previewImageUrl: string;
|
|
18
18
|
tags: string[];
|
|
19
19
|
}
|
|
20
|
+
interface CurrentCompositionInfo {
|
|
21
|
+
compositionId: string | null;
|
|
22
|
+
compositionName: string | null;
|
|
23
|
+
compositionTags: string[] | null;
|
|
24
|
+
}
|
|
20
25
|
export declare class ZakekeEnvironment {
|
|
21
26
|
private token;
|
|
22
27
|
private platformAttributesSelection;
|
|
@@ -42,6 +47,7 @@ export declare class ZakekeEnvironment {
|
|
|
42
47
|
private savedCompositions;
|
|
43
48
|
private initialSelection;
|
|
44
49
|
currentAttributesSelection: Object | null;
|
|
50
|
+
currentCompositionInfo: CurrentCompositionInfo | null;
|
|
45
51
|
sellerSettings: SellerSettings | null;
|
|
46
52
|
get internalProduct(): MPlaza.Model | null;
|
|
47
53
|
get internalScene(): Zakeke.Scene | null;
|
|
@@ -79,6 +85,7 @@ export declare class ZakekeEnvironment {
|
|
|
79
85
|
private getFonts;
|
|
80
86
|
private getSettings;
|
|
81
87
|
private getSellerSetting;
|
|
88
|
+
createQuote: (formData: any) => Promise<any>;
|
|
82
89
|
private loadScript;
|
|
83
90
|
boot: (parameters?: any) => Promise<void>;
|
|
84
91
|
appendViewer: (container: HTMLElement) => void;
|
|
@@ -50,9 +50,15 @@ export interface ProviderValue {
|
|
|
50
50
|
formatString: string;
|
|
51
51
|
}[] | null;
|
|
52
52
|
currentAttributesSelection: object | null;
|
|
53
|
+
currentCompositionInfo: {
|
|
54
|
+
compositionId: string | null;
|
|
55
|
+
compositionName: string | null;
|
|
56
|
+
compositionTags: string[] | null;
|
|
57
|
+
} | null;
|
|
53
58
|
selectOption: (optionId: number) => void;
|
|
54
59
|
internalAppendViewer: (container: HTMLElement) => void;
|
|
55
60
|
designUpdate: () => void;
|
|
61
|
+
createQuote: (formData: any) => Promise<any>;
|
|
56
62
|
setTemplate: (templateId: number) => void;
|
|
57
63
|
isAreaVisible: (areaId: number) => boolean;
|
|
58
64
|
quantity: number;
|
package/dist/index.js
CHANGED
|
@@ -24935,6 +24935,7 @@ class ZakekeEnvironment {
|
|
|
24935
24935
|
this.sharedCompositionDocId = null;
|
|
24936
24936
|
this.savedCompositions = null;
|
|
24937
24937
|
this.currentAttributesSelection = null;
|
|
24938
|
+
this.currentCompositionInfo = null;
|
|
24938
24939
|
this.sellerSettings = null;
|
|
24939
24940
|
this.themeCompositions = null;
|
|
24940
24941
|
this.currency = 'EUR';
|
|
@@ -25184,6 +25185,23 @@ class ZakekeEnvironment {
|
|
|
25184
25185
|
resolve(sellerSetting);
|
|
25185
25186
|
}));
|
|
25186
25187
|
});
|
|
25188
|
+
// Create quote for composition
|
|
25189
|
+
this.createQuote = (formData) => __awaiter(this, void 0, void 0, function* () {
|
|
25190
|
+
var _c, _d;
|
|
25191
|
+
let quote = new _models__WEBPACK_IMPORTED_MODULE_10__.Quote();
|
|
25192
|
+
quote.formData = JSON.stringify(formData);
|
|
25193
|
+
quote.quantity = this.quantity;
|
|
25194
|
+
quote.compositionDocID = this.composition.get('docID');
|
|
25195
|
+
quote.modelPrice = (_c = yield this.integration.getPrice(this.composition, this.zkProduct, this.platformAttributesSelection, 0, 1)) !== null && _c !== void 0 ? _c : 0;
|
|
25196
|
+
quote.variantName = (_d = this.product.name) !== null && _d !== void 0 ? _d : "";
|
|
25197
|
+
try {
|
|
25198
|
+
const quoteCreated = (yield _api__WEBPACK_IMPORTED_MODULE_3__.axiosApi.post(Zakeke.config.baseApiUrl + "quotes", quote)).data;
|
|
25199
|
+
return quoteCreated;
|
|
25200
|
+
}
|
|
25201
|
+
catch (ex) {
|
|
25202
|
+
throw "Failed create quotation";
|
|
25203
|
+
}
|
|
25204
|
+
});
|
|
25187
25205
|
this.loadScript = (src) => __awaiter(this, void 0, void 0, function* () {
|
|
25188
25206
|
return new Promise((resolve, reject) => {
|
|
25189
25207
|
var script = document.createElement("script");
|
|
@@ -25193,7 +25211,7 @@ class ZakekeEnvironment {
|
|
|
25193
25211
|
});
|
|
25194
25212
|
});
|
|
25195
25213
|
this.boot = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
25196
|
-
var
|
|
25214
|
+
var _e, _f;
|
|
25197
25215
|
this.parseParameters(parameters);
|
|
25198
25216
|
(0,_api__WEBPACK_IMPORTED_MODULE_3__.setupApi)(this.culture, this.token);
|
|
25199
25217
|
this.settings = yield this.getSettings();
|
|
@@ -25216,7 +25234,7 @@ class ZakekeEnvironment {
|
|
|
25216
25234
|
this.trigger("change");
|
|
25217
25235
|
this.zkTemplates = yield this.getTemplates();
|
|
25218
25236
|
this.templates = this.zkTemplates.map(zkTemplate => _models__WEBPACK_IMPORTED_MODULE_10__.Template.fromTemplate(zkTemplate));
|
|
25219
|
-
this.cameras = (
|
|
25237
|
+
this.cameras = (_f = (_e = this.zkScene) === null || _e === void 0 ? void 0 : _e.get('cameraLocations').map(x => _models__WEBPACK_IMPORTED_MODULE_10__.Camera.fromZkCamera(x))) !== null && _f !== void 0 ? _f : [];
|
|
25220
25238
|
this.trigger("change");
|
|
25221
25239
|
this.viewer = yield _3D_src__WEBPACK_IMPORTED_MODULE_2__.SceneViewer.createSceneViewerAsync();
|
|
25222
25240
|
this.viewer.addBeginAssetsLoadingListener(() => {
|
|
@@ -26249,10 +26267,10 @@ class ZakekeEnvironment {
|
|
|
26249
26267
|
})).data;
|
|
26250
26268
|
});
|
|
26251
26269
|
this.getPDF = () => __awaiter(this, void 0, void 0, function* () {
|
|
26252
|
-
var
|
|
26270
|
+
var _g;
|
|
26253
26271
|
const data = yield this.getScreenshot(2048, 2048);
|
|
26254
26272
|
const items = this.getDesignItemsInfo();
|
|
26255
|
-
const areas = (
|
|
26273
|
+
const areas = (_g = this.product) === null || _g === void 0 ? void 0 : _g.areas.filter(x => this.isAreaVisible(x.id)).map(x => ({
|
|
26256
26274
|
name: x.name,
|
|
26257
26275
|
textItems: items.filter(i => i.areaId == x.id && i.type === ___WEBPACK_IMPORTED_MODULE_1__.ItemType.Text)
|
|
26258
26276
|
})).filter(x => x.textItems.length > 0);
|
|
@@ -26293,8 +26311,8 @@ class ZakekeEnvironment {
|
|
|
26293
26311
|
this.getShareCompositionUrl = () => __awaiter(this, void 0, void 0, function* () {
|
|
26294
26312
|
// salvo (e riassegno dopo la creazione dello share url) l'id , per evitare problemi in caso di add to cart e edit
|
|
26295
26313
|
// in questo modo ogni composizione condivisa è sempre diversa da quella di partenza
|
|
26296
|
-
var
|
|
26297
|
-
const isDraft = (
|
|
26314
|
+
var _h;
|
|
26315
|
+
const isDraft = (_h = this.composition.get("isDraft")) !== null && _h !== void 0 ? _h : false;
|
|
26298
26316
|
this.composition.set("isDraft", false);
|
|
26299
26317
|
const docID = yield this.saveCompositionCopy();
|
|
26300
26318
|
this.composition.set("isDraft", isDraft);
|
|
@@ -26529,9 +26547,9 @@ class ZakekeEnvironment {
|
|
|
26529
26547
|
});
|
|
26530
26548
|
};
|
|
26531
26549
|
this.getDisableTextColors = () => __awaiter(this, void 0, void 0, function* () {
|
|
26532
|
-
var
|
|
26550
|
+
var _j, _k;
|
|
26533
26551
|
try {
|
|
26534
|
-
let disableTextColors = (
|
|
26552
|
+
let disableTextColors = (_k = (_j = this.zkProduct.get("printTypes").at(0).get("printTypeRestrictions")) === null || _j === void 0 ? void 0 : _j.get("disableTextColors")) !== null && _k !== void 0 ? _k : false;
|
|
26535
26553
|
return disableTextColors;
|
|
26536
26554
|
}
|
|
26537
26555
|
catch (ex) {
|
|
@@ -26540,9 +26558,9 @@ class ZakekeEnvironment {
|
|
|
26540
26558
|
}
|
|
26541
26559
|
});
|
|
26542
26560
|
this.getTextColors = () => __awaiter(this, void 0, void 0, function* () {
|
|
26543
|
-
var
|
|
26561
|
+
var _l, _m;
|
|
26544
26562
|
try {
|
|
26545
|
-
let textColors = (
|
|
26563
|
+
let textColors = (_m = (_l = this.zkProduct.get("printTypes").at(0).get("printTypeRestrictions")) === null || _l === void 0 ? void 0 : _l.get("textColors")) !== null && _m !== void 0 ? _m : [];
|
|
26546
26564
|
return textColors;
|
|
26547
26565
|
}
|
|
26548
26566
|
catch (ex) {
|
|
@@ -26551,9 +26569,9 @@ class ZakekeEnvironment {
|
|
|
26551
26569
|
}
|
|
26552
26570
|
});
|
|
26553
26571
|
this.getDefaultColor = () => __awaiter(this, void 0, void 0, function* () {
|
|
26554
|
-
var
|
|
26572
|
+
var _o, _p;
|
|
26555
26573
|
try {
|
|
26556
|
-
let defaultColor = (
|
|
26574
|
+
let defaultColor = (_p = (_o = this.zkProduct.get("printTypes").at(0).get("printTypeRestrictions")) === null || _o === void 0 ? void 0 : _o.get("defaultColor")) !== null && _p !== void 0 ? _p : '#000000';
|
|
26557
26575
|
return defaultColor;
|
|
26558
26576
|
}
|
|
26559
26577
|
catch (ex) {
|
|
@@ -26562,7 +26580,7 @@ class ZakekeEnvironment {
|
|
|
26562
26580
|
}
|
|
26563
26581
|
});
|
|
26564
26582
|
this.saveComposition = (customPreviewSize, legacyScreenshot) => __awaiter(this, void 0, void 0, function* () {
|
|
26565
|
-
var
|
|
26583
|
+
var _q, _r;
|
|
26566
26584
|
console.log("Saving...");
|
|
26567
26585
|
// Restore camera position
|
|
26568
26586
|
if (this.getCameraByName('buy_screenshot_camera'))
|
|
@@ -26571,7 +26589,7 @@ class ZakekeEnvironment {
|
|
|
26571
26589
|
this.viewer.restoreCameraState();
|
|
26572
26590
|
yield (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.sleep)(1);
|
|
26573
26591
|
// Save image
|
|
26574
|
-
const data = yield this.viewer.getSceneContentScreenshotAsync((
|
|
26592
|
+
const data = yield this.viewer.getSceneContentScreenshotAsync((_q = customPreviewSize === null || customPreviewSize === void 0 ? void 0 : customPreviewSize.customCartPreviewHeight) !== null && _q !== void 0 ? _q : this.previewWidth, (_r = customPreviewSize === null || customPreviewSize === void 0 ? void 0 : customPreviewSize.customCartPreviewWidth) !== null && _r !== void 0 ? _r : this.previewHeight, 0, this.zkCurrentTemplate, legacyScreenshot);
|
|
26575
26593
|
this.composition.set("previewImageData", data);
|
|
26576
26594
|
// Save composition
|
|
26577
26595
|
yield this.saveDesignBackbone();
|
|
@@ -26589,10 +26607,19 @@ class ZakekeEnvironment {
|
|
|
26589
26607
|
this.templates = yield this.getTemplates();
|
|
26590
26608
|
this.setTemplate(this.templates[0].id);
|
|
26591
26609
|
}
|
|
26610
|
+
if (!this.currentCompositionInfo)
|
|
26611
|
+
this.currentCompositionInfo = {
|
|
26612
|
+
compositionId: "",
|
|
26613
|
+
compositionName: "",
|
|
26614
|
+
compositionTags: []
|
|
26615
|
+
};
|
|
26616
|
+
this.currentCompositionInfo.compositionId = this.compositionId;
|
|
26617
|
+
this.currentCompositionInfo.compositionName = this.composition.get("name");
|
|
26618
|
+
this.currentCompositionInfo.compositionTags = this.composition.get("tags");
|
|
26592
26619
|
});
|
|
26593
26620
|
this.loadSavedComposition = (docID) => __awaiter(this, void 0, void 0, function* () {
|
|
26594
|
-
var
|
|
26595
|
-
const composition = (
|
|
26621
|
+
var _s;
|
|
26622
|
+
const composition = (_s = this.savedCompositions) === null || _s === void 0 ? void 0 : _s.find(x => x.docID == docID);
|
|
26596
26623
|
if (composition)
|
|
26597
26624
|
yield this.bootstrapComposition(new MPlaza.Composition(composition));
|
|
26598
26625
|
});
|
|
@@ -27446,6 +27473,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
27446
27473
|
/* harmony export */ "Product": () => (/* reexport safe */ _models__WEBPACK_IMPORTED_MODULE_4__.Product),
|
|
27447
27474
|
/* harmony export */ "ProductArea": () => (/* reexport safe */ _models__WEBPACK_IMPORTED_MODULE_4__.ProductArea),
|
|
27448
27475
|
/* harmony export */ "ProductQuantityRule": () => (/* reexport safe */ _models__WEBPACK_IMPORTED_MODULE_4__.ProductQuantityRule),
|
|
27476
|
+
/* harmony export */ "Quote": () => (/* reexport safe */ _models__WEBPACK_IMPORTED_MODULE_4__.Quote),
|
|
27449
27477
|
/* harmony export */ "QuoteRule": () => (/* reexport safe */ _models__WEBPACK_IMPORTED_MODULE_4__.QuoteRule),
|
|
27450
27478
|
/* harmony export */ "Step": () => (/* reexport safe */ _models__WEBPACK_IMPORTED_MODULE_4__.Step),
|
|
27451
27479
|
/* harmony export */ "Template": () => (/* reexport safe */ _models__WEBPACK_IMPORTED_MODULE_4__.Template),
|
|
@@ -27684,6 +27712,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
27684
27712
|
/* harmony export */ "Product": () => (/* binding */ Product),
|
|
27685
27713
|
/* harmony export */ "ProductArea": () => (/* binding */ ProductArea),
|
|
27686
27714
|
/* harmony export */ "ProductQuantityRule": () => (/* binding */ ProductQuantityRule),
|
|
27715
|
+
/* harmony export */ "Quote": () => (/* binding */ Quote),
|
|
27687
27716
|
/* harmony export */ "QuoteRule": () => (/* binding */ QuoteRule),
|
|
27688
27717
|
/* harmony export */ "Step": () => (/* binding */ Step),
|
|
27689
27718
|
/* harmony export */ "Template": () => (/* binding */ Template),
|
|
@@ -27747,6 +27776,13 @@ class QuoteRule {
|
|
|
27747
27776
|
this.products = quoteRule.products;
|
|
27748
27777
|
}
|
|
27749
27778
|
}
|
|
27779
|
+
class Quote {
|
|
27780
|
+
constructor() {
|
|
27781
|
+
this.statusID = 1;
|
|
27782
|
+
this.quantity = 1;
|
|
27783
|
+
this.modelPrice = 0;
|
|
27784
|
+
}
|
|
27785
|
+
}
|
|
27750
27786
|
class ProductArea {
|
|
27751
27787
|
static fromSide(modelSide) {
|
|
27752
27788
|
let area = new ProductArea();
|
|
@@ -28187,6 +28223,7 @@ const createProviderValue = (state, dispatch) => {
|
|
|
28187
28223
|
eventMessages: state.environment.eventMessages,
|
|
28188
28224
|
isAssetsLoading: state.environment.isAssetsLoading,
|
|
28189
28225
|
extensionFields: state.environment.extensionFields,
|
|
28226
|
+
currentCompositionInfo: state.environment.currentCompositionInfo,
|
|
28190
28227
|
saveComposition: state.environment.saveComposition,
|
|
28191
28228
|
loadComposition: state.environment.loadComposition,
|
|
28192
28229
|
getPDF: state.environment.getPDF.bind(state.environment),
|
|
@@ -28200,6 +28237,7 @@ const createProviderValue = (state, dispatch) => {
|
|
|
28200
28237
|
setQuantity: state.environment.setQuantity.bind(state.environment),
|
|
28201
28238
|
getImages: state.environment.getImages.bind(state.environment),
|
|
28202
28239
|
getMacroCategories: state.environment.getMacroCategories.bind(state.environment),
|
|
28240
|
+
createQuote: state.environment.createQuote,
|
|
28203
28241
|
previewOnly__setItemImageFromBase64: (guid, base64) => __awaiter(void 0, void 0, void 0, function* () { return dispatch({ type: 'SET_ITEM_IMAGE_FROM_BASE64', guid, base64 }); }),
|
|
28204
28242
|
setItemImageFromFile: (guid, file) => __awaiter(void 0, void 0, void 0, function* () { return dispatch({ type: 'SET_ITEM_IMAGE_FROM_FILE', guid, file }); }),
|
|
28205
28243
|
addItemImage: (imageId, areaId) => __awaiter(void 0, void 0, void 0, function* () { return dispatch({ type: 'ADD_ITEM_IMAGE', imageId, areaId }); }),
|