Skip to content

Commit

Permalink
Fix/network error (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickimoore authored Aug 3, 2023
1 parent fd9d2ca commit 39bd11f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/forms/ConfigConnectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const ConfigConnectionForm: FC<ConfigConnectionFormProps> = ({ children }) => {
validatorClient,
)

const handleError = (e: unknown) => {
const handleError = (e: unknown, autoClose?: false | number) => {
let message = 'Unknown Error'
const requiredErrors = [
'beaconDataRequired',
Expand All @@ -162,7 +162,7 @@ const ConfigConnectionForm: FC<ConfigConnectionFormProps> = ({ children }) => {
if (e instanceof AxiosError && e.response?.status === 403) {
message = t('error.invalidApiToken')
}
displayToast(message, ToastType.ERROR)
displayToast(message, ToastType.ERROR, { autoClose })
}

const handleValidationErrors = (values: ConnectionForm) => {
Expand Down Expand Up @@ -285,11 +285,11 @@ const ConfigConnectionForm: FC<ConfigConnectionFormProps> = ({ children }) => {
} catch (e) {
if (!isValidBeaconNode || !isValidValidatorClient) {
if (!isValidBeaconNode) {
handleError('invalidBeacon')
handleError('invalidBeacon', false)
}

if (!isValidValidatorClient) {
handleError('invalidValidator')
handleError('invalidValidator', false)
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion src/locales/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
},
"invalidJson": "Invalid JSON data. Please ensure to use correct format.",
"executionFailure": "Execution broadcast failed. Please ensure all fields and signature are valid.",
"networkError": "{{type}} NODE NETWORK ERROR: Make sure your IP is correct and/or CORS is correctly configured. Use --http-allow-origin in {{type}} config",
"networkError": "{{type}} NODE NETWORK ERROR: Make sure your IP is correct and/or CORS is correctly configured. Use --http-allow-origin \"*\" in {{type}} config",
"unknownError": "Unknown {{type}} NODE error.",
"validatorInfo": "Error Loading Validator Info...",
"missingValidatorData": "Invalid Validator Node Data",
Expand Down
5 changes: 3 additions & 2 deletions src/utilities/displayToast.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { toast } from 'react-toastify'
import { ToastType } from '../types'
import { ToastOptions } from 'react-toastify/dist/types'

const displayToast = (message: string, type: ToastType, options?: any) => {
const displayToast = (message: string, type: ToastType, options?: ToastOptions) => {
const toastOptions = {
position: options?.position || 'top-right',
autoClose: options?.autoClose || 5000,
autoClose: options?.autoClose ?? 5000,
style: type === ToastType.SUCCESS ? { background: '#70D370' } : undefined,
theme: options?.theme || 'colored',
hideProgressBar: options?.hideProgressBar || true,
Expand Down

0 comments on commit 39bd11f

Please sign in to comment.