Skip to content

Commit

Permalink
refactor(confirmModal): use explicit export
Browse files Browse the repository at this point in the history
  • Loading branch information
escapedcat committed Oct 1, 2024
1 parent c4335ac commit 21163cf
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 28 deletions.
22 changes: 12 additions & 10 deletions src/components/ConfirmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -47,11 +51,11 @@ const ConfirmModal: ConfirmModalComponent = ({

return (
<>
{headline && <ModalHeader>{headline}</ModalHeader>}
{headline && <ConfirmModalHeader>{headline}</ConfirmModalHeader>}

<ModalBody>{children || props.body}</ModalBody>
<ConfirmModalBody>{children || props.body}</ConfirmModalBody>

<ModalFooter>
<ConfirmModalFooter>
<Button onClick={onClose} disabled={isLoading}>
{cancelText || t("settings.cancel")}
</Button>
Expand All @@ -63,7 +67,7 @@ const ConfirmModal: ConfirmModalComponent = ({
>
{confirmText || t("settings.confirm")}
</Button>
</ModalFooter>
</ConfirmModalFooter>
</>
);
};
Expand All @@ -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;
3 changes: 2 additions & 1 deletion src/pages/Home/ListChannelModal/ListChannelModal.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Home/OpenChannelModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home/ReceiveModal/ReceiveLN.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Home/ReceiveModal/ReceiveModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home/SendModal/ConfirmSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home/SendModal/SendLN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Home/SendModal/SendModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home/SendModal/SendOnChain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home/SendModal/__tests__/ConfirmSend.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Home/UnlockModal.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Settings/ChangePwModal.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Settings/RebootModal.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Settings/ShutdownModal.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Setup/FormatDialog.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Setup/InputPassword.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Setup/MigrationDialog.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Setup/StartDoneDialog.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit 21163cf

Please sign in to comment.