@artaio/arta-browser 2.15.0 → 2.15.1-add-multiple-shipments-trackingdeaad00440cb99f26c53b08202bee5bcc63b9f19
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/ModalStatus.js +1 -1
- package/dist/bundle.js +1 -1
- package/dist/components/Date/SimpleDate.js +1 -12
- package/dist/components/Destination/index.js +3 -14
- package/dist/components/Disqualified/index.js +1 -12
- package/dist/components/DrawerFooter/index.js +1 -12
- package/dist/components/DrawerHeader/index.d.ts +6 -1
- package/dist/components/DrawerHeader/index.js +5 -13
- package/dist/components/DrawerInsurance/index.js +1 -12
- package/dist/components/Footer/index.d.ts +1 -1
- package/dist/components/Footer/index.js +1 -12
- package/dist/components/Header/index.js +1 -12
- package/dist/components/Modal/index.js +4 -4
- package/dist/components/Package/index.d.ts +2 -1
- package/dist/components/Package/index.js +28 -38
- package/dist/components/PackageEvents/index.js +13 -24
- package/dist/components/Pill/index.d.ts +3 -3
- package/dist/components/Pill/index.js +3 -13
- package/dist/components/Quotes/index.js +3 -14
- package/dist/components/SelectTrackingShipment/index.d.ts +9 -0
- package/dist/components/SelectTrackingShipment/index.js +48 -0
- package/dist/components/ShipToFrom/index.js +1 -12
- package/dist/components/ShipmentException/icons/HexagonAlertBase.js +1 -12
- package/dist/components/ShipmentException/icons/HexagonPauseBase.js +1 -12
- package/dist/components/ShipmentException/icons/HexagonStopBase.js +1 -12
- package/dist/components/ShipmentException/index.d.ts +4 -1
- package/dist/components/ShipmentException/index.js +4 -12
- package/dist/components/Summary/index.js +1 -12
- package/dist/components/Timeline/CheckedStep.js +1 -12
- package/dist/components/Timeline/CheckedSteps.js +1 -12
- package/dist/components/Timeline/EmptyStep.js +1 -12
- package/dist/components/Timeline/SecondaryStep.js +1 -12
- package/dist/components/Timeline/SecondarySteps.js +1 -12
- package/dist/components/Timeline/TimelineDefault.js +2 -13
- package/dist/components/Timeline/TimlineMinimal.js +1 -12
- package/dist/components/Timeline/defaultIcons/CancelledIcon.js +1 -12
- package/dist/components/Timeline/defaultIcons/CollectedIcon.js +1 -12
- package/dist/components/Timeline/defaultIcons/CompletedIcon.js +1 -12
- package/dist/components/Timeline/defaultIcons/ConfirmedIcon.js +1 -12
- package/dist/components/Timeline/defaultIcons/InTransitIcon.js +1 -12
- package/dist/components/Timeline/defaultIcons/PendingIcon.js +1 -12
- package/dist/components/Timeline/icons/CancelledIconBase.js +1 -12
- package/dist/components/Timeline/icons/CollectedIconBase.js +1 -12
- package/dist/components/Timeline/icons/CompletedIconBase.js +1 -12
- package/dist/components/Timeline/icons/ConfirmedIconBase.js +1 -12
- package/dist/components/Timeline/icons/InTransitIconBase.js +1 -12
- package/dist/components/Timeline/icons/PendingIconBase.js +1 -12
- package/dist/components/Timeline/index.js +1 -12
- package/dist/components/TrackingDrawer/index.css +104 -15
- package/dist/components/TrackingDrawer/index.d.ts +2 -2
- package/dist/components/TrackingDrawer/index.js +25 -39
- package/dist/components/TrackingShipment/index.d.ts +9 -0
- package/dist/components/TrackingShipment/index.js +73 -0
- package/dist/components/TrackingTop/index.d.ts +4 -0
- package/dist/components/TrackingTop/index.js +50 -62
- package/dist/estimate.js +2 -2
- package/dist/helper.d.ts +6 -0
- package/dist/helper.js +11 -5
- package/dist/requests.js +18 -5
- package/dist/tracking.d.ts +3 -2
- package/dist/tracking.js +53 -10
- package/dist/trackingConfig.d.ts +14 -0
- package/dist/trackingConfig.js +40 -10
- package/package.json +2 -2
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -20,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
15
|
function step(op) {
|
|
27
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -54,45 +43,42 @@ var helper_1 = require("../../helper");
|
|
|
54
43
|
var DrawerHeader_1 = require("../DrawerHeader");
|
|
55
44
|
require("./index.css");
|
|
56
45
|
var requests_1 = require("../../requests");
|
|
57
|
-
var ShipToFrom_1 = require("../ShipToFrom");
|
|
58
|
-
var Package_1 = require("../Package");
|
|
59
|
-
var Timeline_1 = require("../Timeline");
|
|
60
|
-
var TrackingTop_1 = require("../TrackingTop");
|
|
61
46
|
var DrawerFooter_1 = require("../DrawerFooter");
|
|
62
|
-
var
|
|
63
|
-
var
|
|
64
|
-
var ShipmentException_1 = require("../ShipmentException");
|
|
65
|
-
var PackageEvents_1 = require("../PackageEvents");
|
|
47
|
+
var TrackingShipment_1 = require("../TrackingShipment");
|
|
48
|
+
var SelectTrackingShipment_1 = require("../SelectTrackingShipment");
|
|
66
49
|
var TrackingDrawer = function (_a) {
|
|
67
|
-
var
|
|
50
|
+
var shipmentIds = _a.shipmentIds, config = _a.config, onClose = _a.onClose;
|
|
68
51
|
var position = config.style.position;
|
|
69
52
|
var style = (0, helper_1.getTrackingStyle)(config);
|
|
70
|
-
var _b = (0, hooks_1.useState)(null),
|
|
71
|
-
var _c = (0, hooks_1.useState)(
|
|
72
|
-
var _d = (0, hooks_1.useState)(null), packageId = _d[0], setPackageId = _d[1];
|
|
73
|
-
var hasActiveException = function (shipment) {
|
|
74
|
-
// TODO check with Dylan about status here
|
|
75
|
-
return (shipment.shipment_exceptions.some(function (ex) { return ex.status !== 'resolved'; }) &&
|
|
76
|
-
shipment.status !== 'completed');
|
|
77
|
-
};
|
|
53
|
+
var _b = (0, hooks_1.useState)(null), shipments = _b[0], setShipments = _b[1];
|
|
54
|
+
var _c = (0, hooks_1.useState)(null), selectedShipment = _c[0], setSelectedShipment = _c[1];
|
|
78
55
|
(0, hooks_1.useEffect)(function () {
|
|
79
56
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
-
var
|
|
57
|
+
var ships;
|
|
81
58
|
return __generator(this, function (_a) {
|
|
82
59
|
switch (_a.label) {
|
|
83
|
-
case 0: return [4 /*yield*/, (
|
|
60
|
+
case 0: return [4 /*yield*/, Promise.all(shipmentIds.map(function (shipmentId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0: return [4 /*yield*/, (0, requests_1.loadShipment)(config, shipmentId)];
|
|
64
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}); }))];
|
|
84
68
|
case 1:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
//TODO should we ship.packages.filter(pkg => pkg.objects?.length)); ??
|
|
88
|
-
setPackagesWithObjects(ship.packages);
|
|
69
|
+
ships = _a.sent();
|
|
70
|
+
setShipments(ships);
|
|
89
71
|
return [2 /*return*/];
|
|
90
72
|
}
|
|
91
73
|
});
|
|
92
74
|
}); })();
|
|
93
|
-
}, [
|
|
94
|
-
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div",
|
|
75
|
+
}, [shipmentIds]);
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", { class: "artajs", children: [config.style.backdropEnabled && ((0, jsx_runtime_1.jsx)("div", { onClick: onClose, style: style, class: "artajs__drawer__backdrop" })), (0, jsx_runtime_1.jsx)("div", { style: style, class: "artajs__drawer ".concat(position === 'left'
|
|
95
77
|
? 'artajs__drawer__left'
|
|
96
|
-
: 'artajs__drawer__right')
|
|
78
|
+
: 'artajs__drawer__right'), children: (0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__out__wrapper", children: [(0, jsx_runtime_1.jsx)(DrawerHeader_1.DrawerHeader, { title: selectedShipment
|
|
79
|
+
? config.text.header.titleShipmentDetail
|
|
80
|
+
: shipments && shipments.length > 1
|
|
81
|
+
? config.text.header.titleShipmentList
|
|
82
|
+
: config.text.header.title, onClose: onClose, setSelectedShipment: setSelectedShipment, multiple: !!selectedShipment, config: config }), (shipments === null || shipments === void 0 ? void 0 : shipments.length) ? (shipments.length === 1 || selectedShipment ? ((0, jsx_runtime_1.jsx)(TrackingShipment_1.TrackingShipment, { shipment: selectedShipment !== null && selectedShipment !== void 0 ? selectedShipment : shipments[0], config: config })) : ((0, jsx_runtime_1.jsx)(SelectTrackingShipment_1.SelectTrackingShipment, { shipments: shipments, config: config, setSelectedShipment: setSelectedShipment }))) : ((0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__body", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__drawer__loading" }), (0, jsx_runtime_1.jsx)(DrawerFooter_1.DrawerFooter, {})] }))] }) })] }) }));
|
|
97
83
|
};
|
|
98
84
|
exports.TrackingDrawer = TrackingDrawer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TrackingFullConfig } from '../../trackingConfig';
|
|
2
|
+
import type { Shipment } from '../TrackingDrawer';
|
|
3
|
+
interface TrackingShipmentsProps {
|
|
4
|
+
shipment: Shipment;
|
|
5
|
+
config: TrackingFullConfig;
|
|
6
|
+
}
|
|
7
|
+
export declare const hasActiveException: (shipment: Shipment) => boolean;
|
|
8
|
+
export declare const TrackingShipment: ({ shipment, config, }: TrackingShipmentsProps) => import("preact").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.TrackingShipment = exports.hasActiveException = void 0;
|
|
40
|
+
var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
41
|
+
var hooks_1 = require("preact/hooks");
|
|
42
|
+
var ShipToFrom_1 = require("../ShipToFrom");
|
|
43
|
+
var Package_1 = require("../Package");
|
|
44
|
+
var Timeline_1 = require("../Timeline");
|
|
45
|
+
var TrackingTop_1 = require("../TrackingTop");
|
|
46
|
+
var DrawerFooter_1 = require("../DrawerFooter");
|
|
47
|
+
var DrawerInsurance_1 = require("../DrawerInsurance");
|
|
48
|
+
var Summary_1 = require("../Summary");
|
|
49
|
+
var ShipmentException_1 = require("../ShipmentException");
|
|
50
|
+
var PackageEvents_1 = require("../PackageEvents");
|
|
51
|
+
var hasActiveException = function (shipment) {
|
|
52
|
+
return (shipment.shipment_exceptions.some(function (ex) { return ex.status !== 'resolved'; }) &&
|
|
53
|
+
shipment.status !== 'completed');
|
|
54
|
+
};
|
|
55
|
+
exports.hasActiveException = hasActiveException;
|
|
56
|
+
var TrackingShipment = function (_a) {
|
|
57
|
+
var shipment = _a.shipment, config = _a.config;
|
|
58
|
+
var _b = (0, hooks_1.useState)([]), packagesWithObjects = _b[0], setPackagesWithObjects = _b[1];
|
|
59
|
+
var _c = (0, hooks_1.useState)(null), packageId = _c[0], setPackageId = _c[1];
|
|
60
|
+
(0, hooks_1.useEffect)(function () {
|
|
61
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
setPackagesWithObjects(shipment.packages);
|
|
64
|
+
return [2 /*return*/];
|
|
65
|
+
});
|
|
66
|
+
}); })();
|
|
67
|
+
}, [shipment]);
|
|
68
|
+
if (packageId != null) {
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)(PackageEvents_1.PackageEvents, { packageId: packageId, shipment: shipment, config: config, setPackageId: setPackageId }));
|
|
70
|
+
}
|
|
71
|
+
return ((0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__body", children: [(0, jsx_runtime_1.jsx)(Timeline_1.Timeline, { shipment: shipment, config: config }), (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__timeline__divider" }), (0, exports.hasActiveException)(shipment) && ((0, jsx_runtime_1.jsx)(ShipmentException_1.ShipmentException, { shipment: shipment, config: config })), (0, jsx_runtime_1.jsx)(TrackingTop_1.TrackingTop, { config: config, shipment: shipment }), (0, jsx_runtime_1.jsx)(ShipToFrom_1.ShipToFrom, { config: config, shipment: shipment }), packagesWithObjects.map(function (pkg, index) { return ((0, jsx_runtime_1.jsx)(Package_1.Package, { title: "#".concat(index + 1), pkg: pkg, shipment: shipment, config: config, setPackageId: setPackageId })); }), shipment.insurance_policy != null && (0, jsx_runtime_1.jsx)(DrawerInsurance_1.DrawerInsurance, {}), (0, jsx_runtime_1.jsx)(Summary_1.Summary, { config: config, shipment: shipment }), (0, jsx_runtime_1.jsx)(DrawerFooter_1.DrawerFooter, {})] }));
|
|
72
|
+
};
|
|
73
|
+
exports.TrackingShipment = TrackingShipment;
|
|
@@ -4,4 +4,8 @@ export interface TrackingTopProps {
|
|
|
4
4
|
shipment: Shipment;
|
|
5
5
|
config: TrackingConfig;
|
|
6
6
|
}
|
|
7
|
+
export declare const getLabelAndDates: (shipment: Shipment, config: TrackingConfig) => {
|
|
8
|
+
label: string;
|
|
9
|
+
dates: Date[] | null;
|
|
10
|
+
};
|
|
7
11
|
export declare const TrackingTop: ({ shipment, config }: TrackingTopProps) => import("preact").JSX.Element;
|
|
@@ -1,76 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.TrackingTop = void 0;
|
|
3
|
+
exports.TrackingTop = exports.getLabelAndDates = void 0;
|
|
15
4
|
var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
16
5
|
var Date_1 = require("../Date");
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
if (start != null && end != null) {
|
|
44
|
-
if (start.toDateString() === end.toDateString()) {
|
|
45
|
-
return {
|
|
46
|
-
label: config.text.inTransitCTAOnLabel,
|
|
47
|
-
dates: [start],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
label: config.text.inTransitCTABetweenLabel,
|
|
52
|
-
dates: [start, end],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (start == null && end != null) {
|
|
56
|
-
return {
|
|
57
|
-
label: config.text.inTransitCTABeforeLabel,
|
|
58
|
-
dates: [end],
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (start != null && end == null) {
|
|
6
|
+
var getLabelAndDates = function (shipment, config) {
|
|
7
|
+
if (shipment.status === 'completed') {
|
|
8
|
+
return {
|
|
9
|
+
label: config.text.completedCTA,
|
|
10
|
+
dates: shipment.completed_at ? [new Date(shipment.completed_at)] : null,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (shipment.status === 'cancelled') {
|
|
14
|
+
return {
|
|
15
|
+
label: config.text.cancelledMessage,
|
|
16
|
+
// TODO: maybe we want to check for cancelled_at here?
|
|
17
|
+
dates: null,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
var start = shipment.delivery_start != null ? new Date(shipment.delivery_start) : null;
|
|
21
|
+
var end = shipment.delivery_end != null ? new Date(shipment.delivery_end) : null;
|
|
22
|
+
if (start == null && end == null) {
|
|
23
|
+
return {
|
|
24
|
+
label: config.text.checkBackLater,
|
|
25
|
+
dates: null,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (start != null && end != null) {
|
|
29
|
+
if (start.toDateString() === end.toDateString()) {
|
|
62
30
|
return {
|
|
63
|
-
label: config.text.
|
|
31
|
+
label: config.text.inTransitCTAOnLabel,
|
|
64
32
|
dates: [start],
|
|
65
33
|
};
|
|
66
34
|
}
|
|
67
35
|
return {
|
|
68
|
-
label: config.text.
|
|
69
|
-
dates:
|
|
36
|
+
label: config.text.inTransitCTABetweenLabel,
|
|
37
|
+
dates: [start, end],
|
|
70
38
|
};
|
|
39
|
+
}
|
|
40
|
+
if (start == null && end != null) {
|
|
41
|
+
return {
|
|
42
|
+
label: config.text.inTransitCTABeforeLabel,
|
|
43
|
+
dates: [end],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (start != null && end == null) {
|
|
47
|
+
return {
|
|
48
|
+
label: config.text.inTransitCTAAfterLabel,
|
|
49
|
+
dates: [start],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
label: config.text.checkBackLater,
|
|
54
|
+
dates: null,
|
|
71
55
|
};
|
|
72
|
-
|
|
56
|
+
};
|
|
57
|
+
exports.getLabelAndDates = getLabelAndDates;
|
|
58
|
+
var TrackingTop = function (_a) {
|
|
59
|
+
var shipment = _a.shipment, config = _a.config;
|
|
60
|
+
var _b = (0, exports.getLabelAndDates)(shipment, config), label = _b.label, dates = _b.dates;
|
|
73
61
|
var parsedDates = dates === null || dates === void 0 ? void 0 : dates.map(Date_1.parseStringDate);
|
|
74
|
-
return ((0, jsx_runtime_1.jsx)("div",
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__wrapper", children: (0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__top__divider", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__cta", children: (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__text", children: label }) }), parsedDates != null && parsedDates.length === 1 && ((0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__wrapper", children: (0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__top__date__aligner", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day", children: "".concat(config.text.dates.weekdays[parsedDates[0].weekday], ", ").concat(config.text.dates.months[parsedDates[0].month]) }), (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day__numeric", children: "".concat(parsedDates[0].day).padStart(2, '0') })] }) })), parsedDates != null && parsedDates.length === 2 && ((0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__top__date__wrapper", children: [(0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__top__date__aligner", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day", children: "".concat(config.text.dates.weekdays[parsedDates[0].weekday], ", ").concat(config.text.dates.months[parsedDates[0].month]) }), (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day__numeric", children: "".concat(parsedDates[0].day).padStart(2, '0') })] }), (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__aligner", children: (0, jsx_runtime_1.jsx)("div", { class: "artajas__tracking__top__date__and", children: config.text.inTransitCTAAndLabel }) }), (0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__top__date__aligner", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day", children: "".concat(config.text.dates.weekdays[parsedDates[1].weekday], ", ").concat(config.text.dates.months[parsedDates[1].month]) }), (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__top__date__day__numeric", children: "".concat(parsedDates[1].day).padStart(2, '0') })] })] }))] }) }));
|
|
75
63
|
};
|
|
76
64
|
exports.TrackingTop = TrackingTop;
|
package/dist/estimate.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
package/dist/helper.d.ts
CHANGED
|
@@ -48,6 +48,12 @@ export declare const getTrackingStyle: (config: TrackingFullConfig) => {
|
|
|
48
48
|
'--location-flex': string;
|
|
49
49
|
'--backdrop-color': string;
|
|
50
50
|
'--animationIn': string;
|
|
51
|
+
'--button-background': string;
|
|
52
|
+
'--button-background-hover': string;
|
|
53
|
+
'--button-border': string;
|
|
54
|
+
'--button-text': string;
|
|
55
|
+
'--button-text-hover': string;
|
|
56
|
+
'--button-border-hover': string;
|
|
51
57
|
};
|
|
52
58
|
export declare function isSmallMobile(): boolean;
|
|
53
59
|
export declare function applySmallMobileStyling(finalConfig: EstimateFullConfig): void;
|
package/dist/helper.js
CHANGED
|
@@ -11,7 +11,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
14
|
+
exports.getTrackingStyle = exports.getEstimateStyle = exports.getDestinationConfig = exports.getDisqualifiedConfig = exports.getQuoteConfig = exports.parseErrors = exports.parseEstimatedLocation = void 0;
|
|
15
|
+
exports.isSmallMobile = isSmallMobile;
|
|
16
|
+
exports.applySmallMobileStyling = applySmallMobileStyling;
|
|
17
|
+
exports.nestedObjectAssign = nestedObjectAssign;
|
|
18
|
+
exports.deepClone = deepClone;
|
|
15
19
|
var parseEstimatedLocation = function (loc) {
|
|
16
20
|
if (!loc) {
|
|
17
21
|
return '';
|
|
@@ -96,6 +100,12 @@ var getTrackingStyle = function (config) {
|
|
|
96
100
|
'--location-flex': config.style.variant === 'default' ? '1 0 0' : '0 1 auto',
|
|
97
101
|
'--backdrop-color': config.style.backdropColor,
|
|
98
102
|
'--animationIn': getAnimationStyleIn(config.animation.in, config),
|
|
103
|
+
'--button-background': config.style.color.buttonBackground,
|
|
104
|
+
'--button-background-hover': config.style.color.buttonBackgroundHover,
|
|
105
|
+
'--button-border': config.style.color.buttonBorder,
|
|
106
|
+
'--button-text': config.style.color.buttonText,
|
|
107
|
+
'--button-text-hover': config.style.color.buttonTextHover,
|
|
108
|
+
'--button-border-hover': config.style.color.buttonBorderHover,
|
|
99
109
|
};
|
|
100
110
|
};
|
|
101
111
|
exports.getTrackingStyle = getTrackingStyle;
|
|
@@ -115,7 +125,6 @@ var MINIMUM_RENDERING_HEIGHT = 467;
|
|
|
115
125
|
function isSmallMobile() {
|
|
116
126
|
return window.innerWidth <= 800 && window.innerHeight <= 600;
|
|
117
127
|
}
|
|
118
|
-
exports.isSmallMobile = isSmallMobile;
|
|
119
128
|
function applySmallMobileStyling(finalConfig) {
|
|
120
129
|
if (isSmallMobile()) {
|
|
121
130
|
finalConfig.style.position = 'center';
|
|
@@ -123,7 +132,6 @@ function applySmallMobileStyling(finalConfig) {
|
|
|
123
132
|
finalConfig.style.height = Math.max(window.screen.availHeight, MINIMUM_RENDERING_HEIGHT);
|
|
124
133
|
}
|
|
125
134
|
}
|
|
126
|
-
exports.applySmallMobileStyling = applySmallMobileStyling;
|
|
127
135
|
function nestedObjectAssign(target) {
|
|
128
136
|
var sources = [];
|
|
129
137
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
@@ -146,8 +154,6 @@ function nestedObjectAssign(target) {
|
|
|
146
154
|
});
|
|
147
155
|
return target;
|
|
148
156
|
}
|
|
149
|
-
exports.nestedObjectAssign = nestedObjectAssign;
|
|
150
157
|
function deepClone(obj) {
|
|
151
158
|
return JSON.parse(JSON.stringify(obj));
|
|
152
159
|
}
|
|
153
|
-
exports.deepClone = deepClone;
|
package/dist/requests.js
CHANGED
|
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g =
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -46,6 +46,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
49
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
59
|
exports.loadPackageEvents = exports.validateShipment = exports.loadShipment = exports.validateEstimateBody = exports.loadQuoteRequests = exports.loadHostedSessions = void 0;
|
|
51
60
|
var AUTH_KEY = 'ARTA_APIKey';
|
|
@@ -73,10 +82,14 @@ var logError = function (_a) {
|
|
|
73
82
|
console.error('Unkonwn error', status, errors);
|
|
74
83
|
}
|
|
75
84
|
};
|
|
76
|
-
var artaRequest = function (
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
var artaRequest = function (path_1, config_1, body_1, headers_1) {
|
|
86
|
+
var args_1 = [];
|
|
87
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
|
88
|
+
args_1[_i - 4] = arguments[_i];
|
|
89
|
+
}
|
|
90
|
+
return __awaiter(void 0, __spreadArray([path_1, config_1, body_1, headers_1], args_1, true), void 0, function (path, config, body, headers, method) {
|
|
79
91
|
var schema, res, resBody, err;
|
|
92
|
+
if (method === void 0) { method = 'POST'; }
|
|
80
93
|
return __generator(this, function (_a) {
|
|
81
94
|
switch (_a.label) {
|
|
82
95
|
case 0:
|
package/dist/tracking.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { TrackingFullConfig } from './trackingConfig';
|
|
2
2
|
export default class Tracking {
|
|
3
|
-
private readonly
|
|
3
|
+
private readonly shipmentIdOrIds;
|
|
4
4
|
private readonly config;
|
|
5
5
|
private readonly el;
|
|
6
6
|
isReady: boolean;
|
|
7
7
|
isOpen: boolean;
|
|
8
|
+
private shipmentIds;
|
|
8
9
|
private fadeOut;
|
|
9
|
-
constructor(
|
|
10
|
+
constructor(shipmentIdOrIds: string | string[], config: TrackingFullConfig, el: HTMLDivElement);
|
|
10
11
|
open(): void;
|
|
11
12
|
private render;
|
|
12
13
|
close(): void;
|
package/dist/tracking.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -40,13 +40,15 @@ var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
|
40
40
|
var preact_1 = require("preact");
|
|
41
41
|
var TrackingDrawer_1 = require("./components/TrackingDrawer");
|
|
42
42
|
var requests_1 = require("./requests");
|
|
43
|
+
var SHIPMENT_LIMIT_IDX = 100;
|
|
43
44
|
var Tracking = /** @class */ (function () {
|
|
44
|
-
function Tracking(
|
|
45
|
-
this.
|
|
45
|
+
function Tracking(shipmentIdOrIds, config, el) {
|
|
46
|
+
this.shipmentIdOrIds = shipmentIdOrIds;
|
|
46
47
|
this.config = config;
|
|
47
48
|
this.el = el;
|
|
48
49
|
this.isReady = false;
|
|
49
50
|
this.isOpen = false;
|
|
51
|
+
this.shipmentIds = [];
|
|
50
52
|
this.fadeOut = {
|
|
51
53
|
fade: {
|
|
52
54
|
left: [{ opacity: 1 }, { opacity: 0 }],
|
|
@@ -63,6 +65,23 @@ var Tracking = /** @class */ (function () {
|
|
|
63
65
|
],
|
|
64
66
|
},
|
|
65
67
|
};
|
|
68
|
+
if (Array.isArray(this.shipmentIdOrIds)) {
|
|
69
|
+
if (this.shipmentIdOrIds.length === 0) {
|
|
70
|
+
throw new Error('Shipment id array is empty');
|
|
71
|
+
}
|
|
72
|
+
if (this.shipmentIdOrIds.some(function (shipmentId) { return typeof shipmentId !== 'string'; })) {
|
|
73
|
+
throw new Error('Shipment id array contains non-string values');
|
|
74
|
+
}
|
|
75
|
+
if (this.shipmentIdOrIds.some(function (shipmentId) { return shipmentId.length === 0; })) {
|
|
76
|
+
throw new Error('Shipment id array contains empty strings');
|
|
77
|
+
}
|
|
78
|
+
if (this.shipmentIdOrIds.length > SHIPMENT_LIMIT_IDX) {
|
|
79
|
+
throw new Error("Shipment id array contains more than ".concat(SHIPMENT_LIMIT_IDX, " shipment ids"));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
this.shipmentIds = Array.isArray(this.shipmentIdOrIds)
|
|
83
|
+
? this.shipmentIdOrIds
|
|
84
|
+
: [this.shipmentIdOrIds];
|
|
66
85
|
}
|
|
67
86
|
Tracking.prototype.open = function () {
|
|
68
87
|
this.render();
|
|
@@ -70,7 +89,7 @@ var Tracking = /** @class */ (function () {
|
|
|
70
89
|
};
|
|
71
90
|
Tracking.prototype.render = function () {
|
|
72
91
|
var _a;
|
|
73
|
-
(0, preact_1.render)((0, jsx_runtime_1.jsx)(TrackingDrawer_1.TrackingDrawer, {
|
|
92
|
+
(0, preact_1.render)((0, jsx_runtime_1.jsx)(TrackingDrawer_1.TrackingDrawer, { shipmentIds: this.shipmentIds, config: this.config, onClose: (_a = this.config.onClose) !== null && _a !== void 0 ? _a : this.onClose.bind(this) }), this.el);
|
|
74
93
|
};
|
|
75
94
|
Tracking.prototype.close = function () {
|
|
76
95
|
var _this = this;
|
|
@@ -100,14 +119,38 @@ var Tracking = /** @class */ (function () {
|
|
|
100
119
|
};
|
|
101
120
|
Tracking.prototype.validate = function () {
|
|
102
121
|
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
var
|
|
122
|
+
var shipmentIdsOrErrors, newShipmentIds, _i, shipmentIdsOrErrors_1, shipmentIdOrError;
|
|
123
|
+
var _this = this;
|
|
104
124
|
return __generator(this, function (_a) {
|
|
105
125
|
switch (_a.label) {
|
|
106
|
-
case 0: return [4 /*yield*/,
|
|
126
|
+
case 0: return [4 /*yield*/, Promise.all(this.shipmentIds.map(function (shipmentId) { return __awaiter(_this, void 0, void 0, function () {
|
|
127
|
+
var errors;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0: return [4 /*yield*/, (0, requests_1.validateShipment)(this.config, shipmentId)];
|
|
131
|
+
case 1:
|
|
132
|
+
errors = _a.sent();
|
|
133
|
+
if (errors && Object.keys(errors).length > 0) {
|
|
134
|
+
return [2 /*return*/, errors];
|
|
135
|
+
}
|
|
136
|
+
return [2 /*return*/, shipmentId];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}); }))];
|
|
107
140
|
case 1:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
141
|
+
shipmentIdsOrErrors = _a.sent();
|
|
142
|
+
newShipmentIds = [];
|
|
143
|
+
for (_i = 0, shipmentIdsOrErrors_1 = shipmentIdsOrErrors; _i < shipmentIdsOrErrors_1.length; _i++) {
|
|
144
|
+
shipmentIdOrError = shipmentIdsOrErrors_1[_i];
|
|
145
|
+
if (typeof shipmentIdOrError === 'object') {
|
|
146
|
+
console.error('Shipment validation failed', shipmentIdOrError);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
newShipmentIds.push(shipmentIdOrError);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (newShipmentIds.length === 0) {
|
|
153
|
+
return [2 /*return*/, Promise.reject('No valid shipment ids')];
|
|
111
154
|
}
|
|
112
155
|
this.isReady = true;
|
|
113
156
|
return [2 /*return*/];
|
package/dist/trackingConfig.d.ts
CHANGED
|
@@ -52,6 +52,12 @@ export interface TrackingConfig {
|
|
|
52
52
|
iconSecondary: string;
|
|
53
53
|
iconTertiary: string;
|
|
54
54
|
exceptionIcon: string;
|
|
55
|
+
buttonBackground: string;
|
|
56
|
+
buttonBackgroundHover: string;
|
|
57
|
+
buttonBorder: string;
|
|
58
|
+
buttonText: string;
|
|
59
|
+
buttonTextHover: string;
|
|
60
|
+
buttonBorderHover: string;
|
|
55
61
|
};
|
|
56
62
|
variant: 'default' | 'minimal';
|
|
57
63
|
position: 'left' | 'right';
|
|
@@ -63,6 +69,8 @@ export interface TrackingConfig {
|
|
|
63
69
|
text: {
|
|
64
70
|
header: {
|
|
65
71
|
title: string;
|
|
72
|
+
titleShipmentList: string;
|
|
73
|
+
titleShipmentDetail: string;
|
|
66
74
|
};
|
|
67
75
|
pendingLabel: string;
|
|
68
76
|
completedLabel: string;
|
|
@@ -95,6 +103,8 @@ export interface TrackingConfig {
|
|
|
95
103
|
singleShipmentHeldAtCustomsLabel: string;
|
|
96
104
|
changeOfAddressRequestLabel: string;
|
|
97
105
|
shipmentExceptionDefaultLabel: string;
|
|
106
|
+
viewShipmentDetailLabel: string;
|
|
107
|
+
viewShipmentsListLabel: string;
|
|
98
108
|
};
|
|
99
109
|
pill: {
|
|
100
110
|
unknown: PillConfig;
|
|
@@ -106,6 +116,10 @@ export interface TrackingConfig {
|
|
|
106
116
|
undelivered: PillConfig;
|
|
107
117
|
exception: PillConfig;
|
|
108
118
|
expired: PillConfig;
|
|
119
|
+
cancelled: PillConfig;
|
|
120
|
+
collected: PillConfig;
|
|
121
|
+
completed: PillConfig;
|
|
122
|
+
confirmed: PillConfig;
|
|
109
123
|
};
|
|
110
124
|
animation: {
|
|
111
125
|
in: AnimationConfig;
|