tek-wallet 0.0.444 → 0.0.446

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.
@@ -52,12 +52,12 @@ function ActivitiesTypeSlice(props) {
52
52
  if (!!activitiesByType)
53
53
  return;
54
54
  updateActivities({
55
- transaction_type: type.slug,
55
+ transaction_types: type.slug,
56
56
  page: 1,
57
57
  take: 10,
58
58
  });
59
59
  }, [isActive, type, activitiesByType, updateActivities]);
60
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [status === Status.Empty && ((0, jsx_runtime_1.jsx)(EmptyData_1.default, { 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.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12, paddingTop: theme.mixins.customPadding.p16 }), children: activitiesByType === null || activitiesByType === void 0 ? void 0 : activitiesByType.map(function (activity, index) {
60
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { width: "100%" }, children: [status === Status.Empty && ((0, jsx_runtime_1.jsx)(EmptyData_1.default, { 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.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12, paddingTop: theme.mixins.customPadding.p16 }), children: activitiesByType === null || activitiesByType === void 0 ? void 0 : activitiesByType.map(function (activity, index) {
61
61
  if (!activity)
62
62
  return null;
63
63
  var dataAsJson = JSON.stringify(activity);
@@ -100,7 +100,7 @@ var useWalletData_1 = __importDefault(require("../../hooks/useWalletData"));
100
100
  var get_activities_service_1 = __importDefault(require("../../services/axios/get-activities-service"));
101
101
  var const_1 = require("./const");
102
102
  exports.initialActivities = {
103
- isLoadingActivities: true,
103
+ isLoadingActivities: {},
104
104
  activities: undefined,
105
105
  updateActivities: function () { },
106
106
  activityTypes: [const_1.ACTIVITIES_TYPE_ALL],
@@ -112,7 +112,7 @@ function ActivitiesProvider(_a) {
112
112
  var _this = this;
113
113
  var children = _a.children;
114
114
  var isAuthenticated = (0, useWalletData_1.default)().isAuthenticated;
115
- var _b = (0, react_1.useState)(true), isLoadingActivities = _b[0], setIsLoadingActivities = _b[1];
115
+ var _b = (0, react_1.useState)({}), isLoadingActivities = _b[0], setIsLoadingActivities = _b[1];
116
116
  var _c = react_1.default.useState(undefined), activities = _c[0], setActivities = _c[1];
117
117
  var _d = react_1.default.useState(undefined), activityTypes = _d[0], setActivityTypes = _d[1];
118
118
  var _e = (0, react_1.useState)(1), page = _e[0], setPage = _e[1];
@@ -120,48 +120,59 @@ function ActivitiesProvider(_a) {
120
120
  setPage(page);
121
121
  }, []);
122
122
  var updateActivities = (0, react_1.useCallback)(function (query) { return __awaiter(_this, void 0, void 0, function () {
123
- var response_1, error_1;
124
- var _a, _b;
125
- return __generator(this, function (_c) {
126
- switch (_c.label) {
123
+ var slug, response_1, error_1;
124
+ var _a, _b, _c;
125
+ return __generator(this, function (_d) {
126
+ switch (_d.label) {
127
127
  case 0:
128
- _c.trys.push([0, 2, , 3]);
128
+ slug = (_a = query === null || query === void 0 ? void 0 : query.transaction_types) !== null && _a !== void 0 ? _a : const_1.ACTIVITIES_TYPE_ALL.slug;
129
+ _d.label = 1;
130
+ case 1:
131
+ _d.trys.push([1, 3, , 4]);
129
132
  if (!isAuthenticated) {
130
133
  throw new Error("Authenticate to get receive tokens");
131
134
  }
132
- setIsLoadingActivities(true);
135
+ setIsLoadingActivities(function (prev) {
136
+ var _a;
137
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = true, _a)));
138
+ });
133
139
  return [4 /*yield*/, (0, get_activities_service_1.default)(query)];
134
- case 1:
135
- response_1 = _c.sent();
140
+ case 2:
141
+ response_1 = _d.sent();
136
142
  console.warn("🚀 ~ getBalance ~ response:", response_1);
137
143
  setActivityTypes(__spreadArray([
138
144
  const_1.ACTIVITIES_TYPE_ALL
139
- ], ((_b = (_a = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _a === void 0 ? void 0 : _a.transaction_types) !== null && _b !== void 0 ? _b : []), true));
145
+ ], ((_c = (_b = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _b === void 0 ? void 0 : _b.transaction_types) !== null && _c !== void 0 ? _c : []), true));
140
146
  setActivities(function (prev) {
141
147
  var _a;
142
148
  var _b, _c, _d;
143
- var slug = (query === null || query === void 0 ? void 0 : query.transaction_type) || const_1.ACTIVITIES_TYPE_ALL.slug;
144
149
  return __assign(__assign({}, (prev !== null && prev !== void 0 ? prev : {})), (_a = {}, _a[slug] = __spreadArray(__spreadArray([], ((_b = prev === null || prev === void 0 ? void 0 : prev[slug]) !== null && _b !== void 0 ? _b : []), true), ((_d = (_c = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _c === void 0 ? void 0 : _c.transactions) !== null && _d !== void 0 ? _d : []), true), _a));
145
150
  });
146
- setIsLoadingActivities(false);
147
- return [3 /*break*/, 3];
148
- case 2:
149
- error_1 = _c.sent();
151
+ setIsLoadingActivities(function (prev) {
152
+ var _a;
153
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = false, _a)));
154
+ });
155
+ return [3 /*break*/, 4];
156
+ case 3:
157
+ error_1 = _d.sent();
150
158
  console.error("🚀 ~ getBalance ~ error:", error_1);
151
- setIsLoadingActivities(false);
152
- return [3 /*break*/, 3];
153
- case 3: return [2 /*return*/];
159
+ setIsLoadingActivities(function (prev) {
160
+ var _a;
161
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = false, _a)));
162
+ });
163
+ return [3 /*break*/, 4];
164
+ case 4: return [2 /*return*/];
154
165
  }
155
166
  });
156
167
  }); }, [isAuthenticated]);
157
168
  (0, react_1.useEffect)(function () {
158
- if (isAuthenticated && !activities) {
159
- updateActivities({
160
- page: page,
161
- take: const_1.ACTIVITIES_PAGE_SIZE,
162
- });
163
- }
164
- }, [isAuthenticated, activities]);
169
+ if (!!activities)
170
+ return;
171
+ updateActivities({
172
+ page: page,
173
+ take: const_1.ACTIVITIES_PAGE_SIZE,
174
+ });
175
+ }, [updateActivities, activities]);
165
176
  return ((0, jsx_runtime_1.jsx)(exports.ActivitiesContext.Provider, { value: {
166
177
  isLoadingActivities: isLoadingActivities,
167
178
  activities: activities,
@@ -1,6 +1,6 @@
1
1
  import { GetActivitiesServiceQuery, Transaction, TransactionSlug, TransactionType } from "../../services/axios/get-activities-service/type";
2
2
  export interface ActivitiesProviderDataType {
3
- isLoadingActivities: boolean;
3
+ isLoadingActivities: Partial<Record<TransactionSlug, boolean>>;
4
4
  activities: Activities | undefined;
5
5
  updateActivities: (query?: GetActivitiesServiceQuery) => void;
6
6
  activityTypes: ActivityTypes[] | undefined;
@@ -4,7 +4,7 @@ export interface GetActivitiesServiceQuery {
4
4
  take?: number;
5
5
  from_date?: string;
6
6
  to_date?: string;
7
- transaction_type?: TransactionSlug;
7
+ transaction_types?: TransactionSlug;
8
8
  }
9
9
  export interface GetActivitiesServiceResponse {
10
10
  success: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.444",
3
+ "version": "0.0.446",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",