tek-wallet 0.0.795 → 0.0.797

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.
package/README.md CHANGED
@@ -214,3 +214,5 @@ Nếu phía trước có path: `<path>/tek-wallet/[[...pathname]]/page.tsx` thì
214
214
  ---
215
215
 
216
216
  # tek-wallet
217
+
218
+ ##
@@ -69,8 +69,7 @@ var material_1 = require("@mui/material");
69
69
  var ThemeProvider_1 = require("../../../providers/ThemeProvider");
70
70
  var AppBackDrop_1 = __importDefault(require("../../ui/AppBackDrop"));
71
71
  var react_simple_pull_to_refresh_1 = __importDefault(require("react-simple-pull-to-refresh"));
72
- var lottie_react_1 = __importDefault(require("lottie-react"));
73
- var refresh_json_1 = __importDefault(require("./refresh.json"));
72
+ var Refresh_1 = __importDefault(require("../../ui/Atoms/Refresh"));
74
73
  var ChildPageLayout = (0, react_1.forwardRef)(function (props, ref) {
75
74
  var header = props.header, footer = props.footer, children = props.children, sx = props.sx, className = props.className, classNames = props.classNames, statusMessage = props.statusMessage, sxs = props.sxs, pullToRefreshProps = props.pullToRefreshProps, rest = __rest(props, ["header", "footer", "children", "sx", "className", "classNames", "statusMessage", "sxs", "pullToRefreshProps"]);
76
75
  var _a = (0, react_1.useState)(StatusDisplay_1.StatusDisplayType.Normal), status = _a[0], setStatus = _a[1];
@@ -97,10 +96,7 @@ var ChildPageLayout = (0, react_1.forwardRef)(function (props, ref) {
97
96
  return [2 /*return*/, Promise.all([new Promise(function (resolve) { return setTimeout(resolve, 1000); }), onRefresh === null || onRefresh === void 0 ? void 0 : onRefresh()])]; // for user feel data is loading
98
97
  });
99
98
  }); };
100
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ ref: ref, sx: __assign({ height: "100%", width: "100%", display: "grid", gridTemplateRows: "auto 1fr auto", position: "relative", overflow: "hidden", backgroundColor: theme.palette.background.white }, sx), className: className }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign({ width: "100%" }, sxs === null || sxs === void 0 ? void 0 : sxs.header), className: classNames === null || classNames === void 0 ? void 0 : classNames.header, children: header }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({ height: "100%", width: "100%", overflowX: "hidden", overflowY: "auto" }, sxs === null || sxs === void 0 ? void 0 : sxs.body), className: classNames === null || classNames === void 0 ? void 0 : classNames.body, children: [!!isPullable && ((0, jsx_runtime_1.jsx)(react_simple_pull_to_refresh_1.default, __assign({ pullingContent: null, refreshingContent: ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: "flex", alignItems: "center", justifyContent: "center", pt: 3 }, children: (0, jsx_runtime_1.jsx)(lottie_react_1.default, { animationData: refresh_json_1.default, style: {
101
- width: "2.5rem",
102
- height: "2.5rem",
103
- } }) })) }, restPullToRefreshProps, { onRefresh: handleRefresh, children: children }))), !isPullable && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign({ width: "100%" }, sxs === null || sxs === void 0 ? void 0 : sxs.footer), className: classNames === null || classNames === void 0 ? void 0 : classNames.footer, children: footer }), status !== StatusDisplay_1.StatusDisplayType.Normal && ((0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { open: true, hideProgress: true, message: (0, jsx_runtime_1.jsx)(StatusDisplay_2.default, { status: status, statusMessage: statusMessage === null || statusMessage === void 0 ? void 0 : statusMessage[status] }) }))] })));
99
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ ref: ref, sx: __assign({ height: "100%", width: "100%", display: "grid", gridTemplateRows: "auto 1fr auto", position: "relative", overflow: "hidden", backgroundColor: theme.palette.background.white }, sx), className: className }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign({ width: "100%" }, sxs === null || sxs === void 0 ? void 0 : sxs.header), className: classNames === null || classNames === void 0 ? void 0 : classNames.header, children: header }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({ height: "100%", width: "100%", overflowX: "hidden", overflowY: "auto" }, sxs === null || sxs === void 0 ? void 0 : sxs.body), className: classNames === null || classNames === void 0 ? void 0 : classNames.body, children: [!!isPullable && ((0, jsx_runtime_1.jsx)(react_simple_pull_to_refresh_1.default, __assign({ pullingContent: null, refreshingContent: ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: "flex", alignItems: "center", justifyContent: "center", pt: 3 }, children: (0, jsx_runtime_1.jsx)(Refresh_1.default, {}) })) }, restPullToRefreshProps, { onRefresh: handleRefresh, children: children }))), !isPullable && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign({ width: "100%" }, sxs === null || sxs === void 0 ? void 0 : sxs.footer), className: classNames === null || classNames === void 0 ? void 0 : classNames.footer, children: footer }), status !== StatusDisplay_1.StatusDisplayType.Normal && ((0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { open: true, hideProgress: true, message: (0, jsx_runtime_1.jsx)(StatusDisplay_2.default, { status: status, statusMessage: statusMessage === null || statusMessage === void 0 ? void 0 : statusMessage[status] }) }))] })));
104
100
  });
