@dotdev/next-components
Advanced tools
Comparing version 1.1.4 to 1.2.0
@@ -26,9 +26,2 @@ "use strict"; | ||
}; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -51,3 +44,3 @@ var React = require("react"); | ||
var _a; | ||
return (__assign(__assign({}, allBlocks), (_a = {}, _a[blockKey] = (item[blockKey] || []).map(function (block, i) { return ({ | ||
return (__assign({}, allBlocks, (_a = {}, _a[blockKey] = (item[blockKey] || []).map(function (block, i) { return ({ | ||
id: i, | ||
@@ -106,3 +99,3 @@ type: "default", | ||
return (React.createElement("main", { className: this.props.className }, this.sections(this.props.dtkSections | ||
? this.transform(__spreadArrays(this.props.dtkSections)) | ||
? this.transform(this.props.dtkSections.slice()) | ||
: this.props.data.sections))); | ||
@@ -109,0 +102,0 @@ }; |
@@ -10,4 +10,12 @@ import "whatwg-fetch"; | ||
addItem: (id: number, qty: number, properties?: any) => Promise<void>; | ||
addItems: (items: { | ||
id: number; | ||
qty: number; | ||
properties?: any; | ||
}[]) => Promise<void>; | ||
removeItem: (key: string) => Promise<void>; | ||
updateQty: (key: string, qty: number) => Promise<void>; | ||
updateProperties: (key: string, properties: { | ||
[key: string]: string; | ||
}) => Promise<void>; | ||
updateVariant: (key: string, id: number, qty: number) => Promise<void>; | ||
@@ -14,0 +22,0 @@ getCart: () => Promise<void>; |
@@ -14,7 +14,6 @@ "use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -101,4 +100,5 @@ }); | ||
}); }; | ||
this.removeItem = function (key) { return __awaiter(_this, void 0, void 0, function () { | ||
this.addItems = function (items) { return __awaiter(_this, void 0, void 0, function () { | ||
var response, err_2; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -108,2 +108,35 @@ switch (_a.label) { | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, Promise.all(items.map(function (item) { | ||
return _this.cart.addItem(item.id, __assign({ quantity: item.qty }, item.properties)); | ||
}))]; | ||
case 1: | ||
response = _a.sent(); | ||
this.context.update({ message: "CART_ITEM_ADDED_SUCCESS" }); | ||
this.getCartJSON(); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
err_2 = _a.sent(); | ||
if (err_2.status == 422) { | ||
this.context.update({ | ||
message: "CART_ITEM_ADDED_QTY_NOT_AVAILABLE", | ||
error: err_2.message | ||
}); | ||
} | ||
else { | ||
this.context.update({ | ||
message: "CART_ITEM_ADDED_FAILED", | ||
error: err_2.message | ||
}); | ||
} | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
this.removeItem = function (key) { return __awaiter(_this, void 0, void 0, function () { | ||
var response, err_3; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.cart.removeItem(key)]; | ||
@@ -116,6 +149,6 @@ case 1: | ||
case 2: | ||
err_2 = _a.sent(); | ||
err_3 = _a.sent(); | ||
this.context.update({ | ||
message: "CART_ITEM_REMOVED_FAILED", | ||
error: err_2.message | ||
error: err_3.message | ||
}); | ||
@@ -128,3 +161,3 @@ return [3 /*break*/, 3]; | ||
this.updateQty = function (key, qty) { return __awaiter(_this, void 0, void 0, function () { | ||
var response, err_3; | ||
var response, err_4; | ||
return __generator(this, function (_a) { | ||
@@ -141,6 +174,6 @@ switch (_a.label) { | ||
case 2: | ||
err_3 = _a.sent(); | ||
err_4 = _a.sent(); | ||
this.context.update({ | ||
message: "CART_QTY_UPDATE_FAILED", | ||
error: err_3.message | ||
error: err_4.message | ||
}); | ||
@@ -152,4 +185,29 @@ return [3 /*break*/, 3]; | ||
}); }; | ||
this.updateProperties = function (key, properties) { return __awaiter(_this, void 0, void 0, function () { | ||
var response, err_5; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.cart.updateItem(key, { | ||
properties: properties | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
this.context.update({ message: "CART_PROPERTIES_UPDATE_SUCCESS" }); | ||
this.getCartJSON(); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
err_5 = _a.sent(); | ||
this.context.update({ | ||
message: "CART_PROPERTIES_UPDATE_FAILED", | ||
error: err_5.message | ||
}); | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
this.updateVariant = function (key, id, qty) { return __awaiter(_this, void 0, void 0, function () { | ||
var response, err_4; | ||
var response, err_6; | ||
return __generator(this, function (_a) { | ||
@@ -171,6 +229,6 @@ switch (_a.label) { | ||
case 4: | ||
err_4 = _a.sent(); | ||
err_6 = _a.sent(); | ||
this.context.update({ | ||
message: "CART_VARIANT_UPDATE_FAILED", | ||
error: err_4.message | ||
error: err_6.message | ||
}); | ||
@@ -183,3 +241,3 @@ return [3 /*break*/, 5]; | ||
this.getCart = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response, err_5; | ||
var response, err_7; | ||
return __generator(this, function (_a) { | ||
@@ -195,6 +253,6 @@ switch (_a.label) { | ||
case 2: | ||
err_5 = _a.sent(); | ||
err_7 = _a.sent(); | ||
this.context.update({ | ||
message: "CART_REQUEST_FAILED", | ||
error: err_5.message | ||
error: err_7.message | ||
}); | ||
@@ -207,3 +265,3 @@ return [3 /*break*/, 3]; | ||
this.updateNote = function (note) { return __awaiter(_this, void 0, void 0, function () { | ||
var response, err_6; | ||
var response, err_8; | ||
return __generator(this, function (_a) { | ||
@@ -220,6 +278,6 @@ switch (_a.label) { | ||
case 2: | ||
err_6 = _a.sent(); | ||
err_8 = _a.sent(); | ||
this.context.update({ | ||
message: "CART_NOTE_UPDATE_FAILED", | ||
error: err_6.message | ||
error: err_8.message | ||
}); | ||
@@ -232,3 +290,3 @@ return [3 /*break*/, 3]; | ||
this.clearNote = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response, err_7; | ||
var response, err_9; | ||
return __generator(this, function (_a) { | ||
@@ -245,6 +303,6 @@ switch (_a.label) { | ||
case 2: | ||
err_7 = _a.sent(); | ||
err_9 = _a.sent(); | ||
this.context.update({ | ||
message: "CART_NOTE_CLEARED_FAILED", | ||
error: err_7.message | ||
error: err_9.message | ||
}); | ||
@@ -257,3 +315,3 @@ return [3 /*break*/, 3]; | ||
this.clearCart = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response, err_8; | ||
var response, err_10; | ||
return __generator(this, function (_a) { | ||
@@ -270,6 +328,6 @@ switch (_a.label) { | ||
case 2: | ||
err_8 = _a.sent(); | ||
err_10 = _a.sent(); | ||
this.context.update({ | ||
message: "CART_CLEARED_FAILED", | ||
error: err_8.message | ||
error: err_10.message | ||
}); | ||
@@ -276,0 +334,0 @@ return [3 /*break*/, 3]; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -9,0 +8,0 @@ }); |
@@ -20,2 +20,4 @@ export declare class Notifications { | ||
CART_QTY_UPDATE_FAILED: string; | ||
CART_PROPERTIES_UPDATE_SUCCESS: string; | ||
CART_PROPERTIES_UPDATE_FAILED: string; | ||
CART_VARIANT_UPDATE_SUCCESS: string; | ||
@@ -22,0 +24,0 @@ CART_VARIANT_UPDATE_FAILED: string; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -9,0 +8,0 @@ }); |
@@ -35,3 +35,3 @@ "use strict"; | ||
_this.setState(function (state) { return ({ | ||
state: __assign(__assign({}, state.state), newState) | ||
state: __assign({}, state.state, newState) | ||
}); }); | ||
@@ -38,0 +38,0 @@ }; |
@@ -13,9 +13,2 @@ "use strict"; | ||
}; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -46,3 +39,3 @@ require("url-search-params-polyfill"); | ||
ShopifyNext.prototype.parse = function () { | ||
return __assign(__assign({}, this.parseShopifyData()), this.parseShopifySections()); | ||
return __assign({}, this.parseShopifyData(), this.parseShopifySections()); | ||
}; | ||
@@ -73,3 +66,3 @@ ShopifyNext.prototype.parseShopifyData = function () { | ||
return !objectType | ||
? __assign(__assign({}, result), (_a = {}, _a[scriptProperty] = scriptData, _a)) : __assign(__assign({}, result), (_b = {}, _b[objectType] = __assign(__assign({}, result[objectType]), (_c = {}, _c[objectKey] = scriptData, _c)), _b)); | ||
? __assign({}, result, (_a = {}, _a[scriptProperty] = scriptData, _a)) : __assign({}, result, (_b = {}, _b[objectType] = __assign({}, result[objectType], (_c = {}, _c[objectKey] = scriptData, _c)), _b)); | ||
}, {}); | ||
@@ -97,3 +90,3 @@ if (searchParamView) | ||
return scriptData.type == "static" | ||
? __assign(__assign({}, result), (_a = {}, _a[scriptProperty] = scriptData, _a)) : result; | ||
? __assign({}, result, (_a = {}, _a[scriptProperty] = scriptData, _a)) : result; | ||
}, {}); | ||
@@ -112,3 +105,3 @@ var dynamicSections = Object.values(scriptTags).reduce(function (result, scriptTag) { | ||
} | ||
return scriptData.type == "dynamic" ? __spreadArrays(result, [scriptData]) : result; | ||
return scriptData.type == "dynamic" ? result.concat([scriptData]) : result; | ||
}, []); | ||
@@ -115,0 +108,0 @@ return { |
{ | ||
"name": "@dotdev/next-components", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"license": "SEE LICENSE IN LICENCE.md", | ||
@@ -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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
134706
1949
14