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
46dc6e28
Unverified
Commit
46dc6e28
authored
Jun 15, 2022
by
tom goriunov
Committed by
GitHub
Jun 15, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8 from tom2drum/edit-address-fix
один модал для всех адресов
parents
af6f75cd
4add4ee7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
136 additions
and
33 deletions
+136
-33
AddressModal.tsx
components/AddressModal/AddressModal.tsx
+15
-8
DeleteModal.tsx
components/DeleteModal/DeleteModal.tsx
+48
-0
WatchListTableItem.tsx
components/WatchlistTable/WatchListTableItem.tsx
+23
-19
WatchlistTable.tsx
components/WatchlistTable/WatchlistTable.tsx
+12
-3
watchlist.tsx
pages/watchlist.tsx
+37
-3
Modal.ts
theme/components/Modal.ts
+1
-0
No files found.
components/AddressModal/AddressModal.tsx
View file @
46dc6e28
import
React
,
{
useCallback
,
useState
}
from
'
react
'
;
import
React
,
{
useCallback
,
use
Effect
,
use
State
}
from
'
react
'
;
import
{
import
{
Box
,
Box
,
...
@@ -28,12 +28,18 @@ type Props = {
...
@@ -28,12 +28,18 @@ type Props = {
data
?:
TWatchlistItem
;
data
?:
TWatchlistItem
;
}
}
const
AddressModal
:
React
.
FC
<
Props
>
=
({
isOpen
,
onClose
,
data
=
{}
as
TWatchlistItem
})
=>
{
const
AddressModal
:
React
.
FC
<
Props
>
=
({
isOpen
,
onClose
,
data
})
=>
{
// надо чето придумать с формой
// надо чето придумать с формой
// потом доделаем
// потом доделаем
const
[
address
,
setAddress
]
=
useState
(
data
.
address
);
const
[
address
,
setAddress
]
=
useState
<
string
>
();
const
[
tag
,
setTag
]
=
useState
(
data
.
tag
);
const
[
tag
,
setTag
]
=
useState
<
string
>
();
const
[
notification
,
setNotification
]
=
useState
(
data
.
notification
);
const
[
notification
,
setNotification
]
=
useState
<
boolean
>
();
useEffect
(()
=>
{
setAddress
(
data
?.
address
);
setTag
(
data
?.
tag
);
setNotification
(
data
?.
notification
);
},
[
data
]);
const
onAddressChange
=
useCallback
((
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
setAddress
(
event
.
target
.
value
),
[
setAddress
]);
const
onAddressChange
=
useCallback
((
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
setAddress
(
event
.
target
.
value
),
[
setAddress
]);
const
onTagChange
=
useCallback
((
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
setTag
(
event
.
target
.
value
),
[
setTag
]);
const
onTagChange
=
useCallback
((
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
setTag
(
event
.
target
.
value
),
[
setTag
]);
...
@@ -44,12 +50,13 @@ const AddressModal: React.FC<Props> = ({ isOpen, onClose, data = {} as TWatchlis
...
@@ -44,12 +50,13 @@ const AddressModal: React.FC<Props> = ({ isOpen, onClose, data = {} as TWatchlis
console
.
log
(
address
,
tag
,
notification
);
console
.
log
(
address
,
tag
,
notification
);
onClose
()
onClose
()
},
[
address
,
tag
,
notification
,
onClose
]);
},
[
address
,
tag
,
notification
,
onClose
]);
return
(
return
(
<
Modal
isOpen=
{
isOpen
}
onClose=
{
onClose
}
size=
"md"
>
<
Modal
isOpen=
{
isOpen
}
onClose=
{
onClose
}
size=
"md"
>
<
ModalOverlay
/>
<
ModalOverlay
/>
<
ModalContent
>
<
ModalContent
>
<
ModalHeader
fontWeight=
"500"
>
New Address to Watchlist
</
ModalHeader
>
<
ModalHeader
fontWeight=
"500"
>
New Address to Watchlist
</
ModalHeader
>
<
ModalCloseButton
color=
"blue.500"
/>
<
ModalCloseButton
/>
<
ModalBody
>
<
ModalBody
>
<
Text
lineHeight=
"30px"
marginBottom=
"40px"
>
<
Text
lineHeight=
"30px"
marginBottom=
"40px"
>
An Email notification can be sent to you when an address on your watch list sends or receives any transactions.
An Email notification can be sent to you when an address on your watch list sends or receives any transactions.
...
@@ -58,13 +65,13 @@ const AddressModal: React.FC<Props> = ({ isOpen, onClose, data = {} as TWatchlis
...
@@ -58,13 +65,13 @@ const AddressModal: React.FC<Props> = ({ isOpen, onClose, data = {} as TWatchlis
placeholder=
"Address (0x...)*"
placeholder=
"Address (0x...)*"
marginBottom=
"20px"
marginBottom=
"20px"
onChange=
{
onAddressChange
}
onChange=
{
onAddressChange
}
value=
{
address
}
value=
{
address
||
''
}
/>
/>
<
Input
<
Input
placeholder=
"Private tag (max 35 characters)*"
placeholder=
"Private tag (max 35 characters)*"
marginBottom=
"30px"
marginBottom=
"30px"
onChange=
{
onTagChange
}
onChange=
{
onTagChange
}
value=
{
tag
}
value=
{
tag
||
''
}
/>
/>
<
Text
color=
"gray.600"
fontSize=
"14px"
marginBottom=
"32px"
>
<
Text
color=
"gray.600"
fontSize=
"14px"
marginBottom=
"32px"
>
Please select what types of notifications you will receive:
Please select what types of notifications you will receive:
...
...
components/DeleteModal/DeleteModal.tsx
0 → 100644
View file @
46dc6e28
import
React
,
{
useCallback
}
from
'
react
'
;
import
{
Button
,
Modal
,
ModalOverlay
,
ModalContent
,
ModalFooter
,
ModalBody
,
ModalCloseButton
,
}
from
'
@chakra-ui/react
'
;
type
Props
=
{
isOpen
:
boolean
;
onClose
:
()
=>
void
;
getDisclosureProps
:
()
=>
any
;
address
?:
string
;
}
const
DeleteModal
:
React
.
FC
<
Props
>
=
({
isOpen
,
onClose
,
address
})
=>
{
const
onDeleteClick
=
useCallback
(()
=>
{
// eslint-disable-next-line no-console
console
.
log
(
'
delete
'
,
address
);
onClose
()
},
[
address
,
onClose
]);
return
(
<
Modal
isOpen=
{
isOpen
}
onClose=
{
onClose
}
size=
"md"
>
<
ModalOverlay
/>
<
ModalContent
>
<
ModalCloseButton
/>
<
ModalBody
>
{
`Delete ${ address || 'address' } from watchlist?`
}
</
ModalBody
>
<
ModalFooter
>
<
Button
variant=
"ghost"
onClick=
{
onDeleteClick
}
>
Yes
</
Button
>
<
Button
colorScheme=
"blue"
ml=
{
3
}
onClick=
{
onClose
}
>
No
</
Button
>
</
ModalFooter
>
</
ModalContent
>
</
Modal
>
)
}
export
default
DeleteModal
;
components/WatchlistTable/WatchListTableItem.tsx
View file @
46dc6e28
import
React
from
'
react
'
;
import
React
,
{
useCallback
}
from
'
react
'
;
import
{
import
{
Tag
,
Tag
,
...
@@ -7,37 +7,41 @@ import {
...
@@ -7,37 +7,41 @@ import {
Switch
,
Switch
,
Icon
,
Icon
,
HStack
,
HStack
,
useDisclosure
,
}
from
'
@chakra-ui/react
'
}
from
'
@chakra-ui/react
'
import
{
FaEdit
,
FaTrash
}
from
'
react-icons/fa
'
;
import
{
FaEdit
,
FaTrash
}
from
'
react-icons/fa
'
;
import
type
{
TWatchlistItem
}
from
'
../../data/watchlist
'
;
import
type
{
TWatchlistItem
}
from
'
../../data/watchlist
'
;
import
AddressModal
from
'
../AddressModal/AddressModal
'
;
import
WatchListAddressItem
from
'
./WatchListAddressItem
'
;
import
WatchListAddressItem
from
'
./WatchListAddressItem
'
;
interface
Props
{
interface
Props
{
item
:
TWatchlistItem
;
item
:
TWatchlistItem
;
onEditClick
:
(
data
:
TWatchlistItem
)
=>
void
;
onDeleteClick
:
(
data
:
TWatchlistItem
)
=>
void
;
}
}
const
WatchlistTableItem
=
({
item
}:
Props
)
=>
{
const
WatchlistTableItem
=
({
item
,
onEditClick
,
onDeleteClick
}:
Props
)
=>
{
const
modalProps
=
useDisclosure
();
const
onItemEditClick
=
useCallback
(()
=>
{
return
onEditClick
(
item
);
},
[
item
,
onEditClick
]);
const
onItemDeleteClick
=
useCallback
(()
=>
{
return
onDeleteClick
(
item
);
},
[
item
,
onDeleteClick
]);
return
(
return
(
<>
<
Tr
alignItems=
"top"
key=
{
item
.
address
}
>
<
Tr
alignItems=
"top"
key=
{
item
.
address
}
>
<
Td
><
WatchListAddressItem
item=
{
item
}
/></
Td
>
<
Td
><
WatchListAddressItem
item=
{
item
}
/></
Td
>
<
Td
><
Tag
>
{
item
.
tag
}
</
Tag
></
Td
>
<
Td
><
Tag
>
{
item
.
tag
}
</
Tag
></
Td
>
<
Td
><
Switch
colorScheme=
"green"
size=
"md"
isChecked=
{
item
.
notification
}
/></
Td
>
<
Td
><
Switch
colorScheme=
"green"
size=
"md"
isChecked=
{
item
.
notification
}
/></
Td
>
<
Td
>
<
Td
>
<
HStack
spacing=
"30px"
>
<
HStack
spacing=
"30px"
>
<
Icon
as=
{
FaEdit
}
w=
"20px"
h=
"20px"
cursor=
"pointer"
color=
"blue.500"
onClick=
{
onItemEditClick
}
/>
<
Icon
as=
{
FaEdit
}
w=
"20px"
h=
"20px"
cursor=
"pointer"
color=
"blue.500"
onClick=
{
modalProps
.
onOpen
}
/>
<
Icon
as=
{
FaTrash
}
w=
"20px"
h=
"20px"
cursor=
"pointer"
color=
"red.200"
onClick=
{
onItemDeleteClick
}
/>
<
Icon
as=
{
FaTrash
}
w=
"20px"
h=
"20px"
cursor=
"pointer"
color=
"red.200"
/>
</
HStack
>
</
HStack
>
</
Td
>
</
Td
>
</
Tr
>
</
Tr
>
<
AddressModal
{
...
modalProps
}
data=
{
item
}
/>
</>
)
)
};
};
...
...
components/WatchlistTable/WatchlistTable.tsx
View file @
46dc6e28
...
@@ -9,15 +9,17 @@ import {
...
@@ -9,15 +9,17 @@ import {
TableContainer
,
TableContainer
,
}
from
'
@chakra-ui/react
'
}
from
'
@chakra-ui/react
'
import
type
{
TWatchlist
}
from
'
../../data/watchlist
'
;
import
type
{
TWatchlist
,
TWatchlistItem
}
from
'
../../data/watchlist
'
;
import
WatchlistTableItem
from
'
./WatchListTableItem
'
;
import
WatchlistTableItem
from
'
./WatchListTableItem
'
;
interface
Props
{
interface
Props
{
data
:
TWatchlist
;
data
:
TWatchlist
;
onEditClick
:
(
data
:
TWatchlistItem
)
=>
void
;
onDeleteClick
:
(
data
:
TWatchlistItem
)
=>
void
;
}
}
const
WatchlistTable
=
({
data
}:
Props
)
=>
{
const
WatchlistTable
=
({
data
,
onDeleteClick
,
onEditClick
}:
Props
)
=>
{
return
(
return
(
<
TableContainer
width=
"100%"
>
<
TableContainer
width=
"100%"
>
<
Table
variant=
"simple"
>
<
Table
variant=
"simple"
>
...
@@ -30,7 +32,14 @@ const WatchlistTable = ({ data }: Props) => {
...
@@ -30,7 +32,14 @@ const WatchlistTable = ({ data }: Props) => {
</
Tr
>
</
Tr
>
</
Thead
>
</
Thead
>
<
Tbody
>
<
Tbody
>
{
data
.
map
(
item
=>
<
WatchlistTableItem
item=
{
item
}
key=
{
item
.
address
}
/>)
}
{
data
.
map
((
item
)
=>
(
<
WatchlistTableItem
item=
{
item
}
key=
{
item
.
address
}
onDeleteClick=
{
onDeleteClick
}
onEditClick=
{
onEditClick
}
/>
))
}
</
Tbody
>
</
Tbody
>
</
Table
>
</
Table
>
</
TableContainer
>
</
TableContainer
>
...
...
pages/watchlist.tsx
View file @
46dc6e28
import
React
from
'
react
'
;
import
React
,
{
useCallback
,
useState
}
from
'
react
'
;
import
type
{
NextPage
}
from
'
next
'
;
import
type
{
NextPage
}
from
'
next
'
;
import
{
Box
,
Button
,
Text
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Button
,
Text
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
...
@@ -8,15 +8,48 @@ import Page from '../components/Page/Page';
...
@@ -8,15 +8,48 @@ import Page from '../components/Page/Page';
import
WatchlistTable
from
'
../components/WatchlistTable/WatchlistTable
'
;
import
WatchlistTable
from
'
../components/WatchlistTable/WatchlistTable
'
;
import
AddressModal
from
'
../components/AddressModal/AddressModal
'
;
import
AddressModal
from
'
../components/AddressModal/AddressModal
'
;
import
type
{
TWatchlistItem
}
from
'
../data/watchlist
'
;
import
{
watchlist
}
from
'
../data/watchlist
'
;
import
{
watchlist
}
from
'
../data/watchlist
'
;
import
DeleteModal
from
'
../components/DeleteModal/DeleteModal
'
;
const
WatchList
:
NextPage
=
()
=>
{
const
WatchList
:
NextPage
=
()
=>
{
const
addressModalProps
=
useDisclosure
();
const
addressModalProps
=
useDisclosure
();
const
deleteModalProps
=
useDisclosure
();
const
[
addressModalData
,
setAddressModalData
]
=
useState
<
TWatchlistItem
>
();
const
[
deleteModalData
,
setDeleteModalData
]
=
useState
<
string
>
();
const
onEditClick
=
useCallback
((
data
:
TWatchlistItem
)
=>
{
setAddressModalData
(
data
);
addressModalProps
.
onOpen
();
},
[
addressModalProps
])
const
onAddressModalClose
=
useCallback
(()
=>
{
setAddressModalData
(
undefined
);
addressModalProps
.
onClose
();
},
[
addressModalProps
]);
const
onDeleteClick
=
useCallback
((
data
:
TWatchlistItem
)
=>
{
setDeleteModalData
(
data
.
address
);
deleteModalProps
.
onOpen
();
},
[
deleteModalProps
])
const
onDeleteModalClose
=
useCallback
(()
=>
{
setDeleteModalData
(
undefined
);
deleteModalProps
.
onClose
();
},
[
deleteModalProps
]);
return
(
return
(
<
Page
>
<
Page
>
<
Box
h=
"100%"
>
<
Box
h=
"100%"
>
<
Text
marginBottom=
"40px"
>
An Email notification can be sent to you when an address on your watch list sends or receives any transactions.
</
Text
>
<
Text
marginBottom=
"40px"
>
An Email notification can be sent to you when an address on your watch list sends or receives any transactions.
</
Text
>
{
Boolean
(
watchlist
.
length
)
&&
<
WatchlistTable
data=
{
watchlist
}
/>
}
{
Boolean
(
watchlist
.
length
)
&&
(
<
WatchlistTable
data=
{
watchlist
}
onDeleteClick=
{
onDeleteClick
}
onEditClick=
{
onEditClick
}
/>
)
}
<
Box
marginTop=
"32px"
>
<
Box
marginTop=
"32px"
>
<
Button
<
Button
colorScheme=
"blue"
colorScheme=
"blue"
...
@@ -26,7 +59,8 @@ const WatchList: NextPage = () => {
...
@@ -26,7 +59,8 @@ const WatchList: NextPage = () => {
</
Button
>
</
Button
>
</
Box
>
</
Box
>
</
Box
>
</
Box
>
<
AddressModal
{
...
addressModalProps
}
/>
<
AddressModal
{
...
addressModalProps
}
onClose=
{
onAddressModalClose
}
data=
{
addressModalData
}
/>
<
DeleteModal
{
...
deleteModalProps
}
onClose=
{
onDeleteModalClose
}
address=
{
deleteModalData
}
/>
</
Page
>
</
Page
>
);
);
};
};
...
...
theme/components/Modal.ts
View file @
46dc6e28
...
@@ -29,6 +29,7 @@ const Modal: ComponentMultiStyleConfig = {
...
@@ -29,6 +29,7 @@ const Modal: ComponentMultiStyleConfig = {
closeButton
:
{
closeButton
:
{
top
:
'
40px
'
,
top
:
'
40px
'
,
right
:
'
40px
'
,
right
:
'
40px
'
,
color
:
'
blue.500
'
,
},
},
},
},
}
}
...
...
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