@fileverse-dev/fortune-react 1.0.88-patch-1 → 1.0.88-patch-2

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.
@@ -27,11 +27,8 @@ export function timeFromNowMessage(expiryStr) {
27
27
  if (!expiryStr) {
28
28
  return "0 minute";
29
29
  }
30
- var _a = expiryStr.split(":").map(Number),
31
- mm = _a[0],
32
- ss = _a[1];
33
- var minutes = ss > 0 ? mm + 1 : mm;
34
- return "".concat(minutes, " minute").concat(minutes !== 1 ? "s" : "");
30
+ var mm = expiryStr.split(":").map(Number)[0];
31
+ return "".concat(mm, " minute").concat(mm !== 1 ? "s" : "");
35
32
  }
36
33
  var FormulaHint = function FormulaHint(props) {
37
34
  var _a;
@@ -57,11 +54,11 @@ var FormulaHint = function FormulaHint(props) {
57
54
  var _g = useState(""),
58
55
  expiryTime = _g[0],
59
56
  setExpiryTime = _g[1];
60
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "wallet";
57
+ var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
61
58
  var handleGnosisPayToken = function handleGnosisPayToken(onDone) {
62
59
  if (localStorage.getItem("GNOSIS_PAY_ACCESS")) {
63
60
  var access = JSON.parse(localStorage.getItem("GNOSIS_PAY_ACCESS") || "");
64
- if (!access || isExpired(access === null || access === void 0 ? void 0 : access.createdAt)) {
61
+ if (!(access === null || access === void 0 ? void 0 : access.token) || isExpired(access === null || access === void 0 ? void 0 : access.createdAt)) {
65
62
  if (hasGnosisPayToken) {
66
63
  setHasGnosisPayToken(false);
67
64
  }
@@ -71,8 +68,17 @@ var FormulaHint = function FormulaHint(props) {
71
68
  return;
72
69
  }
73
70
  setHasGnosisPayToken(!!access.token);
74
- setExpiryTime(formatExpiryTime(access.createAt));
71
+ setExpiryTime(formatExpiryTime(access.createdAt));
75
72
  onDone === null || onDone === void 0 ? void 0 : onDone();
73
+ } else {
74
+ var urlParams = new URLSearchParams(window.location.search);
75
+ var isRejected = urlParams.has("reject");
76
+ if (isRejected) {
77
+ var url = new URL(window.location.href);
78
+ url.searchParams.delete("reject");
79
+ window.history.replaceState({}, "", url.toString());
80
+ onDone === null || onDone === void 0 ? void 0 : onDone();
81
+ }
76
82
  }
77
83
  };
78
84
  useEffect(function () {
@@ -139,6 +145,9 @@ var FormulaHint = function FormulaHint(props) {
139
145
  };
140
146
  }, []);
141
147
  var gnosisTokenTokenIntervalRef = useRef(null);
148
+ var _j = useState(false),
149
+ isLoading = _j[0],
150
+ setIsLoading = _j[1];
142
151
  useEffect(function () {
143
152
  return function () {
144
153
  if (gnosisTokenTokenIntervalRef.current) clearInterval(gnosisTokenTokenIntervalRef.current);
@@ -335,16 +344,22 @@ var FormulaHint = function FormulaHint(props) {
335
344
  var button = document.getElementById("grant-gnosispay-access");
336
345
  if (!button) return;
337
346
  button.click();
347
+ setIsLoading(true);
338
348
  var interval = setInterval(function () {
339
349
  handleGnosisPayToken(function () {
340
- return clearInterval(interval);
350
+ clearInterval(interval);
351
+ setIsLoading(false);
341
352
  });
342
353
  }, 5000);
343
354
  gnosisTokenTokenIntervalRef.current = interval;
344
355
  },
345
- disabled: hasGnosisPayToken || isWrongGnosisPayConnector,
346
- className: "w-full flex gap-1"
347
- }, /*#__PURE__*/React.createElement("p", null, "Grant access "), " ", expiryTime && /*#__PURE__*/React.createElement("div", null, expiryTime))))), /*#__PURE__*/React.createElement("div", {
356
+ disabled: hasGnosisPayToken || isWrongGnosisPayConnector || isLoading,
357
+ className: "w-full items-center flex gap-1"
358
+ }, isLoading && (/*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(LucideIcon, {
359
+ name: "LoaderCircle",
360
+ className: "animate-spin",
361
+ size: "sm"
362
+ }))), /*#__PURE__*/React.createElement("p", null, "Grant access "), " ", expiryTime && /*#__PURE__*/React.createElement("div", null, expiryTime))))), /*#__PURE__*/React.createElement("div", {
348
363
  style: {
349
364
  backgroundColor: "white",
350
365
  padding: "6px",
@@ -16,10 +16,9 @@ import WorkbookContext from "../../../context";
16
16
  import "./index.css";
17
17
  var FormulaSearch = function FormulaSearch(props) {
18
18
  var _a;
19
- var _b = useContext(WorkbookContext),
20
- context = _b.context,
21
- isAuthorized = _b.settings.isAuthorized;
22
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "wallet";
19
+ var context = useContext(WorkbookContext).context;
20
+ var isAuthorized = true;
21
+ var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
23
22
  var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "GNOSIS", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT"];
24
23
  var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
25
24
  return !authedFunction.includes(item.n);
@@ -33,9 +32,9 @@ var FormulaSearch = function FormulaSearch(props) {
33
32
  });
34
33
  var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
35
34
  var hintRef = useRef(null);
36
- var _c = useState(0),
37
- top = _c[0],
38
- setTop = _c[1];
35
+ var _b = useState(0),
36
+ top = _b[0],
37
+ setTop = _b[1];
39
38
  var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
40
39
  var _a, _b, _c;
41
40
  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;
@@ -39,11 +39,8 @@ function timeFromNowMessage(expiryStr) {
39
39
  if (!expiryStr) {
40
40
  return "0 minute";
41
41
  }
42
- var _a = expiryStr.split(":").map(Number),
43
- mm = _a[0],
44
- ss = _a[1];
45
- var minutes = ss > 0 ? mm + 1 : mm;
46
- return "".concat(minutes, " minute").concat(minutes !== 1 ? "s" : "");
42
+ var mm = expiryStr.split(":").map(Number)[0];
43
+ return "".concat(mm, " minute").concat(mm !== 1 ? "s" : "");
47
44
  }
48
45
  var FormulaHint = function FormulaHint(props) {
49
46
  var _a;
@@ -69,11 +66,11 @@ var FormulaHint = function FormulaHint(props) {
69
66
  var _g = (0, _react.useState)(""),
70
67
  expiryTime = _g[0],
71
68
  setExpiryTime = _g[1];
72
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "wallet";
69
+ var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
73
70
  var handleGnosisPayToken = function handleGnosisPayToken(onDone) {
74
71
  if (localStorage.getItem("GNOSIS_PAY_ACCESS")) {
75
72
  var access = JSON.parse(localStorage.getItem("GNOSIS_PAY_ACCESS") || "");
76
- if (!access || isExpired(access === null || access === void 0 ? void 0 : access.createdAt)) {
73
+ if (!(access === null || access === void 0 ? void 0 : access.token) || isExpired(access === null || access === void 0 ? void 0 : access.createdAt)) {
77
74
  if (hasGnosisPayToken) {
78
75
  setHasGnosisPayToken(false);
79
76
  }
@@ -83,8 +80,17 @@ var FormulaHint = function FormulaHint(props) {
83
80
  return;
84
81
  }
85
82
  setHasGnosisPayToken(!!access.token);
86
- setExpiryTime(formatExpiryTime(access.createAt));
83
+ setExpiryTime(formatExpiryTime(access.createdAt));
87
84
  onDone === null || onDone === void 0 ? void 0 : onDone();
85
+ } else {
86
+ var urlParams = new URLSearchParams(window.location.search);
87
+ var isRejected = urlParams.has("reject");
88
+ if (isRejected) {
89
+ var url = new URL(window.location.href);
90
+ url.searchParams.delete("reject");
91
+ window.history.replaceState({}, "", url.toString());
92
+ onDone === null || onDone === void 0 ? void 0 : onDone();
93
+ }
88
94
  }
89
95
  };
90
96
  (0, _react.useEffect)(function () {
@@ -151,6 +157,9 @@ var FormulaHint = function FormulaHint(props) {
151
157
  };
152
158
  }, []);
153
159
  var gnosisTokenTokenIntervalRef = (0, _react.useRef)(null);
160
+ var _j = (0, _react.useState)(false),
161
+ isLoading = _j[0],
162
+ setIsLoading = _j[1];
154
163
  (0, _react.useEffect)(function () {
155
164
  return function () {
156
165
  if (gnosisTokenTokenIntervalRef.current) clearInterval(gnosisTokenTokenIntervalRef.current);
@@ -347,16 +356,22 @@ var FormulaHint = function FormulaHint(props) {
347
356
  var button = document.getElementById("grant-gnosispay-access");
348
357
  if (!button) return;
349
358
  button.click();
359
+ setIsLoading(true);
350
360
  var interval = setInterval(function () {
351
361
  handleGnosisPayToken(function () {
352
- return clearInterval(interval);
362
+ clearInterval(interval);
363
+ setIsLoading(false);
353
364
  });
354
365
  }, 5000);
355
366
  gnosisTokenTokenIntervalRef.current = interval;
356
367
  },
357
- disabled: hasGnosisPayToken || isWrongGnosisPayConnector,
358
- className: "w-full flex gap-1"
359
- }, /*#__PURE__*/_react.default.createElement("p", null, "Grant access "), " ", expiryTime && /*#__PURE__*/_react.default.createElement("div", null, expiryTime))))), /*#__PURE__*/_react.default.createElement("div", {
368
+ disabled: hasGnosisPayToken || isWrongGnosisPayConnector || isLoading,
369
+ className: "w-full items-center flex gap-1"
370
+ }, isLoading && (/*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
371
+ name: "LoaderCircle",
372
+ className: "animate-spin",
373
+ size: "sm"
374
+ }))), /*#__PURE__*/_react.default.createElement("p", null, "Grant access "), " ", expiryTime && /*#__PURE__*/_react.default.createElement("div", null, expiryTime))))), /*#__PURE__*/_react.default.createElement("div", {
360
375
  style: {
361
376
  backgroundColor: "white",
362
377
  padding: "6px",
@@ -25,10 +25,9 @@ var __assign = void 0 && (void 0).__assign || function () {
25
25
  };
26
26
  var FormulaSearch = function FormulaSearch(props) {
27
27
  var _a;
28
- var _b = (0, _react.useContext)(_context.default),
29
- context = _b.context,
30
- isAuthorized = _b.settings.isAuthorized;
31
- var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "wallet";
28
+ var context = (0, _react.useContext)(_context.default).context;
29
+ var isAuthorized = true;
30
+ var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
32
31
  var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "GNOSIS", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT"];
33
32
  var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
34
33
  return !authedFunction.includes(item.n);
@@ -42,9 +41,9 @@ var FormulaSearch = function FormulaSearch(props) {
42
41
  });
43
42
  var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
44
43
  var hintRef = (0, _react.useRef)(null);
45
- var _c = (0, _react.useState)(0),
46
- top = _c[0],
47
- setTop = _c[1];
44
+ var _b = (0, _react.useState)(0),
45
+ top = _b[0],
46
+ setTop = _b[1];
48
47
  var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
49
48
  var _a, _b, _c;
50
49
  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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.0.88-patch-1",
3
+ "version": "1.0.88-patch-2",
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-1",
19
+ "@fileverse-dev/fortune-core": "1.0.88-patch-2",
20
20
  "@fileverse/ui": "^4.1.7-patch-21",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",