Skip to content

Commit

Permalink
Simplify the structure of modals
Browse files Browse the repository at this point in the history
After separating the `content` directory for modals, there was a problem with cycle dependencies. Therefore, all files were moved to a higher directory. This solves the problem with dependencies. In addition, it simplifies the directory structure. However, if we find a new approach in the near future we can easily update it.
  • Loading branch information
kkosiorowska committed Apr 8, 2024
1 parent fdafbfd commit 541229d
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ import {
import { ACTION_FLOW_TYPES, ActionFlowType } from "#/types"
import { TokenAmountFormValues } from "#/components/shared/TokenAmountForm/TokenAmountFormBase"
import { logPromiseFailure } from "#/utils"
import StakeFormModal from "../ActiveStakingStep/StakeFormModal"
import UnstakeFormModal from "../ActiveUnstakingStep/UnstakeFormModal"
import StakeFormModal from "./ActiveStakingStep/StakeFormModal"
import UnstakeFormModal from "./ActiveUnstakingStep/UnstakeFormModal"

const TABS = Object.values(ACTION_FLOW_TYPES)

export function ActionFormModal({
defaultType,
}: {
defaultType: ActionFlowType
}) {
function ActionFormModal({ defaultType }: { defaultType: ActionFlowType }) {
const { btcAccount, ethAccount } = useWalletContext()
const { type, setType } = useModalFlowContext()
const { setTokenAmount } = useTransactionContext()
Expand Down Expand Up @@ -103,3 +99,5 @@ export function ActionFormModal({
</>
)
}

export default ActionFormModal
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PROCESS_STATUSES } from "#/types"
import { logPromiseFailure } from "#/utils"
import ServerErrorModal from "./ServerErrorModal"
import RetryModal from "./RetryModal"
import { LoadingModal } from "../../content"
import LoadingModal from "../../LoadingModal"

export default function StakingErrorModal() {
const { setStatus } = useModalFlowContext()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react"
import { ActionFlowType } from "#/types"
import StakingErrorModal from "../ActiveStakingStep/StakingErrorModal"
import StakingErrorModal from "./ActiveStakingStep/StakingErrorModal"

export function ErrorModal({ type }: { type: ActionFlowType }) {
export default function ErrorModal({ type }: { type: ActionFlowType }) {
if (type === "stake") return <StakingErrorModal />
// TODO: Handle the case of unstake action
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ModalBody, ModalHeader, VStack } from "@chakra-ui/react"
import Spinner from "#/components/shared/Spinner"
import Skeleton from "#/components/shared/Skeleton"

export function LoadingModal() {
export default function LoadingModal() {
return (
<>
<ModalHeader>Loading...</ModalHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type MissingAccountModalProps = {
requestAccount: (...params: RequestAccountParams) => Promise<void>
}

export function MissingAccountModal({
export default function MissingAccountModal({
currency,
icon,
requestAccount,
Expand Down
14 changes: 6 additions & 8 deletions dapp/src/components/TransactionModal/ModalContentWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import {
import { BitcoinIcon, EthereumIcon } from "#/assets/icons"
import { ActionFlowType, PROCESS_STATUSES } from "#/types"
import { isSupportedBTCAddressType } from "#/utils"
import {
MissingAccountModal,
ActionFormModal,
ResumeModal,
LoadingModal,
SuccessModal,
ErrorModal,
} from "./content"
import ActionFormModal from "./ActionFormModal"
import ErrorModal from "./ErrorModal"
import LoadingModal from "./LoadingModal"
import MissingAccountModal from "./MissingAccountModal"
import ResumeModal from "./ResumeModal"
import SuccessModal from "./SuccessModal"

export default function ModalContentWrapper({
defaultType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Spinner from "#/components/shared/Spinner"
import { PauseIcon } from "#/assets/icons"
import { TextMd } from "#/components/shared/Typography"

export function ResumeModal({
export default function ResumeModal({
onResume,
onClose,
}: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type SuccessModalProps = {
tokenAmount: TokenAmount
}

export function SuccessModal({ type, tokenAmount }: SuccessModalProps) {
export default function SuccessModal({ type, tokenAmount }: SuccessModalProps) {
const { onClose } = useModalFlowContext()

return (
Expand Down
6 changes: 0 additions & 6 deletions dapp/src/components/TransactionModal/content/index.tsx

This file was deleted.

0 comments on commit 541229d

Please sign in to comment.