tek-wallet 0.0.754 → 0.0.756

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.
Files changed (63) hide show
  1. package/README.md +83 -32
  2. package/dist/components/TekWallet/components/ui/ActivitiesTypeSlice/index.d.ts +3 -0
  3. package/dist/components/TekWallet/components/ui/ActivitiesTypeSlice/index.js +7 -7
  4. package/dist/components/TekWallet/components/ui/ActivityDetail/index.js +5 -5
  5. package/dist/components/TekWallet/components/ui/ActivityItem/index.js +9 -4
  6. package/dist/components/TekWallet/components/ui/AmountGroupAndChart/index.js +103 -101
  7. package/dist/components/TekWallet/components/ui/AnalyticGroup/index.d.ts +2 -1
  8. package/dist/components/TekWallet/components/ui/AnalyticGroup/index.js +47 -32
  9. package/dist/components/TekWallet/components/ui/FiatDeposit/index.js +5 -3
  10. package/dist/components/TekWallet/components/ui/HistorySwap/index.js +1 -2
  11. package/dist/components/TekWallet/components/ui/NeonLineChart/index.d.ts +6 -5
  12. package/dist/components/TekWallet/components/ui/NeonLineChart/index.js +2 -2
  13. package/dist/components/TekWallet/components/ui/ReceiveHistory/index.js +1 -2
  14. package/dist/components/TekWallet/components/ui/SmartList/index.d.ts +0 -1
  15. package/dist/components/TekWallet/components/ui/SmartList/index.js +5 -4
  16. package/dist/components/TekWallet/components/ui/SvgPath/index.d.ts +1 -0
  17. package/dist/components/TekWallet/components/ui/SvgPath/index.js +3 -2
  18. package/dist/components/TekWallet/components/ui/SwapToken/index.js +0 -5
  19. package/dist/components/TekWallet/components/ui/SwapToken copy/index.d.ts +32 -0
  20. package/dist/components/TekWallet/components/ui/SwapToken copy/index.js +293 -0
  21. package/dist/components/TekWallet/components/ui/SwiperControlled/index.js +5 -1
  22. package/dist/components/TekWallet/components/ui/TimeFilter/index.d.ts +4 -3
  23. package/dist/components/TekWallet/components/ui/TimeFilter/index.js +27 -30
  24. package/dist/components/TekWallet/components/ui/TokenItem/index.js +11 -6
  25. package/dist/components/TekWallet/components/ui/TokensBoard/index.js +1 -3
  26. package/dist/components/TekWallet/components/views/ActivityView/index.d.ts +10 -0
  27. package/dist/components/TekWallet/components/views/ActivityView/index.js +64 -0
  28. package/dist/components/TekWallet/components/views/AssetView/index.js +69 -6
  29. package/dist/components/TekWallet/components/views/TekWalletView/index.js +1 -1
  30. package/dist/components/TekWallet/components/views/TekWalletView/routes.d.ts +5 -4
  31. package/dist/components/TekWallet/components/views/TekWalletView/routes.js +11 -5
  32. package/dist/components/TekWallet/const/app.config.d.ts +1 -0
  33. package/dist/components/TekWallet/const/app.config.js +4 -0
  34. package/dist/components/TekWallet/index.d.ts +1 -1
  35. package/dist/components/TekWallet/index.js +1 -1
  36. package/dist/components/TekWallet/providers/ActivitiesProvider/const.d.ts +1 -1
  37. package/dist/components/TekWallet/providers/ActivitiesProvider/const.js +1 -1
  38. package/dist/components/TekWallet/providers/ActivitiesProvider/functions/sortActivity.d.ts +3 -0
  39. package/dist/components/TekWallet/providers/ActivitiesProvider/functions/sortActivity.js +8 -0
  40. package/dist/components/TekWallet/providers/ActivitiesProvider/index.js +55 -51
  41. package/dist/components/TekWallet/providers/ActivitiesProvider/type.d.ts +1 -1
  42. package/dist/components/TekWallet/providers/WalletDataProvider/index.js +2 -0
  43. package/dist/components/TekWallet/providers/WalletDataProviderNoImport/index.js +41 -6
  44. package/dist/components/TekWallet/services/axios/get-activities-service/index.js +0 -3
  45. package/dist/components/TekWallet/services/axios/get-activities-service/type.d.ts +4 -4
  46. package/dist/components/TekWallet/services/axios/get-balance-analytic/index.d.ts +3 -0
  47. package/dist/components/TekWallet/services/axios/get-balance-analytic/index.js +56 -0
  48. package/dist/components/TekWallet/services/axios/get-balance-analytic/type.d.ts +18 -0
  49. package/dist/components/TekWallet/services/axios/get-balance-analytic/type.js +2 -0
  50. package/dist/components/TekWallet/store/balance/index.d.ts +15 -0
  51. package/dist/components/TekWallet/store/balance/index.js +24 -0
  52. package/dist/components/TekWallet/store/balance/type.d.ts +9 -0
  53. package/dist/components/TekWallet/store/balance/type.js +2 -0
  54. package/dist/components/TekWallet/store/createStorage.d.ts +3 -0
  55. package/dist/components/TekWallet/store/createStorage.js +17 -0
  56. package/dist/components/TekWallet/store/user/index.d.ts +15 -0
  57. package/dist/components/TekWallet/store/user/index.js +52 -0
  58. package/dist/components/TekWallet/store/user/type.d.ts +38 -0
  59. package/dist/components/TekWallet/store/user/type.js +9 -0
  60. package/dist/components/TekWallet/types/expose-type.d.ts +3 -0
  61. package/package.json +3 -2
  62. package/dist/components/TekWallet/components/ui/Activities/index.d.ts +0 -12
  63. package/dist/components/TekWallet/components/ui/Activities/index.js +0 -117
