@ape.swap/bonds-sdk 1.0.424 → 1.0.425

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.
@@ -75,6 +75,7 @@ import useCurrentTime from '../../hooks/useTimer';
75
75
  import { getPendingVesting } from '../../hooks/usePendingVesting';
76
76
  import axios from 'axios';
77
77
  import { fetchUserOwnedBillsDataAsync } from './fetchBillsUser';
78
+ import { Input } from '../uikit-sdk/Input';
78
79
  var YourBonds = function (_a) {
79
80
  var connectionString = _a.connectionString;
80
81
  var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
@@ -119,7 +120,7 @@ var YourBonds = function (_a) {
119
120
  }
120
121
  });
121
122
  }); };
122
- // Fetch data for user owned bill
123
+ // Fetch data
123
124
  var _d = useState([]), bondData = _d[0], setBondData = _d[1];
124
125
  var _e = useState([]), mappedUserBills = _e[0], setMappedUserBills = _e[1];
125
126
  useEffect(function () {
@@ -209,7 +210,7 @@ var YourBonds = function (_a) {
209
210
  });
210
211
  setSortedBonds(sorted);
211
212
  }, [sortConfig, mappedUserBills]);
212
- // Functions to calculate display values for each row
213
+ // Functions for calculations
213
214
  var chainId = useWeb3React().chainId;
214
215
  var currentTime = useCurrentTime() / 1000;
215
216
  var vestingTimeRemaining = function (userBill) {
@@ -235,19 +236,36 @@ var YourBonds = function (_a) {
235
236
  setIsModalOpen(true);
236
237
  navigate("/YourBonds/?bondAddress=".concat(bill.address, "&bondChain=").concat(bill.bond.chainId), { replace: true });
237
238
  };
238
- var _k = useState(false), bondsRendered = _k[0], setBondsRendered = _k[1];
239
+ // Search logic
240
+ var _k = useState(''), inputValue = _k[0], setInputValue = _k[1];
241
+ var _l = useState(sortedBonds), filteredBonds = _l[0], setFilteredBonds = _l[1];
239
242
  useEffect(function () {
240
- if (sortedBonds.length > 0) {
243
+ if (inputValue === '') {
244
+ setFilteredBonds(sortedBonds);
245
+ }
246
+ else {
247
+ setFilteredBonds(sortedBonds.filter(function (bond) {
248
+ return bond.bond.showcaseTokenName.toLowerCase().includes(inputValue.toLowerCase());
249
+ }));
250
+ }
251
+ }, [inputValue, sortedBonds]);
252
+ var handleInputChange = function (event) {
253
+ setInputValue(event.target.value);
254
+ };
255
+ // Page render logic
256
+ var _m = useState(false), bondsRendered = _m[0], setBondsRendered = _m[1];
257
+ useEffect(function () {
258
+ if (filteredBonds.length > 0) {
241
259
  setBondsRendered(true);
242
260
  }
243
- }, [sortedBonds]);
244
- return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), bondsRendered && (_jsxs(Flex, __assign({ className: "container table-container" }, { children: [_jsxs(Flex, __assign({ className: "container header-container" }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, { className: "column column-tokeninfoname" }) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column header-claimable" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Claimable" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('claimable'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column header-pending" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Pending" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('pending'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column header-terms" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Terms" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('terms'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsx(Flex, __assign({ className: "column header-claimall" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
261
+ }, [filteredBonds]);
262
+ return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), bondsRendered && (_jsxs(Flex, __assign({ className: "container table-container" }, { children: [_jsxs(Flex, __assign({ className: "container header-container" }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-search", sx: { width: '100%', maxWidth: ['200px', '200px', '200px', '340px'] } }, { children: _jsx(Input, { value: inputValue, onChange: handleInputChange, variant: "search", sx: { fontWeight: 400, background: 'white2', height: '30px', fontSize: '14px' }, width: '100%', placeholder: 'Search...' }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column header-claimable" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Claimable" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('claimable'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column header-pending" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Pending" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('pending'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column header-terms" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Terms" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('terms'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsx(Flex, __assign({ className: "column header-claimall" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
245
263
  height: ['36px', '36px', '36px', '26px'],
246
264
  lineHeight: '12px',
247
265
  fontSize: '14px',
248
266
  fontWeight: 600,
249
267
  width: '100%',
250
- } }, { children: "CLAIM ALL" })) }))] }))] })), sortedBonds.map(function (bill) {
268
+ } }, { children: "CLAIM ALL" })) }))] }))] })), filteredBonds.map(function (bill) {
251
269
  var _a, _b;
252
270
  return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [formatNumberSI(parseFloat(claimable(bill).toFixed(3)), 0), _jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px', paddingLeft: '5px' } }, { children: "($".concat((claimable(bill) * ((_a = parseFloat(earnTokenPrice(bill.bond))) !== null && _a !== void 0 ? _a : 0)).toFixed(2), ")") }))] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), _jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px', paddingLeft: '5px' } }, { children: "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")") }))] })), _jsx(Flex, __assign({ className: "column column-terms" }, { children: "".concat(vestingTimeRemaining(bill).days, "d, ").concat(vestingTimeRemaining(bill).hours, "h, ").concat(vestingTimeRemaining(bill).minutes, "m") })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Button, __assign({ disabled: !account, onClick: function (event) {
253
271
  event.stopPropagation();
@@ -49,6 +49,10 @@
49
49
  width: 40%;
50
50
  }
51
51
 
52
+ .column.column-search {
53
+ padding-bottom: 15px;
54
+ }
55
+
52
56
  .column.column-tokeninfoname {
53
57
  width: 100%;
54
58
  height: 100%;
@@ -43,6 +43,10 @@
43
43
  width: 40%;
44
44
  }
45
45
 
46
+ .column.column-search {
47
+ padding-bottom: 15px;
48
+ }
49
+
46
50
  .column.column-tokeninfoname {
47
51
  width: 100%;
48
52
  height: 100%;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "1.0.424",
6
+ "version": "1.0.425",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",