105
101
  ChildPageLayout.displayName = "ChildPageLayout";
106
102
  exports.default = ChildPageLayout;
@@ -10,6 +10,42 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
13
49
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
51
  };
@@ -38,10 +74,11 @@ var Status;
38
74
  })(Status || (exports.Status = Status = {}));
39
75
  var prefix = "activities_";
40
76
  function ActivitiesTypeSlice(props) {
77
+ var _this = this;
41
78
  var _a, _b;
42
79
  var theme = (0, ThemeProvider_1.useTheme)();
43
80
  var router = (0, useCustomRouter_1.default)();
44
- var _c = (0, useActivities_1.default)(), activities = _c.activities, loadActivities = _c.loadActivities, loadOutActivityType = _c.loadOutActivityType;
81
+ var _c = (0, useActivities_1.default)(), activities = _c.activities, loadActivities = _c.loadActivities, loadOutActivityType = _c.loadOutActivityType, refreshActivities = _c.refreshActivities;
45
82
  var type = props.type, isActive = props.isActive, limitItems = props.limitItems, sx = props.sx, smartListProps = props.smartListProps, useAction = props.useAction;
46
83
  var options = (0, TekWalletProvider_1.useWalletSetup)().options;
47
84
  var basePath = (options || {}).basePath;
@@ -71,16 +108,26 @@ function ActivitiesTypeSlice(props) {
71
108
  var gotoHome = function () {
72
109
  router.push("".concat(basePath || "", "/tek-wallet"));
73
110
  };
74
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({ width: "100%", height: "100%", display: "flex" }, sx), children: [status === Status.Loading && ((0, jsx_runtime_1.jsx)(WaitingData_1.default, { sx: { marginBottom: "auto", p: theme.mixins.customPadding.p16 }, numberOfSkeleton: 8 })), status === Status.Empty && ((0, jsx_runtime_1.jsx)(EmptyData_1.default, { action: useAction && type.slug === const_1.ACTIVITIES_TYPE_ALL.slug ? gotoHome : undefined, actionText: "Start your journey", sx: { marginBottom: "auto", marginTop: "6rem", px: theme.mixins.customPadding.p16 }, icon: (0, getIcon_1.default)(prefix + "empty_" + type.slug), description: type.slug === const_1.ACTIVITIES_TYPE_ALL.slug
75
- ? "You haven't any activity yet"
76
- : "No ".concat((_a = type.name) === null || _a === void 0 ? void 0 : _a.toLowerCase(), " activity") })), status === Status.Filled && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(SmartList_1.default, { loadMoreData: loadMore, sx: __assign({ px: theme.mixins.customPadding.p16 }, smartListProps === null || smartListProps === void 0 ? void 0 : smartListProps.sx), hasMore: !loadOutActivityType[type.slug] &&
77
- ((activitiesByType === null || activitiesByType === void 0 ? void 0 : activitiesByType.length) || 0) < (limitItems || Infinity), loadingComponent: (0, jsx_runtime_1.jsx)(WaitingData_1.default, { numberOfSkeleton: 4, sx: {
111
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({ width: "100%", height: "100%" }, sx), children: [status === Status.Loading && ((0, jsx_runtime_1.jsx)(WaitingData_1.default, { sx: {
112
+ marginBottom: "auto",
113
+ p: theme.mixins.customPadding.p16,
114
+ }, numberOfSkeleton: 8 })), (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(SmartList_1.default, { loadMoreData: loadMore, sx: __assign({ px: theme.mixins.customPadding.p16 }, smartListProps === null || smartListProps === void 0 ? void 0 : smartListProps.sx), hasMore: !loadOutActivityType[type.slug] &&
115
+ ((activitiesByType === null || activitiesByType === void 0 ? void 0 : activitiesByType.length) || 0) < (limitItems || Infinity), loadingComponent: status === Status.Filled && ((0, jsx_runtime_1.jsx)(WaitingData_1.default, { numberOfSkeleton: 4, sx: {
78
116
  marginTop: theme.mixins.customMargin.m12,
79
- } }), bodySx: __assign({ pb: theme.mixins.customPadding.p32, pt: theme.mixins.customPadding.p16 }, smartListProps === null || smartListProps === void 0 ? void 0 : smartListProps.bodySx), 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) {
80
- if (!activity)
81
- return null;
82
- var dataAsJson = JSON.stringify(activity);
83
- return ((0, jsx_runtime_1.jsx)(ClickEffect_1.default, { children: (0, jsx_runtime_1.jsx)(ActivityItem_1.default, { data: dataAsJson, component: link_1.default, href: "".concat(basePath || "", "/tek-wallet/activity/").concat(activity === null || activity === void 0 ? void 0 : activity.id) }) }, (activity === null || activity === void 0 ? void 0 : activity.id) + "-" + index + "-" + (type === null || type === void 0 ? void 0 : type.slug)));
84
- }) }) }) }))] }));
117
+ } })), bodySx: __assign({ pb: theme.mixins.customPadding.p32, pt: theme.mixins.customPadding.p16 }, smartListProps === null || smartListProps === void 0 ? void 0 : smartListProps.bodySx), pullToRefreshProps: {
118
+ isPullable: true,
119
+ onRefresh: function () { return __awaiter(_this, void 0, void 0, function () {
120
+ return __generator(this, function (_a) {
121
+ return [2 /*return*/, refreshActivities(type.slug)];
122
+ });
123
+ }); },
124
+ }, children: [status === Status.Empty && ((0, jsx_runtime_1.jsx)(EmptyData_1.default, { action: useAction && type.slug === const_1.ACTIVITIES_TYPE_ALL.slug ? gotoHome : undefined, actionText: "Start your journey", sx: { marginBottom: "auto", marginTop: "6rem", px: theme.mixins.customPadding.p16 }, icon: (0, getIcon_1.default)(prefix + "empty_" + type.slug), description: type.slug === const_1.ACTIVITIES_TYPE_ALL.slug
125
+ ? "You haven't any activity yet"
126
+ : "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 }), children: (_b = activitiesByType === null || activitiesByType === void 0 ? void 0 : activitiesByType.slice(0, limitItems)) === null || _b === void 0 ? void 0 : _b.map(function (activity, index) {
127
+ if (!activity)
128
+ return null;
129
+ var dataAsJson = JSON.stringify(activity);
130
+ return ((0, jsx_runtime_1.jsx)(ClickEffect_1.default, { children: (0, jsx_runtime_1.jsx)(ActivityItem_1.default, { data: dataAsJson, component: link_1.default, href: "".concat(basePath || "", "/tek-wallet/activity/").concat(activity === null || activity === void 0 ? void 0 : activity.id) }) }, (activity === null || activity === void 0 ? void 0 : activity.id) + "-" + index + "-" + (type === null || type === void 0 ? void 0 : type.slug)));
131
+ }) }))] }) })] }));
85
132
  }
