tek-wallet 0.0.458 → 0.0.459

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.
@@ -0,0 +1,7 @@
1
+ import { NotificationType } from "../providers/RealtimeProvider/type";
2
+ import { Transaction } from "../services/axios/get-activities-service/type";
3
+ export type EventHandler = (messageEvent: Transaction) => NotificationType | undefined;
4
+ export type EventHandlerHookType = {
5
+ eventHandler: EventHandler;
6
+ };
7
+ export declare const useEventHandler: () => EventHandlerHookType;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useEventHandler = void 0;
4
+ var useEventHandler = function () {
5
+ var handler = function (messageEvent) {
6
+ if (!messageEvent)
7
+ return undefined;
8
+ var type = messageEvent.transaction_type;
9
+ var amount = messageEvent.amount;
10
+ var currency = messageEvent.currency_slug;
11
+ var status = messageEvent.transaction_status;
12
+ var transactionId = messageEvent.id;
13
+ var notificationType = "success";
14
+ switch (status) {
15
+ case "processing":
16
+ notificationType = "info";
17
+ break;
18
+ case "failed":
19
+ notificationType = "error";
20
+ break;
21
+ case "success":
22
+ notificationType = "success";
23
+ break;
24
+ default:
25
+ notificationType = "info";
26
+ }
27
+ return {
28
+ message: "".concat(type, " ").concat(amount, " ").concat(currency, " is ").concat(status),
29
+ type: notificationType,
30
+ id: "".concat(transactionId, "-").concat(status),
31
+ };
32
+ };
33
+ return { eventHandler: handler };
34
+ };
35
+ exports.useEventHandler = useEventHandler;
@@ -64,6 +64,7 @@ var useWalletData_1 = __importDefault(require("../../hooks/useWalletData"));
64
64
  var ably_service_1 = require("../../services/ably/ably.service");
65
65
  var material_1 = require("@mui/material");
66
66
  var notistack_1 = require("notistack");
67
+ var useEventHandler_1 = require("../../hooks/useEventHandler");
67
68
  exports.initialRealtime = {
68
69
  transaction: undefined,
69
70
  isConnected: false,
@@ -83,6 +84,7 @@ function RealtimeProvider(_a) {
83
84
  var pushNotification = function (notification) {
84
85
  setNotifications(function (prev) { return __spreadArray(__spreadArray([], prev, true), [notification], false); });
85
86
  };
87
+ var eventHandler = (0, useEventHandler_1.useEventHandler)().eventHandler;
86
88
  (0, react_1.useEffect)(function () {
87
89
  try {
88
90
  if (!masterWallet)
@@ -119,9 +121,9 @@ function RealtimeProvider(_a) {
119
121
  horizontal: (_e = (_d = notification === null || notification === void 0 ? void 0 : notification.anchorOrigin) === null || _d === void 0 ? void 0 : _d.horizontal) !== null && _e !== void 0 ? _e : "right",
120
122
  }, onClose: function () {
121
123
  closeNotification(notification.id);
122
- }, slots: { transition: GrowTransition }, autoHideDuration: (_f = notification.duration) !== null && _f !== void 0 ? _f : 2000, children: (0, jsx_runtime_1.jsx)(material_1.Alert, { icon: false, severity: notification.type, sx: {
124
+ }, slots: { transition: GrowTransition }, autoHideDuration: (_f = notification.duration) !== null && _f !== void 0 ? _f : 3000, children: (0, jsx_runtime_1.jsx)(material_1.Alert, { icon: false, severity: notification.type, sx: {
123
125
  width: "fit-content",
124
- borderRadius: theme.mixins.customRadius.r16,
126
+ borderRadius: theme.mixins.customRadius.r6,
125
127
  mx: "auto",
126
128
  padding: "".concat(theme.mixins.customPadding.p0, " ").concat(theme.mixins.customPadding.p12),
127
129
  fontSize: theme.typography.fontSize14,
@@ -132,31 +134,3 @@ function RealtimeProvider(_a) {
132
134
  }) })] }));
133
135
  }
134
136
  exports.default = RealtimeProvider;
135
- var eventHandler = function (messageEvent) {
136
- if (!messageEvent)
137
- return null;
138
- var type = messageEvent.transaction_type;
139
- var amount = messageEvent.amount;
140
- var currency = messageEvent.currency_slug;
141
- var status = messageEvent.transaction_status;
142
- var transactionId = messageEvent.id;
143
- var notificationType = "success";
144
- switch (status) {
145
- case "processing":
146
- notificationType = "info";
147
- break;
148
- case "failed":
149
- notificationType = "error";
150
- break;
151
- case "success":
152
- notificationType = "success";
153
- break;
154
- default:
155
- notificationType = "info";
156
- }
157
- return {
158
- message: "".concat(type, " ").concat(amount, " ").concat(currency, " is ").concat(status),
159
- type: notificationType,
160
- id: "".concat(transactionId, "-").concat(status),
161
- };
162
- };
@@ -116,8 +116,16 @@ var customMargin = {
116
116
  };
117
117
  var customRadius = {
118
118
  full: "999px",
119
+ r6: "0.375rem",
120
+ r8: "0.5rem",
121
+ r10: "0.625rem",
119
122
  r12: "0.75rem",
120
123
  r16: "1rem",
124
+ r20: "1.25rem",
125
+ r24: "1.5rem",
126
+ r32: "2rem",
127
+ r40: "2.5rem",
128
+ r48: "3rem",
121
129
  };
122
130
  var shadows = [
123
131
  "none",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.458",
3
+ "version": "0.0.459",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",