@pioneer-platform/pioneer-react 0.2.35 → 0.2.37

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.
@@ -1,166 +0,0 @@
1
- import {
2
- Avatar,
3
- AvatarBadge,
4
- Box,
5
- Button,
6
- HStack,
7
- Stack,
8
- Image,
9
- Modal,
10
- ModalOverlay,
11
- ModalContent,
12
- ModalHeader,
13
- ModalCloseButton,
14
- ModalBody,
15
- ModalFooter,
16
- useDisclosure,
17
- InputGroup,
18
- InputLeftElement,
19
- Input,
20
- Text,
21
- } from "@chakra-ui/react";
22
- import React, { useState, useEffect } from "react";
23
-
24
- // Import icons
25
- // @ts-ignore
26
- import KEEPKEY_ICON from "lib/assets/png/keepkey.png";
27
- // @ts-ignore
28
- import METAMASK_ICON from "lib/assets/png/metamask.png";
29
- // @ts-ignore
30
- import PIONEER_ICON from "lib/assets/png/pioneer.png";
31
- import { usePioneer } from "lib/context/Pioneer";
32
-
33
- import MiddleEllipsis from "./MiddleEllipsis";
34
-
35
- interface Wallet {
36
- context: string;
37
- type: string;
38
- valueUsdContext: number;
39
- icon: any; // @ts-ignore
40
- paired: boolean;
41
- }
42
-
43
- const getWalletBadgeContent = (walletType: string) => {
44
- const icons: any = {
45
- metamask: METAMASK_ICON,
46
- keepkey: KEEPKEY_ICON,
47
- native: PIONEER_ICON,
48
- };
49
-
50
- const icon = icons[walletType];
51
-
52
- if (!icon) {
53
- return null;
54
- }
55
-
56
- return (
57
- <AvatarBadge boxSize="1.25em" bg="green.500">
58
- <Image rounded="full" src={icon} />
59
- </AvatarBadge>
60
- );
61
- };
62
-
63
- export default function Wallets({ wallets }: { wallets: Wallet[] }) {
64
- const { state, dispatch } = usePioneer();
65
- const { user } = state;
66
- const [currentPage, setCurrentPage] = useState(1);
67
- const [walletsWithIcons, setWalletsWithIcons] = useState([]);
68
- const { isOpen, onOpen, onClose } = useDisclosure();
69
- const walletsPerPage = 3;
70
-
71
- const handlePageChange = (pageNumber: any) => {
72
- setCurrentPage(pageNumber);
73
- };
74
-
75
- for (let i = 0; i < wallets.length; i++) {
76
- const wallet = wallets[i];
77
- if (wallet.type === "native") {
78
- wallets[i].icon = PIONEER_ICON;
79
- } else if (wallet.type === "metamask") {
80
- wallets[i].icon = METAMASK_ICON;
81
- } else if (wallet.type === "keepkey") {
82
- wallets[i].icon = KEEPKEY_ICON;
83
- }
84
- }
85
-
86
- const currentWallets = wallets.slice(
87
- (currentPage - 1) * walletsPerPage,
88
- currentPage * walletsPerPage
89
- );
90
- const totalPages = Math.ceil(wallets.length / walletsPerPage);
91
-
92
- // Function to generate custom pagination array
93
- const generatePaginationArray = () => {
94
- const paginationArray = [];
95
- const totalPageButtons = 5; // Number of page buttons to display around the current page
96
-
97
- if (totalPages <= totalPageButtons) {
98
- // If total pages are less than or equal to totalPageButtons, show all page numbers
99
- for (let i = 1; i <= totalPages; i++) {
100
- paginationArray.push(i);
101
- }
102
- } else {
103
- // If total pages are more than totalPageButtons, generate custom pagination
104
- const middleButton = Math.floor(totalPageButtons / 2);
105
- const startPage = Math.max(currentPage - middleButton, 1);
106
- const endPage = Math.min(currentPage + middleButton, totalPages);
107
-
108
- if (startPage > 1) {
109
- // Add the first page and ellipsis if the current page is far enough from the first page
110
- paginationArray.push(1, "...");
111
- }
112
-
113
- // Add page numbers between startPage and endPage (inclusive)
114
- for (let i = startPage; i <= endPage; i++) {
115
- paginationArray.push(i);
116
- }
117
-
118
- if (endPage < totalPages) {
119
- // Add the last page and ellipsis if the current page is far enough from the last page
120
- paginationArray.push("...", totalPages);
121
- }
122
- }
123
-
124
- return paginationArray;
125
- };
126
-
127
- return (
128
- <Stack spacing={4}>
129
- {/* <Text fontSize='xl'>Wallets Tracked</Text> */}
130
- {currentWallets.map((wallet: Wallet, index: number) => (
131
- <Box key={index}>
132
- <HStack spacing={4} alignItems="center">
133
- <Avatar src={wallet.icon} />
134
- <Box>
135
- <small>
136
- Context: <MiddleEllipsis text={wallet?.context} />
137
- </small>
138
- <br />
139
- <small>Type: {wallet.type}</small>
140
- <br />
141
- <small>Value (USD): {wallet.valueUsdContext}</small>
142
- <br />
143
- <small>Paired: {wallet.paired ? "Yes" : "No"}</small>
144
- <br />
145
- </Box>
146
- </HStack>
147
- <HStack mt={2} spacing={2}>
148
- {/* ... (rest of the buttons and click handlers) */}
149
- </HStack>
150
- </Box>
151
- ))}
152
- <Box mt={4}>
153
- {generatePaginationArray().map((page, index) => (
154
- <Button
155
- key={index}
156
- size="sm"
157
- variant={currentPage === page ? "solid" : "outline"}
158
- onClick={() => handlePageChange(page)}
159
- >
160
- {page === "..." ? "..." : page}
161
- </Button>
162
- ))}
163
- </Box>
164
- </Stack>
165
- );
166
- }