Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
238330dd
Commit
238330dd
authored
Aug 19, 2022
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
review fixes
parent
1c81dbae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
24 deletions
+28
-24
get-with-tokens.ts
pages/api/account/watchlist/get-with-tokens.ts
+1
-2
Watchlist.tsx
ui/pages/Watchlist.tsx
+24
-16
AddressForm.tsx
ui/watchlist/AddressModal/AddressForm.tsx
+2
-5
WatchListAddressItem.tsx
ui/watchlist/WatchlistTable/WatchListAddressItem.tsx
+1
-1
No files found.
pages/api/account/watchlist/get-with-tokens.ts
View file @
238330dd
import
type
{
NextApiRequest
,
NextApiResponse
}
from
'
next
'
;
import
nodeFetch
from
'
node-fetch
'
;
import
type
{
WatchlistAddresses
}
from
'
types/api/account
'
;
import
type
{
Tokenlist
}
from
'
types/api/tokenlist
'
;
...
...
@@ -19,7 +18,7 @@ const watchlistWithTokensHandler = async(_req: NextApiRequest, res: NextApiRespo
const
watchlistData
=
await
watchlistResponse
.
json
()
as
WatchlistAddresses
;
const
data
=
await
Promise
.
all
(
watchlistData
.
map
(
async
item
=>
{
const
tokens
=
await
nodeFetch
(
`https://blockscout.com/xdai/testnet/api
?module=account&action=tokenlist&address=
${
item
.
address_hash
}
`
);
const
tokens
=
await
fetch
(
`
?module=account&action=tokenlist&address=
${
item
.
address_hash
}
`
);
const
tokensData
=
await
tokens
.
json
()
as
Tokenlist
;
return
({
...
item
,
tokens_count
:
Array
.
isArray
(
tokensData
.
result
)
?
tokensData
.
result
.
length
:
0
});
...
...
ui/pages/Watchlist.tsx
View file @
238330dd
import
{
Box
,
Button
,
Text
,
S
pinner
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Button
,
Text
,
S
keleton
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
React
,
{
useCallback
,
useState
}
from
'
react
'
;
...
...
@@ -6,6 +6,7 @@ import type { TWatchlist, TWatchlistItem } from 'types/client/account';
import
AccountPageHeader
from
'
ui/shared/AccountPageHeader
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
import
SkeletonTable
from
'
ui/shared/SkeletonTable
'
;
import
AddressModal
from
'
ui/watchlist/AddressModal/AddressModal
'
;
import
DeleteAddressModal
from
'
ui/watchlist/DeleteAddressModal
'
;
import
WatchlistTable
from
'
ui/watchlist/WatchlistTable/WatchlistTable
'
;
...
...
@@ -45,23 +46,30 @@ const WatchList: React.FC = () => {
<
Box
h=
"100%"
>
<
AccountPageHeader
text=
"Watch list"
/>
<
Text
marginBottom=
{
12
}
>
An email notification can be sent to you when an address on your watch list sends or receives any transactions.
</
Text
>
{
!
watchlistData
&&
<
Spinner
/>
}
{
!
watchlistData
&&
(
<>
<
SkeletonTable
columns=
{
[
'
70%
'
,
'
30%
'
,
'
160px
'
,
'
108px
'
]
}
/>
<
Skeleton
height=
"44px"
width=
"156px"
marginTop=
{
8
}
/>
</>
)
}
{
Boolean
(
watchlistData
?.
length
)
&&
(
<
WatchlistTable
data=
{
watchlistData
}
onDeleteClick=
{
onDeleteClick
}
onEditClick=
{
onEditClick
}
/>
<>
<
WatchlistTable
data=
{
watchlistData
}
onDeleteClick=
{
onDeleteClick
}
onEditClick=
{
onEditClick
}
/>
<
Box
marginTop=
{
8
}
>
<
Button
variant=
"primary"
size=
"lg"
onClick=
{
addressModalProps
.
onOpen
}
>
Add address
</
Button
>
</
Box
>
</>
)
}
<
Box
marginTop=
{
8
}
>
<
Button
variant=
"primary"
size=
"lg"
onClick=
{
addressModalProps
.
onOpen
}
>
Add address
</
Button
>
</
Box
>
</
Box
>
<
AddressModal
{
...
addressModalProps
}
onClose=
{
onAddressModalClose
}
data=
{
addressModalData
}
/>
<
DeleteAddressModal
{
...
deleteModalProps
}
onClose=
{
onDeleteModalClose
}
data=
{
deleteModalData
}
/>
...
...
ui/watchlist/AddressModal/AddressForm.tsx
View file @
238330dd
...
...
@@ -63,8 +63,6 @@ const AddressForm: React.FC<Props> = ({ data, onClose }) => {
const
queryClient
=
useQueryClient
();
const
{
mutate
}
=
useMutation
((
formData
:
Inputs
)
=>
{
let
mutationFunction
;
const
requestParams
=
{
name
:
formData
?.
tag
,
address_hash
:
formData
?.
address
,
...
...
@@ -75,12 +73,11 @@ const AddressForm: React.FC<Props> = ({ data, onClose }) => {
};
if
(
data
)
{
// edit address
mutationFunction
=
()
=>
fetch
(
`/api/account/watchlist/
${
data
.
id
}
`
,
{
method
:
'
PUT
'
,
body
:
JSON
.
stringify
(
requestParams
)
});
return
fetch
(
`/api/account/watchlist/
${
data
.
id
}
`
,
{
method
:
'
PUT
'
,
body
:
JSON
.
stringify
(
requestParams
)
});
}
else
{
// add address
mutationFunction
=
()
=>
fetch
(
'
/api/account/watchlist
'
,
{
method
:
'
POST
'
,
body
:
JSON
.
stringify
(
requestParams
)
});
return
fetch
(
'
/api/account/watchlist
'
,
{
method
:
'
POST
'
,
body
:
JSON
.
stringify
(
requestParams
)
});
}
return
mutationFunction
();
},
{
onError
:
()
=>
{
// eslint-disable-next-line no-console
...
...
ui/watchlist/WatchlistTable/WatchListAddressItem.tsx
View file @
238330dd
...
...
@@ -25,7 +25,7 @@ const WatchListAddressItem = ({ item }: {item: TWatchlistItem}) => {
<
VStack
spacing=
{
2
}
align=
"stretch"
overflow=
"hidden"
fontWeight=
{
500
}
color=
"gray.700"
>
<
AddressLinkWithTooltip
address=
{
item
.
address_hash
}
/>
<
HStack
spacing=
{
0
}
fontSize=
"sm"
h=
{
6
}
>
<
Image
src=
"
.
/xdai.png"
alt=
"chain-logo"
marginRight=
"10px"
w=
"16px"
h=
"16px"
/>
<
Image
src=
"/xdai.png"
alt=
"chain-logo"
marginRight=
"10px"
w=
"16px"
h=
"16px"
/>
<
Text
color=
{
mainTextColor
}
>
{
`xDAI balance:${ nbsp }`
+
nativeBalance
}
</
Text
>
<
Text
variant=
"secondary"
>
{
`${ nbsp }(${ nativeBalanceUSD })`
}
</
Text
>
</
HStack
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment