fontdue-js 2.12.0 → 2.12.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated SignedSource<<
|
|
2
|
+
* @generated SignedSource<<a4b4b22cee06bf7a0b71e5b62dbc94d0>>
|
|
3
3
|
* @lightSyntaxTransform
|
|
4
4
|
* @nogrep
|
|
5
5
|
*/
|
|
@@ -8,11 +8,10 @@ export type CartTotalsCreateSnapshotMutation$variables = Record<PropertyKey, nev
|
|
|
8
8
|
export type CartTotalsCreateSnapshotMutation$data = {
|
|
9
9
|
readonly createOrderSnapshot: {
|
|
10
10
|
readonly orderSnapshot: {
|
|
11
|
-
readonly description: string | null;
|
|
12
11
|
readonly id: string | null;
|
|
13
|
-
readonly
|
|
12
|
+
readonly quotePdfUrl: string | null;
|
|
13
|
+
readonly shareUrl: string | null;
|
|
14
14
|
} | null;
|
|
15
|
-
readonly shareUrl: string | null;
|
|
16
15
|
} | null;
|
|
17
16
|
};
|
|
18
17
|
export type CartTotalsCreateSnapshotMutation = {
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
|
-
* @generated SignedSource<<
|
|
8
|
+
* @generated SignedSource<<a4b4b22cee06bf7a0b71e5b62dbc94d0>>
|
|
9
9
|
* @lightSyntaxTransform
|
|
10
10
|
* @nogrep
|
|
11
11
|
*/
|
|
@@ -39,22 +39,16 @@ const node = function () {
|
|
|
39
39
|
"alias": null,
|
|
40
40
|
"args": null,
|
|
41
41
|
"kind": "ScalarField",
|
|
42
|
-
"name": "
|
|
42
|
+
"name": "quotePdfUrl",
|
|
43
43
|
"storageKey": null
|
|
44
44
|
}, {
|
|
45
45
|
"alias": null,
|
|
46
46
|
"args": null,
|
|
47
47
|
"kind": "ScalarField",
|
|
48
|
-
"name": "
|
|
48
|
+
"name": "shareUrl",
|
|
49
49
|
"storageKey": null
|
|
50
50
|
}],
|
|
51
51
|
"storageKey": null
|
|
52
|
-
}, {
|
|
53
|
-
"alias": null,
|
|
54
|
-
"args": null,
|
|
55
|
-
"kind": "ScalarField",
|
|
56
|
-
"name": "shareUrl",
|
|
57
|
-
"storageKey": null
|
|
58
52
|
}],
|
|
59
53
|
"storageKey": null
|
|
60
54
|
}];
|
|
@@ -76,15 +70,15 @@ const node = function () {
|
|
|
76
70
|
"selections": v0 /*: any*/
|
|
77
71
|
},
|
|
78
72
|
"params": {
|
|
79
|
-
"cacheID": "
|
|
73
|
+
"cacheID": "68ef1e5c60fc0176904bdfe545718bd9",
|
|
80
74
|
"id": null,
|
|
81
75
|
"metadata": {},
|
|
82
76
|
"name": "CartTotalsCreateSnapshotMutation",
|
|
83
77
|
"operationKind": "mutation",
|
|
84
|
-
"text": "mutation CartTotalsCreateSnapshotMutation {\n createOrderSnapshot {\n orderSnapshot {\n id\n
|
|
78
|
+
"text": "mutation CartTotalsCreateSnapshotMutation {\n createOrderSnapshot {\n orderSnapshot {\n id\n quotePdfUrl\n shareUrl\n }\n }\n}\n"
|
|
85
79
|
}
|
|
86
80
|
};
|
|
87
81
|
}();
|
|
88
|
-
node.hash = "
|
|
82
|
+
node.hash = "97e00cf77f0cc65bb808123fe5944c02";
|
|
89
83
|
var _default = node;
|
|
90
84
|
exports.default = _default;
|
|
@@ -20,38 +20,26 @@ function percentage(decimalValue) {
|
|
|
20
20
|
if (!decimalValue) return null;
|
|
21
21
|
return `${parseFloat(decimalValue) * 100}%`;
|
|
22
22
|
}
|
|
23
|
-
const getSnapshotIdFromShareUrl = url => {
|
|
24
|
-
const urlParts = url.split('/');
|
|
25
|
-
return urlParts[urlParts.length - 1] || null;
|
|
26
|
-
};
|
|
27
|
-
const getPdfUrl = (snapshotId, token) => {
|
|
28
|
-
return `/quotes/${snapshotId}${token ? `?token=${token}` : ''}`;
|
|
29
|
-
};
|
|
30
23
|
function ShareCart() {
|
|
31
24
|
const environment = (0, _reactRelay.useRelayEnvironment)();
|
|
32
25
|
const [isSharing, setIsSharing] = (0, _react.useState)(false);
|
|
33
|
-
const [
|
|
26
|
+
const [snapshot, setSnapshot] = (0, _react.useState)(null);
|
|
34
27
|
const [shareError, setShareError] = (0, _react.useState)(null);
|
|
35
|
-
const [snapshotToken, setSnapshotToken] = (0, _react.useState)(null);
|
|
36
28
|
const [copied, setCopied] = (0, _react.useState)(false);
|
|
37
29
|
const inputRef = (0, _react.useRef)(null);
|
|
38
30
|
const handleShareCart = () => {
|
|
39
31
|
setIsSharing(true);
|
|
40
32
|
setShareError(null);
|
|
41
33
|
(0, _reactRelay.commitMutation)(environment, {
|
|
42
|
-
mutation: (_CartTotalsCreateSnapshotMutation2.default.hash && _CartTotalsCreateSnapshotMutation2.default.hash !== "
|
|
34
|
+
mutation: (_CartTotalsCreateSnapshotMutation2.default.hash && _CartTotalsCreateSnapshotMutation2.default.hash !== "97e00cf77f0cc65bb808123fe5944c02" && console.error("The definition of 'CartTotalsCreateSnapshotMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CartTotalsCreateSnapshotMutation2.default),
|
|
43
35
|
variables: {},
|
|
44
36
|
onCompleted: (response, errors) => {
|
|
45
37
|
var _response$createOrder;
|
|
46
38
|
setIsSharing(false);
|
|
47
39
|
if (errors && errors.length > 0) {
|
|
48
40
|
setShareError(errors[0].message);
|
|
49
|
-
} else if ((_response$createOrder = response.createOrderSnapshot) !== null && _response$createOrder !== void 0 && _response$createOrder.
|
|
50
|
-
|
|
51
|
-
setShareUrl(response.createOrderSnapshot.shareUrl);
|
|
52
|
-
if ((_response$createOrder2 = response.createOrderSnapshot.orderSnapshot) !== null && _response$createOrder2 !== void 0 && _response$createOrder2.token) {
|
|
53
|
-
setSnapshotToken(response.createOrderSnapshot.orderSnapshot.token);
|
|
54
|
-
}
|
|
41
|
+
} else if ((_response$createOrder = response.createOrderSnapshot) !== null && _response$createOrder !== void 0 && _response$createOrder.orderSnapshot) {
|
|
42
|
+
setSnapshot(response.createOrderSnapshot.orderSnapshot);
|
|
55
43
|
} else {
|
|
56
44
|
setShareError('Failed to create shareable link');
|
|
57
45
|
}
|
|
@@ -65,11 +53,11 @@ function ShareCart() {
|
|
|
65
53
|
(0, _react.useEffect)(() => {
|
|
66
54
|
var _inputRef$current;
|
|
67
55
|
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.select();
|
|
68
|
-
}, [
|
|
56
|
+
}, [snapshot]);
|
|
69
57
|
const timeout = (0, _react.useRef)(null);
|
|
70
58
|
const handleCopyToClipboard = () => {
|
|
71
|
-
if (shareUrl) {
|
|
72
|
-
navigator.clipboard.writeText(shareUrl);
|
|
59
|
+
if (snapshot !== null && snapshot !== void 0 && snapshot.shareUrl) {
|
|
60
|
+
navigator.clipboard.writeText(snapshot.shareUrl);
|
|
73
61
|
setCopied(true);
|
|
74
62
|
if (timeout.current) clearTimeout(timeout.current);
|
|
75
63
|
timeout.current = setTimeout(() => {
|
|
@@ -77,7 +65,7 @@ function ShareCart() {
|
|
|
77
65
|
}, 1000);
|
|
78
66
|
}
|
|
79
67
|
};
|
|
80
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shareUrl ? /*#__PURE__*/_react.default.createElement("div", {
|
|
68
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, snapshot !== null && snapshot !== void 0 && snapshot.shareUrl && snapshot !== null && snapshot !== void 0 && snapshot.quotePdfUrl ? /*#__PURE__*/_react.default.createElement("div", {
|
|
81
69
|
className: "cart__share"
|
|
82
70
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
83
71
|
className: "cart__share-title"
|
|
@@ -86,7 +74,7 @@ function ShareCart() {
|
|
|
86
74
|
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
87
75
|
className: "cart__share-url-input",
|
|
88
76
|
ref: inputRef,
|
|
89
|
-
value: shareUrl,
|
|
77
|
+
value: snapshot.shareUrl ?? '',
|
|
90
78
|
readOnly: true,
|
|
91
79
|
onClick: e => e.currentTarget.select()
|
|
92
80
|
}), /*#__PURE__*/_react.default.createElement("button", {
|
|
@@ -95,7 +83,7 @@ function ShareCart() {
|
|
|
95
83
|
onClick: handleCopyToClipboard,
|
|
96
84
|
"data-copied": copied
|
|
97
85
|
}, /*#__PURE__*/_react.default.createElement("span", null, "Copy"), /*#__PURE__*/_react.default.createElement(_Icons.Check, null))), /*#__PURE__*/_react.default.createElement("a", {
|
|
98
|
-
href:
|
|
86
|
+
href: snapshot.quotePdfUrl,
|
|
99
87
|
className: "cart__share__button cart__share__pdf-button",
|
|
100
88
|
target: "_blank",
|
|
101
89
|
rel: "noopener noreferrer"
|
|
@@ -104,7 +92,7 @@ function ShareCart() {
|
|
|
104
92
|
className: "cart__share__button cart__share__share-button",
|
|
105
93
|
onClick: handleShareCart,
|
|
106
94
|
disabled: isSharing
|
|
107
|
-
}, isSharing ? '
|
|
95
|
+
}, isSharing ? 'Loading...' : 'Share cart'), shareError && /*#__PURE__*/_react.default.createElement("div", {
|
|
108
96
|
className: "cart__share-error"
|
|
109
97
|
}, "Cannot share your cart right now. Please try again later."));
|
|
110
98
|
}
|