From 0c02b7010f29157f000db2128fe424a35c9ccc7d Mon Sep 17 00:00:00 2001 From: matzapata Date: Fri, 9 Aug 2024 15:59:41 +0300 Subject: [PATCH 1/6] static ui done. missing validations --- .../LendPositionAction/LendPositionAction.tsx | 21 ++- .../components/WithdrawModal/WithdrawForm.tsx | 123 ++++++++++++++++++ .../WithdrawModal/WithdrawModalContainer.tsx | 30 +++++ 3 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 apps/frontend/src/app/5_pages/AavePage/components/LendPositionsList/components/WithdrawModal/WithdrawForm.tsx create mode 100644 apps/frontend/src/app/5_pages/AavePage/components/LendPositionsList/components/WithdrawModal/WithdrawModalContainer.tsx diff --git a/apps/frontend/src/app/5_pages/AavePage/components/LendPositionsList/components/LendPositionAction/LendPositionAction.tsx b/apps/frontend/src/app/5_pages/AavePage/components/LendPositionsList/components/LendPositionAction/LendPositionAction.tsx index bbba9103e..b86d1a8ad 100644 --- a/apps/frontend/src/app/5_pages/AavePage/components/LendPositionsList/components/LendPositionAction/LendPositionAction.tsx +++ b/apps/frontend/src/app/5_pages/AavePage/components/LendPositionsList/components/LendPositionAction/LendPositionAction.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React, { FC, useCallback, useState } from 'react'; import { t } from 'i18next'; @@ -6,19 +6,36 @@ import { Button, ButtonStyle } from '@sovryn/ui'; import { translations } from '../../../../../../../locales/i18n'; import { LendPosition } from '../../LendPositionsList.types'; +import { WithdrawModalContainer } from '../WithdrawModal/WithdrawModalContainer'; type LendPositionActionProps = { position: LendPosition; }; export const LendPositionAction: FC = () => { + const [isWithdrawModalOpen, setIsWithdrawModalOpen] = + useState(false); + + const handleWithdrawClick = useCallback(() => { + setIsWithdrawModalOpen(true); + }, []); + + const handleWithdrawClose = useCallback(() => { + setIsWithdrawModalOpen(false); + }, []); + return (
- {/* TODO: these should be modal triggers */}
); diff --git a/apps/frontend/src/app/5_pages/AavePage/components/LendPositionsList/components/WithdrawModal/WithdrawForm.tsx b/apps/frontend/src/app/5_pages/AavePage/components/LendPositionsList/components/WithdrawModal/WithdrawForm.tsx new file mode 100644 index 000000000..2d2fcfad3 --- /dev/null +++ b/apps/frontend/src/app/5_pages/AavePage/components/LendPositionsList/components/WithdrawModal/WithdrawForm.tsx @@ -0,0 +1,123 @@ +import React, { FC, useCallback, useMemo, useState } from 'react'; + +import { t } from 'i18next'; + +import { + AmountInput, + Button, + Select, + SimpleTable, + SimpleTableRow, + Tabs, + TabType, +} from '@sovryn/ui'; + +import { AmountRenderer } from '../../../../../../2_molecules/AmountRenderer/AmountRenderer'; +import { AssetRenderer } from '../../../../../../2_molecules/AssetRenderer/AssetRenderer'; +import { useDecimalAmountInput } from '../../../../../../../hooks/useDecimalAmountInput'; +import { translations } from '../../../../../../../locales/i18n'; + +type WithdrawFormProps = {}; + +export const WithdrawForm: FC = () => { + const withdrawableAssets = useMemo(() => ['BTC', 'SOV'], []); // TODO: Mock data + const [withdrawAsset, setWithdrawAsset] = useState( + withdrawableAssets[0], + ); + const [maxWithdrawableAmount] = useState(10); + const [withdrawAmount, setWithdrawAmount] = useDecimalAmountInput(''); + + const onWithdrawAssetChange = useCallback(v => { + setWithdrawAsset(v); + }, []); + + const withdrawableAssetsOptions = useMemo( + () => + withdrawableAssets.map(token => ({ + value: token, + label: ( + + ), + })), + [withdrawableAssets], + ); + + return ( +
+
+
+ + + (Max{' '} + + ) + +
+ +
+
+ +
+ +
+
+ + = () => { options={withdrawableAssetsOptions} labelRenderer={({ value }) => ( )} className="min-w-[6.7rem]" menuClassName="max-h-[10rem] sm:max-h-[20rem]" - dataAttribute="new-loan-collateral-select" + dataAttribute="withdraw-asset-select" />
@@ -111,13 +138,18 @@ export const WithdrawForm: FC = () => {
} + label={t(translations.aavePage.withdrawForm.remainingSupply)} + value={ + + } />
-