diff --git a/src/App.tsx b/src/App.tsx index 48c8f98..a490778 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -80,15 +80,19 @@ export const App = () => { } }) .catch((error) => { + let errorMsg if (error.response.status === 401 || error.response.status === 400) { setAuthorization(null) navigate('/') setLoading(false) return } - const errorMsg = error.response.data.error - ? error.response.data.error - : 'Something went wrong... Please, try again later!' + + if (error.response.status === 404) { + errorMsg = error.response.data + ". If you can't log in again, please contact our support or try again later!" + } else { + errorMsg = error.response.data ? error.response.data : 'Something went wrong... Please, try again later!' + } setError(errorMsg) setLoading(false) diff --git a/src/components/AccountSummary/AccountSummary.tsx b/src/components/AccountSummary/AccountSummary.tsx index 8b3d084..c1404d2 100644 --- a/src/components/AccountSummary/AccountSummary.tsx +++ b/src/components/AccountSummary/AccountSummary.tsx @@ -38,9 +38,16 @@ export const AccountSummary = () => { setDetails(accountDetails) }) .catch((error) => { - if (error) { - setErrors('Something went wrong... Please, try again later!') + let errorMsg + + if (error.response.status === 404) { + errorMsg = + "User's account details not found. If you can't log in again, please contact our support or try again later!" + } else { + errorMsg = error.response.data ? error.response.data : 'Something went wrong... Please, try again later!' } + + setErrors(errorMsg) }) .finally(() => { setLoading(false) diff --git a/src/components/Modal/_modals/TransactionConfirmModal/TransactionConfirmModal.tsx b/src/components/Modal/_modals/TransactionConfirmModal/TransactionConfirmModal.tsx index 9b9452f..d1f40ee 100644 --- a/src/components/Modal/_modals/TransactionConfirmModal/TransactionConfirmModal.tsx +++ b/src/components/Modal/_modals/TransactionConfirmModal/TransactionConfirmModal.tsx @@ -85,7 +85,9 @@ export const TransactionConfirmModal: FC = ({ } setErrors( - 'Transfer was not sent. Please verify transfer data and try once again. If problem will happen again, contact with our support.' + error.response.data + ? error.response.data + : 'Transfer was not sent. Please verify transfer data and try once again. If problem will happen again, contact with our support.' ) } }) diff --git a/src/components/Modal/_modals/TransactionDetailsModal/TransactionDetailsModal.tsx b/src/components/Modal/_modals/TransactionDetailsModal/TransactionDetailsModal.tsx index 196c534..c460f18 100644 --- a/src/components/Modal/_modals/TransactionDetailsModal/TransactionDetailsModal.tsx +++ b/src/components/Modal/_modals/TransactionDetailsModal/TransactionDetailsModal.tsx @@ -31,7 +31,8 @@ export const TransactionDetailsModal: FC = ({ open, pri setTransactionData(response) }) .catch((error) => { - error && setErrors('Something went wrong... Please try again later') + const errorMsg = error.response.data ? error.response.data : 'Something went wrong... Please try again later' + errorMsg && setErrors(errorMsg) }) .finally(() => { setLoading(false) diff --git a/src/components/TransactionHistory/TransactionTable/TransactionTable.tsx b/src/components/TransactionHistory/TransactionTable/TransactionTable.tsx index 0cadf20..edd5726 100644 --- a/src/components/TransactionHistory/TransactionTable/TransactionTable.tsx +++ b/src/components/TransactionHistory/TransactionTable/TransactionTable.tsx @@ -56,7 +56,8 @@ export const TransactionTable = () => { setLoading(false) }) .catch((error) => { - setErrors(error) + const errorMsg = error.response.data ? error.response.data : 'Something went wrong... Please try again later' + setErrors(errorMsg) }) .finally(() => setLoading(false)) }, [currentPage, autoupdate]) @@ -76,7 +77,7 @@ export const TransactionTable = () => { {!transactionsList ? ( No transaction yet ) : errors ? ( - + ) : ( diff --git a/src/components/UserMenu/UserMenu.tsx b/src/components/UserMenu/UserMenu.tsx index bb2adc6..84069f9 100644 --- a/src/components/UserMenu/UserMenu.tsx +++ b/src/components/UserMenu/UserMenu.tsx @@ -54,7 +54,8 @@ export const UserMenu: FC = ({ userEmail }) => { Navigate('/') }) .catch((error) => { - error && setErrors('Something went wrong... Please try again!') + const errorMsg = error.response.data ? error.response.data : 'Something went wrong... Please try again!' + errorMsg && setErrors(errorMsg) }) .finally(() => { setLoading(false) diff --git a/src/views/SignupPage/SignupPage.tsx b/src/views/SignupPage/SignupPage.tsx index ece88e1..9ae6022 100644 --- a/src/views/SignupPage/SignupPage.tsx +++ b/src/views/SignupPage/SignupPage.tsx @@ -55,9 +55,7 @@ export const SignupPage = () => { setLoading(false) }) .catch((error) => { - const errorMsg = error.response.data.error - ? error.response.data.error - : 'Something went wrong... Please, try again later!' + const errorMsg = error.response.data ? error.response.data : 'Something went wrong... Please, try again later!' setErrors(errorMsg) setRegistered(false) setLoading(false)