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
dd630ffd
Commit
dd630ffd
authored
Nov 02, 2023
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
87396358
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
64 additions
and
26 deletions
+64
-26
resources.ts
lib/api/resources.ts
+5
-2
tokenTypes.ts
lib/token/tokenTypes.ts
+8
-3
address.ts
types/api/address.ts
+5
-1
token.ts
types/api/token.ts
+2
-1
AddressTokens.tsx
ui/address/AddressTokens.tsx
+29
-5
AddressCollections.tsx
ui/address/tokens/AddressCollections.tsx
+1
-1
Tokens.tsx
ui/pages/Tokens.tsx
+1
-1
RadioButtonGroup.tsx
ui/shared/RadioButtonGroup.tsx
+3
-2
TokenTransferFilter.tsx
ui/shared/TokenTransfer/TokenTransferFilter.tsx
+1
-1
TokenTypeFilter.tsx
ui/shared/filters/TokenTypeFilter.tsx
+9
-9
No files found.
lib/api/resources.ts
View file @
dd630ffd
...
@@ -28,6 +28,7 @@ import type {
...
@@ -28,6 +28,7 @@ import type {
AddressWithdrawalsResponse
,
AddressWithdrawalsResponse
,
AddressNFTsResponse
,
AddressNFTsResponse
,
AddressCollectionsResponse
,
AddressCollectionsResponse
,
AddressNFTTokensFilter
,
}
from
'
types/api/address
'
;
}
from
'
types/api/address
'
;
import
type
{
AddressesResponse
}
from
'
types/api/addresses
'
;
import
type
{
AddressesResponse
}
from
'
types/api/addresses
'
;
import
type
{
BlocksResponse
,
BlockTransactionsResponse
,
Block
,
BlockFilters
,
BlockWithdrawalsResponse
}
from
'
types/api/block
'
;
import
type
{
BlocksResponse
,
BlockTransactionsResponse
,
Block
,
BlockFilters
,
BlockWithdrawalsResponse
}
from
'
types/api/block
'
;
...
@@ -311,12 +312,12 @@ export const RESOURCES = {
...
@@ -311,12 +312,12 @@ export const RESOURCES = {
address_nfts
:
{
address_nfts
:
{
path
:
'
/api/v2/addresses/:hash/nft
'
,
path
:
'
/api/v2/addresses/:hash/nft
'
,
pathParams
:
[
'
hash
'
as
const
],
pathParams
:
[
'
hash
'
as
const
],
filterFields
:
[
],
filterFields
:
[
'
type
'
as
const
],
},
},
address_collections
:
{
address_collections
:
{
path
:
'
/api/v2/addresses/:hash/nft/collections
'
,
path
:
'
/api/v2/addresses/:hash/nft/collections
'
,
pathParams
:
[
'
hash
'
as
const
],
pathParams
:
[
'
hash
'
as
const
],
filterFields
:
[
],
filterFields
:
[
'
type
'
as
const
],
},
},
address_withdrawals
:
{
address_withdrawals
:
{
path
:
'
/api/v2/addresses/:hash/withdrawals
'
,
path
:
'
/api/v2/addresses/:hash/withdrawals
'
,
...
@@ -710,6 +711,8 @@ Q extends 'token_transfers' ? TokenTransferFilters :
...
@@ -710,6 +711,8 @@ Q extends 'token_transfers' ? TokenTransferFilters :
Q
extends
'
address_txs
'
|
'
address_internal_txs
'
?
AddressTxsFilters
:
Q
extends
'
address_txs
'
|
'
address_internal_txs
'
?
AddressTxsFilters
:
Q
extends
'
address_token_transfers
'
?
AddressTokenTransferFilters
:
Q
extends
'
address_token_transfers
'
?
AddressTokenTransferFilters
:
Q
extends
'
address_tokens
'
?
AddressTokensFilter
:
Q
extends
'
address_tokens
'
?
AddressTokensFilter
:
Q
extends
'
address_nfts
'
?
AddressNFTTokensFilter
:
Q
extends
'
address_collections
'
?
AddressNFTTokensFilter
:
Q
extends
'
search
'
?
SearchResultFilters
:
Q
extends
'
search
'
?
SearchResultFilters
:
Q
extends
'
token_inventory
'
?
TokenInventoryFilters
:
Q
extends
'
token_inventory
'
?
TokenInventoryFilters
:
Q
extends
'
tokens
'
?
TokensFilters
:
Q
extends
'
tokens
'
?
TokensFilters
:
...
...
lib/token/tokenTypes.ts
View file @
dd630ffd
import
type
{
TokenType
}
from
'
types/api/token
'
;
import
type
{
NFTTokenType
,
TokenType
}
from
'
types/api/token
'
;
export
const
TOKEN_TYPES
:
Array
<
{
title
:
string
;
id
:
TokenType
}
>
=
[
export
const
NFT_TOKEN_TYPES
:
Array
<
{
title
:
string
;
id
:
NFTTokenType
}
>
=
[
{
title
:
'
ERC-20
'
,
id
:
'
ERC-20
'
},
{
title
:
'
ERC-721
'
,
id
:
'
ERC-721
'
},
{
title
:
'
ERC-721
'
,
id
:
'
ERC-721
'
},
{
title
:
'
ERC-1155
'
,
id
:
'
ERC-1155
'
},
{
title
:
'
ERC-1155
'
,
id
:
'
ERC-1155
'
},
];
];
export
const
TOKEN_TYPES
:
Array
<
{
title
:
string
;
id
:
TokenType
}
>
=
[
{
title
:
'
ERC-20
'
,
id
:
'
ERC-20
'
},
...
NFT_TOKEN_TYPES
,
];
export
const
NFT_TOKEN_TYPE_IDS
=
NFT_TOKEN_TYPES
.
map
(
i
=>
i
.
id
);
export
const
TOKEN_TYPE_IDS
=
TOKEN_TYPES
.
map
(
i
=>
i
.
id
);
export
const
TOKEN_TYPE_IDS
=
TOKEN_TYPES
.
map
(
i
=>
i
.
id
);
types/api/address.ts
View file @
dd630ffd
...
@@ -3,7 +3,7 @@ import type { Transaction } from 'types/api/transaction';
...
@@ -3,7 +3,7 @@ import type { Transaction } from 'types/api/transaction';
import
type
{
UserTags
}
from
'
./addressParams
'
;
import
type
{
UserTags
}
from
'
./addressParams
'
;
import
type
{
Block
}
from
'
./block
'
;
import
type
{
Block
}
from
'
./block
'
;
import
type
{
InternalTransaction
}
from
'
./internalTransaction
'
;
import
type
{
InternalTransaction
}
from
'
./internalTransaction
'
;
import
type
{
TokenInfo
,
TokenInstance
,
TokenType
}
from
'
./token
'
;
import
type
{
NFTTokenType
,
TokenInfo
,
TokenInstance
,
TokenType
}
from
'
./token
'
;
import
type
{
TokenTransfer
,
TokenTransferPagination
}
from
'
./tokenTransfer
'
;
import
type
{
TokenTransfer
,
TokenTransferPagination
}
from
'
./tokenTransfer
'
;
export
interface
Address
extends
UserTags
{
export
interface
Address
extends
UserTags
{
...
@@ -126,6 +126,10 @@ export type AddressTokensFilter = {
...
@@ -126,6 +126,10 @@ export type AddressTokensFilter = {
type
:
TokenType
;
type
:
TokenType
;
}
}
export
type
AddressNFTTokensFilter
=
{
type
:
Array
<
NFTTokenType
>
|
undefined
;
}
export
interface
AddressCoinBalanceHistoryItem
{
export
interface
AddressCoinBalanceHistoryItem
{
block_number
:
number
;
block_number
:
number
;
block_timestamp
:
string
;
block_timestamp
:
string
;
...
...
types/api/token.ts
View file @
dd630ffd
import
type
{
TokenInfoApplication
}
from
'
./account
'
;
import
type
{
TokenInfoApplication
}
from
'
./account
'
;
import
type
{
AddressParam
}
from
'
./addressParams
'
;
import
type
{
AddressParam
}
from
'
./addressParams
'
;
export
type
TokenType
=
'
ERC-20
'
|
'
ERC-721
'
|
'
ERC-1155
'
;
export
type
NFTTokenType
=
'
ERC-721
'
|
'
ERC-1155
'
;
export
type
TokenType
=
'
ERC-20
'
|
NFTTokenType
;
export
interface
TokenInfo
<
T
extends
TokenType
=
TokenType
>
{
export
interface
TokenInfo
<
T
extends
TokenType
=
TokenType
>
{
address
:
string
;
address
:
string
;
...
...
ui/address/AddressTokens.tsx
View file @
dd630ffd
import
{
Box
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
HStack
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
NFTTokenType
}
from
'
types/api/token
'
;
import
type
{
PaginationParams
}
from
'
ui/shared/pagination/types
'
;
import
type
{
PaginationParams
}
from
'
ui/shared/pagination/types
'
;
import
listIcon
from
'
icons/apps.svg
'
;
import
listIcon
from
'
icons/apps.svg
'
;
import
collectionIcon
from
'
icons/collection.svg
'
;
import
collectionIcon
from
'
icons/collection.svg
'
;
import
{
useAppContext
}
from
'
lib/contexts/app
'
;
import
{
useAppContext
}
from
'
lib/contexts/app
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
getFilterValuesFromQuery
from
'
lib/getFilterValuesFromQuery
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
{
NFT_TOKEN_TYPE_IDS
}
from
'
lib/token/tokenTypes
'
;
import
{
ADDRESS_TOKEN_BALANCE_ERC_20
,
ADDRESS_NFT_1155
,
ADDRESS_COLLECTION
}
from
'
stubs/address
'
;
import
{
ADDRESS_TOKEN_BALANCE_ERC_20
,
ADDRESS_NFT_1155
,
ADDRESS_COLLECTION
}
from
'
stubs/address
'
;
import
{
generateListStub
}
from
'
stubs/utils
'
;
import
{
generateListStub
}
from
'
stubs/utils
'
;
import
PopoverFilter
from
'
ui/shared/filters/PopoverFilter
'
;
import
TokenTypeFilter
from
'
ui/shared/filters/TokenTypeFilter
'
;
import
Pagination
from
'
ui/shared/pagination/Pagination
'
;
import
Pagination
from
'
ui/shared/pagination/Pagination
'
;
import
useQueryWithPages
from
'
ui/shared/pagination/useQueryWithPages
'
;
import
useQueryWithPages
from
'
ui/shared/pagination/useQueryWithPages
'
;
import
RadioButtonGroup
from
'
ui/shared/RadioButtonGroup
'
;
import
RadioButtonGroup
from
'
ui/shared/RadioButtonGroup
'
;
...
@@ -25,17 +30,18 @@ import TokenBalances from './tokens/TokenBalances';
...
@@ -25,17 +30,18 @@ import TokenBalances from './tokens/TokenBalances';
type
TNftDisplayType
=
'
collection
'
|
'
list
'
;
type
TNftDisplayType
=
'
collection
'
|
'
list
'
;
const
TAB_LIST_PROPS
=
{
const
TAB_LIST_PROPS
=
{
m
arginBottom
:
0
,
m
y
:
3
,
py
:
5
,
py
:
5
,
marginTop
:
3
,
columnGap
:
3
,
columnGap
:
3
,
};
};
const
TAB_LIST_PROPS_MOBILE
=
{
const
TAB_LIST_PROPS_MOBILE
=
{
m
t
:
8
,
m
y
:
8
,
columnGap
:
3
,
columnGap
:
3
,
};
};
const
getTokenFilterValue
=
(
getFilterValuesFromQuery
<
NFTTokenType
>
).
bind
(
null
,
NFT_TOKEN_TYPE_IDS
);
const
AddressTokens
=
()
=>
{
const
AddressTokens
=
()
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
...
@@ -44,6 +50,7 @@ const AddressTokens = () => {
...
@@ -44,6 +50,7 @@ const AddressTokens = () => {
const
displayTypeCookie
=
cookies
.
get
(
cookies
.
NAMES
.
ADDRESS_NFT_DISPLAY_TYPE
,
useAppContext
().
cookies
);
const
displayTypeCookie
=
cookies
.
get
(
cookies
.
NAMES
.
ADDRESS_NFT_DISPLAY_TYPE
,
useAppContext
().
cookies
);
const
[
nftDisplayType
,
setNftDisplayType
]
=
React
.
useState
<
TNftDisplayType
>
(
displayTypeCookie
===
'
list
'
?
'
list
'
:
'
collection
'
);
const
[
nftDisplayType
,
setNftDisplayType
]
=
React
.
useState
<
TNftDisplayType
>
(
displayTypeCookie
===
'
list
'
?
'
list
'
:
'
collection
'
);
const
[
tokenTypes
,
setTokenTypes
]
=
React
.
useState
<
Array
<
NFTTokenType
>
|
undefined
>
(
getTokenFilterValue
(
router
.
query
.
type
)
||
[]);
const
tab
=
getQueryParamString
(
router
.
query
.
tab
);
const
tab
=
getQueryParamString
(
router
.
query
.
tab
);
const
hash
=
getQueryParamString
(
router
.
query
.
hash
);
const
hash
=
getQueryParamString
(
router
.
query
.
hash
);
...
@@ -69,6 +76,7 @@ const AddressTokens = () => {
...
@@ -69,6 +76,7 @@ const AddressTokens = () => {
refetchOnMount
:
false
,
refetchOnMount
:
false
,
placeholderData
:
generateListStub
<
'
address_collections
'
>
(
ADDRESS_COLLECTION
,
10
,
{
next_page_params
:
null
}),
placeholderData
:
generateListStub
<
'
address_collections
'
>
(
ADDRESS_COLLECTION
,
10
,
{
next_page_params
:
null
}),
},
},
filters
:
{
type
:
tokenTypes
},
});
});
const
nftsQuery
=
useQueryWithPages
({
const
nftsQuery
=
useQueryWithPages
({
...
@@ -80,6 +88,7 @@ const AddressTokens = () => {
...
@@ -80,6 +88,7 @@ const AddressTokens = () => {
refetchOnMount
:
false
,
refetchOnMount
:
false
,
placeholderData
:
generateListStub
<
'
address_nfts
'
>
(
ADDRESS_NFT_1155
,
10
,
{
next_page_params
:
null
}),
placeholderData
:
generateListStub
<
'
address_nfts
'
>
(
ADDRESS_NFT_1155
,
10
,
{
next_page_params
:
null
}),
},
},
filters
:
{
type
:
tokenTypes
},
});
});
const
handleNFTsDisplayTypeChange
=
React
.
useCallback
((
val
:
TNftDisplayType
)
=>
{
const
handleNFTsDisplayTypeChange
=
React
.
useCallback
((
val
:
TNftDisplayType
)
=>
{
...
@@ -87,6 +96,18 @@ const AddressTokens = () => {
...
@@ -87,6 +96,18 @@ const AddressTokens = () => {
setNftDisplayType
(
val
);
setNftDisplayType
(
val
);
},
[]);
},
[]);
const
handleTokenTypesChange
=
React
.
useCallback
((
value
:
Array
<
NFTTokenType
>
)
=>
{
nftsQuery
.
onFilterChange
({
type
:
value
});
collectionsQuery
.
onFilterChange
({
type
:
value
});
setTokenTypes
(
value
);
},
[
nftsQuery
,
collectionsQuery
]);
const
nftTypeFilter
=
(
<
PopoverFilter
isActive=
{
tokenTypes
&&
tokenTypes
.
length
>
0
}
contentProps=
{
{
w
:
'
200px
'
}
}
appliedFiltersNum=
{
tokenTypes
?.
length
}
>
<
TokenTypeFilter
<
NFTTokenType
>
nftOnly onChange=
{
handleTokenTypesChange
}
defaultValue=
{
tokenTypes
}
/
>
</
PopoverFilter
>
);
const tabs = [
const tabs = [
{
id
:
'
tokens_erc20
'
,
title
:
'
ERC-20
'
,
component
:
<
ERC20Tokens
tokensQuery
=
{
erc20Query
}
/>
}
,
{
id
:
'
tokens_erc20
'
,
title
:
'
ERC-20
'
,
component
:
<
ERC20Tokens
tokensQuery
=
{
erc20Query
}
/>
}
,
{
{
...
@@ -120,7 +141,10 @@ const AddressTokens = () => {
...
@@ -120,7 +141,10 @@ const AddressTokens = () => {
const rightSlot = (
const rightSlot = (
<>
<>
{
tab
!==
'
tokens
'
&&
tab
!==
'
tokens_erc20
'
&&
nftDisplayTypeRadio
}
<
HStack
spacing=
{
3
}
>
{
tab
!==
'
tokens
'
&&
tab
!==
'
tokens_erc20
'
&&
nftDisplayTypeRadio
}
{
tab
!==
'
tokens
'
&&
tab
!==
'
tokens_erc20
'
&&
nftTypeFilter
}
</
HStack
>
{
pagination
.
isVisible
&&
!
isMobile
&&
<
Pagination
{
...
pagination
}
/>
}
{
pagination
.
isVisible
&&
!
isMobile
&&
<
Pagination
{
...
pagination
}
/>
}
</>
</>
);
);
...
...
ui/address/tokens/AddressCollections.tsx
View file @
dd630ffd
...
@@ -44,7 +44,7 @@ const AddressCollections = ({ collectionsQuery, address }: Props) => {
...
@@ -44,7 +44,7 @@ const AddressCollections = ({ collectionsQuery, address }: Props) => {
const
hasOverload
=
Number
(
item
.
amount
)
>
item
.
token_instances
.
length
;
const
hasOverload
=
Number
(
item
.
amount
)
>
item
.
token_instances
.
length
;
return
(
return
(
<
Box
key=
{
item
.
token
.
address
+
index
}
mb=
{
6
}
>
<
Box
key=
{
item
.
token
.
address
+
index
}
mb=
{
6
}
>
<
Flex
mb=
{
3
}
flexWrap=
"wrap"
>
<
Flex
mb=
{
3
}
flexWrap=
"wrap"
lineHeight=
"30px"
>
<
TokenEntity
<
TokenEntity
width=
"auto"
width=
"auto"
noSymbol
noSymbol
...
...
ui/pages/Tokens.tsx
View file @
dd630ffd
...
@@ -105,7 +105,7 @@ const Tokens = () => {
...
@@ -105,7 +105,7 @@ const Tokens = () => {
</
PopoverFilter
>
</
PopoverFilter
>
)
:
(
)
:
(
<
PopoverFilter
isActive=
{
tokenTypes
&&
tokenTypes
.
length
>
0
}
contentProps=
{
{
w
:
'
200px
'
}
}
appliedFiltersNum=
{
tokenTypes
?.
length
}
>
<
PopoverFilter
isActive=
{
tokenTypes
&&
tokenTypes
.
length
>
0
}
contentProps=
{
{
w
:
'
200px
'
}
}
appliedFiltersNum=
{
tokenTypes
?.
length
}
>
<
TokenTypeFilter
onChange=
{
handleTokenTypesChange
}
defaultValue=
{
tokenTypes
}
/>
<
TokenTypeFilter
onChange=
{
handleTokenTypesChange
}
defaultValue=
{
tokenTypes
}
nftOnly=
{
false
}
/>
</
PopoverFilter
>
</
PopoverFilter
>
);
);
...
...
ui/shared/RadioButtonGroup.tsx
View file @
dd630ffd
...
@@ -17,6 +17,7 @@ type RadioButtonProps = UseRadioProps & RadioItemProps;
...
@@ -17,6 +17,7 @@ type RadioButtonProps = UseRadioProps & RadioItemProps;
const
RadioButton
=
(
props
:
RadioButtonProps
)
=>
{
const
RadioButton
=
(
props
:
RadioButtonProps
)
=>
{
const
{
getInputProps
,
getRadioProps
}
=
useRadio
(
props
);
const
{
getInputProps
,
getRadioProps
}
=
useRadio
(
props
);
const
buttonColor
=
useColorModeValue
(
'
blue.50
'
,
'
gray.800
'
);
const
buttonColor
=
useColorModeValue
(
'
blue.50
'
,
'
gray.800
'
);
const
checkedTextColor
=
useColorModeValue
(
'
blue.700
'
,
'
gray.50
'
);
const
input
=
getInputProps
();
const
input
=
getInputProps
();
const
checkbox
=
getRadioProps
();
const
checkbox
=
getRadioProps
();
...
@@ -35,7 +36,7 @@ const RadioButton = (props: RadioButtonProps) => {
...
@@ -35,7 +36,7 @@ const RadioButton = (props: RadioButtonProps) => {
_active
:
{
_active
:
{
backgroundColor
:
'
none
'
,
backgroundColor
:
'
none
'
,
},
},
...(
props
.
isChecked
?
{
color
:
'
text
'
}
:
{}),
...(
props
.
isChecked
?
{
color
:
checkedTextColor
}
:
{}),
};
};
if
(
props
.
onlyIcon
)
{
if
(
props
.
onlyIcon
)
{
...
@@ -58,7 +59,7 @@ const RadioButton = (props: RadioButtonProps) => {
...
@@ -58,7 +59,7 @@ const RadioButton = (props: RadioButtonProps) => {
return
(
return
(
<
Button
<
Button
as=
"label"
as=
"label"
leftIcon=
{
props
.
icon
?
<
Icon
as=
{
props
.
icon
}
boxSize=
{
5
}
/>
:
undefined
}
leftIcon=
{
props
.
icon
?
<
Icon
as=
{
props
.
icon
}
boxSize=
{
5
}
mr=
{
-
1
}
/>
:
undefined
}
{
...
styleProps
}
{
...
styleProps
}
>
>
<
input
{
...
input
}
/>
<
input
{
...
input
}
/>
...
...
ui/shared/TokenTransfer/TokenTransferFilter.tsx
View file @
dd630ffd
...
@@ -56,7 +56,7 @@ const TokenTransferFilter = ({
...
@@ -56,7 +56,7 @@ const TokenTransferFilter = ({
</>
</>
)
}
)
}
<
Text
variant=
"secondary"
fontWeight=
{
600
}
>
Type
</
Text
>
<
Text
variant=
"secondary"
fontWeight=
{
600
}
>
Type
</
Text
>
<
TokenTypeFilter
onChange=
{
onTypeFilterChange
}
defaultValue=
{
defaultTypeFilters
}
/>
<
TokenTypeFilter
onChange=
{
onTypeFilterChange
}
defaultValue=
{
defaultTypeFilters
}
nftOnly=
{
false
}
/>
</
PopoverFilter
>
</
PopoverFilter
>
);
);
};
};
...
...
ui/shared/filters/TokenTypeFilter.tsx
View file @
dd630ffd
import
{
CheckboxGroup
,
Checkbox
,
Text
,
Flex
,
Link
,
useCheckboxGroup
}
from
'
@chakra-ui/react
'
;
import
{
CheckboxGroup
,
Checkbox
,
Text
,
Flex
,
Link
,
useCheckboxGroup
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
TokenType
}
from
'
types/api/token
'
;
import
type
{
NFTTokenType
,
TokenType
}
from
'
types/api/token
'
;
import
{
TOKEN_TYPES
}
from
'
lib/token/tokenTypes
'
;
import
{
NFT_TOKEN_TYPES
,
TOKEN_TYPES
}
from
'
lib/token/tokenTypes
'
;
type
Props
=
{
type
Props
<
T
extends
TokenType
|
NFTTokenType
>
=
{
onChange
:
(
nextValue
:
Array
<
TokenType
>
)
=>
void
;
onChange
:
(
nextValue
:
Array
<
T
>
)
=>
void
;
defaultValue
?:
Array
<
TokenType
>
;
defaultValue
?:
Array
<
T
>
;
nftOnly
:
T
extends
NFTTokenType
?
true
:
false
;
}
}
const
TokenTypeFilter
=
<
T
extends
TokenType
|
NFTTokenType
>
(
{
nftOnly
,
onChange
,
defaultValue
}
: Props
<
T
>
) =
>
{
const
TokenTypeFilter
=
({
onChange
,
defaultValue
}:
Props
)
=>
{
const
{
value
,
setValue
}
=
useCheckboxGroup
({
defaultValue
});
const
{
value
,
setValue
}
=
useCheckboxGroup
({
defaultValue
});
const
handleReset
=
React
.
useCallback
(()
=>
{
const
handleReset
=
React
.
useCallback
(()
=>
{
...
@@ -21,7 +21,7 @@ const TokenTypeFilter = ({ onChange, defaultValue }: Props) => {
...
@@ -21,7 +21,7 @@ const TokenTypeFilter = ({ onChange, defaultValue }: Props) => {
onChange
([]);
onChange
([]);
},
[
onChange
,
setValue
,
value
.
length
]);
},
[
onChange
,
setValue
,
value
.
length
]);
const
handleChange
=
React
.
useCallback
((
nextValue
:
Array
<
T
okenType
>
)
=>
{
const
handleChange
=
React
.
useCallback
((
nextValue
:
Array
<
T
>
)
=>
{
setValue
(
nextValue
);
setValue
(
nextValue
);
onChange
(
nextValue
);
onChange
(
nextValue
);
},
[
onChange
,
setValue
]);
},
[
onChange
,
setValue
]);
...
@@ -41,7 +41,7 @@ const TokenTypeFilter = ({ onChange, defaultValue }: Props) => {
...
@@ -41,7 +41,7 @@ const TokenTypeFilter = ({ onChange, defaultValue }: Props) => {
</
Link
>
</
Link
>
</
Flex
>
</
Flex
>
<
CheckboxGroup
size=
"lg"
onChange=
{
handleChange
}
value=
{
value
}
>
<
CheckboxGroup
size=
"lg"
onChange=
{
handleChange
}
value=
{
value
}
>
{
TOKEN_TYPES
.
map
(({
title
,
id
})
=>
(
{
(
nftOnly
?
NFT_TOKEN_TYPES
:
TOKEN_TYPES
)
.
map
(({
title
,
id
})
=>
(
<
Checkbox
key=
{
id
}
value=
{
id
}
>
<
Checkbox
key=
{
id
}
value=
{
id
}
>
<
Text
fontSize=
"md"
>
{
title
}
</
Text
>
<
Text
fontSize=
"md"
>
{
title
}
</
Text
>
</
Checkbox
>
</
Checkbox
>
...
...
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