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
aebfae0e
Commit
aebfae0e
authored
Jun 13, 2022
by
Natalia Stus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
модал редактирования адреса
parent
176057fc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
26 deletions
+155
-26
AddressModal.tsx
components/AddressModal/AddressModal.tsx
+105
-0
WatchListTableItem.tsx
components/WatchlistTable/WatchListTableItem.tsx
+44
-0
WatchlistTable.tsx
components/WatchlistTable/WatchlistTable.tsx
+2
-22
watchlist.tsx
pages/watchlist.tsx
+4
-4
No files found.
components/Add
AddressModal/Add
AddressModal.tsx
→
components/Add
ressModal/
AddressModal.tsx
View file @
aebfae0e
import
React
from
'
react
'
;
import
React
,
{
useCallback
,
useState
}
from
'
react
'
;
import
{
Box
,
...
...
@@ -17,14 +17,33 @@ import {
GridItem
,
}
from
'
@chakra-ui/react
'
;
import
type
{
TWatchlistItem
}
from
'
../../data/watchlist
'
;
const
NOTIFICATIONS
=
[
'
xDAI
'
,
'
ERC-20
'
,
'
ERC-721, ERC-1155 (NFT)
'
];
type
Props
=
{
isOpen
:
boolean
;
onClose
:
()
=>
void
;
getDisclosureProps
:
()
=>
any
;
data
?:
TWatchlistItem
;
}
const
AddAddressModal
:
React
.
FC
<
Props
>
=
({
isOpen
,
onClose
})
=>
{
const
AddressModal
:
React
.
FC
<
Props
>
=
({
isOpen
,
onClose
,
data
=
{}
as
TWatchlistItem
})
=>
{
// надо чето придумать с формой
// потом доделаем
const
[
address
,
setAddress
]
=
useState
(
data
.
address
);
const
[
tag
,
setTag
]
=
useState
(
data
.
tag
);
const
[
notification
,
setNotification
]
=
useState
(
data
.
notification
);
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
onNotificationChange
=
useCallback
((
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
setNotification
(
event
.
target
.
checked
),
[
setNotification
]);
const
onButtonClick
=
useCallback
(()
=>
{
// eslint-disable-next-line no-console
console
.
log
(
address
,
tag
,
notification
);
onClose
()
},
[
address
,
tag
,
notification
,
onClose
]);
return
(
<
Modal
isOpen=
{
isOpen
}
onClose=
{
onClose
}
size=
"md"
>
<
ModalOverlay
/>
...
...
@@ -35,8 +54,18 @@ const AddAddressModal: React.FC<Props> = ({ isOpen, onClose }) => {
<
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.
</
Text
>
<
Input
placeholder=
"Address (0x...)*"
marginBottom=
"20px"
/>
<
Input
placeholder=
"Private tag (max 35 characters)*"
marginBottom=
"30px"
/>
<
Input
placeholder=
"Address (0x...)*"
marginBottom=
"20px"
onChange=
{
onAddressChange
}
value=
{
address
}
/>
<
Input
placeholder=
"Private tag (max 35 characters)*"
marginBottom=
"30px"
onChange=
{
onTagChange
}
value=
{
tag
}
/>
<
Text
color=
"gray.600"
fontSize=
"14px"
marginBottom=
"32px"
>
Please select what types of notifications you will receive:
</
Text
>
...
...
@@ -54,11 +83,17 @@ const AddAddressModal: React.FC<Props> = ({ isOpen, onClose }) => {
</
Grid
>
</
Box
>
<
Text
color=
"gray.600"
fontSize=
"14px"
marginBottom=
"20px"
>
Notification methods:
</
Text
>
<
Checkbox
defaultChecked
colorScheme=
"green"
>
Email notifications
</
Checkbox
>
<
Checkbox
defaultChecked=
{
notification
}
colorScheme=
"green"
onChange=
{
onNotificationChange
}
>
Email notifications
</
Checkbox
>
</
ModalBody
>
<
ModalFooter
justifyContent=
"flex-start"
>
<
Button
colorScheme=
"blue"
onClick=
{
on
Close
}
>
<
Button
colorScheme=
"blue"
onClick=
{
on
ButtonClick
}
>
Add address
</
Button
>
</
ModalFooter
>
...
...
@@ -67,4 +102,4 @@ const AddAddressModal: React.FC<Props> = ({ isOpen, onClose }) => {
)
}
export
default
Add
Add
ressModal
;
export
default
AddressModal
;
components/WatchlistTable/WatchListTableItem.tsx
0 → 100644
View file @
aebfae0e
import
React
from
'
react
'
;
import
{
Tag
,
Tr
,
Td
,
Switch
,
Icon
,
HStack
,
useDisclosure
,
}
from
'
@chakra-ui/react
'
import
{
FaEdit
,
FaTrash
}
from
'
react-icons/fa
'
;
import
type
{
TWatchlistItem
}
from
'
../../data/watchlist
'
;
import
AddressModal
from
'
../AddressModal/AddressModal
'
;
import
WatchListAddressItem
from
'
./WatchListAddressItem
'
;
interface
Props
{
item
:
TWatchlistItem
;
}
const
WatchlistTableItem
=
({
item
}:
Props
)
=>
{
const
modalProps
=
useDisclosure
();
return
(
<>
<
Tr
alignItems=
"top"
key=
{
item
.
address
}
>
<
Td
><
WatchListAddressItem
item=
{
item
}
/></
Td
>
<
Td
><
Tag
>
{
item
.
tag
}
</
Tag
></
Td
>
<
Td
><
Switch
colorScheme=
"green"
size=
"md"
isChecked=
{
item
.
notification
}
/></
Td
>
<
Td
>
<
HStack
spacing=
"30px"
>
<
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"
/>
</
HStack
>
</
Td
>
</
Tr
>
<
AddressModal
{
...
modalProps
}
data=
{
item
}
/>
</>
)
};
export
default
WatchlistTableItem
;
components/WatchlistTable/WatchlistTable.tsx
View file @
aebfae0e
import
React
from
'
react
'
;
import
{
Tag
,
Table
,
Thead
,
Tbody
,
Tr
,
Th
,
Td
,
TableContainer
,
Switch
,
Icon
,
HStack
,
}
from
'
@chakra-ui/react
'
import
{
FaEdit
,
FaTrash
}
from
'
react-icons/fa
'
;
import
type
{
TWatchlist
}
from
'
../../data/watchlist
'
;
import
Watch
ListAddressItem
from
'
./WatchListAddress
Item
'
;
import
Watch
listTableItem
from
'
./WatchListTable
Item
'
;
interface
Props
{
data
:
TWatchlist
;
...
...
@@ -36,21 +30,7 @@ const WatchlistTable = ({ data }: Props) => {
</
Tr
>
</
Thead
>
<
Tbody
>
{
data
.
map
(
item
=>
{
return
(
<
Tr
alignItems=
"top"
key=
{
item
.
address
}
>
<
Td
><
WatchListAddressItem
item=
{
item
}
/></
Td
>
<
Td
><
Tag
>
{
item
.
tag
}
</
Tag
></
Td
>
<
Td
><
Switch
colorScheme=
"green"
size=
"md"
isChecked=
{
item
.
notification
}
/></
Td
>
<
Td
>
<
HStack
spacing=
"30px"
>
<
Icon
as=
{
FaEdit
}
w=
"20px"
h=
"20px"
cursor=
"pointer"
color=
"blue.500"
/>
<
Icon
as=
{
FaTrash
}
w=
"20px"
h=
"20px"
cursor=
"pointer"
color=
"red.200"
/>
</
HStack
>
</
Td
>
</
Tr
>
)
})
}
{
data
.
map
(
item
=>
<
WatchlistTableItem
item=
{
item
}
key=
{
item
.
address
}
/>)
}
</
Tbody
>
</
Table
>
</
TableContainer
>
...
...
pages/watchlist.tsx
View file @
aebfae0e
...
...
@@ -6,12 +6,12 @@ import { Box, Button, Text, useDisclosure } from '@chakra-ui/react';
import
Page
from
'
../components/Page/Page
'
;
import
WatchlistTable
from
'
../components/WatchlistTable/WatchlistTable
'
;
import
Add
AddressModal
from
'
../components/AddAddressModal/Add
AddressModal
'
;
import
Add
ressModal
from
'
../components/AddressModal/
AddressModal
'
;
import
{
watchlist
}
from
'
../data/watchlist
'
;
const
WatchList
:
NextPage
=
()
=>
{
const
add
ModalProps
=
useDisclosure
()
const
add
ressModalProps
=
useDisclosure
();
return
(
<
Page
>
<
Box
h=
"100%"
>
...
...
@@ -20,13 +20,13 @@ const WatchList: NextPage = () => {
<
Box
marginTop=
"32px"
>
<
Button
colorScheme=
"blue"
onClick=
{
addModalProps
.
onOpen
}
onClick=
{
add
ress
ModalProps
.
onOpen
}
>
Add address
</
Button
>
</
Box
>
</
Box
>
<
Add
AddressModal
{
...
add
ModalProps
}
/>
<
Add
ressModal
{
...
address
ModalProps
}
/>
</
Page
>
);
};
...
...
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