From 05c22b6eaafddb2cb0b48b88f94ae2e0fc56ba73 Mon Sep 17 00:00:00 2001 From: Fabricio Robles Date: Tue, 17 Dec 2024 11:59:57 -0600 Subject: [PATCH 01/10] feat: Rename Log out to Disconnect --- frontend/src/components/WalletSection.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/WalletSection.jsx b/frontend/src/components/WalletSection.jsx index 0dc94869..394562dd 100644 --- a/frontend/src/components/WalletSection.jsx +++ b/frontend/src/components/WalletSection.jsx @@ -74,7 +74,7 @@ const WalletSection = ({ onConnectWallet, onLogout }) => { onLogout(); }} > - Log out + Disconnect )} From 6b406ec94dd63880d7497617db542452070b3dbc Mon Sep 17 00:00:00 2001 From: Fabricio Robles Date: Tue, 17 Dec 2024 15:57:21 -0600 Subject: [PATCH 02/10] feat: Change Balance to Position balance in Collateral component --- frontend/src/components/collateral/Collateral.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/collateral/Collateral.jsx b/frontend/src/components/collateral/Collateral.jsx index ef50530e..7714705e 100644 --- a/frontend/src/components/collateral/Collateral.jsx +++ b/frontend/src/components/collateral/Collateral.jsx @@ -14,7 +14,7 @@ function Collateral({ data, startSum, currentSum, getCurrentSumColor }) { {data[0]?.currencyName || 'N/A'} - Balance: + Position Balance: {data[0]?.balance ? Number(data[0].balance).toFixed(8) : '0.00'} From d765f2dea9a0152b3b171cd848877a600dab2c85 Mon Sep 17 00:00:00 2001 From: Fabricio Robles Date: Tue, 17 Dec 2024 16:43:30 -0600 Subject: [PATCH 03/10] Using react-tostify to display error toasts --- frontend/src/App.jsx | 2 ++ frontend/src/components/MultiplierSelector.jsx | 3 ++- frontend/src/components/SlideBarFour.jsx | 3 ++- frontend/src/components/Toast/ErrorToast.jsx | 18 ++++++++++++++++++ frontend/src/pages/forms/Form.jsx | 10 +++------- .../src/pages/spotnet/dashboard/Dashboard.jsx | 8 ++------ 6 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 frontend/src/components/Toast/ErrorToast.jsx diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 43926cc1..685fe179 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -19,6 +19,7 @@ import OverviewPage from 'pages/spotnet/overview/Overview'; import { ActionModal } from 'components/ui/ActionModal'; import Stake from 'pages/vault/stake/Stake'; import { notifyError } from 'utils/notification'; +import { ErrorToast } from 'components/Toast/ErrorToast'; function App() { const { walletId, setWalletId, removeWalletId } = useWalletStore(); @@ -63,6 +64,7 @@ function App() { return (
+ {showModal && createPortal( { const minMultiplier = 1.1; @@ -104,7 +105,7 @@ const MultiplierSelector = ({ setSelectedMultiplier, selectedToken }) => { }, [maxMultiplier, actualValue, setSelectedMultiplier]); if (isLoading) return
Loading multiplier data...
; - if (error) return
Error loading multiplier data: {error.message}
; + if (error) return notifyError(error.message); return (
diff --git a/frontend/src/components/SlideBarFour.jsx b/frontend/src/components/SlideBarFour.jsx index afb5aa54..76e5a5ad 100644 --- a/frontend/src/components/SlideBarFour.jsx +++ b/frontend/src/components/SlideBarFour.jsx @@ -1,6 +1,7 @@ import React, { useState, useCallback, useMemo } from 'react'; import { useMaxMultiplier } from 'hooks/useMaxMultiplier'; import './slider-three.css'; +import { notifyError } from 'components/Toast/ErrorToast'; const StepSlider = ({ min = 0, max = 10, step = 1, defaultValue = 1, setSelectedMultiplier, selectedToken }) => { const { data, isLoading, error } = useMaxMultiplier(); @@ -34,7 +35,7 @@ const StepSlider = ({ min = 0, max = 10, step = 1, defaultValue = 1, setSelected }, [value, maxMultiplier, TOTAL_MARKS]); if (isLoading) return
Loading multiplier data...
; - if (error) return
Error loading multiplier data: {error.message}
; + if (error) return notifyError(error.message); const currentMark = getCurrentMark(); diff --git a/frontend/src/components/Toast/ErrorToast.jsx b/frontend/src/components/Toast/ErrorToast.jsx new file mode 100644 index 00000000..f754dfcd --- /dev/null +++ b/frontend/src/components/Toast/ErrorToast.jsx @@ -0,0 +1,18 @@ +import { ToastContainer, toast } from 'react-toastify'; +import 'react-toastify/dist/ReactToastify.css'; + +import React from 'react' + +const notifyError = (message, id, autoClose) => { + toast.error(message, {toastId: id || undefined, autoClose: autoClose !== undefined ? autoClose : 3000} ); + }; + +const ErrorToast = () => { + return ( +
+ +
+ ) +} + +export {ErrorToast, notifyError} diff --git a/frontend/src/pages/forms/Form.jsx b/frontend/src/pages/forms/Form.jsx index 8a0d817f..0697cd94 100644 --- a/frontend/src/pages/forms/Form.jsx +++ b/frontend/src/pages/forms/Form.jsx @@ -7,7 +7,6 @@ import BalanceCards from 'components/BalanceCards'; import MultiplierSelector from 'components/MultiplierSelector'; import { handleTransaction } from 'services/transaction'; import Spinner from 'components/spinner/Spinner'; -import { ReactComponent as AlertHexagon } from 'assets/icons/alert_hexagon.svg'; import './form.css'; import { createPortal } from 'react-dom'; import useLockBodyScroll from 'hooks/useLockBodyScroll'; @@ -19,6 +18,7 @@ import { useCheckPosition } from 'hooks/useClosePosition'; import { useNavigate } from 'react-router-dom'; import { ActionModal } from 'components/ui/ActionModal'; import { useHealthFactor } from 'hooks/useHealthRatio'; +import { notifyError } from 'components/Toast/ErrorToast'; const Form = () => { const navigate = useNavigate(); @@ -117,11 +117,7 @@ const Form = () => {

Please submit your leverage details

- {alertMessage && ( -

- {alertMessage} -

- )} + {alertMessage && notifyError(alertMessage, "error1")} @@ -132,7 +128,7 @@ const Form = () => { />
- {error &&

{error}

} + {error && notifyError(alertMessage, "error1")} {isClosing ? 'Closing...' : 'Redeem'} - {closePositionError && ( -
- Error: {closePositionError.message} -
- )} + {closePositionError && (notifyError("Error: " + closePositionError.message))} - {closePositionError && (notifyError("Error: " + closePositionError.message))} + {closePositionError && (notify("Error: " + closePositionError.message))} - {closePositionError && (notify("Error: " + closePositionError.message))}