86
133
  exports.default = ActivitiesTypeSlice;
@@ -0,0 +1,2 @@
1
+ declare function Refresh(): import("react/jsx-runtime").JSX.Element;
2
+ export default Refresh;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var jsx_runtime_1 = require("react/jsx-runtime");
7
+ var lottie_react_1 = __importDefault(require("lottie-react"));
8
+ var refresh_json_1 = __importDefault(require("./refresh.json"));
9
+ function Refresh() {
10
+ return (0, jsx_runtime_1.jsx)(lottie_react_1.default, { animationData: refresh_json_1.default, style: { width: "2.5rem", height: "2.5rem" } });
11
+ }
12
+ exports.default = Refresh;
@@ -1,4 +1,5 @@
1
1
  import { BoxProps } from "@mui/material";
2
+ import { PullToRefreshProps } from "../../layouts/ChildPageLayout";
2
3
  export interface SmartListProps extends BoxProps {
3
4
  children: React.ReactNode;
4
5
  loadMoreData: () => void;
@@ -6,6 +7,7 @@ export interface SmartListProps extends BoxProps {
6
7
  loadingComponent?: React.ReactNode;
7
8
  loadingComponentProps?: BoxProps;
8
9
  bodySx?: BoxProps;
10
+ pullToRefreshProps?: PullToRefreshProps;
9
11
  }
10
12
  declare const SmartList: (props: SmartListProps) => import("react/jsx-runtime").JSX.Element;
11
13
  export default SmartList;
@@ -10,17 +10,70 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __rest = (this && this.__rest) || function (s, e) {
50
+ var t = {};
51
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
52
+ t[p] = s[p];
53
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
54
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
55
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
56
+ t[p[i]] = s[p[i]];
57
+ }
58
+ return t;
59
+ };
60
+ var __importDefault = (this && this.__importDefault) || function (mod) {
61
+ return (mod && mod.__esModule) ? mod : { "default": mod };
62
+ };
13
63
  Object.defineProperty(exports, "__esModule", { value: true });
