From f70948c92fb231e688f5f597321971d767f66c12 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Thu, 13 Jul 2023 13:42:33 +0200 Subject: [PATCH 1/2] Render empty state for the Unmint page --- src/pages/tBTC/Bridge/Mint.tsx | 30 +--- src/pages/tBTC/Bridge/Unmint.tsx | 134 ++++++++++-------- .../components/BridgeProcessEmptyState.tsx | 46 ++++++ 3 files changed, 124 insertions(+), 86 deletions(-) create mode 100644 src/pages/tBTC/Bridge/components/BridgeProcessEmptyState.tsx diff --git a/src/pages/tBTC/Bridge/Mint.tsx b/src/pages/tBTC/Bridge/Mint.tsx index 99705d043..7cb7e6abe 100644 --- a/src/pages/tBTC/Bridge/Mint.tsx +++ b/src/pages/tBTC/Bridge/Mint.tsx @@ -27,6 +27,7 @@ import { BridgeLayoutAsideSection, BridgeLayoutMainSection, } from "./BridgeLayout" +import { BridgeProcessEmptyState } from "./components/BridgeProcessEmptyState" export const MintPage: PageComponent = ({}) => { return @@ -80,12 +81,6 @@ MintingFormPage.route = { const MintPageLayout: PageComponent = () => { const { active } = useWeb3React() - const [tvlInUSD, fetchTvl, tvl] = useFetchTvl() - const [deposits] = useFetchRecentDeposits(3) - - useEffect(() => { - fetchTvl() - }, [fetchTvl]) return ( @@ -93,28 +88,7 @@ const MintPageLayout: PageComponent = () => { {active ? ( ) : ( - <> - -
Ready to mint tBTC?
- - - - - - + )} diff --git a/src/pages/tBTC/Bridge/Unmint.tsx b/src/pages/tBTC/Bridge/Unmint.tsx index ded719241..54969db3c 100644 --- a/src/pages/tBTC/Bridge/Unmint.tsx +++ b/src/pages/tBTC/Bridge/Unmint.tsx @@ -1,4 +1,5 @@ import { FC } from "react" +import { useWeb3React } from "@web3-react/core" import { Outlet } from "react-router-dom" import { FormikErrors, useFormikContext, withFormik } from "formik" import { @@ -60,6 +61,7 @@ import { UnmintingCard } from "./UnmintingCard" import { featureFlags } from "../../../constants" import { RedemptionWalletData } from "../../../threshold-ts/tbtc" import { UnspentTransactionOutputPlainObject } from "../../../types/tbtc" +import { BridgeProcessEmptyState } from "./components/BridgeProcessEmptyState" const UnmintFormPage: PageComponent = ({}) => { const { balance } = useToken(Token.TBTCV2) @@ -92,64 +94,65 @@ const UnmintFormPage: PageComponent = ({}) => { return !featureFlags.TBTC_V2_REDEMPTION ? ( ) : ( - - - - - - Unminting requires one Ethereum transaction and it takes around 5 - hours. - - - - - - - - Duration - - - ~ 5 Hours - - - - min. - {" "} - - 0.01 - {" "} - - BTC - - - - Timeline - - - Step 1 - action on Ethereum - action on Bitcoin - - Unmint - - - Your unwrapped and withdrawn BTC will be sent to the BTC address - of your choice, in the next sweep. - - - + <> + + + + Unminting requires one Ethereum transaction and it takes around 5 hours. + + + + + + + ) +} - - - +const UnmintAsideLayout = () => { + return ( + + Duration + + + ~ 5 Hours + + + + min. + {" "} + + 0.01 + {" "} + + BTC + + + + Timeline + + + Step 1 + action on Ethereum + action on Bitcoin + + Unmint + + + Your unwrapped and withdrawn BTC will be sent to the BTC address of + your choice, in the next sweep. + + + + + ) } @@ -286,7 +289,22 @@ UnmintFormPage.route = { } export const UnmintPage: PageComponent = ({}) => { - return + const { active } = useWeb3React() + + return ( + + + {active ? ( + + ) : ( + + )} + + + + + + ) } UnmintPage.route = { diff --git a/src/pages/tBTC/Bridge/components/BridgeProcessEmptyState.tsx b/src/pages/tBTC/Bridge/components/BridgeProcessEmptyState.tsx new file mode 100644 index 000000000..59c6dd7df --- /dev/null +++ b/src/pages/tBTC/Bridge/components/BridgeProcessEmptyState.tsx @@ -0,0 +1,46 @@ +import { FC, useEffect } from "react" +import { H5 } from "@threshold-network/components" +import { BridgeProcessCardTitle } from "./BridgeProcessCardTitle" +import SubmitTxButton from "../../../../components/SubmitTxButton" +import { + ProtocolHistoryRecentDeposits, + ProtocolHistoryTitle, + ProtocolHistoryViewMoreLink, + TVL, +} from "../../../../components/tBTC" +import { useFetchRecentDeposits } from "../../../../hooks/tbtc" +import { useFetchTvl } from "../../../../hooks/useFetchTvl" + +export const BridgeProcessEmptyState: FC<{ title: string }> = ({ title }) => { + const [tvlInUSD, fetchTvl, tvl] = useFetchTvl() + const [deposits] = useFetchRecentDeposits(3) + + useEffect(() => { + fetchTvl() + }, [fetchTvl]) + + return ( + <> + +
{title}
+ + + + + + + ) +} From f35c09168ed514ad412ac8428fb437cf5462d32e Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Thu, 13 Jul 2023 14:59:58 +0200 Subject: [PATCH 2/2] Fix the Unmint page layout --- src/pages/tBTC/Bridge/Mint.tsx | 18 +++-------------- src/pages/tBTC/Bridge/Unmint.tsx | 20 ++++++++++++++++--- .../components/BridgeProcessEmptyState.tsx | 8 ++++++-- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/pages/tBTC/Bridge/Mint.tsx b/src/pages/tBTC/Bridge/Mint.tsx index 7cb7e6abe..8d43736f4 100644 --- a/src/pages/tBTC/Bridge/Mint.tsx +++ b/src/pages/tBTC/Bridge/Mint.tsx @@ -1,27 +1,15 @@ import { useEffect } from "react" import { Outlet } from "react-router" import { useWeb3React } from "@web3-react/core" -import { H5 } from "@threshold-network/components" import { PageComponent } from "../../../types" import { DepositDetails } from "./DepositDetails" import { ResumeDepositPage } from "./ResumeDeposit" import { MintingTimeline } from "./Minting/MintingTimeline" -import { - useFetchRecentDeposits, - useTBTCDepositDataFromLocalStorage, -} from "../../../hooks/tbtc" +import { useTBTCDepositDataFromLocalStorage } from "../../../hooks/tbtc" import { useTbtcState } from "../../../hooks/useTbtcState" import { isSameETHAddress } from "../../../web3/utils" import { MintingFlowRouter } from "./Minting/MintingFlowRouter" -import { useFetchTvl } from "../../../hooks/useFetchTvl" -import { BridgeProcessCardTitle } from "./components/BridgeProcessCardTitle" -import SubmitTxButton from "../../../components/SubmitTxButton" -import { - ProtocolHistoryRecentDeposits, - ProtocolHistoryTitle, - ProtocolHistoryViewMoreLink, - TVL, -} from "../../../components/tBTC" + import { BridgeLayout, BridgeLayoutAsideSection, @@ -88,7 +76,7 @@ const MintPageLayout: PageComponent = () => { {active ? ( ) : ( - + )} diff --git a/src/pages/tBTC/Bridge/Unmint.tsx b/src/pages/tBTC/Bridge/Unmint.tsx index 54969db3c..6e7dc1005 100644 --- a/src/pages/tBTC/Bridge/Unmint.tsx +++ b/src/pages/tBTC/Bridge/Unmint.tsx @@ -288,7 +288,7 @@ UnmintFormPage.route = { isPageEnabled: true, } -export const UnmintPage: PageComponent = ({}) => { +export const UnmintPageLayout: PageComponent = ({}) => { const { active } = useWeb3React() return ( @@ -297,7 +297,10 @@ export const UnmintPage: PageComponent = ({}) => { {active ? ( ) : ( - + )} @@ -307,11 +310,22 @@ export const UnmintPage: PageComponent = ({}) => { ) } +UnmintPageLayout.route = { + path: "", + index: false, + isPageEnabled: true, + pages: [UnmintFormPage], +} + +export const UnmintPage: PageComponent = () => { + return +} + UnmintPage.route = { path: "unmint", pathOverride: "unmint/*", index: true, title: "Unmint", - pages: [UnmintFormPage, UnmintDetails], + pages: [UnmintPageLayout, UnmintDetails], isPageEnabled: true, } diff --git a/src/pages/tBTC/Bridge/components/BridgeProcessEmptyState.tsx b/src/pages/tBTC/Bridge/components/BridgeProcessEmptyState.tsx index 59c6dd7df..2aea93420 100644 --- a/src/pages/tBTC/Bridge/components/BridgeProcessEmptyState.tsx +++ b/src/pages/tBTC/Bridge/components/BridgeProcessEmptyState.tsx @@ -10,8 +10,12 @@ import { } from "../../../../components/tBTC" import { useFetchRecentDeposits } from "../../../../hooks/tbtc" import { useFetchTvl } from "../../../../hooks/useFetchTvl" +import { BridgeProcess } from "../../../../types" -export const BridgeProcessEmptyState: FC<{ title: string }> = ({ title }) => { +export const BridgeProcessEmptyState: FC<{ + title: string + bridgeProcess?: BridgeProcess +}> = ({ title, bridgeProcess = "mint" }) => { const [tvlInUSD, fetchTvl, tvl] = useFetchTvl() const [deposits] = useFetchRecentDeposits(3) @@ -21,7 +25,7 @@ export const BridgeProcessEmptyState: FC<{ title: string }> = ({ title }) => { return ( <> - +
{title}