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
4c3e6783
Commit
4c3e6783
authored
Dec 25, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use 2 resources for domain lookup
parent
5827803b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
17 deletions
+52
-17
NameDomainsActionBar.tsx
ui/nameDomains/NameDomainsActionBar.tsx
+4
-2
NameDomains.tsx
ui/pages/NameDomains.tsx
+48
-15
No files found.
ui/nameDomains/NameDomainsActionBar.tsx
View file @
4c3e6783
...
@@ -35,9 +35,10 @@ interface Props {
...
@@ -35,9 +35,10 @@ interface Props {
sort
:
TSort
|
undefined
;
sort
:
TSort
|
undefined
;
onSortChange
:
(
nextValue
:
TSort
|
undefined
)
=>
void
;
onSortChange
:
(
nextValue
:
TSort
|
undefined
)
=>
void
;
isLoading
:
boolean
;
isLoading
:
boolean
;
isAddressSearch
:
boolean
;
}
}
const
NameDomainsActionBar
=
({
searchTerm
,
onSearchChange
,
filterValue
,
onFilterValueChange
,
sort
,
onSortChange
,
isLoading
}:
Props
)
=>
{
const
NameDomainsActionBar
=
({
searchTerm
,
onSearchChange
,
filterValue
,
onFilterValueChange
,
sort
,
onSortChange
,
isLoading
,
isAddressSearch
}:
Props
)
=>
{
const
isInitialLoading
=
useIsInitialLoading
(
isLoading
);
const
isInitialLoading
=
useIsInitialLoading
(
isLoading
);
const
searchInput
=
(
const
searchInput
=
(
...
@@ -56,7 +57,7 @@ const NameDomainsActionBar = ({ searchTerm, onSearchChange, filterValue, onFilte
...
@@ -56,7 +57,7 @@ const NameDomainsActionBar = ({ searchTerm, onSearchChange, filterValue, onFilte
<
div
>
<
div
>
<
CheckboxGroup
size=
"lg"
onChange=
{
onFilterValueChange
}
value=
{
filterValue
}
defaultValue=
{
filterValue
}
>
<
CheckboxGroup
size=
"lg"
onChange=
{
onFilterValueChange
}
value=
{
filterValue
}
defaultValue=
{
filterValue
}
>
<
Text
variant=
"secondary"
fontWeight=
{
600
}
mb=
{
3
}
fontSize=
"sm"
>
Address
</
Text
>
<
Text
variant=
"secondary"
fontWeight=
{
600
}
mb=
{
3
}
fontSize=
"sm"
>
Address
</
Text
>
<
Checkbox
value=
"ownedBy"
display=
"block"
>
<
Checkbox
value=
"ownedBy"
display=
"block"
isDisabled=
{
!
isAddressSearch
}
>
Owned by
Owned by
</
Checkbox
>
</
Checkbox
>
<
Checkbox
<
Checkbox
...
@@ -67,6 +68,7 @@ const NameDomainsActionBar = ({ searchTerm, onSearchChange, filterValue, onFilte
...
@@ -67,6 +68,7 @@ const NameDomainsActionBar = ({ searchTerm, onSearchChange, filterValue, onFilte
pb=
{
4
}
pb=
{
4
}
borderBottom=
"1px solid"
borderBottom=
"1px solid"
borderColor=
"divider"
borderColor=
"divider"
isDisabled=
{
!
isAddressSearch
}
>
>
Resolved to address
Resolved to address
</
Checkbox
>
</
Checkbox
>
...
...
ui/pages/NameDomains.tsx
View file @
4c3e6783
...
@@ -9,6 +9,7 @@ import useApiQuery from 'lib/api/useApiQuery';
...
@@ -9,6 +9,7 @@ import useApiQuery from 'lib/api/useApiQuery';
import
useDebounce
from
'
lib/hooks/useDebounce
'
;
import
useDebounce
from
'
lib/hooks/useDebounce
'
;
import
{
apos
}
from
'
lib/html-entities
'
;
import
{
apos
}
from
'
lib/html-entities
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
{
ADDRESS_REGEXP
}
from
'
lib/validations/address
'
;
import
{
ENS_DOMAIN
}
from
'
stubs/ENS
'
;
import
{
ENS_DOMAIN
}
from
'
stubs/ENS
'
;
import
{
generateListStub
}
from
'
stubs/utils
'
;
import
{
generateListStub
}
from
'
stubs/utils
'
;
import
NameDomainsActionBar
from
'
ui/nameDomains/NameDomainsActionBar
'
;
import
NameDomainsActionBar
from
'
ui/nameDomains/NameDomainsActionBar
'
;
...
@@ -22,7 +23,7 @@ import PageTitle from 'ui/shared/Page/PageTitle';
...
@@ -22,7 +23,7 @@ import PageTitle from 'ui/shared/Page/PageTitle';
const
NameDomains
=
()
=>
{
const
NameDomains
=
()
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
address
=
getQueryParamString
(
router
.
query
.
address
);
const
q
=
getQueryParamString
(
router
.
query
.
q
);
const
ownedBy
=
getQueryParamString
(
router
.
query
.
ownedBy
);
const
ownedBy
=
getQueryParamString
(
router
.
query
.
ownedBy
);
const
resolvedTo
=
getQueryParamString
(
router
.
query
.
resolvedTo
);
const
resolvedTo
=
getQueryParamString
(
router
.
query
.
resolvedTo
);
const
withInactive
=
getQueryParamString
(
router
.
query
.
withInactive
);
const
withInactive
=
getQueryParamString
(
router
.
query
.
withInactive
);
...
@@ -33,32 +34,63 @@ const NameDomains = () => {
...
@@ -33,32 +34,63 @@ const NameDomains = () => {
withInactive
===
'
true
'
?
'
withInactive
'
as
const
:
undefined
,
withInactive
===
'
true
'
?
'
withInactive
'
as
const
:
undefined
,
].
filter
(
Boolean
);
].
filter
(
Boolean
);
const
[
searchTerm
,
setSearchTerm
]
=
React
.
useState
<
string
>
(
address
??
''
);
const
[
searchTerm
,
setSearchTerm
]
=
React
.
useState
<
string
>
(
q
||
''
);
const
[
filterValue
,
setFilterValue
]
=
React
.
useState
<
EnsDomainLookupFiltersOptions
>
(
initialFilters
);
const
[
filterValue
,
setFilterValue
]
=
React
.
useState
<
EnsDomainLookupFiltersOptions
>
(
initialFilters
);
const
[
sort
,
setSort
]
=
React
.
useState
<
Sort
>
();
const
[
sort
,
setSort
]
=
React
.
useState
<
Sort
>
();
const
debouncedSearchTerm
=
useDebounce
(
searchTerm
||
''
,
300
);
const
debouncedSearchTerm
=
useDebounce
(
searchTerm
,
300
);
const
isAddressSearch
=
React
.
useMemo
(()
=>
ADDRESS_REGEXP
.
test
(
debouncedSearchTerm
),
[
debouncedSearchTerm
]);
const
sortParam
=
sort
?.
split
(
'
-
'
)[
0
];
const
orderParam
=
sort
?.
split
(
'
-
'
)[
1
].
toUpperCase
();
const
{
isError
,
isPlaceholderData
,
data
}
=
useApiQuery
(
'
addresses_lookup
'
,
{
const
addressesLookupQuery
=
useApiQuery
(
'
addresses_lookup
'
,
{
pathParams
:
{
chainId
:
config
.
chain
.
id
},
pathParams
:
{
chainId
:
config
.
chain
.
id
},
fetchParams
:
{
fetchParams
:
{
method
:
'
POST
'
,
method
:
'
POST
'
,
body
:
{
body
:
{
address
:
debouncedSearchTerm
,
address
:
debouncedSearchTerm
,
resolvedTo
:
true
,
resolvedTo
:
filterValue
.
includes
(
'
resolvedTo
'
)
,
ownedBy
:
true
,
ownedBy
:
filterValue
.
includes
(
'
ownedBy
'
)
,
onlyActive
:
true
,
onlyActive
:
!
filterValue
.
includes
(
'
withInactive
'
)
,
sort
:
'
registration_date
'
,
sort
:
sortParam
,
order
:
'
ASC
'
,
order
:
orderParam
,
},
},
},
},
queryOptions
:
{
queryOptions
:
{
enabled
:
isAddressSearch
,
placeholderData
:
generateListStub
<
'
addresses_lookup
'
>
(
ENS_DOMAIN
,
50
,
{
totalRecords
:
50
}),
placeholderData
:
generateListStub
<
'
addresses_lookup
'
>
(
ENS_DOMAIN
,
50
,
{
totalRecords
:
50
}),
},
},
});
});
const
domainsLookupQuery
=
useApiQuery
(
'
domains_lookup
'
,
{
pathParams
:
{
chainId
:
config
.
chain
.
id
},
fetchParams
:
{
method
:
'
POST
'
,
body
:
{
name
:
debouncedSearchTerm
,
onlyActive
:
!
filterValue
.
includes
(
'
withInactive
'
),
sort
:
sortParam
,
order
:
orderParam
,
},
},
queryOptions
:
{
enabled
:
!
isAddressSearch
,
placeholderData
:
generateListStub
<
'
domains_lookup
'
>
(
ENS_DOMAIN
,
50
,
{
totalRecords
:
50
}),
},
});
const
query
=
isAddressSearch
?
addressesLookupQuery
:
domainsLookupQuery
;
const
{
data
,
isError
,
isPlaceholderData
:
isLoading
}
=
query
;
React
.
useEffect
(()
=>
{
if
(
isAddressSearch
&&
filterValue
.
filter
((
value
)
=>
value
!==
'
withInactive
'
).
length
===
0
)
{
setFilterValue
([
'
ownedBy
'
,
'
resolvedTo
'
]);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
isAddressSearch
]);
const
handleSortToggle
=
React
.
useCallback
((
event
:
React
.
MouseEvent
)
=>
{
const
handleSortToggle
=
React
.
useCallback
((
event
:
React
.
MouseEvent
)
=>
{
if
(
is
PlaceholderData
)
{
if
(
is
Loading
)
{
return
;
return
;
}
}
const
field
=
(
event
.
currentTarget
as
HTMLDivElement
).
getAttribute
(
'
data-field
'
)
as
SortField
|
undefined
;
const
field
=
(
event
.
currentTarget
as
HTMLDivElement
).
getAttribute
(
'
data-field
'
)
as
SortField
|
undefined
;
...
@@ -66,7 +98,7 @@ const NameDomains = () => {
...
@@ -66,7 +98,7 @@ const NameDomains = () => {
if
(
field
)
{
if
(
field
)
{
setSort
(
getNextSortValue
(
field
));
setSort
(
getNextSortValue
(
field
));
}
}
},
[
is
PlaceholderData
]);
},
[
is
Loading
]);
const
handleSearchTermChange
=
React
.
useCallback
((
value
:
string
)
=>
{
const
handleSearchTermChange
=
React
.
useCallback
((
value
:
string
)
=>
{
setSearchTerm
(
value
);
setSearchTerm
(
value
);
...
@@ -84,9 +116,9 @@ const NameDomains = () => {
...
@@ -84,9 +116,9 @@ const NameDomains = () => {
<
Box
>
<
Box
>
{
data
?.
items
.
map
((
item
,
index
)
=>
(
{
data
?.
items
.
map
((
item
,
index
)
=>
(
<
NameDomainsListItem
<
NameDomainsListItem
key=
{
item
.
id
+
(
is
PlaceholderData
?
index
:
''
)
}
key=
{
item
.
id
+
(
is
Loading
?
index
:
''
)
}
{
...
item
}
{
...
item
}
isLoading=
{
is
PlaceholderData
}
isLoading=
{
is
Loading
}
/>
/>
))
}
))
}
</
Box
>
</
Box
>
...
@@ -94,7 +126,7 @@ const NameDomains = () => {
...
@@ -94,7 +126,7 @@ const NameDomains = () => {
<
Hide
below=
"lg"
ssr=
{
false
}
>
<
Hide
below=
"lg"
ssr=
{
false
}
>
<
NameDomainsTable
<
NameDomainsTable
data=
{
data
}
data=
{
data
}
isLoading=
{
is
PlaceholderData
}
isLoading=
{
is
Loading
}
sort=
{
sort
}
sort=
{
sort
}
onSortToggle=
{
handleSortToggle
}
onSortToggle=
{
handleSortToggle
}
/>
/>
...
@@ -104,13 +136,14 @@ const NameDomains = () => {
...
@@ -104,13 +136,14 @@ const NameDomains = () => {
const
actionBar
=
(
const
actionBar
=
(
<
NameDomainsActionBar
<
NameDomainsActionBar
isLoading=
{
is
PlaceholderData
}
isLoading=
{
is
Loading
}
searchTerm=
{
searchTerm
}
searchTerm=
{
searchTerm
}
onSearchChange=
{
handleSearchTermChange
}
onSearchChange=
{
handleSearchTermChange
}
filterValue=
{
filterValue
}
filterValue=
{
filterValue
}
onFilterValueChange=
{
handleFilterValueChange
}
onFilterValueChange=
{
handleFilterValueChange
}
sort=
{
sort
}
sort=
{
sort
}
onSortChange=
{
setSort
}
onSortChange=
{
setSort
}
isAddressSearch=
{
isAddressSearch
}
/>
/>
);
);
...
...
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