14
64
  var jsx_runtime_1 = require("react/jsx-runtime");
15
65
  //This component is used to render a list of items but not use react query because some reasons
16
66
  var material_1 = require("@mui/material");
17
67
  var ThemeProvider_1 = require("../../../providers/ThemeProvider");
18
68
  var react_1 = require("react");
69
+ var react_simple_pull_to_refresh_1 = __importDefault(require("react-simple-pull-to-refresh"));
70
+ var Refresh_1 = __importDefault(require("../Atoms/Refresh"));
19
71
  var SmartList = function (props) {
20
- var children = props.children, loadMoreData = props.loadMoreData, hasMore = props.hasMore, loadingComponent = props.loadingComponent, loadingComponentProps = props.loadingComponentProps, bodySx = props.bodySx;
72
+ var children = props.children, loadMoreData = props.loadMoreData, hasMore = props.hasMore, loadingComponent = props.loadingComponent, loadingComponentProps = props.loadingComponentProps, bodySx = props.bodySx, pullToRefreshProps = props.pullToRefreshProps;
21
73
  var theme = (0, ThemeProvider_1.useTheme)();
22
74
  var containerRef = (0, react_1.useRef)(null);
23
75
  var loadingRef = (0, react_1.useRef)(null);
76
+ var _a = pullToRefreshProps || {}, onRefresh = _a.onRefresh, isPullable = _a.isPullable, restPullToRefreshProps = __rest(_a, ["onRefresh", "isPullable"]);
24
77
  (0, react_1.useEffect)(function () {
25
78
  function handleIntersection(entries) {
26
79
  entries.forEach(function (entry) {
@@ -46,6 +99,11 @@ var SmartList = function (props) {
46
99
  observer.disconnect();
47
100
  };
48
101
  }, [loadMoreData, hasMore]);
49
- return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign({ overflowY: "auto", width: "100%", height: "100%" }, props.sx), ref: containerRef, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign(__assign({}, theme.mixins.column), { height: "fit-content", my: "auto", gap: 0 }), bodySx), children: [children, (0, jsx_runtime_1.jsx)("div", { ref: loadingRef }), hasMore && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign({ width: "100%" }, loadingComponentProps), children: loadingComponent }))] }) }));
102
+ var handleRefresh = function () { return __awaiter(void 0, void 0, void 0, function () {
103
+ return __generator(this, function (_a) {
104
+ return [2 /*return*/, Promise.all([new Promise(function (resolve) { return setTimeout(resolve, 1000); }), onRefresh === null || onRefresh === void 0 ? void 0 : onRefresh()])]; // for user feel data is loading
105
+ });
106
+ }); };
107
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign({ overflowY: "auto", width: "100%", height: "100%" }, props.sx), ref: containerRef, children: (0, jsx_runtime_1.jsx)(react_simple_pull_to_refresh_1.default, __assign({ pullingContent: null, refreshingContent: ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: "flex", alignItems: "center", justifyContent: "center", pt: 3 }, children: (0, jsx_runtime_1.jsx)(Refresh_1.default, {}) })), isPullable: !!isPullable }, restPullToRefreshProps, { onRefresh: handleRefresh, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign(__assign({}, theme.mixins.column), { height: "fit-content", my: "auto", gap: 0 }), bodySx), children: [children, (0, jsx_runtime_1.jsx)("div", { ref: loadingRef }), hasMore && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign({ width: "100%" }, loadingComponentProps), children: loadingComponent }))] }) })) }));
50
108
  };
