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
fea7d736
Unverified
Commit
fea7d736
authored
Dec 07, 2022
by
Igor Stuev
Committed by
GitHub
Dec 07, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #401 from blockscout/fixes2
Fixes2
parents
39346abf
f2438ff3
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
102 additions
and
49 deletions
+102
-49
Modal.ts
theme/components/Modal.ts
+2
-1
ApiKeyForm.tsx
ui/apiKey/ApiKeyModal/ApiKeyForm.tsx
+2
-2
CustomAbiForm.tsx
ui/customAbi/CustomAbiModal/CustomAbiForm.tsx
+3
-3
PublicTags.tsx
ui/pages/PublicTags.tsx
+3
-3
AddressForm.tsx
ui/privateTags/AddressModal/AddressForm.tsx
+1
-1
TransactionForm.tsx
ui/privateTags/TransactionModal/TransactionForm.tsx
+1
-1
PublicTagFormComment.tsx
ui/publicTags/PublicTagsForm/PublicTagFormComment.tsx
+1
-1
PublicTagsForm.tsx
ui/publicTags/PublicTagsForm/PublicTagsForm.tsx
+1
-14
PublicTagsFormInput.tsx
ui/publicTags/PublicTagsForm/PublicTagsFormInput.tsx
+1
-1
AddressInput.tsx
ui/shared/AddressInput.tsx
+1
-1
FormModal.tsx
ui/shared/FormModal.tsx
+1
-1
InputPlaceholder.tsx
ui/shared/InputPlaceholder.tsx
+9
-2
PageTitle.tsx
ui/shared/Page/PageTitle.tsx
+4
-4
TagInput.tsx
ui/shared/TagInput.tsx
+1
-1
TransactionInput.tsx
ui/shared/TransactionInput.tsx
+1
-1
AddressForm.tsx
ui/watchlist/AddressModal/AddressForm.tsx
+1
-1
WatchListItem.tsx
ui/watchlist/WatchlistTable/WatchListItem.tsx
+49
-6
WatchListTableItem.tsx
ui/watchlist/WatchlistTable/WatchListTableItem.tsx
+20
-5
No files found.
theme/components/Modal.ts
View file @
fea7d736
...
@@ -22,7 +22,7 @@ const baseStyleDialog = defineStyle((props) => {
...
@@ -22,7 +22,7 @@ const baseStyleDialog = defineStyle((props) => {
const
baseStyleDialogContainer
=
defineStyle
({
const
baseStyleDialogContainer
=
defineStyle
({
'
::-webkit-scrollbar
'
:
{
display
:
'
none
'
},
'
::-webkit-scrollbar
'
:
{
display
:
'
none
'
},
'
scrollbar-width
'
:
'
none
'
,
'
scrollbar-width
'
:
'
none
'
,
'
@supports (height: -webkit-fill-available)
'
:
{
height
:
'
100vh
'
},
'
@supports (height: -webkit-fill-available)
'
:
{
height
:
'
-webkit-fill-available
'
},
});
});
const
baseStyleHeader
=
defineStyle
((
props
)
=>
({
const
baseStyleHeader
=
defineStyle
((
props
)
=>
({
...
@@ -63,6 +63,7 @@ const baseStyleOverlay = defineStyle({
...
@@ -63,6 +63,7 @@ const baseStyleOverlay = defineStyle({
const
baseStyle
=
definePartsStyle
((
props
)
=>
({
const
baseStyle
=
definePartsStyle
((
props
)
=>
({
dialog
:
runIfFn
(
baseStyleDialog
,
props
),
dialog
:
runIfFn
(
baseStyleDialog
,
props
),
dialogContainer
:
baseStyleDialogContainer
,
dialogContainer
:
baseStyleDialogContainer
,
header
:
runIfFn
(
baseStyleHeader
,
props
),
header
:
runIfFn
(
baseStyleHeader
,
props
),
body
:
baseStyleBody
,
body
:
baseStyleBody
,
footer
:
baseStyleFooter
,
footer
:
baseStyleFooter
,
...
...
ui/apiKey/ApiKeyModal/ApiKeyForm.tsx
View file @
fea7d736
...
@@ -34,7 +34,7 @@ const NAME_MAX_LENGTH = 255;
...
@@ -34,7 +34,7 @@ const NAME_MAX_LENGTH = 255;
const
ApiKeyForm
:
React
.
FC
<
Props
>
=
({
data
,
onClose
,
setAlertVisible
})
=>
{
const
ApiKeyForm
:
React
.
FC
<
Props
>
=
({
data
,
onClose
,
setAlertVisible
})
=>
{
const
{
control
,
handleSubmit
,
formState
:
{
errors
,
isValid
,
isDirty
},
setError
}
=
useForm
<
Inputs
>
({
const
{
control
,
handleSubmit
,
formState
:
{
errors
,
isValid
,
isDirty
},
setError
}
=
useForm
<
Inputs
>
({
mode
:
'
all
'
,
mode
:
'
onTouched
'
,
defaultValues
:
{
defaultValues
:
{
token
:
data
?.
api_key
||
''
,
token
:
data
?.
api_key
||
''
,
name
:
data
?.
name
||
''
,
name
:
data
?.
name
||
''
,
...
@@ -113,7 +113,7 @@ const ApiKeyForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
...
@@ -113,7 +113,7 @@ const ApiKeyForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
maxLength=
{
NAME_MAX_LENGTH
}
maxLength=
{
NAME_MAX_LENGTH
}
/>
/>
<
FormLabel
>
<
FormLabel
>
<
InputPlaceholder
text=
"Application name for API key (e.g Web3 project)"
error=
{
errors
.
name
?.
message
}
/>
<
InputPlaceholder
text=
"Application name for API key (e.g Web3 project)"
error=
{
errors
.
name
}
/>
</
FormLabel
>
</
FormLabel
>
</
FormControl
>
</
FormControl
>
);
);
...
...
ui/customAbi/CustomAbiModal/CustomAbiForm.tsx
View file @
fea7d736
...
@@ -42,7 +42,7 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
...
@@ -42,7 +42,7 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
name
:
data
?.
name
||
''
,
name
:
data
?.
name
||
''
,
abi
:
JSON
.
stringify
(
data
?.
abi
)
||
''
,
abi
:
JSON
.
stringify
(
data
?.
abi
)
||
''
,
},
},
mode
:
'
all
'
,
mode
:
'
onTouched
'
,
});
});
const
queryClient
=
useQueryClient
();
const
queryClient
=
useQueryClient
();
...
@@ -118,7 +118,7 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
...
@@ -118,7 +118,7 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
isInvalid=
{
Boolean
(
errors
.
name
)
}
isInvalid=
{
Boolean
(
errors
.
name
)
}
maxLength=
{
NAME_MAX_LENGTH
}
maxLength=
{
NAME_MAX_LENGTH
}
/>
/>
<
InputPlaceholder
text=
"Project name"
error=
{
errors
.
name
?.
message
}
/>
<
InputPlaceholder
text=
"Project name"
error=
{
errors
.
name
}
/>
</
FormControl
>
</
FormControl
>
);
);
}
, [ errors, formBackgroundColor ]);
}
, [ errors, formBackgroundColor ]);
...
@@ -132,7 +132,7 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
...
@@ -132,7 +132,7 @@ const CustomAbiForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
minH=
"300px"
minH=
"300px"
isInvalid=
{
Boolean
(
errors
.
abi
)
}
isInvalid=
{
Boolean
(
errors
.
abi
)
}
/>
/>
<
InputPlaceholder
text=
"Custom ABI [
{
...
}
]
(
JSON
format
)"
error=
{
errors
.
abi
?.
message
}
/>
<
InputPlaceholder
text=
"Custom ABI [
{
...
}
]
(
JSON
format
)"
error=
{
errors
.
abi
}
/>
</
FormControl
>
</
FormControl
>
);
);
}
, [ errors, formBackgroundColor ]);
}
, [ errors, formBackgroundColor ]);
...
...
ui/pages/PublicTags.tsx
View file @
fea7d736
...
@@ -79,13 +79,13 @@ const PublicTagsComponent: React.FC = () => {
...
@@ -79,13 +79,13 @@ const PublicTagsComponent: React.FC = () => {
return
(
return
(
<
Page
>
<
Page
>
{
isMobile
&&
screen
===
'
form
'
&&
(
{
screen
===
'
form
'
&&
(
<
Link
display=
"inline-flex"
alignItems=
"center"
mb=
{
6
}
onClick=
{
onGoBack
}
>
<
Link
display=
"inline-flex"
alignItems=
"center"
mb=
{
6
}
onClick=
{
onGoBack
}
>
<
Icon
as=
{
eastArrowIcon
}
boxSize=
{
6
}
transform=
"rotate(180deg)"
/>
<
Icon
as=
{
eastArrowIcon
}
boxSize=
{
6
}
transform=
"rotate(180deg)"
/>
<
Text
variant=
"inherit"
fontSize=
"sm"
ml=
{
2
}
>
Public tags
</
Text
>
{
isMobile
&&
<
Text
variant=
"inherit"
fontSize=
"sm"
ml=
{
2
}
>
Public tags
</
Text
>
}
</
Link
>
</
Link
>
)
}
)
}
<
PageTitle
text=
{
header
}
/>
<
PageTitle
text=
{
header
}
display=
{
{
base
:
'
block
'
,
lg
:
'
inline-flex
'
}
}
ml=
{
{
base
:
0
,
lg
:
3
}
}
/>
{
content
}
{
content
}
</
Page
>
</
Page
>
);
);
...
...
ui/privateTags/AddressModal/AddressForm.tsx
View file @
fea7d736
...
@@ -35,7 +35,7 @@ const AddressForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
...
@@ -35,7 +35,7 @@ const AddressForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
const
[
pending
,
setPending
]
=
useState
(
false
);
const
[
pending
,
setPending
]
=
useState
(
false
);
const
{
control
,
handleSubmit
,
formState
:
{
errors
,
isValid
,
isDirty
},
setError
}
=
useForm
<
Inputs
>
({
const
{
control
,
handleSubmit
,
formState
:
{
errors
,
isValid
,
isDirty
},
setError
}
=
useForm
<
Inputs
>
({
mode
:
'
all
'
,
mode
:
'
onTouched
'
,
defaultValues
:
{
defaultValues
:
{
address
:
data
?.
address_hash
||
''
,
address
:
data
?.
address_hash
||
''
,
tag
:
data
?.
name
||
''
,
tag
:
data
?.
name
||
''
,
...
...
ui/privateTags/TransactionModal/TransactionForm.tsx
View file @
fea7d736
...
@@ -36,7 +36,7 @@ const TransactionForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) =>
...
@@ -36,7 +36,7 @@ const TransactionForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) =>
const
formBackgroundColor
=
useColorModeValue
(
'
white
'
,
'
gray.900
'
);
const
formBackgroundColor
=
useColorModeValue
(
'
white
'
,
'
gray.900
'
);
const
{
control
,
handleSubmit
,
formState
:
{
errors
,
isValid
,
isDirty
},
setError
}
=
useForm
<
Inputs
>
({
const
{
control
,
handleSubmit
,
formState
:
{
errors
,
isValid
,
isDirty
},
setError
}
=
useForm
<
Inputs
>
({
mode
:
'
all
'
,
mode
:
'
onTouched
'
,
defaultValues
:
{
defaultValues
:
{
transaction
:
data
?.
transaction_hash
||
''
,
transaction
:
data
?.
transaction_hash
||
''
,
tag
:
data
?.
name
||
''
,
tag
:
data
?.
name
||
''
,
...
...
ui/publicTags/PublicTagsForm/PublicTagFormComment.tsx
View file @
fea7d736
...
@@ -25,7 +25,7 @@ export default function PublicTagFormComment({ control, error, size }: Props) {
...
@@ -25,7 +25,7 @@ export default function PublicTagFormComment({ control, error, size }: Props) {
isInvalid=
{
Boolean
(
error
)
}
isInvalid=
{
Boolean
(
error
)
}
/>
/>
<
FormLabel
>
<
FormLabel
>
<
InputPlaceholder
text=
"Specify the reason for adding tags and color preference(s)"
error=
{
error
?.
message
}
/>
<
InputPlaceholder
text=
"Specify the reason for adding tags and color preference(s)"
error=
{
error
}
/>
</
FormLabel
>
</
FormLabel
>
</
FormControl
>
</
FormControl
>
);
);
...
...
ui/publicTags/PublicTagsForm/PublicTagsForm.tsx
View file @
fea7d736
...
@@ -73,7 +73,7 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => {
...
@@ -73,7 +73,7 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => {
comment
:
data
?.
additional_comment
||
''
,
comment
:
data
?.
additional_comment
||
''
,
action
:
data
?.
is_owner
===
undefined
||
data
?.
is_owner
?
'
add
'
:
'
report
'
,
action
:
data
?.
is_owner
===
undefined
||
data
?.
is_owner
?
'
add
'
:
'
report
'
,
},
},
mode
:
'
all
'
,
mode
:
'
onTouched
'
,
});
});
const
{
fields
,
append
,
remove
}
=
useFieldArray
({
const
{
fields
,
append
,
remove
}
=
useFieldArray
({
...
@@ -146,11 +146,6 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => {
...
@@ -146,11 +146,6 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => {
mutation
.
mutate
(
data
);
mutation
.
mutate
(
data
);
},
[
mutation
]);
},
[
mutation
]);
const
changeToData
=
useCallback
(()
=>
{
setAlertVisible
(
false
);
changeToDataScreen
(
false
);
},
[
changeToDataScreen
]);
return
(
return
(
<
chakra
.
form
<
chakra
.
form
noValidate
noValidate
...
@@ -242,14 +237,6 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => {
...
@@ -242,14 +237,6 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => {
>
>
Send request
Send request
</
Button
>
</
Button
>
<
Button
size=
"lg"
variant=
"outline"
onClick=
{
changeToData
}
disabled=
{
mutation
.
isLoading
}
>
Cancel
</
Button
>
</
HStack
>
</
HStack
>
</
chakra
.
form
>
</
chakra
.
form
>
);
);
...
...
ui/publicTags/PublicTagsForm/PublicTagsFormInput.tsx
View file @
fea7d736
...
@@ -36,7 +36,7 @@ export default function PublicTagsFormInput<Inputs extends FieldValues>({
...
@@ -36,7 +36,7 @@ export default function PublicTagsFormInput<Inputs extends FieldValues>({
isInvalid=
{
Boolean
(
error
)
}
isInvalid=
{
Boolean
(
error
)
}
maxLength=
{
TEXT_INPUT_MAX_LENGTH
}
maxLength=
{
TEXT_INPUT_MAX_LENGTH
}
/>
/>
<
InputPlaceholder
text=
{
label
}
error=
{
error
?.
message
}
/>
<
InputPlaceholder
text=
{
label
}
error=
{
error
}
/>
</
FormControl
>
</
FormControl
>
);
);
},
[
label
,
required
,
error
,
size
]);
},
[
label
,
required
,
error
,
size
]);
...
...
ui/shared/AddressInput.tsx
View file @
fea7d736
...
@@ -32,7 +32,7 @@ export default function AddressInput<Inputs extends FieldValues, Name extends Pa
...
@@ -32,7 +32,7 @@ export default function AddressInput<Inputs extends FieldValues, Name extends Pa
isInvalid=
{
Boolean
(
error
)
}
isInvalid=
{
Boolean
(
error
)
}
maxLength=
{
ADDRESS_LENGTH
}
maxLength=
{
ADDRESS_LENGTH
}
/>
/>
<
InputPlaceholder
text=
{
placeholder
}
error=
{
error
?.
message
}
/>
<
InputPlaceholder
text=
{
placeholder
}
error=
{
error
}
/>
</
FormControl
>
</
FormControl
>
);
);
}
}
ui/shared/FormModal.tsx
View file @
fea7d736
...
@@ -47,7 +47,7 @@ export default function FormModal<TData>({
...
@@ -47,7 +47,7 @@ export default function FormModal<TData>({
<
ModalContent
>
<
ModalContent
>
<
ModalHeader
fontWeight=
"500"
textStyle=
"h3"
>
{
title
}
</
ModalHeader
>
<
ModalHeader
fontWeight=
"500"
textStyle=
"h3"
>
{
title
}
</
ModalHeader
>
<
ModalCloseButton
/>
<
ModalCloseButton
/>
<
ModalBody
mb=
{
0
}
>
<
ModalBody
>
{
(
isAlertVisible
||
text
)
&&
(
{
(
isAlertVisible
||
text
)
&&
(
<
Box
marginBottom=
{
{
base
:
6
,
lg
:
8
}
}
>
<
Box
marginBottom=
{
{
base
:
6
,
lg
:
8
}
}
>
{
text
&&
(
{
text
&&
(
...
...
ui/shared/InputPlaceholder.tsx
View file @
fea7d736
import
{
FormLabel
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
FormLabel
,
chakra
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
FieldError
}
from
'
react-hook-form
'
;
interface
Props
{
interface
Props
{
text
:
string
;
text
:
string
;
error
?:
string
;
error
?:
FieldError
;
}
}
const
InputPlaceholder
=
({
text
,
error
}:
Props
)
=>
{
const
InputPlaceholder
=
({
text
,
error
}:
Props
)
=>
{
let
errorMessage
=
error
?.
message
;
if
(
!
errorMessage
&&
error
?.
type
===
'
pattern
'
)
{
errorMessage
=
'
Invalid format
'
;
}
return
(
return
(
<
FormLabel
>
<
FormLabel
>
<
chakra
.
span
>
{
text
}
</
chakra
.
span
>
<
chakra
.
span
>
{
text
}
</
chakra
.
span
>
{
error
&&
<
chakra
.
span
order=
{
3
}
whiteSpace=
"pre"
>
-
{
error
}
</
chakra
.
span
>
}
{
error
Message
&&
<
chakra
.
span
order=
{
3
}
whiteSpace=
"pre"
>
-
{
errorMessage
}
</
chakra
.
span
>
}
</
FormLabel
>
</
FormLabel
>
);
);
};
};
...
...
ui/shared/Page/PageTitle.tsx
View file @
fea7d736
import
{
Heading
}
from
'
@chakra-ui/react
'
;
import
{
Heading
,
chakra
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
const
PageTitle
=
({
text
}:
{
text
:
string
})
=>
{
const
PageTitle
=
({
text
,
className
}:
{
text
:
string
;
className
?
:
string
})
=>
{
return
(
return
(
<
Heading
as=
"h1"
size=
"lg"
marginBottom=
{
6
}
>
{
text
}
</
Heading
>
<
Heading
as=
"h1"
size=
"lg"
marginBottom=
{
6
}
className=
{
className
}
>
{
text
}
</
Heading
>
);
);
};
};
export
default
PageTitle
;
export
default
chakra
(
PageTitle
)
;
ui/shared/TagInput.tsx
View file @
fea7d736
...
@@ -23,7 +23,7 @@ function TagInput<Inputs extends FieldValues, Name extends Path<Inputs>>({ field
...
@@ -23,7 +23,7 @@ function TagInput<Inputs extends FieldValues, Name extends Path<Inputs>>({ field
isInvalid=
{
Boolean
(
error
)
}
isInvalid=
{
Boolean
(
error
)
}
maxLength=
{
TAG_MAX_LENGTH
}
maxLength=
{
TAG_MAX_LENGTH
}
/>
/>
<
InputPlaceholder
text=
"Private tag (max 35 characters)"
error=
{
error
?.
message
}
/>
<
InputPlaceholder
text=
"Private tag (max 35 characters)"
error=
{
error
}
/>
</
FormControl
>
</
FormControl
>
);
);
}
}
...
...
ui/shared/TransactionInput.tsx
View file @
fea7d736
...
@@ -22,7 +22,7 @@ function TransactionInput<Field extends Partial<ControllerRenderProps<FieldValue
...
@@ -22,7 +22,7 @@ function TransactionInput<Field extends Partial<ControllerRenderProps<FieldValue
isInvalid=
{
Boolean
(
error
)
}
isInvalid=
{
Boolean
(
error
)
}
maxLength=
{
TRANSACTION_HASH_LENGTH
}
maxLength=
{
TRANSACTION_HASH_LENGTH
}
/>
/>
<
InputPlaceholder
text=
"Transaction hash (0x...)"
error=
{
error
?.
message
}
/>
<
InputPlaceholder
text=
"Transaction hash (0x...)"
error=
{
error
}
/>
</
FormControl
>
</
FormControl
>
);
);
}
}
...
...
ui/watchlist/AddressModal/AddressForm.tsx
View file @
fea7d736
...
@@ -80,7 +80,7 @@ const AddressForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
...
@@ -80,7 +80,7 @@ const AddressForm: React.FC<Props> = ({ data, onClose, setAlertVisible }) => {
notification
:
data
?
data
.
notification_methods
.
email
:
true
,
notification
:
data
?
data
.
notification_methods
.
email
:
true
,
notification_settings
:
notificationsDefault
,
notification_settings
:
notificationsDefault
,
},
},
mode
:
'
all
'
,
mode
:
'
onTouched
'
,
});
});
const
queryClient
=
useQueryClient
();
const
queryClient
=
useQueryClient
();
...
...
ui/watchlist/WatchlistTable/WatchListItem.tsx
View file @
fea7d736
...
@@ -4,6 +4,8 @@ import React, { useCallback, useState } from 'react';
...
@@ -4,6 +4,8 @@ import React, { useCallback, useState } from 'react';
import
type
{
TWatchlistItem
}
from
'
types/client/account
'
;
import
type
{
TWatchlistItem
}
from
'
types/client/account
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useToast
from
'
lib/hooks/useToast
'
;
import
AccountListItemMobile
from
'
ui/shared/AccountListItemMobile
'
;
import
AccountListItemMobile
from
'
ui/shared/AccountListItemMobile
'
;
import
TableItemActionButtons
from
'
ui/shared/TableItemActionButtons
'
;
import
TableItemActionButtons
from
'
ui/shared/TableItemActionButtons
'
;
...
@@ -17,6 +19,7 @@ interface Props {
...
@@ -17,6 +19,7 @@ interface Props {
const
WatchListItem
=
({
item
,
onEditClick
,
onDeleteClick
}:
Props
)
=>
{
const
WatchListItem
=
({
item
,
onEditClick
,
onDeleteClick
}:
Props
)
=>
{
const
[
notificationEnabled
,
setNotificationEnabled
]
=
useState
(
item
.
notification_methods
.
email
);
const
[
notificationEnabled
,
setNotificationEnabled
]
=
useState
(
item
.
notification_methods
.
email
);
const
[
switchDisabled
,
setSwitchDisabled
]
=
useState
(
false
);
const
onItemEditClick
=
useCallback
(()
=>
{
const
onItemEditClick
=
useCallback
(()
=>
{
return
onEditClick
(
item
);
return
onEditClick
(
item
);
},
[
item
,
onEditClick
]);
},
[
item
,
onEditClick
]);
...
@@ -25,16 +28,49 @@ const WatchListItem = ({ item, onEditClick, onDeleteClick }: Props) => {
...
@@ -25,16 +28,49 @@ const WatchListItem = ({ item, onEditClick, onDeleteClick }: Props) => {
return
onDeleteClick
(
item
);
return
onDeleteClick
(
item
);
},
[
item
,
onDeleteClick
]);
},
[
item
,
onDeleteClick
]);
const
errorToast
=
useToast
();
const
fetch
=
useFetch
();
const
showErrorToast
=
useCallback
(()
=>
{
errorToast
({
position
:
'
top-right
'
,
description
:
'
There has been an error processing your request
'
,
colorScheme
:
'
red
'
,
status
:
'
error
'
,
variant
:
'
subtle
'
,
isClosable
:
true
,
icon
:
null
,
});
},
[
errorToast
]);
const
notificationToast
=
useToast
();
const
showNotificationToast
=
useCallback
((
isOn
:
boolean
)
=>
{
notificationToast
({
position
:
'
top-right
'
,
description
:
isOn
?
'
Email notification is ON
'
:
'
Email notification is OFF
'
,
colorScheme
:
'
green
'
,
status
:
'
success
'
,
variant
:
'
subtle
'
,
title
:
'
Success
'
,
isClosable
:
true
,
icon
:
null
,
});
},
[
notificationToast
]);
const
{
mutate
}
=
useMutation
(()
=>
{
const
{
mutate
}
=
useMutation
(()
=>
{
const
data
=
{
...
item
,
notification_methods
:
{
email
:
!
notificationEnabled
}
};
setSwitchDisabled
(
true
);
return
fetch
(
`/node-api/account/watchlist/
${
item
.
id
}
`
,
{
method
:
'
PUT
'
,
body
:
JSON
.
stringify
(
data
)
});
const
body
=
{
...
item
,
notification_methods
:
{
email
:
!
notificationEnabled
}
};
setNotificationEnabled
(
prevState
=>
!
prevState
);
return
fetch
(
`/node-api/account/watchlist/
${
item
.
id
}
`
,
{
method
:
'
PUT
'
,
body
});
},
{
},
{
onError
:
()
=>
{
onError
:
()
=>
{
// eslint-disable-next-line no-console
showErrorToast
();
console
.
log
(
'
error
'
);
setNotificationEnabled
(
prevState
=>
!
prevState
);
setSwitchDisabled
(
false
);
},
},
onSuccess
:
()
=>
{
onSuccess
:
()
=>
{
setNotificationEnabled
(
prevState
=>
!
prevState
);
setSwitchDisabled
(
false
);
showNotificationToast
(
!
notificationEnabled
);
},
},
});
});
...
@@ -56,7 +92,14 @@ const WatchListItem = ({ item, onEditClick, onDeleteClick }: Props) => {
...
@@ -56,7 +92,14 @@ const WatchListItem = ({ item, onEditClick, onDeleteClick }: Props) => {
<
Flex
alignItems=
"center"
justifyContent=
"space-between"
mt=
{
6
}
w=
"100%"
>
<
Flex
alignItems=
"center"
justifyContent=
"space-between"
mt=
{
6
}
w=
"100%"
>
<
HStack
spacing=
{
3
}
>
<
HStack
spacing=
{
3
}
>
<
Text
fontSize=
"sm"
fontWeight=
{
500
}
>
Email notification
</
Text
>
<
Text
fontSize=
"sm"
fontWeight=
{
500
}
>
Email notification
</
Text
>
<
Switch
colorScheme=
"blue"
size=
"md"
isChecked=
{
notificationEnabled
}
onChange=
{
onSwitch
}
aria
-
label=
"Email notification"
/>
<
Switch
colorScheme=
"blue"
size=
"md"
isChecked=
{
notificationEnabled
}
onChange=
{
onSwitch
}
aria
-
label=
"Email notification"
isDisabled=
{
switchDisabled
}
/>
</
HStack
>
</
HStack
>
<
TableItemActionButtons
onDeleteClick=
{
onItemDeleteClick
}
onEditClick=
{
onItemEditClick
}
/>
<
TableItemActionButtons
onDeleteClick=
{
onItemDeleteClick
}
onEditClick=
{
onItemEditClick
}
/>
</
Flex
>
</
Flex
>
...
...
ui/watchlist/WatchlistTable/WatchListTableItem.tsx
View file @
fea7d736
...
@@ -33,11 +33,11 @@ const WatchlistTableItem = ({ item, onEditClick, onDeleteClick }: Props) => {
...
@@ -33,11 +33,11 @@ const WatchlistTableItem = ({ item, onEditClick, onDeleteClick }: Props) => {
return
onDeleteClick
(
item
);
return
onDeleteClick
(
item
);
},
[
item
,
onDeleteClick
]);
},
[
item
,
onDeleteClick
]);
const
t
oast
=
useToast
();
const
errorT
oast
=
useToast
();
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
const
showToast
=
useCallback
(()
=>
{
const
show
Error
Toast
=
useCallback
(()
=>
{
t
oast
({
errorT
oast
({
position
:
'
top-right
'
,
position
:
'
top-right
'
,
description
:
'
There has been an error processing your request
'
,
description
:
'
There has been an error processing your request
'
,
colorScheme
:
'
red
'
,
colorScheme
:
'
red
'
,
...
@@ -46,7 +46,21 @@ const WatchlistTableItem = ({ item, onEditClick, onDeleteClick }: Props) => {
...
@@ -46,7 +46,21 @@ const WatchlistTableItem = ({ item, onEditClick, onDeleteClick }: Props) => {
isClosable
:
true
,
isClosable
:
true
,
icon
:
null
,
icon
:
null
,
});
});
},
[
toast
]);
},
[
errorToast
]);
const
notificationToast
=
useToast
();
const
showNotificationToast
=
useCallback
((
isOn
:
boolean
)
=>
{
notificationToast
({
position
:
'
top-right
'
,
description
:
isOn
?
'
Email notification is ON
'
:
'
Email notification is OFF
'
,
colorScheme
:
'
green
'
,
status
:
'
success
'
,
variant
:
'
subtle
'
,
title
:
'
Success
'
,
isClosable
:
true
,
icon
:
null
,
});
},
[
notificationToast
]);
const
{
mutate
}
=
useMutation
(()
=>
{
const
{
mutate
}
=
useMutation
(()
=>
{
setSwitchDisabled
(
true
);
setSwitchDisabled
(
true
);
...
@@ -55,12 +69,13 @@ const WatchlistTableItem = ({ item, onEditClick, onDeleteClick }: Props) => {
...
@@ -55,12 +69,13 @@ const WatchlistTableItem = ({ item, onEditClick, onDeleteClick }: Props) => {
return
fetch
(
`/node-api/account/watchlist/
${
item
.
id
}
`
,
{
method
:
'
PUT
'
,
body
});
return
fetch
(
`/node-api/account/watchlist/
${
item
.
id
}
`
,
{
method
:
'
PUT
'
,
body
});
},
{
},
{
onError
:
()
=>
{
onError
:
()
=>
{
showToast
();
show
Error
Toast
();
setNotificationEnabled
(
prevState
=>
!
prevState
);
setNotificationEnabled
(
prevState
=>
!
prevState
);
setSwitchDisabled
(
false
);
setSwitchDisabled
(
false
);
},
},
onSuccess
:
()
=>
{
onSuccess
:
()
=>
{
setSwitchDisabled
(
false
);
setSwitchDisabled
(
false
);
showNotificationToast
(
!
notificationEnabled
);
},
},
});
});
...
...
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