From d0dee20b5049a70c911dcc1896bb8eeccd5228b2 Mon Sep 17 00:00:00 2001 From: escapedcat Date: Sat, 28 Sep 2024 13:29:10 +0200 Subject: [PATCH] refactor(home): receive modal --- src/pages/Home/ReceiveModal/ReceiveModal.tsx | 178 +++++++++---------- src/pages/Home/index.tsx | 8 +- 2 files changed, 92 insertions(+), 94 deletions(-) diff --git a/src/pages/Home/ReceiveModal/ReceiveModal.tsx b/src/pages/Home/ReceiveModal/ReceiveModal.tsx index 4f28d4cd..7d7031f8 100644 --- a/src/pages/Home/ReceiveModal/ReceiveModal.tsx +++ b/src/pages/Home/ReceiveModal/ReceiveModal.tsx @@ -1,19 +1,20 @@ import SwitchTxType, { TxType } from "../SwitchTxType"; import ReceiveOnChain from "./ReceiveOnChain"; +import { Alert } from "@/components/Alert"; import AmountInput from "@/components/AmountInput"; +import { Button } from "@/components/Button"; +import ConfirmModal, { + type Props as ConfirmModalProps, +} from "@/components/ConfirmModal"; import InputField from "@/components/InputField"; import LoadingSpinner from "@/components/LoadingSpinner/LoadingSpinner"; -import Message from "@/components/Message"; import { AppContext, Unit } from "@/context/app-context"; -import ModalDialog from "@/layouts/ModalDialog"; -import { MODAL_ROOT } from "@/utils"; import { checkError } from "@/utils/checkError"; import { convertBtcToSat, stringToNumber } from "@/utils/format"; import { instance } from "@/utils/interceptor"; -import { PlusCircleIcon } from "@heroicons/react/24/outline"; +import { ModalFooter, ModalBody } from "@nextui-org/react"; import type { ChangeEvent, FC } from "react"; import { useContext, useState } from "react"; -import { createPortal } from "react-dom"; import type { SubmitHandler } from "react-hook-form"; import { useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; @@ -23,11 +24,9 @@ interface IFormInputs { commentInput: string; } -type Props = { - onClose: () => void; -}; - -const ReceiveModal: FC = ({ onClose }) => { +const ReceiveModal: FC> = ({ + disclosure, +}) => { const { unit } = useContext(AppContext); const { t } = useTranslation(); const [invoiceType, setInvoiceType] = useState(TxType.LIGHTNING); @@ -103,86 +102,87 @@ const ReceiveModal: FC = ({ onClose }) => { const onSubmit: SubmitHandler = (_data) => generateInvoiceHandler(); - return createPortal( - -
- {showLnInvoice ? t("wallet.create_invoice_ln") : t("wallet.fund")} -
- -
- -
- -
-
- {isLoading && ( -
- -
- )} - - {showLnInvoice && !address && ( -
- - stringToNumber(val) > 0 || - t("forms.validation.chainAmount.required"), - }, - onChange: amountChangeHandler, - })} - errorMessage={errors.amountInput} - /> - -
- -
-
- )} - - {error && } - - {!address && showLnInvoice && ( -
- -
+ return ( + +
+ +
+ + +
+ {isLoading && ( +
+ +
+ )} + + {showLnInvoice && !address && ( +
+ + stringToNumber(val) > 0 || + t("forms.validation.chainAmount.required"), + }, + onChange: amountChangeHandler, + })} + errorMessage={errors.amountInput} + /> + +
+ +
+
+ )} +
+ + {error && {error}} +
+ + {!address && showLnInvoice && ( + + + + )} + + + {address && ( + )} -
- - - {address && ( - - )} -
, - MODAL_ROOT, + + } + /> ); }; diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index fd954062..8c4c8ff2 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -161,8 +161,6 @@ const Home: FC = () => { openModal("OPEN_CHANNEL"); } if (showModal === "SEND") { - console.log("SEND888888"); - openModal("SEND"); } if (showModal === "RECEIVE") { @@ -224,8 +222,9 @@ const Home: FC = () => { /> )} {activeModal === "RECEIVE" && ( - // - <>YO2 + )} {activeModal === "DETAIL" && ( <>YO3 @@ -254,7 +253,6 @@ const Home: FC = () => {
-

{activeModal}

{!btcOnlyMode && (