From 21163cf6da4b0408116dbb3f65a451b4fc76a0cf Mon Sep 17 00:00:00 2001 From: escapedcat Date: Tue, 1 Oct 2024 17:09:49 +0200 Subject: [PATCH] refactor(confirmModal): use explicit export --- src/components/ConfirmModal.tsx | 22 ++++++++++--------- .../ListChannelModal/ListChannelModal.tsx | 3 ++- src/pages/Home/OpenChannelModal.tsx | 3 ++- src/pages/Home/ReceiveModal/ReceiveLN.tsx | 2 +- src/pages/Home/ReceiveModal/ReceiveModal.tsx | 3 ++- src/pages/Home/SendModal/ConfirmSend.tsx | 2 +- src/pages/Home/SendModal/SendLN.tsx | 2 +- src/pages/Home/SendModal/SendModal.tsx | 3 ++- src/pages/Home/SendModal/SendOnChain.tsx | 2 +- .../SendModal/__tests__/ConfirmSend.test.tsx | 2 +- .../TransactionDetailModal.tsx | 3 ++- src/pages/Home/UnlockModal.tsx | 3 ++- src/pages/Settings/ChangePwModal.tsx | 2 +- src/pages/Settings/RebootModal.tsx | 2 +- src/pages/Settings/ShutdownModal.tsx | 2 +- src/pages/Setup/FormatDialog.tsx | 2 +- src/pages/Setup/InputPassword.tsx | 2 +- src/pages/Setup/MigrationDialog.tsx | 2 +- src/pages/Setup/StartDoneDialog.tsx | 2 +- 19 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/components/ConfirmModal.tsx b/src/components/ConfirmModal.tsx index 840ffdb8..e00fd73e 100644 --- a/src/components/ConfirmModal.tsx +++ b/src/components/ConfirmModal.tsx @@ -27,7 +27,11 @@ type ConfirmModalComponent = { Footer: typeof ModalFooter; }; -const ConfirmModal: ConfirmModalComponent = ({ +export const ConfirmModalHeader = ModalHeader; +export const ConfirmModalBody = ModalBody; +export const ConfirmModalFooter = ModalFooter; + +export const ConfirmModal: ConfirmModalComponent = ({ disclosure, headline, children, @@ -47,11 +51,11 @@ const ConfirmModal: ConfirmModalComponent = ({ return ( <> - {headline && {headline}} + {headline && {headline}} - {children || props.body} + {children || props.body} - + @@ -63,7 +67,7 @@ const ConfirmModal: ConfirmModalComponent = ({ > {confirmText || t("settings.confirm")} - + ); }; @@ -75,8 +79,6 @@ const ConfirmModal: ConfirmModalComponent = ({ ); }; -ConfirmModal.Header = ModalHeader; -ConfirmModal.Body = ModalBody; -ConfirmModal.Footer = ModalFooter; - -export default ConfirmModal; +ConfirmModal.Header = ConfirmModalHeader; +ConfirmModal.Body = ConfirmModalBody; +ConfirmModal.Footer = ConfirmModalFooter; diff --git a/src/pages/Home/ListChannelModal/ListChannelModal.tsx b/src/pages/Home/ListChannelModal/ListChannelModal.tsx index 75506644..a3b22cef 100644 --- a/src/pages/Home/ListChannelModal/ListChannelModal.tsx +++ b/src/pages/Home/ListChannelModal/ListChannelModal.tsx @@ -1,6 +1,7 @@ import ChannelList from "./ChannelList"; import { Alert } from "@/components/Alert"; -import ConfirmModal, { +import { + ConfirmModal, type Props as ConfirmModalProps, } from "@/components/ConfirmModal"; import Message from "@/components/Message"; diff --git a/src/pages/Home/OpenChannelModal.tsx b/src/pages/Home/OpenChannelModal.tsx index 0116dc7e..8ca68117 100644 --- a/src/pages/Home/OpenChannelModal.tsx +++ b/src/pages/Home/OpenChannelModal.tsx @@ -2,7 +2,8 @@ import { Alert } from "@/components/Alert"; import AmountInput from "@/components/AmountInput"; import AvailableBalance from "@/components/AvailableBalance"; import { Button } from "@/components/Button"; -import ConfirmModal, { +import { + ConfirmModal, type Props as ConfirmModalProps, } from "@/components/ConfirmModal"; import InputField from "@/components/InputField"; diff --git a/src/pages/Home/ReceiveModal/ReceiveLN.tsx b/src/pages/Home/ReceiveModal/ReceiveLN.tsx index 7b791809..3768be6b 100644 --- a/src/pages/Home/ReceiveModal/ReceiveLN.tsx +++ b/src/pages/Home/ReceiveModal/ReceiveLN.tsx @@ -1,7 +1,7 @@ import { Alert } from "@/components/Alert"; import AmountInput from "@/components/AmountInput"; import { Button } from "@/components/Button"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import InputField from "@/components/InputField"; import { stringToNumber } from "@/utils/format"; import type { ChangeEvent, FC } from "react"; diff --git a/src/pages/Home/ReceiveModal/ReceiveModal.tsx b/src/pages/Home/ReceiveModal/ReceiveModal.tsx index 02f1ee36..6c792f6d 100644 --- a/src/pages/Home/ReceiveModal/ReceiveModal.tsx +++ b/src/pages/Home/ReceiveModal/ReceiveModal.tsx @@ -2,7 +2,8 @@ import { TxType } from "../SwitchTxType"; import QRCode from "./QRCode"; import ReceiveLN, { type IFormInputs } from "./ReceiveLN"; import { Alert } from "@/components/Alert"; -import ConfirmModal, { +import { + ConfirmModal, type Props as ConfirmModalProps, } from "@/components/ConfirmModal"; import { AppContext, Unit } from "@/context/app-context"; diff --git a/src/pages/Home/SendModal/ConfirmSend.tsx b/src/pages/Home/SendModal/ConfirmSend.tsx index a10d7b9a..44fe8eca 100644 --- a/src/pages/Home/SendModal/ConfirmSend.tsx +++ b/src/pages/Home/SendModal/ConfirmSend.tsx @@ -4,7 +4,7 @@ import { SendOnChainForm } from "./SendOnChain"; import { Alert } from "@/components/Alert"; import AmountInput from "@/components/AmountInput"; import { Button } from "@/components/Button"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import { AppContext, Unit } from "@/context/app-context"; import { checkError } from "@/utils/checkError"; import { diff --git a/src/pages/Home/SendModal/SendLN.tsx b/src/pages/Home/SendModal/SendLN.tsx index 0a399cd9..60344dd6 100644 --- a/src/pages/Home/SendModal/SendLN.tsx +++ b/src/pages/Home/SendModal/SendLN.tsx @@ -4,7 +4,7 @@ import { SendOnChainForm } from "./SendOnChain"; import { Alert } from "@/components/Alert"; import AvailableBalance from "@/components/AvailableBalance"; import { Button } from "@/components/Button"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import InputField from "@/components/InputField"; import { convertMSatToSat } from "@/utils/format"; import { FC, useState } from "react"; diff --git a/src/pages/Home/SendModal/SendModal.tsx b/src/pages/Home/SendModal/SendModal.tsx index c8448272..ccd04fa4 100644 --- a/src/pages/Home/SendModal/SendModal.tsx +++ b/src/pages/Home/SendModal/SendModal.tsx @@ -2,7 +2,8 @@ import { TxType } from "../SwitchTxType"; import ConfirmSend from "./ConfirmSend"; import SendLn, { LnInvoiceForm } from "./SendLN"; import SendOnChain, { SendOnChainForm } from "./SendOnChain"; -import ConfirmModal, { +import { + ConfirmModal, type Props as ConfirmModalProps, } from "@/components/ConfirmModal"; import { DecodePayRequest } from "@/models/decode-pay-req"; diff --git a/src/pages/Home/SendModal/SendOnChain.tsx b/src/pages/Home/SendModal/SendOnChain.tsx index 8ec54bb3..96d5294f 100644 --- a/src/pages/Home/SendModal/SendOnChain.tsx +++ b/src/pages/Home/SendModal/SendOnChain.tsx @@ -3,7 +3,7 @@ import { SendLnForm } from "./SendModal"; import AmountInput from "@/components/AmountInput"; import AvailableBalance from "@/components/AvailableBalance"; import { Button } from "@/components/Button"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import InputField from "@/components/InputField"; import { stringToNumber } from "@/utils/format"; import { ChangeEvent, FC, useState } from "react"; diff --git a/src/pages/Home/SendModal/__tests__/ConfirmSend.test.tsx b/src/pages/Home/SendModal/__tests__/ConfirmSend.test.tsx index ea255466..35b1d7ab 100644 --- a/src/pages/Home/SendModal/__tests__/ConfirmSend.test.tsx +++ b/src/pages/Home/SendModal/__tests__/ConfirmSend.test.tsx @@ -3,7 +3,7 @@ import type { Props } from "../ConfirmSend"; import ConfirmSend from "../ConfirmSend"; import { SendLnForm } from "../SendModal"; import type { SendOnChainForm } from "../SendOnChain"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import { http, server, HttpResponse } from "@/testServer"; import userEvent from "@testing-library/user-event"; import { render, screen, waitFor, mockedDisclosure } from "test-utils"; diff --git a/src/pages/Home/TransactionCard/TransactionDetailModal/TransactionDetailModal.tsx b/src/pages/Home/TransactionCard/TransactionDetailModal/TransactionDetailModal.tsx index 805db296..3574f999 100644 --- a/src/pages/Home/TransactionCard/TransactionDetailModal/TransactionDetailModal.tsx +++ b/src/pages/Home/TransactionCard/TransactionDetailModal/TransactionDetailModal.tsx @@ -1,6 +1,7 @@ import LNDetails from "./LNDetails"; import OnchainDetails from "./OnchainDetails"; -import ConfirmModal, { +import { + ConfirmModal, type Props as ConfirmModalProps, } from "@/components/ConfirmModal"; import { Transaction } from "@/models/transaction.model"; diff --git a/src/pages/Home/UnlockModal.tsx b/src/pages/Home/UnlockModal.tsx index 2caf304e..28a0a98d 100644 --- a/src/pages/Home/UnlockModal.tsx +++ b/src/pages/Home/UnlockModal.tsx @@ -1,7 +1,8 @@ import { Alert } from "@/components/Alert"; import { Button } from "@/components/Button"; import CapsLockWarning from "@/components/CapsLockWarning"; -import ConfirmModal, { +import { + ConfirmModal, type Props as ConfirmModalProps, } from "@/components/ConfirmModal"; import InputField from "@/components/InputField"; diff --git a/src/pages/Settings/ChangePwModal.tsx b/src/pages/Settings/ChangePwModal.tsx index cdc2c193..2ef4cb09 100644 --- a/src/pages/Settings/ChangePwModal.tsx +++ b/src/pages/Settings/ChangePwModal.tsx @@ -1,7 +1,7 @@ import ActionBox from "./ActionBox"; import { Button } from "@/components/Button"; import CapsLockWarning from "@/components/CapsLockWarning"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import useCapsLock from "@/hooks/use-caps-lock"; import { checkError } from "@/utils/checkError"; import { instance } from "@/utils/interceptor"; diff --git a/src/pages/Settings/RebootModal.tsx b/src/pages/Settings/RebootModal.tsx index ef588603..07aa2ad4 100644 --- a/src/pages/Settings/RebootModal.tsx +++ b/src/pages/Settings/RebootModal.tsx @@ -1,5 +1,5 @@ import ActionBox from "./ActionBox"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import { AppContext } from "@/context/app-context"; import { instance } from "@/utils/interceptor"; import { useDisclosure } from "@nextui-org/react"; diff --git a/src/pages/Settings/ShutdownModal.tsx b/src/pages/Settings/ShutdownModal.tsx index 97e3e114..1574d4f3 100644 --- a/src/pages/Settings/ShutdownModal.tsx +++ b/src/pages/Settings/ShutdownModal.tsx @@ -1,5 +1,5 @@ import ActionBox from "./ActionBox"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import { AppContext } from "@/context/app-context"; import { instance } from "@/utils/interceptor"; import { useDisclosure } from "@nextui-org/react"; diff --git a/src/pages/Setup/FormatDialog.tsx b/src/pages/Setup/FormatDialog.tsx index 77841cb3..bf6a211a 100644 --- a/src/pages/Setup/FormatDialog.tsx +++ b/src/pages/Setup/FormatDialog.tsx @@ -1,6 +1,6 @@ import { Alert } from "@/components/Alert"; import { Button } from "@/components/Button"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import { Headline } from "@/components/Headline"; import SetupContainer from "@/layouts/SetupContainer"; import { Checkbox, useDisclosure } from "@nextui-org/react"; diff --git a/src/pages/Setup/InputPassword.tsx b/src/pages/Setup/InputPassword.tsx index ded02e62..ccf0a612 100644 --- a/src/pages/Setup/InputPassword.tsx +++ b/src/pages/Setup/InputPassword.tsx @@ -1,5 +1,5 @@ import { Button } from "@/components/Button"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import { Headline } from "@/components/Headline"; import SetupContainer from "@/layouts/SetupContainer"; import { Input, useDisclosure } from "@nextui-org/react"; diff --git a/src/pages/Setup/MigrationDialog.tsx b/src/pages/Setup/MigrationDialog.tsx index bce7e4d8..424a7cfe 100644 --- a/src/pages/Setup/MigrationDialog.tsx +++ b/src/pages/Setup/MigrationDialog.tsx @@ -1,6 +1,6 @@ import { Alert } from "@/components/Alert"; import { Button } from "@/components/Button"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import { Headline } from "@/components/Headline"; import SetupContainer from "@/layouts/SetupContainer"; import { SetupMigrationMode, SetupMigrationOS } from "@/models/setup.model"; diff --git a/src/pages/Setup/StartDoneDialog.tsx b/src/pages/Setup/StartDoneDialog.tsx index f0915cab..06edf82b 100644 --- a/src/pages/Setup/StartDoneDialog.tsx +++ b/src/pages/Setup/StartDoneDialog.tsx @@ -1,5 +1,5 @@ import { Button } from "@/components/Button"; -import ConfirmModal from "@/components/ConfirmModal"; +import { ConfirmModal } from "@/components/ConfirmModal"; import { Headline } from "@/components/Headline"; import SetupContainer from "@/layouts/SetupContainer"; import { SetupPhase } from "@/models/setup.model";