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
87d1926e
Commit
87d1926e
authored
Apr 12, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle add public tag
parent
40981a37
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
8 deletions
+48
-8
PublicTags.tsx
ui/pages/PublicTags.tsx
+12
-2
PublicTagsForm.tsx
ui/publicTags/PublicTagsForm/PublicTagsForm.tsx
+3
-3
Menu.tsx
ui/shared/AddressActions/Menu.tsx
+2
-3
PublicTagMenuItem.tsx
ui/shared/AddressActions/PublicTagMenuItem.tsx
+31
-0
No files found.
ui/pages/PublicTags.tsx
View file @
87d1926e
import
{
Link
,
Text
,
Icon
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
,
{
useCallback
,
useState
}
from
'
react
'
;
import
{
animateScroll
}
from
'
react-scroll
'
;
...
...
@@ -8,6 +9,7 @@ import eastArrowIcon from 'icons/arrows/east.svg';
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useRedirectForInvalidAuthToken
from
'
lib/hooks/useRedirectForInvalidAuthToken
'
;
import
useToast
from
'
lib/hooks/useToast
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
PublicTagsData
from
'
ui/publicTags/PublicTagsData
'
;
import
PublicTagsForm
from
'
ui/publicTags/PublicTagsForm/PublicTagsForm
'
;
import
Page
from
'
ui/shared/Page/Page
'
;
...
...
@@ -23,13 +25,21 @@ const toastDescriptions = {
}
as
Record
<
TToastAction
,
string
>
;
const
PublicTagsComponent
:
React
.
FC
=
()
=>
{
const
[
screen
,
setScreen
]
=
useState
<
TScreen
>
(
'
data
'
);
const
[
formData
,
setFormData
]
=
useState
<
PublicTag
>
();
const
router
=
useRouter
();
const
addressHash
=
getQueryParamString
(
router
.
query
.
address
);
const
[
screen
,
setScreen
]
=
useState
<
TScreen
>
(
addressHash
?
'
form
'
:
'
data
'
);
const
[
formData
,
setFormData
]
=
useState
<
Partial
<
PublicTag
>
|
undefined
>
(
addressHash
?
{
addresses
:
[
addressHash
]
}
:
undefined
);
const
toast
=
useToast
();
const
isMobile
=
useIsMobile
();
useRedirectForInvalidAuthToken
();
React
.
useEffect
(()
=>
{
router
.
replace
({
pathname
:
'
/account/public_tags_request
'
});
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
]);
const
showToast
=
useCallback
((
action
:
TToastAction
)
=>
{
toast
({
position
:
'
top-right
'
,
...
...
ui/publicTags/PublicTagsForm/PublicTagsForm.tsx
View file @
87d1926e
...
...
@@ -28,7 +28,7 @@ import PublicTagsFormInput from './PublicTagsFormInput';
type
Props
=
{
changeToDataScreen
:
(
success
?:
boolean
)
=>
void
;
data
?:
P
ublicTag
;
data
?:
P
artial
<
PublicTag
>
;
}
export
type
Inputs
=
{
...
...
@@ -67,8 +67,8 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => {
email
:
data
?.
email
||
''
,
companyName
:
data
?.
company
||
''
,
companyUrl
:
data
?.
website
||
''
,
tags
:
data
?.
tags
.
split
(
'
;
'
).
map
((
tag
)
=>
tag
).
join
(
'
;
'
)
||
''
,
addresses
:
data
?.
addresses
.
map
((
address
,
index
:
number
)
=>
({
name
:
`address.
${
index
}
.address`
,
address
}))
||
tags
:
data
?.
tags
?
.
split
(
'
;
'
).
map
((
tag
)
=>
tag
).
join
(
'
;
'
)
||
''
,
addresses
:
data
?.
addresses
?
.
map
((
address
,
index
:
number
)
=>
({
name
:
`address.
${
index
}
.address`
,
address
}))
||
[
{
name
:
'
address.0.address
'
,
address
:
''
}
],
comment
:
data
?.
additional_comment
||
''
,
action
:
data
?.
is_owner
===
undefined
||
data
?.
is_owner
?
'
add
'
:
'
report
'
,
...
...
ui/shared/AddressActions/Menu.tsx
View file @
87d1926e
...
...
@@ -6,6 +6,7 @@ import iconArrow from 'icons/arrows/east-mini.svg';
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
PrivateTagMenuItem
from
'
./PrivateTagMenuItem
'
;
import
PublicTagMenuItem
from
'
./PublicTagMenuItem
'
;
const
AddressActions
=
()
=>
{
const
router
=
useRouter
();
...
...
@@ -29,9 +30,7 @@ const AddressActions = () => {
<
MenuItem
py=
{
2
}
px=
{
4
}
>
Add token info
</
MenuItem
>
<
MenuItem
py=
{
2
}
px=
{
4
}
>
Add public tag
</
MenuItem
>
<
PublicTagMenuItem
py=
{
2
}
px=
{
4
}
hash=
{
hash
}
/>
<
PrivateTagMenuItem
py=
{
2
}
px=
{
4
}
hash=
{
hash
}
/>
</
MenuList
>
</
Menu
>
...
...
ui/shared/AddressActions/PublicTagMenuItem.tsx
0 → 100644
View file @
87d1926e
import
{
MenuItem
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
useRedirectIfNotAuth
from
'
lib/hooks/useRedirectIfNotAuth
'
;
interface
Props
{
className
?:
string
;
hash
:
string
;
}
const
PublicTagMenuItem
=
({
className
,
hash
}:
Props
)
=>
{
const
router
=
useRouter
();
const
redirectIfNotAuth
=
useRedirectIfNotAuth
();
const
handleClick
=
React
.
useCallback
(()
=>
{
if
(
redirectIfNotAuth
())
{
return
;
}
router
.
push
({
pathname
:
'
/account/public_tags_request
'
,
query
:
{
address
:
hash
}
});
},
[
hash
,
redirectIfNotAuth
,
router
]);
return
(
<
MenuItem
className=
{
className
}
onClick=
{
handleClick
}
>
Add public tag
</
MenuItem
>
);
};
export
default
React
.
memo
(
chakra
(
PublicTagMenuItem
));
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