tek-wallet 0.0.416 → 0.0.419

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.
@@ -121,6 +121,7 @@ var type_1 = require("../ConfirmLayout/type");
121
121
  var ConfirmByPasscode_1 = __importDefault(require("../ConfirmByPasscode"));
122
122
  var LineValue_1 = __importDefault(require("../LineValue"));
123
123
  var send_external_service_1 = __importDefault(require("../../../services/axios/send-external-service"));
124
+ var useRealtime_1 = __importDefault(require("../../../hooks/useRealtime"));
124
125
  var SendMethods;
125
126
  (function (SendMethods) {
126
127
  SendMethods["SCAN_QR_CODE"] = "scan qr code";
@@ -150,6 +151,7 @@ var AmountError;
150
151
  })(AmountError || (exports.AmountError = AmountError = {}));
151
152
  var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
152
153
  var _a, _b;
154
+ var pushNotification = (0, useRealtime_1.default)().pushNotification;
153
155
  var drawerRef = (0, react_1.useRef)(null);
154
156
  var swiperRef = (0, react_1.useRef)(null);
155
157
  var confirmLayoutDrawerRef = (0, react_1.useRef)(null);
@@ -201,6 +203,13 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
201
203
  return undefined;
202
204
  return +amount - +(estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.feeInCurrency);
203
205
  }, [estimateFee, amount]);
206
+ var testPushNotification = function () {
207
+ pushNotification({
208
+ message: "Test notification",
209
+ type: "success",
210
+ id: "test-notification",
211
+ });
212
+ };
204
213
  (0, react_1.useEffect)(function () {
205
214
  setTimeout(function () {
206
215
  var _a;
@@ -627,13 +636,13 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
627
636
  : WITHDRAW_STEP_NAME[currentStep], children: (0, jsx_runtime_1.jsx)(CloseModal_1.default, { sx: { marginLeft: "auto" }, onClick: close }) }), children: [(0, jsx_runtime_1.jsxs)(SwiperControlled_1.default, { ref: swiperRef, swiperProps: {
628
637
  autoHeight: true,
629
638
  spaceBetween: 32,
630
- }, disableSwipe: true, children: [(0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { height: "fit-content" }), children: Object.values(SendMethods).map(function (item, index) {
631
- return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [index !== 0 && (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(ListItemCustom_1.default, { title: item, description: item, icon: (0, getIcon_1.default)(item + "_icon"), onClick: function () {
632
- return handleSelectMethod(item);
633
- }, sx: {
634
- my: theme.mixins.customMargin.m12,
635
- } })] }, item));
636
- }) }) }, WithdrawStep.SELECT_METHOD), (0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12, height: "fit-content" }), children: withdrawToken === null || withdrawToken === void 0 ? void 0 : withdrawToken.map(function (item) {
639
+ }, disableSwipe: true, children: [(0, jsx_runtime_1.jsxs)(react_2.SwiperSlide, { children: [(0, jsx_runtime_1.jsxs)(Button_1.default.Primary, { onClick: testPushNotification, children: [" ", "Push"] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { height: "fit-content" }), children: Object.values(SendMethods).map(function (item, index) {
640
+ return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [index !== 0 && (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(ListItemCustom_1.default, { title: item, description: item, icon: (0, getIcon_1.default)(item + "_icon"), onClick: function () {
641
+ return handleSelectMethod(item);
642
+ }, sx: {
643
+ my: theme.mixins.customMargin.m12,
644
+ } })] }, item));
645
+ }) })] }, WithdrawStep.SELECT_METHOD), (0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12, height: "fit-content" }), children: withdrawToken === null || withdrawToken === void 0 ? void 0 : withdrawToken.map(function (item) {
637
646
  var stringifiedTokenData = JSON.stringify(item);
638
647
  if (!item)
639
648
  return null;
@@ -0,0 +1,3 @@
1
+ import { RealtimeProviderDataType } from "../providers/RealtimeProvider/type";
2
+ declare function useRealtime(): RealtimeProviderDataType;
3
+ export default useRealtime;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var react_1 = require("react");
4
+ var RealtimeProvider_1 = require("../providers/RealtimeProvider");
5
+ function useRealtime() {
6
+ try {
7
+ var data = (0, react_1.useContext)(RealtimeProvider_1.RealtimeContext);
8
+ return data;
9
+ }
10
+ catch (error) {
11
+ console.error("🚀 ~ useRealtime ~ error:", error);
12
+ return RealtimeProvider_1.initialRealtime;
13
+ }
14
+ }
15
+ exports.default = useRealtime;
@@ -1,11 +1,6 @@
1
1
  import React from "react";
2
2
  import { RealtimeProviderDataType } from "./type";
3
- import { VariantType } from "notistack";
4
3
  export declare const initialRealtime: RealtimeProviderDataType;
5
- export interface Notification {
6
- message: string;
7
- variant: VariantType;
8
- }
9
4
  export declare const RealtimeContext: React.Context<RealtimeProviderDataType>;
10
5
  declare function RealtimeProvider({ children }: {
11
6
  children: React.ReactNode;
@@ -100,13 +100,21 @@ function RealtimeProvider(_a) {
100
100
  console.error("🚀 ~ TEK-WALLET: Error connecting to realtime", error);
101
101
  }
102
102
  }, [masterWallet]);
103
+ var closeNotification = function (id) {
104
+ setNotifications(function (prev) { return prev.filter(function (n) { return n.id !== id; }); });
105
+ };
103
106
  return ((0, jsx_runtime_1.jsxs)(exports.RealtimeContext.Provider, { value: {
104
107
  isConnected: isConnected,
105
108
  transaction: transaction,
106
109
  pushNotification: pushNotification,
107
110
  }, children: [children, (0, jsx_runtime_1.jsx)(notistack_1.SnackbarProvider, { maxSnack: 2, children: notifications.map(function (notification) {
108
- var _a;
109
- return ((0, jsx_runtime_1.jsx)(material_1.Snackbar, { open: true, onClose: function () { }, slots: { transition: SlideTransition }, message: notification.message, autoHideDuration: (_a = notification.duration) !== null && _a !== void 0 ? _a : 2000 }, notification.id));
111
+ var _a, _b, _c, _d, _e;
112
+ return ((0, jsx_runtime_1.jsx)(material_1.Snackbar, { open: true, anchorOrigin: {
113
+ vertical: (_b = (_a = notification === null || notification === void 0 ? void 0 : notification.anchorOrigin) === null || _a === void 0 ? void 0 : _a.vertical) !== null && _b !== void 0 ? _b : "top",
114
+ horizontal: (_d = (_c = notification === null || notification === void 0 ? void 0 : notification.anchorOrigin) === null || _c === void 0 ? void 0 : _c.horizontal) !== null && _d !== void 0 ? _d : "right",
115
+ }, onClose: function () {
116
+ closeNotification(notification.id);
117
+ }, slots: { transition: SlideTransition }, message: notification.message, autoHideDuration: (_e = notification.duration) !== null && _e !== void 0 ? _e : 2000 }, notification.id));
110
118
  }) })] }));
111
119
  }
112
120
  exports.default = RealtimeProvider;
@@ -8,4 +8,8 @@ export interface NotificationType {
8
8
  type: "success" | "error" | "warning" | "info";
9
9
  duration?: number;
10
10
  id: string;
11
+ anchorOrigin?: {
12
+ vertical: "top" | "bottom";
13
+ horizontal: "left" | "center" | "right";
14
+ };
11
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.416",
3
+ "version": "0.0.419",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",