@fileverse-dev/fortune-react 1.0.88-patch-3 → 1.0.88-patch-4
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/es/components/SheetOverlay/FormulaHint/index.d.ts +0 -3
- package/es/components/SheetOverlay/FormulaHint/index.js +48 -44
- package/es/components/SheetOverlay/FormulaHint/utils/utils.d.ts +3 -0
- package/es/components/SheetOverlay/FormulaHint/utils/utils.js +17 -0
- package/lib/components/SheetOverlay/FormulaHint/index.d.ts +0 -3
- package/lib/components/SheetOverlay/FormulaHint/index.js +49 -48
- package/lib/components/SheetOverlay/FormulaHint/utils/utils.d.ts +3 -0
- package/lib/components/SheetOverlay/FormulaHint/utils/utils.js +25 -0
- package/package.json +2 -2
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./index.css";
|
|
3
|
-
export declare function formatExpiryTime(createdAt: number): string;
|
|
4
|
-
export declare function isExpired(createdAt: number): boolean;
|
|
5
|
-
export declare function timeFromNowMessage(expiryStr: string): string;
|
|
6
3
|
declare const FormulaHint: React.FC<React.HTMLAttributes<HTMLDivElement>>;
|
|
7
4
|
export default FormulaHint;
|
|
@@ -13,23 +13,7 @@ import { Button, TextField, LucideIcon } from "@fileverse/ui";
|
|
|
13
13
|
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
14
14
|
import WorkbookContext from "../../../context";
|
|
15
15
|
import "./index.css";
|
|
16
|
-
|
|
17
|
-
var expiry = new Date(createdAt + 60 * 60 * 1000);
|
|
18
|
-
var mm = String(expiry.getMinutes()).padStart(2, "0");
|
|
19
|
-
var ss = String(expiry.getSeconds()).padStart(2, "0");
|
|
20
|
-
return "".concat(mm, ":").concat(ss);
|
|
21
|
-
}
|
|
22
|
-
export function isExpired(createdAt) {
|
|
23
|
-
var expiryTs = createdAt + 60 * 60 * 1000;
|
|
24
|
-
return Date.now() > expiryTs;
|
|
25
|
-
}
|
|
26
|
-
export function timeFromNowMessage(expiryStr) {
|
|
27
|
-
if (!expiryStr) {
|
|
28
|
-
return "0 minute";
|
|
29
|
-
}
|
|
30
|
-
var mm = expiryStr.split(":").map(Number)[0];
|
|
31
|
-
return "".concat(mm, " minute").concat(mm !== 1 ? "s" : "");
|
|
32
|
-
}
|
|
16
|
+
import { formatTimeLeft, isExpired, timeFromNowMessage } from "./utils/utils";
|
|
33
17
|
var FormulaHint = function FormulaHint(props) {
|
|
34
18
|
var _a;
|
|
35
19
|
var context = useContext(WorkbookContext).context;
|
|
@@ -51,9 +35,12 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
51
35
|
var _f = useState(true),
|
|
52
36
|
showFunctionBody = _f[0],
|
|
53
37
|
setShouldShowFunctionBody = _f[1];
|
|
54
|
-
var _g = useState(""),
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
var _g = useState("0 minute"),
|
|
39
|
+
timeLeft = _g[0],
|
|
40
|
+
setTimeLeft = _g[1];
|
|
41
|
+
var _h = useState(0),
|
|
42
|
+
accessTokenCreatedAt = _h[0],
|
|
43
|
+
setAccessTokenCreatedAt = _h[1];
|
|
57
44
|
var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
|
|
58
45
|
var handleGnosisPayToken = function handleGnosisPayToken(onDone) {
|
|
59
46
|
if (localStorage.getItem("GNOSIS_PAY_ACCESS")) {
|
|
@@ -62,13 +49,13 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
62
49
|
if (hasGnosisPayToken) {
|
|
63
50
|
setHasGnosisPayToken(false);
|
|
64
51
|
}
|
|
65
|
-
if (
|
|
66
|
-
|
|
52
|
+
if (accessTokenCreatedAt) {
|
|
53
|
+
setAccessTokenCreatedAt(0);
|
|
67
54
|
}
|
|
68
55
|
return;
|
|
69
56
|
}
|
|
70
57
|
setHasGnosisPayToken(!!access.token);
|
|
71
|
-
|
|
58
|
+
setAccessTokenCreatedAt(access.createdAt);
|
|
72
59
|
onDone === null || onDone === void 0 ? void 0 : onDone();
|
|
73
60
|
} else {
|
|
74
61
|
var urlParams = new URLSearchParams(window.location.search);
|
|
@@ -93,9 +80,9 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
93
80
|
ETHERSCAN_API_KEY: "Etherscan API key"
|
|
94
81
|
};
|
|
95
82
|
var hintRef = useRef(null);
|
|
96
|
-
var
|
|
97
|
-
top =
|
|
98
|
-
setTop =
|
|
83
|
+
var _j = useState(0),
|
|
84
|
+
top = _j[0],
|
|
85
|
+
setTop = _j[1];
|
|
99
86
|
var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
|
|
100
87
|
var _a, _b, _c;
|
|
101
88
|
if (!((_a = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) === null || _a === void 0 ? void 0 : _a.toString()) || !((_b = firstSelection.height_move) === null || _b === void 0 ? void 0 : _b.toString()) || !hintRef.current) return;
|
|
@@ -145,14 +132,42 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
145
132
|
};
|
|
146
133
|
}, []);
|
|
147
134
|
var gnosisTokenTokenIntervalRef = useRef(null);
|
|
148
|
-
var
|
|
149
|
-
isLoading =
|
|
150
|
-
setIsLoading =
|
|
135
|
+
var _k = useState(false),
|
|
136
|
+
isLoading = _k[0],
|
|
137
|
+
setIsLoading = _k[1];
|
|
151
138
|
useEffect(function () {
|
|
152
139
|
return function () {
|
|
153
140
|
if (gnosisTokenTokenIntervalRef.current) clearInterval(gnosisTokenTokenIntervalRef.current);
|
|
154
141
|
};
|
|
155
142
|
}, [gnosisTokenTokenIntervalRef]);
|
|
143
|
+
useEffect(function () {
|
|
144
|
+
if (accessTokenCreatedAt <= 0) return function () {};
|
|
145
|
+
var interval = setInterval(function () {
|
|
146
|
+
var EXPIRY_DURATION_MS = 60 * 60 * 1000;
|
|
147
|
+
var expiryTimestamp = accessTokenCreatedAt + EXPIRY_DURATION_MS;
|
|
148
|
+
var newTimeLeft = expiryTimestamp - Date.now();
|
|
149
|
+
setTimeLeft(formatTimeLeft(newTimeLeft));
|
|
150
|
+
if (newTimeLeft <= 0 || !document.getElementById("gnosis-pay-area")) {
|
|
151
|
+
clearInterval(interval);
|
|
152
|
+
}
|
|
153
|
+
}, 1000);
|
|
154
|
+
return function () {
|
|
155
|
+
clearInterval(interval);
|
|
156
|
+
};
|
|
157
|
+
}, [accessTokenCreatedAt, fn]);
|
|
158
|
+
var grantAccess = function grantAccess() {
|
|
159
|
+
var button = document.getElementById("grant-gnosispay-access");
|
|
160
|
+
if (!button) return;
|
|
161
|
+
button.click();
|
|
162
|
+
setIsLoading(true);
|
|
163
|
+
var interval = setInterval(function () {
|
|
164
|
+
handleGnosisPayToken(function () {
|
|
165
|
+
clearInterval(interval);
|
|
166
|
+
setIsLoading(false);
|
|
167
|
+
});
|
|
168
|
+
}, 5000);
|
|
169
|
+
gnosisTokenTokenIntervalRef.current = interval;
|
|
170
|
+
};
|
|
156
171
|
if (!fn) return null;
|
|
157
172
|
return /*#__PURE__*/React.createElement("div", __assign({}, props, {
|
|
158
173
|
ref: hintRef,
|
|
@@ -315,6 +330,7 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
315
330
|
disabled: !API_KEY,
|
|
316
331
|
className: "min-w-[80px]"
|
|
317
332
|
}, "Ok"))))))), fn.n === "GNOSISPAY" && (/*#__PURE__*/React.createElement("div", {
|
|
333
|
+
id: "gnosis-pay-area",
|
|
318
334
|
style: {
|
|
319
335
|
borderLeft: "4px solid ".concat(hasGnosisPayToken ? "#177E23" : "#fb923c"),
|
|
320
336
|
backgroundColor: "white",
|
|
@@ -339,27 +355,15 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
339
355
|
margin: "0 0 16px 0"
|
|
340
356
|
},
|
|
341
357
|
className: "text-body-sm color-text-default"
|
|
342
|
-
}, !hasGnosisPayToken ? "To access your Gnosis Pay account, please grant permission. Your dSheet account should be created via the same wallet ss your Gnosis Pay. " : " You have ".concat(timeFromNowMessage(
|
|
343
|
-
onClick:
|
|
344
|
-
var button = document.getElementById("grant-gnosispay-access");
|
|
345
|
-
if (!button) return;
|
|
346
|
-
button.click();
|
|
347
|
-
setIsLoading(true);
|
|
348
|
-
var interval = setInterval(function () {
|
|
349
|
-
handleGnosisPayToken(function () {
|
|
350
|
-
clearInterval(interval);
|
|
351
|
-
setIsLoading(false);
|
|
352
|
-
});
|
|
353
|
-
}, 5000);
|
|
354
|
-
gnosisTokenTokenIntervalRef.current = interval;
|
|
355
|
-
},
|
|
358
|
+
}, !hasGnosisPayToken ? "To access your Gnosis Pay account, please grant permission. Your dSheet account should be created via the same wallet ss your Gnosis Pay. " : " You have ".concat(timeFromNowMessage(timeLeft), " to use your Gnosis Pay account. Then you need to grant access again.")), /*#__PURE__*/React.createElement(Button, {
|
|
359
|
+
onClick: grantAccess,
|
|
356
360
|
disabled: hasGnosisPayToken || isWrongGnosisPayConnector || isLoading,
|
|
357
361
|
className: "w-full items-center flex gap-1"
|
|
358
362
|
}, isLoading && (/*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(LucideIcon, {
|
|
359
363
|
name: "LoaderCircle",
|
|
360
364
|
className: "animate-spin",
|
|
361
365
|
size: "sm"
|
|
362
|
-
}))), /*#__PURE__*/React.createElement("p", null, "Grant access "), " ",
|
|
366
|
+
}))), /*#__PURE__*/React.createElement("p", null, "Grant access "), " ", accessTokenCreatedAt > 0 && /*#__PURE__*/React.createElement("div", null, timeLeft))))), /*#__PURE__*/React.createElement("div", {
|
|
363
367
|
style: {
|
|
364
368
|
backgroundColor: "white",
|
|
365
369
|
padding: "6px",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function formatTimeLeft(msLeft) {
|
|
2
|
+
var totalSeconds = Math.max(0, Math.floor(msLeft / 1000));
|
|
3
|
+
var minutes = String(Math.floor(totalSeconds / 60)).padStart(2, "0");
|
|
4
|
+
var seconds = String(totalSeconds % 60).padStart(2, "0");
|
|
5
|
+
return "".concat(minutes, ":").concat(seconds);
|
|
6
|
+
}
|
|
7
|
+
export function isExpired(createdAt) {
|
|
8
|
+
var expiryTs = createdAt + 60 * 60 * 1000;
|
|
9
|
+
return Date.now() > expiryTs;
|
|
10
|
+
}
|
|
11
|
+
export function timeFromNowMessage(expiryStr) {
|
|
12
|
+
if (!expiryStr) {
|
|
13
|
+
return "0 minute";
|
|
14
|
+
}
|
|
15
|
+
var mm = expiryStr.split(":").map(Number)[0];
|
|
16
|
+
return "".concat(mm, " minute").concat(mm !== 1 ? "s" : "");
|
|
17
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./index.css";
|
|
3
|
-
export declare function formatExpiryTime(createdAt: number): string;
|
|
4
|
-
export declare function isExpired(createdAt: number): boolean;
|
|
5
|
-
export declare function timeFromNowMessage(expiryStr: string): string;
|
|
6
3
|
declare const FormulaHint: React.FC<React.HTMLAttributes<HTMLDivElement>>;
|
|
7
4
|
export default FormulaHint;
|
|
@@ -5,14 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
exports.formatExpiryTime = formatExpiryTime;
|
|
9
|
-
exports.isExpired = isExpired;
|
|
10
|
-
exports.timeFromNowMessage = timeFromNowMessage;
|
|
11
8
|
var _fortuneCore = require("@fileverse-dev/fortune-core");
|
|
12
9
|
var _ui = require("@fileverse/ui");
|
|
13
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
11
|
var _context = _interopRequireDefault(require("../../../context"));
|
|
15
12
|
require("./index.css");
|
|
13
|
+
var _utils = require("./utils/utils");
|
|
16
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
18
16
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
@@ -25,23 +23,6 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
25
23
|
};
|
|
26
24
|
return __assign.apply(this, arguments);
|
|
27
25
|
};
|
|
28
|
-
function formatExpiryTime(createdAt) {
|
|
29
|
-
var expiry = new Date(createdAt + 60 * 60 * 1000);
|
|
30
|
-
var mm = String(expiry.getMinutes()).padStart(2, "0");
|
|
31
|
-
var ss = String(expiry.getSeconds()).padStart(2, "0");
|
|
32
|
-
return "".concat(mm, ":").concat(ss);
|
|
33
|
-
}
|
|
34
|
-
function isExpired(createdAt) {
|
|
35
|
-
var expiryTs = createdAt + 60 * 60 * 1000;
|
|
36
|
-
return Date.now() > expiryTs;
|
|
37
|
-
}
|
|
38
|
-
function timeFromNowMessage(expiryStr) {
|
|
39
|
-
if (!expiryStr) {
|
|
40
|
-
return "0 minute";
|
|
41
|
-
}
|
|
42
|
-
var mm = expiryStr.split(":").map(Number)[0];
|
|
43
|
-
return "".concat(mm, " minute").concat(mm !== 1 ? "s" : "");
|
|
44
|
-
}
|
|
45
26
|
var FormulaHint = function FormulaHint(props) {
|
|
46
27
|
var _a;
|
|
47
28
|
var context = (0, _react.useContext)(_context.default).context;
|
|
@@ -63,24 +44,27 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
63
44
|
var _f = (0, _react.useState)(true),
|
|
64
45
|
showFunctionBody = _f[0],
|
|
65
46
|
setShouldShowFunctionBody = _f[1];
|
|
66
|
-
var _g = (0, _react.useState)(""),
|
|
67
|
-
|
|
68
|
-
|
|
47
|
+
var _g = (0, _react.useState)("0 minute"),
|
|
48
|
+
timeLeft = _g[0],
|
|
49
|
+
setTimeLeft = _g[1];
|
|
50
|
+
var _h = (0, _react.useState)(0),
|
|
51
|
+
accessTokenCreatedAt = _h[0],
|
|
52
|
+
setAccessTokenCreatedAt = _h[1];
|
|
69
53
|
var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
|
|
70
54
|
var handleGnosisPayToken = function handleGnosisPayToken(onDone) {
|
|
71
55
|
if (localStorage.getItem("GNOSIS_PAY_ACCESS")) {
|
|
72
56
|
var access = JSON.parse(localStorage.getItem("GNOSIS_PAY_ACCESS") || "");
|
|
73
|
-
if (!(access === null || access === void 0 ? void 0 : access.token) || isExpired(access === null || access === void 0 ? void 0 : access.createdAt)) {
|
|
57
|
+
if (!(access === null || access === void 0 ? void 0 : access.token) || (0, _utils.isExpired)(access === null || access === void 0 ? void 0 : access.createdAt)) {
|
|
74
58
|
if (hasGnosisPayToken) {
|
|
75
59
|
setHasGnosisPayToken(false);
|
|
76
60
|
}
|
|
77
|
-
if (
|
|
78
|
-
|
|
61
|
+
if (accessTokenCreatedAt) {
|
|
62
|
+
setAccessTokenCreatedAt(0);
|
|
79
63
|
}
|
|
80
64
|
return;
|
|
81
65
|
}
|
|
82
66
|
setHasGnosisPayToken(!!access.token);
|
|
83
|
-
|
|
67
|
+
setAccessTokenCreatedAt(access.createdAt);
|
|
84
68
|
onDone === null || onDone === void 0 ? void 0 : onDone();
|
|
85
69
|
} else {
|
|
86
70
|
var urlParams = new URLSearchParams(window.location.search);
|
|
@@ -105,9 +89,9 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
105
89
|
ETHERSCAN_API_KEY: "Etherscan API key"
|
|
106
90
|
};
|
|
107
91
|
var hintRef = (0, _react.useRef)(null);
|
|
108
|
-
var
|
|
109
|
-
top =
|
|
110
|
-
setTop =
|
|
92
|
+
var _j = (0, _react.useState)(0),
|
|
93
|
+
top = _j[0],
|
|
94
|
+
setTop = _j[1];
|
|
111
95
|
var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
|
|
112
96
|
var _a, _b, _c;
|
|
113
97
|
if (!((_a = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) === null || _a === void 0 ? void 0 : _a.toString()) || !((_b = firstSelection.height_move) === null || _b === void 0 ? void 0 : _b.toString()) || !hintRef.current) return;
|
|
@@ -157,14 +141,42 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
157
141
|
};
|
|
158
142
|
}, []);
|
|
159
143
|
var gnosisTokenTokenIntervalRef = (0, _react.useRef)(null);
|
|
160
|
-
var
|
|
161
|
-
isLoading =
|
|
162
|
-
setIsLoading =
|
|
144
|
+
var _k = (0, _react.useState)(false),
|
|
145
|
+
isLoading = _k[0],
|
|
146
|
+
setIsLoading = _k[1];
|
|
163
147
|
(0, _react.useEffect)(function () {
|
|
164
148
|
return function () {
|
|
165
149
|
if (gnosisTokenTokenIntervalRef.current) clearInterval(gnosisTokenTokenIntervalRef.current);
|
|
166
150
|
};
|
|
167
151
|
}, [gnosisTokenTokenIntervalRef]);
|
|
152
|
+
(0, _react.useEffect)(function () {
|
|
153
|
+
if (accessTokenCreatedAt <= 0) return function () {};
|
|
154
|
+
var interval = setInterval(function () {
|
|
155
|
+
var EXPIRY_DURATION_MS = 60 * 60 * 1000;
|
|
156
|
+
var expiryTimestamp = accessTokenCreatedAt + EXPIRY_DURATION_MS;
|
|
157
|
+
var newTimeLeft = expiryTimestamp - Date.now();
|
|
158
|
+
setTimeLeft((0, _utils.formatTimeLeft)(newTimeLeft));
|
|
159
|
+
if (newTimeLeft <= 0 || !document.getElementById("gnosis-pay-area")) {
|
|
160
|
+
clearInterval(interval);
|
|
161
|
+
}
|
|
162
|
+
}, 1000);
|
|
163
|
+
return function () {
|
|
164
|
+
clearInterval(interval);
|
|
165
|
+
};
|
|
166
|
+
}, [accessTokenCreatedAt, fn]);
|
|
167
|
+
var grantAccess = function grantAccess() {
|
|
168
|
+
var button = document.getElementById("grant-gnosispay-access");
|
|
169
|
+
if (!button) return;
|
|
170
|
+
button.click();
|
|
171
|
+
setIsLoading(true);
|
|
172
|
+
var interval = setInterval(function () {
|
|
173
|
+
handleGnosisPayToken(function () {
|
|
174
|
+
clearInterval(interval);
|
|
175
|
+
setIsLoading(false);
|
|
176
|
+
});
|
|
177
|
+
}, 5000);
|
|
178
|
+
gnosisTokenTokenIntervalRef.current = interval;
|
|
179
|
+
};
|
|
168
180
|
if (!fn) return null;
|
|
169
181
|
return /*#__PURE__*/_react.default.createElement("div", __assign({}, props, {
|
|
170
182
|
ref: hintRef,
|
|
@@ -327,6 +339,7 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
327
339
|
disabled: !API_KEY,
|
|
328
340
|
className: "min-w-[80px]"
|
|
329
341
|
}, "Ok"))))))), fn.n === "GNOSISPAY" && (/*#__PURE__*/_react.default.createElement("div", {
|
|
342
|
+
id: "gnosis-pay-area",
|
|
330
343
|
style: {
|
|
331
344
|
borderLeft: "4px solid ".concat(hasGnosisPayToken ? "#177E23" : "#fb923c"),
|
|
332
345
|
backgroundColor: "white",
|
|
@@ -351,27 +364,15 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
351
364
|
margin: "0 0 16px 0"
|
|
352
365
|
},
|
|
353
366
|
className: "text-body-sm color-text-default"
|
|
354
|
-
}, !hasGnosisPayToken ? "To access your Gnosis Pay account, please grant permission. Your dSheet account should be created via the same wallet ss your Gnosis Pay. " : " You have ".concat(timeFromNowMessage(
|
|
355
|
-
onClick:
|
|
356
|
-
var button = document.getElementById("grant-gnosispay-access");
|
|
357
|
-
if (!button) return;
|
|
358
|
-
button.click();
|
|
359
|
-
setIsLoading(true);
|
|
360
|
-
var interval = setInterval(function () {
|
|
361
|
-
handleGnosisPayToken(function () {
|
|
362
|
-
clearInterval(interval);
|
|
363
|
-
setIsLoading(false);
|
|
364
|
-
});
|
|
365
|
-
}, 5000);
|
|
366
|
-
gnosisTokenTokenIntervalRef.current = interval;
|
|
367
|
-
},
|
|
367
|
+
}, !hasGnosisPayToken ? "To access your Gnosis Pay account, please grant permission. Your dSheet account should be created via the same wallet ss your Gnosis Pay. " : " You have ".concat((0, _utils.timeFromNowMessage)(timeLeft), " to use your Gnosis Pay account. Then you need to grant access again.")), /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
368
|
+
onClick: grantAccess,
|
|
368
369
|
disabled: hasGnosisPayToken || isWrongGnosisPayConnector || isLoading,
|
|
369
370
|
className: "w-full items-center flex gap-1"
|
|
370
371
|
}, isLoading && (/*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
371
372
|
name: "LoaderCircle",
|
|
372
373
|
className: "animate-spin",
|
|
373
374
|
size: "sm"
|
|
374
|
-
}))), /*#__PURE__*/_react.default.createElement("p", null, "Grant access "), " ",
|
|
375
|
+
}))), /*#__PURE__*/_react.default.createElement("p", null, "Grant access "), " ", accessTokenCreatedAt > 0 && /*#__PURE__*/_react.default.createElement("div", null, timeLeft))))), /*#__PURE__*/_react.default.createElement("div", {
|
|
375
376
|
style: {
|
|
376
377
|
backgroundColor: "white",
|
|
377
378
|
padding: "6px",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatTimeLeft = formatTimeLeft;
|
|
7
|
+
exports.isExpired = isExpired;
|
|
8
|
+
exports.timeFromNowMessage = timeFromNowMessage;
|
|
9
|
+
function formatTimeLeft(msLeft) {
|
|
10
|
+
var totalSeconds = Math.max(0, Math.floor(msLeft / 1000));
|
|
11
|
+
var minutes = String(Math.floor(totalSeconds / 60)).padStart(2, "0");
|
|
12
|
+
var seconds = String(totalSeconds % 60).padStart(2, "0");
|
|
13
|
+
return "".concat(minutes, ":").concat(seconds);
|
|
14
|
+
}
|
|
15
|
+
function isExpired(createdAt) {
|
|
16
|
+
var expiryTs = createdAt + 60 * 60 * 1000;
|
|
17
|
+
return Date.now() > expiryTs;
|
|
18
|
+
}
|
|
19
|
+
function timeFromNowMessage(expiryStr) {
|
|
20
|
+
if (!expiryStr) {
|
|
21
|
+
return "0 minute";
|
|
22
|
+
}
|
|
23
|
+
var mm = expiryStr.split(":").map(Number)[0];
|
|
24
|
+
return "".concat(mm, " minute").concat(mm !== 1 ? "s" : "");
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-react",
|
|
3
|
-
"version": "1.0.88-patch-
|
|
3
|
+
"version": "1.0.88-patch-4",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"tsc": "tsc"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@fileverse-dev/fortune-core": "1.0.88-patch-
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.0.88-patch-4",
|
|
20
20
|
"@fileverse/ui": "^4.1.7-patch-21",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|