diff --git a/__tests__/components/CircularProgress.test.tsx b/__tests__/components/CircularProgress.test.tsx index 9ff05356..98251b19 100644 --- a/__tests__/components/CircularProgress.test.tsx +++ b/__tests__/components/CircularProgress.test.tsx @@ -1,11 +1,11 @@ import { render } from '@testing-library/react' import { CircularProgress } from 'components/CircularProgress' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' describe('', () => { afterAll(() => { - localStorage.removeItem(REDUCE_MOTION_KEY) + localStorage.removeItem(LocalStorageKeys.REDUCE_MOTION) }) it('should render', () => { @@ -15,7 +15,7 @@ describe('', () => { }) it('should render `...` when animations disabled', () => { - localStorage.setItem(REDUCE_MOTION_KEY, 'true') + localStorage.setItem(LocalStorageKeys.REDUCE_MOTION, 'true') const { getByText } = render() const threeDots = getByText('...') @@ -24,7 +24,7 @@ describe('', () => { }) it('should render the component with animation classes when animations enabled', () => { - localStorage.setItem(REDUCE_MOTION_KEY, 'false') + localStorage.setItem(LocalStorageKeys.REDUCE_MOTION, 'false') const { container } = render() const progressWithAnimations = container.querySelector('.animate-progress') diff --git a/src/components/Account/AccountDetails/index.tsx b/src/components/Account/AccountDetails/index.tsx index 18e999cc..550e5d78 100644 --- a/src/components/Account/AccountDetails/index.tsx +++ b/src/components/Account/AccountDetails/index.tsx @@ -14,7 +14,7 @@ import { HealthGauge } from 'components/HealthGauge' import { ThreeDots } from 'components/Icons' import Text from 'components/Text' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import { ORACLE_DENOM } from 'constants/oracle' import useAccountId from 'hooks/useAccountId' import useAccountIds from 'hooks/useAccountIds' @@ -56,7 +56,10 @@ interface Props { function AccountDetails(props: Props) { const { account } = props - const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) const updatedAccount = useStore((s) => s.updatedAccount) const accountDetailsExpanded = useStore((s) => s.accountDetailsExpanded) const { health } = useHealthComputer(account) diff --git a/src/components/Account/AccountFund/AccountFundContent.tsx b/src/components/Account/AccountFund/AccountFundContent.tsx index 3e5bbc37..85ebeeff 100644 --- a/src/components/Account/AccountFund/AccountFundContent.tsx +++ b/src/components/Account/AccountFund/AccountFundContent.tsx @@ -9,7 +9,7 @@ import Text from 'components/Text' import TokenInputWithSlider from 'components/TokenInput/TokenInputWithSlider' import WalletBridges from 'components/Wallet/WalletBridges' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { LEND_ASSETS_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import { BN_ZERO } from 'constants/math' import useAutoLend from 'hooks/useAutoLend' import useLocalStorage from 'hooks/useLocalStorage' @@ -38,7 +38,7 @@ export default function AccountFundContent(props: Props) { const walletAssetModal = useStore((s) => s.walletAssetsModal) const [isConfirming, setIsConfirming] = useState(false) const [lendAssets, setLendAssets] = useLocalStorage( - LEND_ASSETS_KEY, + LocalStorageKeys.LEND_ASSETS, DEFAULT_SETTINGS.lendAssets, ) const [fundingAssets, setFundingAssets] = useState([]) diff --git a/src/components/Account/AccountMenuContent.tsx b/src/components/Account/AccountMenuContent.tsx index e1a939c9..f1f11038 100644 --- a/src/components/Account/AccountMenuContent.tsx +++ b/src/components/Account/AccountMenuContent.tsx @@ -11,7 +11,7 @@ import Overlay from 'components/Overlay' import Text from 'components/Text' import WalletBridges from 'components/Wallet/WalletBridges' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { LEND_ASSETS_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useAccountId from 'hooks/useAccountId' import useAccountIds from 'hooks/useAccountIds' import useAutoLend from 'hooks/useAutoLend' @@ -39,7 +39,10 @@ export default function AccountMenuContent() { const [showMenu, setShowMenu] = useToggle() const [isCreating, setIsCreating] = useToggle() const transactionFeeCoinBalance = useCurrentWalletBalance(baseCurrency.denom) - const [lendAssets] = useLocalStorage(LEND_ASSETS_KEY, DEFAULT_SETTINGS.lendAssets) + const [lendAssets] = useLocalStorage( + LocalStorageKeys.LEND_ASSETS, + DEFAULT_SETTINGS.lendAssets, + ) const { enableAutoLendAccountId } = useAutoLend() const hasCreditAccounts = !!accountIds?.length diff --git a/src/components/Account/HealthBar.tsx b/src/components/Account/HealthBar.tsx index e1f594c6..8a4ce6f7 100644 --- a/src/components/Account/HealthBar.tsx +++ b/src/components/Account/HealthBar.tsx @@ -3,7 +3,7 @@ import { useMemo } from 'react' import { Tooltip } from 'components/Tooltip' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useHealthColorAndLabel from 'hooks/useHealthColorAndLabel' import useLocalStorage from 'hooks/useLocalStorage' import { getHealthIndicatorColors } from 'utils/healthIndicator' @@ -30,7 +30,10 @@ function calculateHealth(health: number): number { export default function HealthBar(props: Props) { const { health, updatedHealth } = props - const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) const width = calculateHealth(health) const updatedWidth = calculateHealth(updatedHealth ?? 0) const isUpdated = updatedWidth > 0 && updatedWidth !== width diff --git a/src/components/Account/RiskChart.tsx b/src/components/Account/RiskChart.tsx index 5f2f2921..21e5d2c0 100644 --- a/src/components/Account/RiskChart.tsx +++ b/src/components/Account/RiskChart.tsx @@ -12,13 +12,16 @@ import { import { FormattedNumber } from 'components/FormattedNumber' import Text from 'components/Text' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' +import { BN_ZERO } from 'constants/math' import useLocalStorage from 'hooks/useLocalStorage' import { formatValue } from 'utils/formatters' -import { BN_ZERO } from 'constants/math' export const RiskChart = ({ data }: RiskChartProps) => { - const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) const currentRisk = BN_ZERO return ( diff --git a/src/components/Background.tsx b/src/components/Background.tsx index d02a8426..79fb7cb6 100644 --- a/src/components/Background.tsx +++ b/src/components/Background.tsx @@ -1,11 +1,14 @@ import classNames from 'classnames' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useLocalStorage from 'hooks/useLocalStorage' export default function Background() { - const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) return (
diff --git a/src/components/BorrowCapacity.tsx b/src/components/BorrowCapacity.tsx index 76eff4f9..93f9c306 100644 --- a/src/components/BorrowCapacity.tsx +++ b/src/components/BorrowCapacity.tsx @@ -5,7 +5,7 @@ import { FormattedNumber } from 'components/FormattedNumber' import Text from 'components/Text' import { Tooltip } from 'components/Tooltip' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useLocalStorage from 'hooks/useLocalStorage' interface Props { @@ -31,7 +31,10 @@ export const BorrowCapacity = ({ hideValues, decimals = 2, }: Props) => { - const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) const [percentOfMaxRound, setPercentOfMaxRound] = useState(0) const [percentOfMaxRange, setPercentOfMaxRange] = useState(0) const [limitPercentOfMax, setLimitPercentOfMax] = useState(0) diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx index 27eebed4..63a7eab1 100644 --- a/src/components/Button/index.tsx +++ b/src/components/Button/index.tsx @@ -17,7 +17,7 @@ import { glowElement } from 'components/Button/utils' import { CircularProgress } from 'components/CircularProgress' import { ChevronDown } from 'components/Icons' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useLocalStorage from 'hooks/useLocalStorage' const Button = React.forwardRef(function Button( @@ -44,7 +44,10 @@ const Button = React.forwardRef(function Button( }: ButtonProps, ref, ) { - const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) const isDisabled = disabled || showProgressIndicator const shouldShowText = text && !children const shouldShowGlowElement = variant === 'solid' && !isDisabled && !reduceMotion diff --git a/src/components/CheckMark.tsx b/src/components/CheckMark.tsx index 0c20ba5d..7d6ee4ce 100644 --- a/src/components/CheckMark.tsx +++ b/src/components/CheckMark.tsx @@ -2,7 +2,7 @@ import classNames from 'classnames' import { CheckCircled } from 'components/Icons' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useLocalStorage from 'hooks/useLocalStorage' interface Props { @@ -12,7 +12,10 @@ interface Props { } export const CheckMark = ({ color = '#FFFFFF', size = 20, className }: Props) => { - const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) const classes = classNames('inline-block relative', className) if (reduceMotion) diff --git a/src/components/Checkbox.tsx b/src/components/Checkbox.tsx index fee21e9b..5b27acc8 100644 --- a/src/components/Checkbox.tsx +++ b/src/components/Checkbox.tsx @@ -1,27 +1,39 @@ import classNames from 'classnames' import { Check } from 'components/Icons' +import Text from 'components/Text' interface Props { checked: boolean onChange: (checked: boolean) => void + text?: string } export default function Checkbox(props: Props) { return ( - + ) } diff --git a/src/components/CircularProgress.tsx b/src/components/CircularProgress.tsx index b48ff777..2aa318e6 100644 --- a/src/components/CircularProgress.tsx +++ b/src/components/CircularProgress.tsx @@ -1,7 +1,7 @@ import classNames from 'classnames' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useLocalStorage from 'hooks/useLocalStorage' interface Props { @@ -11,7 +11,10 @@ interface Props { } export const CircularProgress = ({ color = '#FFFFFF', size = 20, className }: Props) => { - const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) const borderWidth = `${size / 10}px` const borderColor = `${color} transparent transparent transparent` const loaderClasses = classNames('inline-block relative', className) diff --git a/src/components/DisplayCurrency.tsx b/src/components/DisplayCurrency.tsx index 8939deb3..f361201e 100644 --- a/src/components/DisplayCurrency.tsx +++ b/src/components/DisplayCurrency.tsx @@ -3,7 +3,7 @@ import { useMemo } from 'react' import { FormattedNumber } from 'components/FormattedNumber' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { DISPLAY_CURRENCY_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import { ORACLE_DENOM } from 'constants/oracle' import useLocalStorage from 'hooks/useLocalStorage' import usePrices from 'hooks/usePrices' @@ -22,7 +22,7 @@ interface Props { export default function DisplayCurrency(props: Props) { const displayCurrencies = getDisplayCurrencies() const [displayCurrency] = useLocalStorage( - DISPLAY_CURRENCY_KEY, + LocalStorageKeys.DISPLAY_CURRENCY, DEFAULT_SETTINGS.displayCurrency, ) const { data: prices } = usePrices() diff --git a/src/components/Earn/Farm/VaultExpanded.tsx b/src/components/Earn/Farm/VaultExpanded.tsx index 81071fe5..b9f70292 100644 --- a/src/components/Earn/Farm/VaultExpanded.tsx +++ b/src/components/Earn/Farm/VaultExpanded.tsx @@ -6,7 +6,7 @@ import Button from 'components/Button' import { AccountArrowDown, LockLocked, LockUnlocked, Plus } from 'components/Icons' import { Tooltip } from 'components/Tooltip' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { SLIPPAGE_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useAccountId from 'hooks/useAccountId' import useLocalStorage from 'hooks/useLocalStorage' import useStore from 'store' @@ -22,7 +22,7 @@ export default function VaultExpanded(props: Props) { const accountId = useAccountId() const [isConfirming, setIsConfirming] = useState(false) const withdrawFromVaults = useStore((s) => s.withdrawFromVaults) - const [slippage] = useLocalStorage(SLIPPAGE_KEY, DEFAULT_SETTINGS.slippage) + const [slippage] = useLocalStorage(LocalStorageKeys.SLIPPAGE, DEFAULT_SETTINGS.slippage) function depositMoreHandler() { useStore.setState({ diff --git a/src/components/Earn/Farm/VaultUnlockBanner.tsx b/src/components/Earn/Farm/VaultUnlockBanner.tsx index 84fbcaea..84e57c64 100644 --- a/src/components/Earn/Farm/VaultUnlockBanner.tsx +++ b/src/components/Earn/Farm/VaultUnlockBanner.tsx @@ -4,7 +4,7 @@ import Button from 'components/Button' import { ChevronRight } from 'components/Icons' import NotificationBanner from 'components/NotificationBanner' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { SLIPPAGE_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useAccountId from 'hooks/useAccountId' import useLocalStorage from 'hooks/useLocalStorage' import useStore from 'store' @@ -17,7 +17,7 @@ export default function VaultUnlockBanner(props: Props) { const accountId = useAccountId() const [isConfirming, setIsConfirming] = useState(false) const withdrawFromVaults = useStore((s) => s.withdrawFromVaults) - const [slippage] = useLocalStorage(SLIPPAGE_KEY, DEFAULT_SETTINGS.slippage) + const [slippage] = useLocalStorage(LocalStorageKeys.SLIPPAGE, DEFAULT_SETTINGS.slippage) async function handleWithdraw() { if (!accountId) return diff --git a/src/components/Earn/Lend/LendingActionButtons.tsx b/src/components/Earn/Lend/LendingActionButtons.tsx index 76f74d27..01cc1870 100644 --- a/src/components/Earn/Lend/LendingActionButtons.tsx +++ b/src/components/Earn/Lend/LendingActionButtons.tsx @@ -3,7 +3,7 @@ import { useCallback } from 'react' import { ACCOUNT_MENU_BUTTON_ID } from 'components/Account/AccountMenuContent' import Button from 'components/Button' import ActionButton from 'components/Button/ActionButton' -import { ArrowDownLine, ArrowUpLine, Enter } from 'components/Icons' +import { ArrowDownLine, ArrowUpLine, Enter, ExclamationMarkCircled } from 'components/Icons' import Text from 'components/Text' import { Tooltip } from 'components/Tooltip' import ConditionalWrapper from 'hocs/ConditionalWrapper' @@ -36,8 +36,9 @@ export default function LendingActionButtons(props: Props) { const handleUnlend = useCallback(() => { if (isAutoLendEnabledForCurrentAccount) { showAlertDialog({ + icon: , title: 'Disable Automatically Lend Assets', - description: + content: "Your auto-lend feature is currently enabled. To unlend your funds, please confirm if you'd like to disable this feature in order to continue.", positiveButton: { onClick: () => document.getElementById(ACCOUNT_MENU_BUTTON_ID)?.click(), diff --git a/src/components/FormattedNumber.tsx b/src/components/FormattedNumber.tsx index 798cb33c..964c49f8 100644 --- a/src/components/FormattedNumber.tsx +++ b/src/components/FormattedNumber.tsx @@ -3,7 +3,7 @@ import React, { useEffect, useRef } from 'react' import { animated, useSpring } from 'react-spring' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useLocalStorage from 'hooks/useLocalStorage' import { formatValue } from 'utils/formatters' @@ -19,7 +19,7 @@ interface Props { export const FormattedNumber = React.memo( (props: Props) => { const [reduceMotion] = useLocalStorage( - REDUCE_MOTION_KEY, + LocalStorageKeys.REDUCE_MOTION, DEFAULT_SETTINGS.reduceMotion, ) const prevAmountRef = useRef(0) diff --git a/src/components/Gauge.tsx b/src/components/Gauge.tsx index 0e948498..b0f31e58 100644 --- a/src/components/Gauge.tsx +++ b/src/components/Gauge.tsx @@ -3,7 +3,7 @@ import { ReactElement, ReactNode } from 'react' import { Tooltip } from 'components/Tooltip' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useLocalStorage from 'hooks/useLocalStorage' interface Props { @@ -27,7 +27,10 @@ export const Gauge = ({ icon, labelClassName, }: Props) => { - const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) const radius = 16 const percentageValue = percentage > 100 ? 100 : percentage < 0 ? 0 : percentage const circlePercent = 100 - percentageValue diff --git a/src/components/HLS/Farm/HLSFarmIntro.tsx b/src/components/HLS/Farm/HLSFarmIntro.tsx index 88bb9e17..a8952492 100644 --- a/src/components/HLS/Farm/HLSFarmIntro.tsx +++ b/src/components/HLS/Farm/HLSFarmIntro.tsx @@ -11,7 +11,7 @@ export default function HlsFarmIntro() { bg='farm' text={ <> - Leverage farming is a strategy where users borrow + Leveraged farming is a strategy where users borrow funds to increase their yield farming position, aiming to earn more in rewards than the cost of the borrowed assets. diff --git a/src/components/HLS/Farm/Table/Columns/Deposit.tsx b/src/components/HLS/Farm/Table/Columns/Deposit.tsx index b833b643..c60ff38f 100644 --- a/src/components/HLS/Farm/Table/Columns/Deposit.tsx +++ b/src/components/HLS/Farm/Table/Columns/Deposit.tsx @@ -1,7 +1,13 @@ -import React from 'react' +import classNames from 'classnames' +import React, { useCallback } from 'react' import ActionButton from 'components/Button/ActionButton' +import { Enter } from 'components/Icons' import Loading from 'components/Loading' +import Text from 'components/Text' +import { LocalStorageKeys } from 'constants/localStorageKeys' +import useAlertDialog from 'hooks/useAlertDialog' +import useLocalStorage from 'hooks/useLocalStorage' export const DEPOSIT_META = { accessorKey: 'deposit', header: 'Deposit' } @@ -13,7 +19,58 @@ interface Props { export default function Deposit(props: Props) { const { vault } = props + const [showHlsInfo, setShowHlsInfo] = useLocalStorage( + LocalStorageKeys.HLS_INFORMATION, + true, + ) + + const { open: openAlertDialog, close } = useAlertDialog() + + const showHlsInfoModal = useCallback(() => { + if (!showHlsInfo) return + openAlertDialog({ + title: 'Understanding HLS Positions', + content: ( +
+ {INFO_ITEMS.map((item) => ( +
+ + {item.icon} + + + {item.title} + {item.description} + +
+ ))} +
+ ), + positiveButton: { + text: 'Continue', + icon: , + onClick: enterVaultHandler, + }, + negativeButton: { + text: 'Cancel', + onClick: () => { + setShowHlsInfo(true) + close() + }, + }, + checkbox: { + text: "Don't show again", + onClick: (isChecked: boolean) => setShowHlsInfo(!isChecked), + }, + }) + }, [close, enterVaultHandler, openAlertDialog, setShowHlsInfo, showHlsInfo]) + function enterVaultHandler() { + showHlsInfoModal() return } @@ -25,3 +82,23 @@ export default function Deposit(props: Props) {
) } + +const INFO_ITEMS = [ + { + icon: , + title: 'One account, one position', + description: + 'A minted HLS account can only have a single position tied to it, in order to limit risk.', + }, + { + icon: , + title: 'Funded from your wallet', + description: 'To fund your HLS position, funds will have to come directly from your wallet.', + }, + { + icon: , + title: 'Accounts are reusable', + description: + 'If you exited a position from a minted account, this account can be reused for a new position.', + }, +] diff --git a/src/components/HealthGauge.tsx b/src/components/HealthGauge.tsx index 52521bd7..c983544d 100644 --- a/src/components/HealthGauge.tsx +++ b/src/components/HealthGauge.tsx @@ -4,7 +4,7 @@ import { useMemo } from 'react' import { Heart } from 'components/Icons' import { Tooltip } from 'components/Tooltip' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { REDUCE_MOTION_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useHealthColorAndLabel from 'hooks/useHealthColorAndLabel' import useLocalStorage from 'hooks/useLocalStorage' import { computeHealthGaugePercentage } from 'utils/accounts' @@ -25,7 +25,10 @@ const ROTATION = { export const HealthGauge = ({ diameter = 40, health = 0, updatedHealth = 0 }: Props) => { const [color, label] = useHealthColorAndLabel(health, 'text') const [updatedColor, updatedLabel] = useHealthColorAndLabel(updatedHealth ?? 0, 'text') - const [reduceMotion] = useLocalStorage(REDUCE_MOTION_KEY, DEFAULT_SETTINGS.reduceMotion) + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) const percentage = useMemo(() => computeHealthGaugePercentage(health), [health]) const updatedPercentage = useMemo( () => computeHealthGaugePercentage(updatedHealth), diff --git a/src/components/MigrationBanner.tsx b/src/components/MigrationBanner.tsx index f3c5e610..6397aef1 100644 --- a/src/components/MigrationBanner.tsx +++ b/src/components/MigrationBanner.tsx @@ -3,14 +3,14 @@ import { Cross, ExclamationMarkCircled } from 'components/Icons' import Text from 'components/Text' import { TextLink } from 'components/TextLink' import { DEFAULT_SETTINGS } from 'constants/defaultSettings' -import { MIGRATION_BANNER_KEY } from 'constants/localStore' +import { LocalStorageKeys } from 'constants/localStorageKeys' import useLocalStorage from 'hooks/useLocalStorage' import useStore from 'store' import { DocURL } from 'types/enums/docURL' export default function MigrationBanner() { const [_, setMigrationBanner] = useLocalStorage( - MIGRATION_BANNER_KEY, + LocalStorageKeys.MIGRATION_BANNER, DEFAULT_SETTINGS.migrationBanner, ) diff --git a/src/components/Modals/Account/AccountDeleteAlertDialog.tsx b/src/components/Modals/Account/AccountDeleteAlertDialog.tsx index 2c658579..e340fc12 100644 --- a/src/components/Modals/Account/AccountDeleteAlertDialog.tsx +++ b/src/components/Modals/Account/AccountDeleteAlertDialog.tsx @@ -4,25 +4,22 @@ import { Enter, InfoCircle } from 'components/Icons' import useAlertDialog from 'hooks/useAlertDialog' interface Props { + content: string | JSX.Element title: string - description: string | JSX.Element + icon?: JSX.Element closeHandler: () => void positiveButton: AlertDialogButton } export default function AccountDeleteAlertDialog(props: Props) { const { open: showAlertDialog } = useAlertDialog() - const { title, description, closeHandler, positiveButton } = props + const { title, content, closeHandler, positiveButton } = props useEffect(() => { showAlertDialog({ - icon: ( -
- -
- ), + icon: , title, - description, + content, negativeButton: { text: 'Cancel', icon: , @@ -30,7 +27,7 @@ export default function AccountDeleteAlertDialog(props: Props) { }, positiveButton, }) - }, [showAlertDialog, title, description, closeHandler, positiveButton]) + }, [showAlertDialog, closeHandler, positiveButton, title, content]) return null } diff --git a/src/components/Modals/Account/AccountDeleteModal.tsx b/src/components/Modals/Account/AccountDeleteModal.tsx index a436963d..9d1f2168 100644 --- a/src/components/Modals/Account/AccountDeleteModal.tsx +++ b/src/components/Modals/Account/AccountDeleteModal.tsx @@ -2,7 +2,7 @@ import { useCallback, useMemo } from 'react' import { useLocation, useNavigate, useParams } from 'react-router-dom' import AssetBalanceRow from 'components/Asset/AssetBalanceRow' -import { ArrowRight } from 'components/Icons' +import { ArrowRight, ExclamationMarkCircled } from 'components/Icons' import AccountDeleteAlertDialog from 'components/Modals/Account/AccountDeleteAlertDialog' import Text from 'components/Text' import useStore from 'store' @@ -51,7 +51,8 @@ function AccountDeleteModal(props: Props) { return ( } + content='You must repay all borrowings before deleting your account.' closeHandler={closeDeleteAccountModal} positiveButton={{ text: 'Repay Debts', @@ -68,7 +69,7 @@ function AccountDeleteModal(props: Props) { return ( The following assets within your Credit Account will be sent to your wallet. diff --git a/src/components/Modals/AlertDialog/index.tsx b/src/components/Modals/AlertDialog/index.tsx index c9e61e64..a5985527 100644 --- a/src/components/Modals/AlertDialog/index.tsx +++ b/src/components/Modals/AlertDialog/index.tsx @@ -1,12 +1,12 @@ import classNames from 'classnames' -import { useState } from 'react' import Button from 'components/Button' -import { ExclamationMarkCircled } from 'components/Icons' +import Checkbox from 'components/Checkbox' import Modal from 'components/Modal' import { NoIcon, YesIcon } from 'components/Modals/AlertDialog/ButtonIcons' import Text from 'components/Text' import useAlertDialog from 'hooks/useAlertDialog' +import useToggle from 'hooks/useToggle' export default function AlertDialogController() { const { config, close } = useAlertDialog() @@ -22,19 +22,32 @@ interface Props { } function AlertDialog(props: Props) { - const { title, icon, description, negativeButton, positiveButton } = props.config + const { title, icon, content, negativeButton, positiveButton, checkbox } = props.config + + const [toggle, handleToggle] = useToggle() + const handleButtonClick = (button?: AlertDialogButton) => { button?.onClick && button.onClick() props.close() } + function handleCheckboxClick() { + handleToggle() + checkbox?.onClick(!toggle) + } + return ( - {icon ?? } +
+ {icon && ( +
+ {icon} +
+ )} + {title}
} modalClassName='max-w-modal-sm' @@ -42,24 +55,28 @@ function AlertDialog(props: Props) { contentClassName='px-8 pb-8' hideCloseBtn > - {title} - {typeof description === 'string' ? ( - {description} + {typeof content === 'string' ? ( + {content} ) : ( - description + content )}
- {positiveButton && ( -