package/README.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # TekWallet Documentation
2
2
 
3
- ## Cấu hình
3
+ ## 📋 Mục lục
4
+
5
+ - [Cấu hình](#cấu-hình)
6
+ - [Components](#components)
7
+ - [States](#states)
8
+ - [Methods](#methods)
9
+ - [Hướng dẫn sử dụng](#hướng-dẫn-sử-dụng)
10
+ - [Lưu ý](#lưu-ý)
11
+
12
+ ---
13
+
14
+ ## ⚙️ Cấu hình
4
15
 
5
16
  ### 1. Provider Setup
6
17
 
@@ -17,10 +28,6 @@ import { TekWalletProvider } from "tek-wallet";
17
28
  >
18
29
  <YourApp />
19
30
  </TekWalletProvider>;
20
-
21
- <TekWalletProvider isSSO accessToken={accessToken}>
22
- <YourApp />
23
- </TekWalletProvider>;
24
31
  ```
25
32
 
26
33
  ### 2. Environment Variables
@@ -36,7 +43,9 @@ NEXT_PUBLIC_TEK_WALLET_SERVER_URL=your_server_url
36
43
  NEXT_PUBLIC_TEK_WALLET_ABLY_API_KEY=your_ably_api_key
37
44
  ```
38
45
 
39
- ## Components
46
+ ---
47
+
48
+ ## 🧩 Components
40
49
 
41
50
  ### RequiredConnect
42
51
 
@@ -52,39 +61,73 @@ const { tokens } = useWallet();
52
61
  </RequiredConnect>;
53
62
  ```
54
63
 
55
- ### LockToken
64
+ ### Các Components Chính
56
65
 
57
- Component cho phép người dùng khóa token trong ví.
66
+ | Component | tả |
67
+ | --------------------- | ----------------------------------------- |
68
+ | **LockToken** | Cho phép người dùng khóa token trong ví |
69
+ | **SwapToken** | Hỗ trợ chức năng hoán đổi token |
70
+ | **UpdateLockedToken** | Cho phép cập nhật thông tin token đã khóa |
71
+ | **ReceiveFunction** | Xử lý chức năng nhận token |
72
+ | **AssetView** | Hiển thị tài sản trong ví |
73
+ | **WithdrawFunction** | Xử lý chức năng rút token |
58
74
 
59
- ### SwapToken
75
+ ### Components Xác nhận (Confirm)
60
76
 
61
- Component hỗ trợ chức năng hoán đổi token.
77
+ | Component | tả |
78
+ | ----------------------- | ---------------------------------------------------------------- |
79
+ | **ConfirmSwapToken** | Xử lý chức năng swap token bản đơn giản (khả năng custom cao) |
80
+ | **ConfirmSendExternal** | Xử lý chức năng rút token bản đơn giản (khả năng custom cao) |
81
+ | **ConfirmSendInternal** | Xử lý chức năng chuyển nội bộ bản đơn giản (khả năng custom cao) |
62
82
 
63
- ### UpdateLockedToken
83
+ ### Components View Đầy đủ
64
84
 
65
- Component cho phép cập nhật thông tin token đã khóa.
85
+ | Component | tả |
86
+ | -------------------- | ---------------------------------------------------------------------- |
87
+ | **SwapView** | Xử lý chức năng swap token bản đầy đủ, có validate, input amount... |
88
+ | **SendExternalView** | Xử lý chức năng rút token bản đầy đủ, có validate, input amount... |
89
+ | **SendInternalView** | Xử lý chức năng chuyển nội bộ bản đầy đủ, có validate, input amount... |
90
+ | **AssetView** | Quản lí asset người dùng |
66
91
 
67
- ### ReceiveFunction
92
+ ### TekWalletView
68
93
 
69
- Component xử chức năng nhận token.
94
+ Component như một app wallet mini (có router nội bộ)
70
95
 
71
- ### AssetView
96
+ **Sử dụng cơ bản:**
72
97
 
73
- Component hiển thị tài sản trong ví.
98
+ ```jsx
99
+ // page: "tek-wallet/[[...pathname]]/page.tsx"
100
+ "use client";
74
101
 
75
- ### WithdrawFunction
102
+ import { TekWalletView } from "tek-wallet";
76
103
 
77
- Component xử lý chức năng rút token.
104
+ function WalletPage() {
105
+ return <TekWalletView />;
106
+ }
78
107
 
79
- ### ConfirmSendExternal
108
+ export default WalletPage;
109
+ ```
80
110
 
81
- Component xử lý chức năng rút token bản đơn giản (khả năng custom cao).
111
+ **Với basePath:**
82
112
 
83
- ### ConfirmSendInternal
113
+ Nếu phía trước có path: `<path>/tek-wallet/[[...pathname]]/page.tsx` thì thêm basePath vào options:
84
114
 
85
- Component xử lý chức năng chuyển nội bộ bản đơn giản (khả năng custom cao).
115
+ ```jsx
116
+ <TekWalletProvider
117
+ isSSO
118
+ accessToken={accessToken}
119
+ options={{
120
+ useDefaultToastMessage: true,
121
+ basePath: <path>
122
+ }}
123
+ >
124
+ {props.children}
125
+ </TekWalletProvider>
126
+ ```
127
+
128
+ ---
86
129
 
87
- ## States
130
+ ## 📊 States
88
131
 
89
132
  ### Wallet States
90
133
 
@@ -116,7 +159,9 @@ Component xử lý chức năng chuyển nội bộ bản đơn giản (khả n
116
159
  | `fromTokens` | `Token[]` | Danh sách tokens có thể swap |
117
160
  | `transaction` | `Transaction` | Dữ liệu event realtime mới nhất (swap token, send token...) |
118
161
 
119
- ## Methods
162
+ ---
163
+
164
+ ## 🔧 Methods
120
165
 
121
166
  ### Wallet Management
122
167
 
@@ -148,18 +193,24 @@ Component xử lý chức năng chuyển nội bộ bản đơn giản (khả n
148
193
  | -------------------- | ---------------------- |
149
194
  | `pushNotification()` | Hiển thị toast message |
150
195
 
151
- ## Hướng dẫn sử dụng
196
+ ---
197
+
198
+ ## 🚀 Hướng dẫn sử dụng
152
199
 
153
200
  Để bắt đầu sử dụng TekWallet, hãy đảm bảo:
154
201
 
155
- 1. Đã cài đặt đầy đủ các dependencies cần thiết
156
- 2. Đã cấu hình đúng các biến môi trường
157
- 3. Đã wrap ứng dụng trong TekWalletProvider
158
- 4. Đã import các components cần thiết từ package
202
+ 1. Đã cài đặt đầy đủ các dependencies cần thiết
203
+ 2. Đã cấu hình đúng các biến môi trường
204
+ 3. Đã wrap ứng dụng trong TekWalletProvider
205
+ 4. Đã import các components cần thiết từ package
206
+
207
+ ---
208
+
209
+ ## ⚠️ Lưu ý
159
210
 
160
- ## Lưu ý
211
+ - 🔒 Đảm bảo luôn sử dụng `RequiredConnect` cho các hành động yêu cầu ví phải được kết nối
212
+ - 🔧 Các biến môi trường phải được cấu hình đúng để đảm bảo ứng dụng hoạt động chính xác
161
213
 
162
- - Đảm bảo luôn sử dụng RequiredConnect cho các hành động yêu cầu ví phải được kết nối
163
- - Các biến môi trường phải được cấu hình đúng để đảm bảo ứng dụng hoạt động chính xác
214
+ ---
164
215
 
165
216
  # tek-wallet
@@ -1,7 +1,10 @@
1
+ import { SxProps } from "@mui/material";
1
2
  import { TransactionType } from "../../../services/axios/get-activities-service/type";
2
3
  export interface ActivitiesTypeSlicePropsType {
3
4
  type: TransactionType;
4
5
  isActive?: boolean;
6
+ limitItems?: number;
7
+ sx?: SxProps;
5
8
  }
6
9
  export declare enum Status {
7
10
  Loading = "loading",
@@ -28,7 +28,6 @@ var DrawerComponent_1 = __importDefault(require("../DrawerComponent"));
28
28
  var ModalLayout_1 = __importDefault(require("../ModalLayout"));
29
29
  var ActivityDetail_1 = __importDefault(require("../ActivityDetail"));
30
30
  var SmartList_1 = __importDefault(require("../SmartList"));
31
- var type_1 = require("../../../providers/ActivitiesProvider/type");
32
31
  var Status;
33
32
  (function (Status) {
34
33
  Status["Loading"] = "loading";
@@ -37,11 +36,11 @@ var Status;
37
36
  })(Status || (exports.Status = Status = {}));
38
37
  var prefix = "activities_";
39
38
  function ActivitiesTypeSlice(props) {
40
- var _a, _b;
39
+ var _a, _b, _c;
41
40
  var theme = (0, ThemeProvider_1.useTheme)();
42
- var _c = (0, useActivities_1.default)(), activities = _c.activities, loadActivities = _c.loadActivities, pages = _c.pages;
43
- var type = props.type, isActive = props.isActive;
44
- var _d = (0, react_1.useState)(undefined), detailActivity = _d[0], setDetailActivity = _d[1];
41
+ var _d = (0, useActivities_1.default)(), activities = _d.activities, loadActivities = _d.loadActivities, loadOutActivityType = _d.loadOutActivityType;
42
+ var type = props.type, isActive = props.isActive, limitItems = props.limitItems, sx = props.sx;
43
+ var _e = (0, react_1.useState)(undefined), detailActivity = _e[0], setDetailActivity = _e[1];
45
44
  var detailDrawerRef = (0, react_1.useRef)(null);
46
45
  var activitiesByType = (0, react_1.useMemo)(function () {
47
46
  if (!(type === null || type === void 0 ? void 0 : type.slug))
@@ -73,11 +72,12 @@ function ActivitiesTypeSlice(props) {
73
72
  var loadMore = (0, react_1.useCallback)(function () {
74
73
  loadActivities(type.slug);
75
74
  }, [loadActivities, type.slug]);
76
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { width: "100%", height: "100%", display: "flex" }, children: [status === Status.Loading && (0, jsx_runtime_1.jsx)(WaitingData_1.default, { sx: { margin: "auto" } }), status === Status.Empty && ((0, jsx_runtime_1.jsx)(EmptyData_1.default, { sx: { margin: "auto" }, icon: (0, getIcon_1.default)(prefix + "empty_" + type.slug), description: "No ".concat((_a = type.name) === null || _a === void 0 ? void 0 : _a.toLowerCase(), " activity") })), status === Status.Filled && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SmartList_1.default, { items: activitiesByType || [], loadMoreData: loadMore, hasMore: pages[type.slug] !== type_1.MAX_PAGE, loadingComponent: (0, jsx_runtime_1.jsx)(WaitingData_1.default, { sx: { margin: "auto" } }), children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12, paddingTop: theme.mixins.customPadding.p16, paddingBottom: theme.mixins.customPadding.p32, px: theme.mixins.customPadding.p16 }), children: activitiesByType === null || activitiesByType === void 0 ? void 0 : activitiesByType.map(function (activity, index) {
75
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({ width: "100%", height: "100%", display: "flex", paddingTop: theme.mixins.customPadding.p8, px: theme.mixins.customPadding.p16 }, sx), children: [status === Status.Loading && (0, jsx_runtime_1.jsx)(WaitingData_1.default, { sx: { marginBottom: "auto" } }), status === Status.Empty && ((0, jsx_runtime_1.jsx)(EmptyData_1.default, { sx: { marginBottom: "auto", marginTop: "4rem" }, icon: (0, getIcon_1.default)(prefix + "empty_" + type.slug), description: "No ".concat((_a = type.name) === null || _a === void 0 ? void 0 : _a.toLowerCase(), " activity") })), status === Status.Filled && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SmartList_1.default, { loadMoreData: loadMore, hasMore: !loadOutActivityType[type.slug] &&
76
+ ((activitiesByType === null || activitiesByType === void 0 ? void 0 : activitiesByType.length) || 0) < (limitItems || Infinity), loadingComponent: (0, jsx_runtime_1.jsx)(WaitingData_1.default, { numberOfSkeleton: 3, sx: { marginTop: theme.mixins.customMargin.m12 } }), sx: {}, children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12 }), children: (_b = activitiesByType === null || activitiesByType === void 0 ? void 0 : activitiesByType.slice(0, limitItems)) === null || _b === void 0 ? void 0 : _b.map(function (activity, index) {
77
77
  if (!activity)
78
78
  return null;
79
79
  var dataAsJson = JSON.stringify(activity);
80
80
  return ((0, jsx_runtime_1.jsx)(ActivityItem_1.default, { onClick: function () { return openDetail(activity); }, data: dataAsJson }, index));
81
- }) }) }), (0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: detailDrawerRef, children: (0, jsx_runtime_1.jsx)(ModalLayout_1.default, { onClose: closeDetail, title: (_b = detailActivity === null || detailActivity === void 0 ? void 0 : detailActivity.transaction_type) === null || _b === void 0 ? void 0 : _b.name, children: (0, jsx_runtime_1.jsx)(ActivityDetail_1.default, { activityData: detailActivity }) }) })] }))] }));
81
+ }) }) }), (0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: detailDrawerRef, children: (0, jsx_runtime_1.jsx)(ModalLayout_1.default, { onClose: closeDetail, title: (_c = detailActivity === null || detailActivity === void 0 ? void 0 : detailActivity.transaction_type) === null || _c === void 0 ? void 0 : _c.name, children: (0, jsx_runtime_1.jsx)(ActivityDetail_1.default, { activityData: detailActivity }) }) })] }))] }));
82
82
  }
83
83
  exports.default = ActivitiesTypeSlice;
@@ -72,19 +72,19 @@ function ActivityDetail(props) {
72
72
  var getAmountColor = (0, react_1.useCallback)(function () {
73
73
  if (isIncrease)
74
74
  return theme.palette.text.successStatus;
75
- return theme.palette.text.white;
75
+ return theme.palette.text.black;
76
76
  }, [isIncrease, theme]);
77
77
  if (!activityData)
78
78
  return null;
79
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g16, alignItems: "center" }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { mr: "0.5rem" }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: currency === null || currency === void 0 ? void 0 : currency.link, width: 64, sx: {
79
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g16, alignItems: "center" }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.row), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: currency === null || currency === void 0 ? void 0 : currency.link, width: 64, sx: {
80
80
  borderRadius: theme.mixins.customRadius.full,
81
81
  border: isSwap ? "0.25rem white solid" : "none",
82
- ml: "-0.5rem",
82
+ // ml: "-0.5rem",
83
83
  } }), (swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.link) && ((0, jsx_runtime_1.jsx)(Icon_1.default, { src: swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.link, width: 64, sx: {
84
84
  borderRadius: theme.mixins.customRadius.full,
85
85
  border: isSwap ? "0.25rem white solid" : "none",
86
- ml: "-0.5rem",
87
- } }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", gap: theme.mixins.gaps.g4, alignItems: "center" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeightBold, fontSize: theme.typography.fontSize24, color: getAmountColor(), opacity: isSwap ? 0.5 : 1 }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: isIncrease ? "+" : "-", value: activityData.amount, unit: " ".concat(currency === null || currency === void 0 ? void 0 : currency.name) }) }), isSwap && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeightBold, fontSize: theme.typography.fontSize24, color: theme.palette.text.successStatus }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: "+", value: swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.swap_total_amount, unit: " ".concat(swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.name) }) })), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: (0, formatDate_1.default)(activityData.date_created) }), status !== type_1.TransactionStatus.Success && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [status === type_1.TransactionStatus.Processing && ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "secondary", size: 16 })), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
86
+ ml: "-1rem",
87
+ } }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", gap: theme.mixins.gaps.g4, alignItems: "center" }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.column), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeight700, fontSize: theme.typography.fontSize24, color: getAmountColor() }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: isIncrease ? "+" : "-", value: activityData.amount, unit: " ".concat(currency === null || currency === void 0 ? void 0 : currency.name) }) }), isSwap && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeight700, fontSize: theme.typography.fontSize24, color: theme.palette.text.successStatus }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: "+", value: swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.swap_total_amount, unit: " ".concat(swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.name) }) }))] }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: (0, formatDate_1.default)(activityData.date_created) }), status !== type_1.TransactionStatus.Success && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [status === type_1.TransactionStatus.Processing && ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "secondary", size: 16 })), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
88
88
  fontSize: theme.typography.fontSize12,
89
89
  textTransform: "capitalize",
90
90
  color: getStatusColor(),
@@ -88,17 +88,22 @@ function ActivityItem(props) {
88
88
  var getAmountColor = (0, react_1.useCallback)(function () {
89
89
  if (isIncrease)
90
90
  return theme.palette.text.successStatus;
91
- return theme.palette.text.white;
91
+ return theme.palette.text.black;
92
92
  }, [isIncrease, theme]);
93
93
  if (!activityData)
94
94
  return null;
95
- return ((0, jsx_runtime_1.jsxs)(material_1.ListItemButton, __assign({ sx: __assign(__assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g8, backgroundColor: theme.palette.background.white16, borderRadius: theme.mixins.customRadius.r16, p: theme.mixins.customPadding.p12, flexGrow: "unset", boxShadow: theme.shadows[1] }), sx) }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
95
+ return ((0, jsx_runtime_1.jsxs)(material_1.ListItemButton, __assign({ sx: __assign(__assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g8, backgroundColor: theme.palette.background.tertiary, borderRadius: theme.mixins.customRadius.r16, p: theme.mixins.customPadding.p12, flexGrow: "unset", boxShadow: theme.shadows[1] }), sx) }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
96
96
  width: "fit-content",
97
97
  height: "fit-content",
98
- }, children: (0, jsx_runtime_1.jsx)(Icon_1.default, { src: type === null || type === void 0 ? void 0 : type.link, width: 24 }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", gap: theme.mixins.gaps.g2 }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.activityTitle, children: type === null || type === void 0 ? void 0 : type.name }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.activityDescription, children: descriptionElement }), status !== type_1.TransactionStatus.Success && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [status === type_1.TransactionStatus.Processing && ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "secondary", size: 12 })), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
98
+ }, children: (0, jsx_runtime_1.jsx)(Icon_1.default, { src: type === null || type === void 0 ? void 0 : type.link, width: 24, sx: { borderRadius: theme.mixins.customRadius.full } }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", gap: theme.mixins.gaps.g2 }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.activityTitle, children: type === null || type === void 0 ? void 0 : type.name }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.activityDescription, children: descriptionElement }), status !== type_1.TransactionStatus.Success && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [status === type_1.TransactionStatus.Processing && ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "secondary", size: 12 })), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
99
99
  fontSize: theme.typography.fontSize12,
100
100
  textTransform: "capitalize",
101
101
  color: getStatusColor(),
102
- }, children: status })] }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g2, width: "fit-content", alignItems: "flex-end", ml: "auto" }), children: [slug === type_1.TransactionSlug.SWAP && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeightBold, color: theme.palette.text.successStatus, textAlign: "right" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: "+", value: swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.swap_total_amount, unit: " ".concat(swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.name) }) })), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeightBold, color: getAmountColor(), textAlign: "right" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: isIncrease ? "+" : "-", value: activityData.amount, unit: " ".concat(currency === null || currency === void 0 ? void 0 : currency.name) }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.valueDescription), { textAlign: "right" }), children: (0, formatDate_1.default)(activityData.date_created) })] })] })));
102
+ }, children: status })] }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g2, width: "fit-content", alignItems: "flex-end", ml: "auto" }), children: [slug === type_1.TransactionSlug.SWAP && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeight700, fontSize: theme.typography.fontSize13, color: theme.palette.text.successStatus, textAlign: "right" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: "+", value: swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.swap_total_amount, unit: " ".concat(swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.name) }) })), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
103
+ fontSize: theme.typography.fontSize13,
104
+ fontWeight: theme.typography.fontWeight700,
105
+ color: getAmountColor(),
106
+ textAlign: "right",
107
+ }, children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: isIncrease ? "+" : "-", value: activityData.amount, unit: " ".concat(currency === null || currency === void 0 ? void 0 : currency.name) }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.valueDescription), { textAlign: "right" }), children: (0, formatDate_1.default)(activityData.date_created) })] })] })));
103
108
  }
104
109
  exports.default = ActivityItem;
@@ -16,123 +16,125 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  var jsx_runtime_1 = require("react/jsx-runtime");
18
18
  var react_1 = require("react");
19
- var framer_motion_1 = require("framer-motion");
20
19
  var AnalyticGroup_1 = __importDefault(require("../AnalyticGroup"));
21
20
  var TimeFilter_1 = __importDefault(require("../TimeFilter"));
22
- var TimeFilter_2 = require("../TimeFilter");
23
21
  var DelayMounted_1 = __importDefault(require("../DelayMounted"));
24
22
  var material_1 = require("@mui/material");
25
23
  var ThemeProvider_1 = require("../../../providers/ThemeProvider");
26
24
  var NeonLineChart_1 = __importDefault(require("../NeonLineChart"));
27
- var ContentHiddenProvider_1 = require("../../../providers/ContentHiddenProvider");
28
25
  var SvgPath_1 = require("../SvgPath");
29
- var fakeSeries = [
30
- {
31
- name: "All",
32
- data: [
33
- 1003785.6864951615, 1003795.988344575, 1003827.99766239, 1003899.7426850981,
34
- 1003891.7710159089, 1003810.6439517767, 1003780.7195320514, 1003797.9506016063,
35
- 1003781.455378438, 1003782.0072632281, 1003715.167883104, 1003724.9791682598,
36
- 1003716.6018329085, 1003711.3282671372, 1003686.1868489254, 1003625.4795220237,
37
- 1003584.3334449014, 1003498.9139435134, 1003310.7825506503, 1003339.72584186,
38
- 1003334.3069939599, 1003364.3540547496, 1003394.4011155394, 1003398.386950134,
39
- 1003233.005474726, 1003185.2981006557, 1003165.7981714085,
40
- ],
41
- },
42
- ];
43
- var labels = [
44
- "2025-03-04T08:10:17.311Z",
45
- "2025-03-04T12:10:18.859Z",
46
- "2025-03-04T16:10:19.118Z",
47
- "2025-03-04T20:10:18.246Z",
48
- "2025-03-05T00:10:18.371Z",
49
- "2025-03-05T10:12:40.882Z",
50
- "2025-03-05T14:12:42.832Z",
51
- "2025-03-05T18:12:41.114Z",
52
- "2025-03-05T22:12:40.544Z",
53
- "2025-03-06T02:12:40.718Z",
54
- "2025-03-08T10:35:52.596Z",
55
- "2025-03-08T14:35:52.979Z",
56
- "2025-03-08T16:01:31.209Z",
57
- "2025-03-08T18:35:52.824Z",
58
- "2025-03-08T22:35:52.901Z",
59
- "2025-03-09T06:35:53.327Z",
60
- "2025-03-09T10:35:52.682Z",
61
- "2025-03-09T14:35:53.001Z",
62
- "2025-03-09T18:35:52.886Z",
63
- "2025-03-09T22:35:52.880Z",
64
- "2025-03-10T03:43:34.153Z",
65
- "2025-03-10T06:35:52.944Z",
66
- "2025-03-10T10:35:52.253Z",
67
- "2025-03-10T14:35:52.727Z",
68
- "2025-03-10T18:35:52.865Z",
69
- "2025-03-10T22:35:53.563Z",
70
- "2025-03-11T04:16:45.409Z",
71
- ];
72
- var defaultTimeRange = TimeFilter_2.TimeFilterType.SEVEN_DAYS;
73
- var variants = {
74
- hidden: { opacity: 0, display: "none" },
75
- visible: { opacity: 1, display: "block" },
76
- };
26
+ var user_1 = __importDefault(require("../../../store/user"));
27
+ var balance_1 = __importDefault(require("../../../store/balance"));
28
+ var useWallet_1 = __importDefault(require("../../../hooks/useWallet"));
29
+ // const fakeSeries = [
30
+ // {
31
+ // name: "All",
32
+ // data: [
33
+ // 1003785.6864951615, 1003795.988344575, 1003827.99766239, 1003899.7426850981,
34
+ // 1003891.7710159089, 1003810.6439517767, 1003780.7195320514, 1003797.9506016063,
35
+ // 1003781.455378438, 1003782.0072632281, 1003715.167883104, 1003724.9791682598,
36
+ // 1003716.6018329085, 1003711.3282671372, 1003686.1868489254, 1003625.4795220237,
37
+ // 1003584.3334449014, 1003498.9139435134, 1003310.7825506503, 1003339.72584186,
38
+ // 1003334.3069939599, 1003364.3540547496, 1003394.4011155394, 1003398.386950134,
39
+ // 1003233.005474726, 1003185.2981006557, 1003165.7981714085,
40
+ // ],
41
+ // },
42
+ // ];
43
+ // const labels = [
44
+ // "2025-03-04T08:10:17.311Z",
45
+ // "2025-03-04T12:10:18.859Z",
46
+ // "2025-03-04T16:10:19.118Z",
47
+ // "2025-03-04T20:10:18.246Z",
48
+ // "2025-03-05T00:10:18.371Z",
49
+ // "2025-03-05T10:12:40.882Z",
50
+ // "2025-03-05T14:12:42.832Z",
51
+ // "2025-03-05T18:12:41.114Z",
52
+ // "2025-03-05T22:12:40.544Z",
53
+ // "2025-03-06T02:12:40.718Z",
54
+ // "2025-03-08T10:35:52.596Z",
55
+ // "2025-03-08T14:35:52.979Z",
56
+ // "2025-03-08T16:01:31.209Z",
57
+ // "2025-03-08T18:35:52.824Z",
58
+ // "2025-03-08T22:35:52.901Z",
59
+ // "2025-03-09T06:35:53.327Z",
60
+ // "2025-03-09T10:35:52.682Z",
61
+ // "2025-03-09T14:35:53.001Z",
62
+ // "2025-03-09T18:35:52.886Z",
63
+ // "2025-03-09T22:35:52.880Z",
64
+ // "2025-03-10T03:43:34.153Z",
65
+ // "2025-03-10T06:35:52.944Z",
66
+ // "2025-03-10T10:35:52.253Z",
67
+ // "2025-03-10T14:35:52.727Z",
68
+ // "2025-03-10T18:35:52.865Z",
69
+ // "2025-03-10T22:35:53.563Z",
70
+ // "2025-03-11T04:16:45.409Z",
71
+ // ];
77
72
  var AmountGroupAndChart = function (props) {
73
+ var defaultTimeRange = (0, user_1.default)(function (state) { return state.settings.balance.timeRangeTracking; });
78
74
  var _a = (0, react_1.useState)(false), expandAreaChart = _a[0], setExpandAreaChart = _a[1];
79
75
  var _b = (0, react_1.useState)(), timeRangeData = _b[0], setTimeRangeData = _b[1];
80
- var isHidden = (0, ContentHiddenProvider_1.useContentHidden)().isHidden;
81
76
  var theme = (0, ThemeProvider_1.useTheme)();
77
+ var isShowBalance = (0, user_1.default)(function (state) { return state.settings.balance.isShowBalance; });
78
+ var analytic = (0, balance_1.default)(function (state) { return state.analytic; });
79
+ var setTimeRangeTracking = (0, user_1.default)(function (state) { return state.setTimeRangeTracking; });
80
+ var updateBalanceAnalytic = (0, useWallet_1.default)().updateBalanceAnalytic;
81
+ var series = (0, react_1.useMemo)(function () {
82
+ var _a;
83
+ return (_a = analytic === null || analytic === void 0 ? void 0 : analytic.data) === null || _a === void 0 ? void 0 : _a.map(function (item) { return ({
84
+ name: item.name,
85
+ data: item.values,
86
+ }); });
87
+ }, [analytic]);
82
88
  var handleChangeTimeRange = function (data) {
83
89
  setTimeRangeData(data);
90
+ setTimeRangeTracking(data.type);
91
+ updateBalanceAnalytic(data.type);
84
92
  };
85
93
  var toggleExpand = function () {
86
94
  setExpandAreaChart(function (prev) { return !prev; });
87
95
  };
88
- return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, props.sx), { width: "100%" }), children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.column), children: [(0, jsx_runtime_1.jsx)(AnalyticGroup_1.default, { timeRange: timeRangeData === null || timeRangeData === void 0 ? void 0 : timeRangeData.type }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { position: "relative", marginTop: theme.mixins.customMargin.m12 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
89
- width: "100%",
90
- position: "relative",
91
- transition: "all 500ms ease-in-out",
92
- // aspectRatio: expandAreaChart ? "1.47317073171" : 999999,
93
- zIndex: 10,
94
- minHeight: expandAreaChart ? "16rem" : "0",
95
- maxHeight: expandAreaChart ? "28rem" : "0",
96
- }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
97
- position: "absolute",
98
- top: 0,
99
- right: 0,
100
- left: 0,
101
- bottom: 0,
102
- transition: "all 500ms ease-in-out",
103
- transform: !expandAreaChart ? "translateX(-25%) scale(0.5)" : "none",
104
- display: isHidden && !expandAreaChart ? "none" : "block",
105
- }, children: (0, jsx_runtime_1.jsx)(DelayMounted_1.default, { delay: 800, children: (0, jsx_runtime_1.jsx)(NeonLineChart_1.default, { showMinMaxValues: expandAreaChart, series: fakeSeries, categories: labels, sx: {
106
- width: "100%",
107
- height: "fit-content",
108
- transition: "all 500ms ease-in-out",
109
- transform: !expandAreaChart ? "translateY(-100%)" : "none",
110
- my: theme.mixins.customMargin.m3,
111
- } }) }) }), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { style: {
112
- position: "relative",
113
- transform: "translateY(350%)",
114
- }, initial: "hidden", animate: expandAreaChart ? "visible" : "hidden", variants: variants, transition: {
115
- opacity: {
116
- duration: expandAreaChart ? 0.5 : 0.25,
117
- ease: "linear",
118
- delay: expandAreaChart ? 0.5 : 0,
119
- },
120
- display: {
121
- duration: 0,
122
- ease: "linear",
123
- delay: expandAreaChart ? 0.5 : 0.25,
124
- },
125
- }, children: (0, jsx_runtime_1.jsx)(DelayMounted_1.default, { delay: 100, children: (0, jsx_runtime_1.jsx)(TimeFilter_1.default, { hideAll: true, initialValue: defaultTimeRange, onChange: handleChangeTimeRange }) }) })] }), (0, jsx_runtime_1.jsx)(material_1.SvgIcon, { onClick: toggleExpand, sx: {
126
- alignSelf: "center",
127
- transition: "all 500ms ease-in-out",
128
- cursor: "pointer",
129
- mt: theme.mixins.customMargin.m4,
130
- transform: !expandAreaChart
131
- ? "rotate(180deg) translateX(900%) translateY(120%)"
132
- : "translateX(-50%) translateY(100%)",
133
- zIndex: 20,
134
- width: 20,
135
- height: 20,
136
- }, children: SvgPath_1.IC_EXPANDER_ARROW })] })] }) }));
96
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({ width: "100%", height: "fit-content", position: "relative" }, props.sx), children: [(0, jsx_runtime_1.jsx)(AnalyticGroup_1.default, { sx: { position: "relative" }, timeRange: timeRangeData === null || timeRangeData === void 0 ? void 0 : timeRangeData.type }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
97
+ width: "100%",
98
+ position: "relative",
99
+ transition: "all 500ms ease-in-out",
100
+ top: expandAreaChart ? "0px" : "-30px",
101
+ aspectRatio: expandAreaChart ? "1.6" : 6.2,
102
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
103
+ position: "absolute",
104
+ top: 0,
105
+ right: 0,
106
+ left: 0,
107
+ bottom: 0,
108
+ transition: "all 500ms ease-in-out",
109
+ transform: !expandAreaChart ? "scale(0.5)" : "scale(1)",
110
+ transformOrigin: "top left",
111
+ }, children: (0, jsx_runtime_1.jsx)(DelayMounted_1.default, { delay: 800, children: (0, jsx_runtime_1.jsx)(NeonLineChart_1.default, { showMinMaxValues: expandAreaChart && isShowBalance, series: series, categories: analytic === null || analytic === void 0 ? void 0 : analytic.labels, sx: {
112
+ width: "100%",
113
+ height: "fit-content",
114
+ transition: "all 500ms ease-in-out",
115
+ my: theme.mixins.customMargin.m3,
116
+ }, children: (0, jsx_runtime_1.jsx)(DelayMounted_1.default, { delay: 800, children: (0, jsx_runtime_1.jsx)(material_1.SvgIcon, { onClick: toggleExpand, sx: {
117
+ position: "absolute",
118
+ right: 0,
119
+ bottom: 0,
120
+ width: 20,
121
+ height: 20,
122
+ cursor: "pointer",
123
+ zIndex: 9999,
124
+ transition: "all 500ms ease-in-out",
125
+ transform: !expandAreaChart
126
+ ? "scale(2) translate(50%, -50%)"
127
+ : "scale(1) translate(50%, -50%)",
128
+ }, children: SvgPath_1.IC_EXPANDER_ARROW }) }) }) }) }), (0, jsx_runtime_1.jsx)(TimeFilter_1.default, { hideAll: true, initialValue: defaultTimeRange, onChange: handleChangeTimeRange, sx: {
129
+ position: "absolute",
130
+ bottom: 0,
131
+ left: 0,
132
+ right: 0,
133
+ opacity: expandAreaChart ? 1 : 0,
134
+ transform: expandAreaChart ? "scale(1)" : "scale(0)",
135
+ transition: expandAreaChart
136
+ ? "opacity 300ms ease-in-out 500ms, transform 0ms ease-in-out 0ms"
137
+ : "opacity 200ms ease-in-out 0ms, transform 0ms ease-in-out 200ms",
138
+ } })] })] }));
137
139
  };
138
140
  exports.default = AmountGroupAndChart;
@@ -1,6 +1,7 @@
1
1
  import { GeneralProps } from "../../../types/ui";
2
+ import { TimeFilterType } from "../TimeFilter";
2
3
  interface AnalyticGroupProps extends GeneralProps {
3
- timeRange?: string;
4
+ timeRange?: TimeFilterType;
4
5
  }
5
6
  declare const AnalyticGroup: (props: AnalyticGroupProps) => import("react/jsx-runtime").JSX.Element;
6
7
  export default AnalyticGroup;