@artaio/arta-browser 2.19.0 → 2.19.1
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 +3 -4
- package/dist/arta.js +26 -39
- package/dist/bundle.js +1 -1
- package/dist/components/Date/SimpleDate.js +11 -11
- package/dist/components/Date/index.js +13 -13
- package/dist/components/Destination/countriesWithoutPostalCode.js +5 -4
- package/dist/components/Destination/index.js +20 -25
- package/dist/components/Disqualified/index.js +15 -14
- package/dist/components/DrawerFooter/index.js +7 -6
- package/dist/components/DrawerHeader/index.js +8 -8
- package/dist/components/DrawerInsurance/index.js +7 -6
- package/dist/components/Footer/index.js +7 -7
- package/dist/components/Header/index.js +7 -7
- package/dist/components/Invalidated/index.js +7 -7
- package/dist/components/Loading/index.js +7 -6
- package/dist/components/Modal/index.css.js +7 -0
- package/dist/components/Modal/index.d.ts +0 -1
- package/dist/components/Modal/index.js +67 -132
- package/dist/components/Package/index.js +24 -25
- package/dist/components/PackageEvents/index.js +43 -88
- package/dist/components/Pill/index.js +8 -8
- package/dist/components/Quotes/index.js +26 -25
- package/dist/components/SelectTrackingShipment/index.js +31 -35
- package/dist/components/ShipToFrom/index.js +13 -13
- package/dist/components/ShipmentException/icons/ExceptionIcon.js +12 -12
- package/dist/components/ShipmentException/icons/HexagonAlertBase.js +7 -7
- package/dist/components/ShipmentException/icons/HexagonPauseBase.js +7 -7
- package/dist/components/ShipmentException/icons/HexagonStopBase.js +7 -7
- package/dist/components/ShipmentException/index.js +25 -27
- package/dist/components/Summary/index.js +7 -7
- package/dist/components/Timeline/CheckedStep.js +12 -12
- package/dist/components/Timeline/CheckedSteps.js +7 -7
- package/dist/components/Timeline/EmptyStep.js +7 -7
- package/dist/components/Timeline/SecondaryStep.js +7 -7
- package/dist/components/Timeline/SecondarySteps.js +7 -7
- package/dist/components/Timeline/TimelineDefault.js +22 -22
- package/dist/components/Timeline/TimlineMinimal.js +24 -25
- package/dist/components/Timeline/defaultIcons/CancelledIcon.js +8 -8
- package/dist/components/Timeline/defaultIcons/CollectedIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/CompletedIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/ConfirmedIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/InTransitIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/PendingIcon.js +8 -8
- package/dist/components/Timeline/icons/CancelledIconBase.js +7 -7
- package/dist/components/Timeline/icons/CollectedIconBase.js +7 -7
- package/dist/components/Timeline/icons/CompletedIconBase.js +7 -7
- package/dist/components/Timeline/icons/ConfirmedIconBase.js +7 -7
- package/dist/components/Timeline/icons/InTransitIconBase.js +7 -7
- package/dist/components/Timeline/icons/PendingIconBase.js +7 -7
- package/dist/components/Timeline/index.js +9 -9
- package/dist/components/TrackingDrawer/index.css.js +7 -0
- package/dist/components/TrackingDrawer/index.d.ts +0 -1
- package/dist/components/TrackingDrawer/index.js +33 -81
- package/dist/components/TrackingShipment/index.js +27 -66
- package/dist/components/TrackingTop/index.js +14 -14
- package/dist/estimate.js +41 -83
- package/dist/estimateConfig.js +16 -14
- package/dist/fixtures/countries.js +5 -4
- package/dist/helper.js +61 -64
- package/dist/index.js +15 -34
- package/dist/requests.js +71 -191
- package/dist/tracking.js +77 -128
- package/dist/trackingConfig.js +11 -9
- package/package.json +8 -5
- package/dist/MetadataTypes.js +0 -2
- package/dist/typing.js +0 -1
|
@@ -1,138 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('preact/jsx-runtime');
|
|
4
|
+
var index$1 = require('../Header/index.js');
|
|
5
|
+
var index$4 = require('../Destination/index.js');
|
|
6
|
+
var index$3 = require('../Footer/index.js');
|
|
7
|
+
var hooks = require('preact/hooks');
|
|
8
|
+
var index = require('./index.css.js');
|
|
9
|
+
var index$2 = require('../Loading/index.js');
|
|
10
|
+
var index$5 = require('../Quotes/index.js');
|
|
11
|
+
var helper = require('../../helper.js');
|
|
12
|
+
var requests = require('../../requests.js');
|
|
13
|
+
var index$7 = require('../Disqualified/index.js');
|
|
14
|
+
var ModalStatus = require('../../ModalStatus.js');
|
|
15
|
+
var index$6 = require('../Invalidated/index.js');
|
|
16
|
+
|
|
17
|
+
const Modal = ({ estimateBody, onClose, config }) => {
|
|
18
|
+
const position = config.style.position;
|
|
19
|
+
const [destination, setDestination] = hooks.useState();
|
|
20
|
+
const [parsedOrigin, setParsedOrigin] = hooks.useState('');
|
|
21
|
+
const [status, setStatus] = hooks.useState(ModalStatus.ModalStatus.LOADING);
|
|
22
|
+
const [hostedSession, setHostedSession] = hooks.useState();
|
|
23
|
+
const [quoteRequest, setQuoteRequest] = hooks.useState();
|
|
24
|
+
const [errors, setErrors] = hooks.useState();
|
|
25
|
+
const style = helper.getEstimateStyle(config);
|
|
26
|
+
hooks.useEffect(() => {
|
|
27
|
+
(async () => {
|
|
28
|
+
setErrors([]);
|
|
29
|
+
setStatus(ModalStatus.ModalStatus.LOADING);
|
|
30
|
+
const session = await requests.loadHostedSessions(config, estimateBody);
|
|
31
|
+
setHostedSession(session);
|
|
32
|
+
setParsedOrigin(helper.parseEstimatedLocation(session.origin));
|
|
33
|
+
if (!session.origin.estimated_city) {
|
|
34
|
+
setStatus(ModalStatus.ModalStatus.INVALIDATED);
|
|
35
|
+
return;
|
|
43
36
|
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.Modal = void 0;
|
|
51
|
-
var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
52
|
-
var Header_1 = require("../Header");
|
|
53
|
-
var Destination_1 = require("../Destination");
|
|
54
|
-
var Footer_1 = require("../Footer");
|
|
55
|
-
var hooks_1 = require("preact/hooks");
|
|
56
|
-
require("./index.css");
|
|
57
|
-
var Loading_1 = require("../Loading");
|
|
58
|
-
var Quotes_1 = require("../Quotes");
|
|
59
|
-
var helper_1 = require("../../helper");
|
|
60
|
-
var requests_1 = require("../../requests");
|
|
61
|
-
var Disqualified_1 = require("../Disqualified");
|
|
62
|
-
var ModalStatus_1 = require("../../ModalStatus");
|
|
63
|
-
var Invalidated_1 = require("../Invalidated");
|
|
64
|
-
var Modal = function (_a) {
|
|
65
|
-
var estimateBody = _a.estimateBody, onClose = _a.onClose, config = _a.config;
|
|
66
|
-
var position = config.style.position;
|
|
67
|
-
var _b = (0, hooks_1.useState)(), destination = _b[0], setDestination = _b[1];
|
|
68
|
-
var _c = (0, hooks_1.useState)(''), parsedOrigin = _c[0], setParsedOrigin = _c[1];
|
|
69
|
-
var _d = (0, hooks_1.useState)(ModalStatus_1.ModalStatus.LOADING), status = _d[0], setStatus = _d[1];
|
|
70
|
-
var _e = (0, hooks_1.useState)(), hostedSession = _e[0], setHostedSession = _e[1];
|
|
71
|
-
var _f = (0, hooks_1.useState)(), quoteRequest = _f[0], setQuoteRequest = _f[1];
|
|
72
|
-
var _g = (0, hooks_1.useState)(), errors = _g[0], setErrors = _g[1];
|
|
73
|
-
var style = (0, helper_1.getEstimateStyle)(config);
|
|
74
|
-
(0, hooks_1.useEffect)(function () {
|
|
75
|
-
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
|
-
var session;
|
|
77
|
-
return __generator(this, function (_a) {
|
|
78
|
-
switch (_a.label) {
|
|
79
|
-
case 0:
|
|
80
|
-
setErrors([]);
|
|
81
|
-
setStatus(ModalStatus_1.ModalStatus.LOADING);
|
|
82
|
-
return [4 /*yield*/, (0, requests_1.loadHostedSessions)(config, estimateBody)];
|
|
83
|
-
case 1:
|
|
84
|
-
session = _a.sent();
|
|
85
|
-
setHostedSession(session);
|
|
86
|
-
setParsedOrigin((0, helper_1.parseEstimatedLocation)(session.origin));
|
|
87
|
-
if (!session.origin.estimated_city) {
|
|
88
|
-
setStatus(ModalStatus_1.ModalStatus.INVALIDATED);
|
|
89
|
-
return [2 /*return*/];
|
|
90
|
-
}
|
|
91
|
-
setStatus(ModalStatus_1.ModalStatus.OPEN);
|
|
92
|
-
return [2 /*return*/];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}); })();
|
|
37
|
+
setStatus(ModalStatus.ModalStatus.OPEN);
|
|
38
|
+
})();
|
|
96
39
|
}, [estimateBody.origin, estimateBody.objects]);
|
|
97
|
-
|
|
98
|
-
(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
setStatus(ModalStatus_1.ModalStatus.OPEN);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
setQuoteRequest(req);
|
|
122
|
-
if (req.quotes && req.quotes.length > 0) {
|
|
123
|
-
setStatus(ModalStatus_1.ModalStatus.QUOTED);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
setStatus(ModalStatus_1.ModalStatus.DISQUALIFIED);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return [2 /*return*/];
|
|
40
|
+
hooks.useEffect(() => {
|
|
41
|
+
(async () => {
|
|
42
|
+
setErrors([]);
|
|
43
|
+
if (!destination) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
setStatus(ModalStatus.ModalStatus.LOADING);
|
|
47
|
+
const esimate = { ...estimateBody, destination };
|
|
48
|
+
const sess = hostedSession
|
|
49
|
+
? hostedSession
|
|
50
|
+
: { id: '', private_token: '', origin: estimateBody.origin };
|
|
51
|
+
const req = await requests.loadQuoteRequests(config, sess, esimate);
|
|
52
|
+
if (req.err) {
|
|
53
|
+
const errorMessages = helper.parseErrors(req.err.errors);
|
|
54
|
+
setErrors(errorMessages);
|
|
55
|
+
setStatus(ModalStatus.ModalStatus.OPEN);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
setQuoteRequest(req);
|
|
59
|
+
if (req.quotes && req.quotes.length > 0) {
|
|
60
|
+
setStatus(ModalStatus.ModalStatus.QUOTED);
|
|
130
61
|
}
|
|
131
|
-
|
|
132
|
-
|
|
62
|
+
else {
|
|
63
|
+
setStatus(ModalStatus.ModalStatus.DISQUALIFIED);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
133
67
|
}, [destination]);
|
|
134
|
-
return ((
|
|
135
|
-
|
|
136
|
-
|
|
68
|
+
return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("style", { children: index.default }), jsxRuntime.jsxs("div", { class: "artajs", children: [position === 'center' && (jsxRuntime.jsx("div", { class: "artajs__modal__backdrop", onClick: onClose })), jsxRuntime.jsxs("div", { class: `artajs__modal artajs__modal__${position}`, style: style, children: [jsxRuntime.jsx(index$1.Header, { onClose: onClose, title: config.text.header.title, lineColor: config.style.color.border }), status === ModalStatus.ModalStatus.LOADING && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(index$2.Loading, {}), jsxRuntime.jsx(index$3.Footer, { absolute: true })] })), status === ModalStatus.ModalStatus.OPEN && (jsxRuntime.jsx(index$4.Destination, { parsedOrigin: parsedOrigin, textConfig: helper.getDestinationConfig(config), setDestination: setDestination })), status === ModalStatus.ModalStatus.QUOTED && quoteRequest && (jsxRuntime.jsx(index$5.Quotes, { quoteRequest: quoteRequest, showCostRange: config.style.pricingDisplay === 'range', textConfig: helper.getQuoteConfig(config), setStatus: setStatus })), status === ModalStatus.ModalStatus.INVALIDATED && (jsxRuntime.jsx(index$6.Invalidated, { message: config.text.invalidated.message, detail: config.text.invalidated.detail })), status === ModalStatus.ModalStatus.DISQUALIFIED && quoteRequest && (jsxRuntime.jsx(index$7.Disqualified, { quoteRequest: quoteRequest, textConfig: helper.getDisqualifiedConfig(config), setStatus: setStatus })), status !== ModalStatus.ModalStatus.LOADING && jsxRuntime.jsx(index$3.Footer, {}), errors && errors.length > 0 && (jsxRuntime.jsxs("div", { class: "artajs__modal__error__container", children: [jsxRuntime.jsx("div", { class: "artajs__modal__error", children: errors.map((error, i) => {
|
|
69
|
+
return jsxRuntime.jsx("span", { children: error }, `arta-error-${i}`);
|
|
70
|
+
}) }), jsxRuntime.jsx("div", { className: "artajs__modal__error__close", children: jsxRuntime.jsx("a", { onClick: () => setErrors([]), href: "#", children: jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("line", { x1: "6.70711", y1: "6.29289", x2: "18.0208", y2: "17.6066", "stroke-width": "2" }), jsxRuntime.jsx("line", { x1: "6.29289", y1: "17.6066", x2: "17.6066", y2: "6.29291", "stroke-width": "2" })] }) }) })] }))] })] })] }));
|
|
137
71
|
};
|
|
72
|
+
|
|
138
73
|
exports.Modal = Modal;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
((_c = obj.details) === null || _c === void 0 ? void 0 : _c.creation_date) == null) {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('preact/jsx-runtime');
|
|
4
|
+
var index = require('../Pill/index.js');
|
|
5
|
+
|
|
6
|
+
const objectDetailTitle = (obj, config) => {
|
|
7
|
+
if (obj.details?.title == null &&
|
|
8
|
+
obj.details?.creator == null &&
|
|
9
|
+
obj.details?.creation_date == null) {
|
|
11
10
|
return config.text.noObjectDetailsTitle;
|
|
12
11
|
}
|
|
13
|
-
|
|
12
|
+
let formattedString = '';
|
|
14
13
|
if (obj.details.title && obj.details.creator) {
|
|
15
|
-
formattedString =
|
|
14
|
+
formattedString = `${obj.details.title}: ${obj.details.creator}`;
|
|
16
15
|
}
|
|
17
16
|
else if (obj.details.title) {
|
|
18
17
|
formattedString = obj.details.title;
|
|
@@ -26,28 +25,28 @@ var objectDetailTitle = function (obj, config) {
|
|
|
26
25
|
}
|
|
27
26
|
return formattedString;
|
|
28
27
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var pkgTracking = shipment.tracking.find(function (t) { return t.package_id === pkg.id; });
|
|
33
|
-
return ((0, jsx_runtime_1.jsx)("div", { class: "artajs__packings__wrapper", children: (0, jsx_runtime_1.jsxs)("div", { class: "artajs__packings__spacer", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__packings__spacer", children: (0, jsx_runtime_1.jsxs)("div", { class: "artajs__packings__header", children: [(0, jsx_runtime_1.jsxs)("div", { class: "artajs__packings__header__top", children: [(0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__header__text", children: title }), (0, jsx_runtime_1.jsx)(Pill_1.Pill, { config: config, status: pkg.status })] }), (pkgTracking === null || pkgTracking === void 0 ? void 0 : pkgTracking.carrier_name) && pkgTracking.tracking_number && ((0, jsx_runtime_1.jsx)("div", { class: "artajs__packings__header__body", children: pkgTracking.url ? ((0, jsx_runtime_1.jsxs)("div", { onClick: function (e) {
|
|
28
|
+
const Package = ({ config, shipment, pkg, title, setPackageId, }) => {
|
|
29
|
+
const pkgTracking = shipment.tracking.find((t) => t.package_id === pkg.id);
|
|
30
|
+
return (jsxRuntime.jsx("div", { class: "artajs__packings__wrapper", children: jsxRuntime.jsxs("div", { class: "artajs__packings__spacer", children: [jsxRuntime.jsx("div", { class: "artajs__packings__spacer", children: jsxRuntime.jsxs("div", { class: "artajs__packings__header", children: [jsxRuntime.jsxs("div", { class: "artajs__packings__header__top", children: [jsxRuntime.jsx("div", { class: "artajs__tracking__header__text", children: title }), jsxRuntime.jsx(index.Pill, { config: config, status: pkg.status })] }), pkgTracking?.carrier_name && pkgTracking.tracking_number && (jsxRuntime.jsx("div", { class: "artajs__packings__header__body", children: pkgTracking.url ? (jsxRuntime.jsxs("div", { onClick: (e) => {
|
|
34
31
|
e.preventDefault();
|
|
35
32
|
if (pkgTracking.url == null) {
|
|
36
33
|
return;
|
|
37
34
|
}
|
|
38
|
-
|
|
35
|
+
const url = pkgTracking.url.startsWith('http')
|
|
39
36
|
? pkgTracking.url
|
|
40
|
-
:
|
|
37
|
+
: `https://${pkgTracking.url}`;
|
|
41
38
|
window.open(url, '_blank');
|
|
42
|
-
}, className: "artajs__packings__text__regular__underline", children: [pkgTracking.carrier_name, " - ", pkgTracking.tracking_number] })) : (
|
|
39
|
+
}, className: "artajs__packings__text__regular__underline", children: [pkgTracking.carrier_name, " - ", pkgTracking.tracking_number] })) : (jsxRuntime.jsxs("div", { class: "artajs__tracking__timeline__step__text__primary", children: [pkgTracking.carrier_name, " - ", pkgTracking.tracking_number] })) })), pkg.package_events_count > 0 && (jsxRuntime.jsx("div", { onClick: (e) => {
|
|
43
40
|
e.preventDefault();
|
|
44
41
|
setPackageId(pkg.id);
|
|
45
|
-
}, class: "artajs__packings__header__body", children:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
?
|
|
42
|
+
}, class: "artajs__packings__header__body", children: jsxRuntime.jsx("div", { class: "artajs__packings__text__small__underline", children: config.text.packageHistoryLabel }) }))] }) }), jsxRuntime.jsx("div", { class: "artajs__packings__line" }), jsxRuntime.jsx("div", { class: "artajs__packings__item", children: pkg.objects.map((obj) => {
|
|
43
|
+
const hasImage = obj.shipment_object_images && obj.shipment_object_images.length > 0;
|
|
44
|
+
const thumbnailUrl = hasImage && obj.shipment_object_images
|
|
45
|
+
? `${config.httpSchema}://${config.host}/shipment_images/60x60/resize/${obj.shipment_object_images[0].filename}`
|
|
49
46
|
: null;
|
|
50
|
-
return (
|
|
47
|
+
return (jsxRuntime.jsxs("div", { class: "artajs__packings__item__row", children: [config.showThumbnails && (jsxRuntime.jsx("div", { class: "artajs__packings__item__thumbnail", children: thumbnailUrl ? (jsxRuntime.jsx("img", { src: thumbnailUrl, alt: "shipment object image", class: "artajs__packings__item__thumbnail__img" })) : (jsxRuntime.jsx("div", { class: "artajs__packings__item__thumbnail__placeholder" })) })), jsxRuntime.jsxs("div", { class: "artajs__packings__item__content", children: [jsxRuntime.jsx("div", { class: "artajs__tracking__title", children: objectDetailTitle(obj, config) }), jsxRuntime.jsx("div", { class: "artajs__tracking__subtype", children: obj.subtype_name })] })] }));
|
|
51
48
|
}) })] }) }));
|
|
52
49
|
};
|
|
50
|
+
|
|
53
51
|
exports.Package = Package;
|
|
52
|
+
exports.objectDetailTitle = objectDetailTitle;
|
|
@@ -1,60 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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.PackageEvents = void 0;
|
|
40
|
-
var jsx_runtime_1 = require("preact/jsx-runtime");
|
|
41
|
-
var hooks_1 = require("preact/hooks");
|
|
42
|
-
var requests_1 = require("../../requests");
|
|
43
|
-
var Date_1 = require("../Date");
|
|
44
|
-
var DrawerFooter_1 = require("../DrawerFooter");
|
|
45
|
-
var cleanLocationString = function (input) {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('preact/jsx-runtime');
|
|
4
|
+
var hooks = require('preact/hooks');
|
|
5
|
+
var requests = require('../../requests.js');
|
|
6
|
+
var index$1 = require('../Date/index.js');
|
|
7
|
+
var index = require('../DrawerFooter/index.js');
|
|
8
|
+
|
|
9
|
+
const cleanLocationString = (input) => {
|
|
46
10
|
if (input == null) {
|
|
47
11
|
return null;
|
|
48
12
|
}
|
|
49
13
|
return input
|
|
50
14
|
.split(',')
|
|
51
|
-
.map(
|
|
52
|
-
.filter(
|
|
15
|
+
.map((part) => part.trim())
|
|
16
|
+
.filter((part) => part !== '')
|
|
53
17
|
.join(', ');
|
|
54
18
|
};
|
|
55
|
-
|
|
56
|
-
return data.reduce(
|
|
57
|
-
|
|
19
|
+
const groupByDate = (data) => {
|
|
20
|
+
return data.reduce((groups, item) => {
|
|
21
|
+
const date = item.datetime.split('T')[0]; // Extract the date portion (YYYY-MM-DD)
|
|
58
22
|
if (!groups[date]) {
|
|
59
23
|
groups[date] = [];
|
|
60
24
|
}
|
|
@@ -62,59 +26,50 @@ var groupByDate = function (data) {
|
|
|
62
26
|
return groups;
|
|
63
27
|
}, {});
|
|
64
28
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return
|
|
29
|
+
const formatDate = (date, config) => {
|
|
30
|
+
const { day, weekday, month, year } = index$1.parseStringDate(date);
|
|
31
|
+
return `${config.text.dates.weekdays[weekday]}, ${config.text.dates.months[month]} ${day}, ${year}`;
|
|
68
32
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
switch (_a.label) {
|
|
82
|
-
case 0: return [4 /*yield*/, (0, requests_1.loadPackageEvents)(config, shipment.id, packageId)];
|
|
83
|
-
case 1:
|
|
84
|
-
hist = _a.sent();
|
|
85
|
-
setEventHistory(hist);
|
|
86
|
-
setGroupedEventHistory(groupByDate(hist));
|
|
87
|
-
return [2 /*return*/];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}); })();
|
|
33
|
+
const PackageEvents = ({ shipment, config, setPackageId, packageId, }) => {
|
|
34
|
+
const [eventHistory, setEventHistory] = hooks.useState(null);
|
|
35
|
+
const [groupedEventHistory, setGroupedEventHistory] = hooks.useState(null);
|
|
36
|
+
const packageIdx = shipment.packages.findIndex((p) => p.id === packageId);
|
|
37
|
+
const pkgTracking = shipment.tracking.find((t) => t.package_id === shipment.packages[packageIdx].id);
|
|
38
|
+
let counter = eventHistory?.length ?? 0;
|
|
39
|
+
hooks.useEffect(() => {
|
|
40
|
+
(async () => {
|
|
41
|
+
const hist = await requests.loadPackageEvents(config, shipment.id, packageId);
|
|
42
|
+
setEventHistory(hist);
|
|
43
|
+
setGroupedEventHistory(groupByDate(hist));
|
|
44
|
+
})();
|
|
91
45
|
}, [packageId]);
|
|
92
|
-
return (
|
|
46
|
+
return (jsxRuntime.jsxs("div", { class: "artajs__tracking__events__wrapper", children: [jsxRuntime.jsx("div", { onClick: (e) => {
|
|
93
47
|
e.preventDefault();
|
|
94
48
|
setPackageId(null);
|
|
95
|
-
}, class: "artajs__tracking__events__return", children:
|
|
49
|
+
}, class: "artajs__tracking__events__return", children: jsxRuntime.jsx("div", { class: "artajs__tracking__events__return__text", children: config.text.packageIdReturnLabel }) }), jsxRuntime.jsxs("div", { class: "artajs__tracking__events__header", children: [jsxRuntime.jsxs("div", { class: "artajs__tracking__events__header__title", children: [config.text.packageLabel, " #", packageIdx + 1, ' ', config.text.historyLabel] }), pkgTracking?.carrier_name &&
|
|
96
50
|
pkgTracking.tracking_number &&
|
|
97
|
-
(pkgTracking.url ? (
|
|
51
|
+
(pkgTracking.url ? (jsxRuntime.jsxs("div", { onClick: (e) => {
|
|
98
52
|
e.preventDefault();
|
|
99
53
|
if (pkgTracking.url == null) {
|
|
100
54
|
return;
|
|
101
55
|
}
|
|
102
|
-
|
|
56
|
+
const url = pkgTracking.url.startsWith('http')
|
|
103
57
|
? pkgTracking.url
|
|
104
|
-
:
|
|
58
|
+
: `https://${pkgTracking.url}`;
|
|
105
59
|
window.open(url, '_blank');
|
|
106
|
-
}, className: "artajs__packings__text__regular__underline", children: [pkgTracking.carrier_name, " - ", pkgTracking.tracking_number] })) : (
|
|
107
|
-
return (
|
|
108
|
-
|
|
109
|
-
return ((0, jsx_runtime_1.jsxs)("div", { class: "artajs__tracking__events__group__content", children: [(0, jsx_runtime_1.jsx)("div", { class: idx === 0 && idx2 === 0
|
|
60
|
+
}, className: "artajs__packings__text__regular__underline", children: [pkgTracking.carrier_name, " - ", pkgTracking.tracking_number] })) : (jsxRuntime.jsxs("div", { class: "artajs__tracking__timeline__step__text__primary", children: [pkgTracking.carrier_name, " - ", pkgTracking.tracking_number] })))] }), groupedEventHistory ? (jsxRuntime.jsxs("div", { class: "artajs__tracking__events__body", children: [Object.values(groupedEventHistory).map((events, idx) => {
|
|
61
|
+
return (jsxRuntime.jsxs("div", { class: "artajs__tracking__events__group", children: [jsxRuntime.jsx("div", { class: "artajs__tracking__events__date", children: formatDate(events[0].datetime, config) }), jsxRuntime.jsx("div", { class: "artajs__tracking__events__group__item", children: events.map((event, idx2) => {
|
|
62
|
+
return (jsxRuntime.jsxs("div", { class: "artajs__tracking__events__group__content", children: [jsxRuntime.jsx("div", { class: idx === 0 && idx2 === 0
|
|
110
63
|
? 'artajs__tracking__events__group__number__primary'
|
|
111
|
-
: 'artajs__tracking__events__group__number__secondary', children: counter-- }),
|
|
64
|
+
: 'artajs__tracking__events__group__number__secondary', children: counter-- }), jsxRuntime.jsxs("div", { class: "artajs__tracking__events__group__divider", children: [jsxRuntime.jsx("div", { class: "artajs__tracking__events__round", children: idx === 0 && idx2 === 0 ? (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "30", height: "30", viewBox: "0 0 30 30", fill: "none", children: jsxRuntime.jsx("circle", { cx: "15", cy: "15", r: "7.5", fill: config.style.color.iconPrimary }) })) : (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "30", height: "30", viewBox: "0 0 30 30", fill: "none", children: jsxRuntime.jsx("circle", { cx: "15", cy: "15", r: "7", fill: "none", stroke: config.style.color.iconTertiary, "stroke-width": "2" }) })) }), jsxRuntime.jsx("hr", { class: "artajs__tracking__events__vertical", style: "0 auto" })] }), jsxRuntime.jsxs("div", { class: "artajs__tracking__events__group__summary", children: [jsxRuntime.jsx("div", { class: idx === 0 && idx2 === 0
|
|
112
65
|
? 'artajs__tracking__events__group__location'
|
|
113
|
-
: 'artajs__tracking__events__group__location__secondary', children:
|
|
66
|
+
: 'artajs__tracking__events__group__location__secondary', children: cleanLocationString(event.location) ??
|
|
67
|
+
config.text.unknownLocation }), jsxRuntime.jsx("div", { class: "artajs__tracking__events__group__time", children: new Date(event.datetime).toLocaleTimeString([], {
|
|
114
68
|
hour: 'numeric',
|
|
115
69
|
minute: '2-digit',
|
|
116
|
-
}) }),
|
|
70
|
+
}) }), jsxRuntime.jsx("div", { class: "artajs__tracking__events__group__description", children: event.summary })] })] }));
|
|
117
71
|
}) })] }));
|
|
118
|
-
}),
|
|
72
|
+
}), jsxRuntime.jsx(index.DrawerFooter, {})] })) : (jsxRuntime.jsxs("div", { class: "artajs__tracking__body", children: [jsxRuntime.jsx("div", { class: "artajs__drawer__loading" }), jsxRuntime.jsx(index.DrawerFooter, {})] }))] }));
|
|
119
73
|
};
|
|
74
|
+
|
|
120
75
|
exports.PackageEvents = PackageEvents;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__pill__wrapper", children: (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__pill__round", style: { background: config.pill[pillStatus].backgroundColor }, children: (0, jsx_runtime_1.jsx)("div", { class: "artajs__tracking__pill__text", style: { color: config.pill[pillStatus].textColor }, children: config.pill[pillStatus].text }) }) }));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('preact/jsx-runtime');
|
|
4
|
+
|
|
5
|
+
const Pill = ({ config, status }) => {
|
|
6
|
+
const pillStatus = status === 'in_transit' ? 'transit' : status;
|
|
7
|
+
return (jsxRuntime.jsx("div", { class: "artajs__tracking__pill__wrapper", children: jsxRuntime.jsx("div", { class: "artajs__tracking__pill__round", style: { background: config.pill[pillStatus].backgroundColor }, children: jsxRuntime.jsx("div", { class: "artajs__tracking__pill__text", style: { color: config.pill[pillStatus].textColor }, children: config.pill[pillStatus].text }) }) }));
|
|
9
8
|
};
|
|
9
|
+
|
|
10
10
|
exports.Pill = Pill;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('preact/jsx-runtime');
|
|
4
|
+
var helper = require('../../helper.js');
|
|
5
|
+
var ModalStatus = require('../../ModalStatus.js');
|
|
6
|
+
|
|
7
|
+
const formatCurrency = (amount, currency) => {
|
|
8
|
+
const formatted = new Intl.NumberFormat('en-US', {
|
|
9
9
|
style: 'currency',
|
|
10
|
-
currency
|
|
10
|
+
currency,
|
|
11
11
|
currencyDisplay: 'narrowSymbol',
|
|
12
12
|
maximumFractionDigits: 0,
|
|
13
13
|
}).format(amount);
|
|
@@ -17,7 +17,7 @@ var formatCurrency = function (amount, currency) {
|
|
|
17
17
|
}
|
|
18
18
|
return formatted;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
const defaultQuoteConfig = {
|
|
21
21
|
shipFromLabel: 'These goods ship from:',
|
|
22
22
|
shipToLabel: 'To:',
|
|
23
23
|
disclaimerLabel: 'Actual shipping costs will be provided at checkout.',
|
|
@@ -25,27 +25,28 @@ exports.defaultQuoteConfig = {
|
|
|
25
25
|
startsAtLabel: 'Shipping Starts at',
|
|
26
26
|
artaInsuranceLabel: 'This estimate includes Arta Shipping Protection.',
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var onChangeDestination = function (e) {
|
|
28
|
+
const Quotes = ({ quoteRequest, showCostRange, textConfig, setStatus, }) => {
|
|
29
|
+
const onChangeDestination = (e) => {
|
|
31
30
|
e.preventDefault();
|
|
32
|
-
setStatus(
|
|
31
|
+
setStatus(ModalStatus.ModalStatus.OPEN);
|
|
33
32
|
};
|
|
34
|
-
|
|
33
|
+
const quotes = quoteRequest.quotes;
|
|
35
34
|
if (quotes && quotes.length > 0) {
|
|
36
|
-
quotes.sort(
|
|
35
|
+
quotes.sort((a, b) => {
|
|
37
36
|
return a.total - b.total;
|
|
38
37
|
});
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const hasInsurance = quoteRequest.insurance === 'arta_transit_insurance';
|
|
40
|
+
const isInternational = quoteRequest.origin.estimated_country ===
|
|
42
41
|
quoteRequest.destination.estimated_country;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
?
|
|
47
|
-
: textConfig.disclaimerLabel }))] })) : (
|
|
48
|
-
?
|
|
49
|
-
: textConfig.disclaimerLabel }))] })),
|
|
42
|
+
const parsedOrigin = helper.parseEstimatedLocation(quoteRequest.origin);
|
|
43
|
+
const parsedDestination = helper.parseEstimatedLocation(quoteRequest.destination);
|
|
44
|
+
return (jsxRuntime.jsxs("div", { class: "artajs__modal__quotes", children: [jsxRuntime.jsx("p", { class: "artajs__modal__quotes__context", children: textConfig.shipFromLabel }), jsxRuntime.jsx("p", { class: "artajs__modal__quotes__origin", children: jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx("strong", { class: "artajs__modal__capitalize", children: parsedOrigin }), ' ', jsxRuntime.jsx("span", { class: "artajs__modal__quotes__light", children: textConfig.detailOriginLabel })] }) }), jsxRuntime.jsxs("p", { class: "artajs__modal__quotes__destination", children: [jsxRuntime.jsx("span", { class: "artajs__modal__quotes__small", children: textConfig.shipToLabel }), ' ', parsedDestination ? (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx("strong", { class: "artajs__modal__capitalize", children: parsedDestination }), ' ', jsxRuntime.jsx("span", { class: "artajs__modal__quotes__light", children: textConfig.detailDestinationLabel })] })) : (jsxRuntime.jsx("span", { children: "..." }))] }), showCostRange && quotes.length > 1 ? (jsxRuntime.jsxs("div", { class: `artajs__modal__quotes__box ${!isInternational ? 'artajs__modal__quotes__box__padding__y' : ''}`, children: [jsxRuntime.jsx("p", { class: "artajs__modal__quotes__context", children: textConfig.rangeLabel }), jsxRuntime.jsxs("div", { class: "artajs__modal__quotes__price", children: [jsxRuntime.jsxs("strong", { class: "artajs__modal__quotes__price__amount", children: [formatCurrency(quotes[0].total, quoteRequest.currency), " -", ' ', formatCurrency(quotes[quotes.length - 1].total, quoteRequest.currency)] }), jsxRuntime.jsx("div", { class: "artajs__modal__quotes__price__currency_code", children: quoteRequest.currency })] }), isInternational && (jsxRuntime.jsx("p", { class: "artajs__modal__quotes__disclaimer", children: hasInsurance
|
|
45
|
+
? `${textConfig.artaInsuranceLabel} ${textConfig.disclaimerLabel}`
|
|
46
|
+
: textConfig.disclaimerLabel }))] })) : (jsxRuntime.jsxs("div", { class: `artajs__modal__quotes__box ${!isInternational ? 'artajs__modal__quotes__box__padding__y' : ''}`, children: [jsxRuntime.jsx("p", { class: "artajs__modal__quotes__context", children: textConfig.startsAtLabel }), jsxRuntime.jsxs("div", { class: "artajs__modal__quotes__price", children: [jsxRuntime.jsx("strong", { class: "artajs__modal__quotes__price__amount", children: formatCurrency(quotes[0].total, quoteRequest.currency) }), jsxRuntime.jsx("div", { class: "artajs__modal__quotes__price__currency_code", children: quoteRequest.currency })] }), isInternational && (jsxRuntime.jsx("p", { class: "artajs__modal__quotes__disclaimer", children: hasInsurance
|
|
47
|
+
? `${textConfig.artaInsuranceLabel} ${textConfig.disclaimerLabel}`
|
|
48
|
+
: textConfig.disclaimerLabel }))] })), jsxRuntime.jsx("p", { class: "artajs__modal__quotes__change", children: jsxRuntime.jsxs("a", { onClick: onChangeDestination, href: "#", children: [jsxRuntime.jsx("svg", { height: "12", id: "chevron-left", viewBox: "0 0 32 32", width: "12", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M20 1 L24 5 L14 16 L24 27 L20 31 L6 16 z" }) }), textConfig.returnLinkLabel] }) })] }));
|
|
50
49
|
};
|
|
50
|
+
|
|
51
51
|
exports.Quotes = Quotes;
|
|
52
|
+
exports.defaultQuoteConfig = defaultQuoteConfig;
|