51
109
  exports.default = SmartList;
@@ -37,6 +37,7 @@ var ActivityView = function (props) {
37
37
  swiperProps: {
38
38
  slidesPerView: 1,
39
39
  spaceBetween: 20,
40
+ allowTouchMove: !!activitiesLength,
40
41
  }, tabsSx: {
41
42
  display: activitiesLength ? "flex" : "none",
42
43
  }, onTabChange: handleSlideChange, tabs: activityTypes === null || activityTypes === void 0 ? void 0 : activityTypes.map(function (type, index) {
@@ -63,7 +64,7 @@ var ActivityView = function (props) {
63
64
  height: "100%",
64
65
  }, swiperStyle: {
65
66
  flex: 1,
66
- }, disableSwipe: !activitiesLength, children: activityTypes === null || activityTypes === void 0 ? void 0 : activityTypes.map(function (type, index) {
67
+ }, children: activityTypes === null || activityTypes === void 0 ? void 0 : activityTypes.map(function (type, index) {
67
68
  return ((0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { style: {
68
69
  position: "relative",
69
70
  }, children: (index === activeTab || index === activeTab - 1 || index === activeTab + 1) && ((0, jsx_runtime_1.jsx)(ActivitiesTypeSlice_1.default, { useAction: true, type: type, isActive: activeTab === index })) }, index));
@@ -86,7 +86,6 @@ var useCustomRouter_1 = __importDefault(require("../../../hooks/useCustomRouter"
86
86
  var BasicAmountGroup_1 = __importDefault(require("../../ui/BasicAmountGroup"));
87
87
  var AssetViewHeader_1 = __importDefault(require("../../ui/AssetViewHeader"));
88
88
  var ClickEffect_1 = __importDefault(require("../../ui/ClickEffect"));
89
- var ScanQRToSend_1 = __importDefault(require("../../ui/ScanQRToSend"));
90
89
  var AssetView = function (props) {
91
90
  var sx = props.sx, rest = __rest(props, ["sx"]);
92
91
  var _a = (0, useWalletData_1.default)(), isInitPasscode = _a.isInitPasscode, masterWallet = _a.masterWallet, updateWalletDetail = _a.updateWalletDetail;
@@ -106,7 +105,7 @@ var AssetView = function (props) {
106
105
  return ((0, jsx_runtime_1.jsxs)(ChildPageLayout_1.default, { header: !!isInitPasscode && (0, jsx_runtime_1.jsx)(AssetViewHeader_1.default, {}), pullToRefreshProps: {
107
106
  isPullable: !!isInitPasscode,
108
107
  onRefresh: handleRefresh,
109
- }, children: [(0, jsx_runtime_1.jsx)(ScanQRToSend_1.default, { children: "Scan" }), !isInitPasscode && !!masterWallet && ((0, jsx_runtime_1.jsx)(ChangePasscodeView_1.default, { isInitPasscode: true, onBack: handleBackInitPasscodeView, idPrefix: idPrefix })), !!isInitPasscode && ((0, jsx_runtime_1.jsxs)(DefaultPageLayout_1.default, __assign({}, rest, { sx: __assign({ display: "flex", flexDirection: "column", gap: theme.mixins.gaps.g16 }, sx), children: [useBasicAmountGroupInAssetView ? (0, jsx_runtime_1.jsx)(BasicAmountGroup_1.default, {}) : (0, jsx_runtime_1.jsx)(AmountGroupAndChart_1.default, {}), (0, jsx_runtime_1.jsx)(Menu_1.default, { items: [
108
+ }, children: [!isInitPasscode && !!masterWallet && ((0, jsx_runtime_1.jsx)(ChangePasscodeView_1.default, { isInitPasscode: true, onBack: handleBackInitPasscodeView, idPrefix: idPrefix })), !!isInitPasscode && ((0, jsx_runtime_1.jsxs)(DefaultPageLayout_1.default, __assign({}, rest, { sx: __assign({ display: "flex", flexDirection: "column", gap: theme.mixins.gaps.g16 }, sx), children: [useBasicAmountGroupInAssetView ? (0, jsx_runtime_1.jsx)(BasicAmountGroup_1.default, {}) : (0, jsx_runtime_1.jsx)(AmountGroupAndChart_1.default, {}), (0, jsx_runtime_1.jsx)(Menu_1.default, { items: [
110
109
  (0, jsx_runtime_1.jsx)(ReceiveFunction_1.default, { children: (0, jsx_runtime_1.jsx)(material_1.ListItem, { component: ClickEffect_1.default, sx: {
111
110
  borderRight: "1px solid ".concat(theme.palette.border.accent3),
112
111
  placeContent: "center",
@@ -113,6 +113,9 @@ exports.initialActivities = {
113
113
  return [2 /*return*/];
114
114
  }); }); },
115
115
  insertActivities: function () { },
116
+ refreshActivities: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
117
+ return [2 /*return*/];
118
+ }); }); },
116
119
  };
117
120
  exports.ActivitiesContext = react_1.default.createContext(exports.initialActivities);
118
121
  function ActivitiesProvider(_a) {
@@ -192,10 +195,10 @@ function ActivitiesProvider(_a) {
192
195
  setActivities(function (prev) {
193
196
  var _a;
194
197
  var _b, _c, _d, _e, _f;
195
- var retainedActivities = (_c = ((_b = prev === null || prev === void 0 ? void 0 : prev[slug]) !== null && _b !== void 0 ? _b : [])) === null || _c === void 0 ? void 0 : _c.filter(function (activity) {
198
+ var remainedActivities = (_c = ((_b = prev === null || prev === void 0 ? void 0 : prev[slug]) !== null && _b !== void 0 ? _b : [])) === null || _c === void 0 ? void 0 : _c.filter(function (activity) {
196
199
  return !(loadedActivities_1 === null || loadedActivities_1 === void 0 ? void 0 : loadedActivities_1.some(function (item) { return item.id === activity.id; }));
197
200
  });
198
- var newActivities = (0, sortActivity_1.default)(__spreadArray(__spreadArray([], retainedActivities, true), loadedActivities_1, true));
201
+ var newActivities = (0, sortActivity_1.default)(__spreadArray(__spreadArray([], remainedActivities, true), loadedActivities_1, true));
199
202
  var isLoadOutActivityType = newActivities.length >= ((_f = (_e = (_d = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _d === void 0 ? void 0 : _d.paginated) === null || _e === void 0 ? void 0 : _e.number_records) !== null && _f !== void 0 ? _f : 0);
200
203
  setLoadOutActivityType(function (prev) {
201
204
  var _a;
@@ -221,7 +224,7 @@ function ActivitiesProvider(_a) {
221
224
  });
222
225
  }); }, [isInitPasscode, isLoadingActivities, loadOutActivityType]);
223
226
  var loadActivities = (0, react_1.useCallback)(function (slug) { return __awaiter(_this, void 0, void 0, function () {
224
- var lastDateCreated, response, activitiesLoaded, numOfRecords, retainedActivities, newActivities;
227
+ var lastDateCreated, response, activitiesLoaded, numOfRecords, remainedActivities, newActivities;
225
228
  var _a, _b, _c, _d, _e, _f, _g;
226
229
  return __generator(this, function (_h) {
227
230
  switch (_h.label) {
@@ -250,10 +253,10 @@ function ActivitiesProvider(_a) {
250
253
  });
251
254
  activitiesLoaded = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.transactions) !== null && _b !== void 0 ? _b : [];
252
255
  numOfRecords = (_e = (_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.paginated) === null || _d === void 0 ? void 0 : _d.number_records) !== null && _e !== void 0 ? _e : 0;
253
- retainedActivities = (_g = (_f = activities === null || activities === void 0 ? void 0 : activities[slug]) === null || _f === void 0 ? void 0 : _f.filter(function (item) {
256
+ remainedActivities = (_g = (_f = activities === null || activities === void 0 ? void 0 : activities[slug]) === null || _f === void 0 ? void 0 : _f.filter(function (item) {
254
257
  return !(activitiesLoaded === null || activitiesLoaded === void 0 ? void 0 : activitiesLoaded.some(function (activity) { return item.id === activity.id; }));
255
258
  })) !== null && _g !== void 0 ? _g : [];
256
- newActivities = (0, sortActivity_1.default)(__spreadArray(__spreadArray([], retainedActivities, true), activitiesLoaded, true));
259
+ newActivities = (0, sortActivity_1.default)(__spreadArray(__spreadArray([], remainedActivities, true), activitiesLoaded, true));
257
260
  setActivities(function (prev) {
258
261
  var _a;
259
262
  return (__assign(__assign({}, prev), (_a = {}, _a[slug] = newActivities, _a)));
@@ -273,6 +276,45 @@ function ActivitiesProvider(_a) {
273
276
  }
274
277
  });
275
278
  }); }, [isInitPasscode, loadOutActivityType, isLoadingActivities, getLatestDateCreated, activities]);
279
+ var refreshActivities = (0, react_1.useCallback)(function (slug) { return __awaiter(_this, void 0, void 0, function () {
280
+ var response, activitiesLoaded, numOfRecords, remainedActivities, newActivities;
281
+ var _a, _b, _c, _d, _e, _f, _g;
282
+ return __generator(this, function (_h) {
283
+ switch (_h.label) {
284
+ case 0:
285
+ if (!isInitPasscode)
286
+ return [2 /*return*/];
287
+ return [4 /*yield*/, (0, get_activities_service_1.default)({
288
+ limit: const_1.ACTIVITIES_PAGE_SIZE,
289
+ transaction_types: slug,
290
+ })];
291
+ case 1:
292
+ response = _h.sent();
293
+ activitiesLoaded = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.transactions) !== null && _b !== void 0 ? _b : [];
294
+ numOfRecords = (_e = (_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.paginated) === null || _d === void 0 ? void 0 : _d.number_records) !== null && _e !== void 0 ? _e : 0;
295
+ remainedActivities = (_g = (_f = activities === null || activities === void 0 ? void 0 : activities[slug]) === null || _f === void 0 ? void 0 : _f.filter(function (item) {
296
+ return !(activitiesLoaded === null || activitiesLoaded === void 0 ? void 0 : activitiesLoaded.some(function (activity) { return item.id === activity.id; }));
297
+ })) !== null && _g !== void 0 ? _g : [];
298
+ newActivities = (0, sortActivity_1.default)(__spreadArray(__spreadArray([], remainedActivities, true), activitiesLoaded, true));
299
+ setActivities(function (prev) {
300
+ var _a;
301
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = newActivities, _a)));
302
+ });
303
+ if (newActivities.length >= numOfRecords) {
304
+ setLoadOutActivityType(function (prev) {
305
+ var _a;
306
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = true, _a)));
307
+ });
308
+ return [2 /*return*/];
309
+ }
310
+ setLoadOutActivityType(function (prev) {
311
+ var _a;
312
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = false, _a)));
313
+ });
314
+ return [2 /*return*/];
315
+ }
316
+ });
317
+ }); }, [isInitPasscode, activities]);
276
318
  (0, react_1.useEffect)(function () {
277
319
  if (!isInitPasscode)
278
320
  return;
@@ -286,6 +328,7 @@ function ActivitiesProvider(_a) {
286
328
  activityTypes: activityTypes,
287
329
  loadOutActivityType: loadOutActivityType,
288
330
  loadActivities: loadActivities,
331
+ refreshActivities: refreshActivities,
289
332
  insertActivities: insertActivities,
290
333
  }, children: children }));
291
334
  }
@@ -8,6 +8,7 @@ export interface ActivitiesProviderDataType {
8
8
  loadActivities: (slug: TransactionSlug) => Promise<void>;
9
9
  loadOutActivityType: Partial<Record<TransactionSlug, boolean>>;
10
10
  insertActivities: (activity: Transaction) => void;
11
+ refreshActivities: (slug: TransactionSlug) => Promise<void>;
11
12
  }
12
13
  export type Activities = Partial<Record<TransactionSlug, Transaction[]>>;
13
14
  export interface ActivityTypes extends TransactionType {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.795",
3
+ "version": "0.0.797",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",