@dotdev/next-components
Advanced tools
Comparing version 0.4.4 to 0.4.5
@@ -47,3 +47,7 @@ "use strict"; | ||
}; | ||
this.requestURL = function (url) { return "" + (window.location.href.includes("localhost") ? "https://app.developertoolkit.io/api/client" : "/apps/toolkit/client") + url + "?shop=" + _this.shop.domain; }; | ||
this.requestURL = function (url) { | ||
return "" + (window.location.href.includes("localhost") | ||
? "https://app.developertoolkit.io/api/client" | ||
: "/apps/toolkit/client") + url + "?shop=" + _this.shop.domain; | ||
}; | ||
this.getProducts = function (productsIds) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -50,0 +54,0 @@ var err_1; |
@@ -54,8 +54,19 @@ "use strict"; | ||
_this.active = match.path === "/apps/toolkit/wishlist/:id"; | ||
_this.myId = data.customer ? data.customer.id : _this.cookies.get("dtk_guest_id"); | ||
_this.activeId = _this.active && match.params.id.length ? match.params.id : _this.myId; | ||
_this.type = data.customer ? "Your" : _this.activeId === _this.myId ? "Guest" : "Shared"; | ||
_this.myId = data.customer | ||
? data.customer.id | ||
: _this.cookies.get("dtk_guest_id"); | ||
_this.activeId = | ||
_this.active && match.params.id.length ? match.params.id : _this.myId; | ||
_this.type = data.customer | ||
? "Your" | ||
: _this.activeId === _this.myId | ||
? "Guest" | ||
: "Shared"; | ||
_this.getWishlist(); | ||
}; | ||
this.requestURL = function (url) { return "" + (window.location.href.includes("localhost") ? "https://app.developertoolkit.io/api/client" : "/apps/toolkit/client") + url + "?shop=" + _this.shop.domain; }; | ||
this.requestURL = function (url) { | ||
return "" + (window.location.href.includes("localhost") | ||
? "https://app.developertoolkit.io/api/client" | ||
: "/apps/toolkit/client") + url + "?shop=" + _this.shop.domain; | ||
}; | ||
this.getID = function () { return _this.myId; }; | ||
@@ -105,7 +116,11 @@ this.getActiveID = function () { return _this.activeId; }; | ||
this.toggleItem = function (productId, variantId) { | ||
_this.checkItem(productId, variantId) ? _this.removeItem(productId, variantId) : _this.addItem(productId, variantId); | ||
_this.checkItem(productId, variantId) | ||
? _this.removeItem(productId, variantId) | ||
: _this.addItem(productId, variantId); | ||
}; | ||
this.checkItem = function (productId, variantId) { | ||
var items = JSON.parse(localStorage.getItem(_this.wishlistKey)).items; | ||
return items.filter(function (item) { return parseInt(item.variantId) == variantId; }).length; | ||
var local = localStorage.getItem(_this.wishlistKey); | ||
var items = JSON.parse(local) ? JSON.parse(local).items : []; | ||
return items.length ? items.filter(function (item) { return parseInt(item.variantId) == variantId; }) | ||
.length : false; | ||
}; | ||
@@ -146,4 +161,3 @@ this.addItem = function (productId, variantId) { | ||
} | ||
}) | ||
.then(function (data) { | ||
}).then(function (data) { | ||
_this.context.update({ | ||
@@ -198,2 +212,3 @@ message: "WISHLIST_ITEM_REMOVED_SUCCESS" | ||
return [4 /*yield*/, fetch(this.requestURL("/wishlist/" + this.activeId + "/share/" + type), { | ||
// link, email, sms | ||
credentials: "same-origin", | ||
@@ -200,0 +215,0 @@ method: "POST", |
{ | ||
"name": "@dotdev/next-components", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"license": "UNLICENSED", | ||
@@ -5,0 +5,0 @@ "description": "Common components for Next projects", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118549
1777