import { SvgDelete1 } from '@chainlink/blocks-icons' import { Button, ButtonSet } from '../Button' import { Typography } from '../Typography' import { ProgressBar } from './ProgressBar' import { Transactions } from './Transactions' import type { TransactionModalState } from './types' const shouldShowCloseButton = ({ isInescapable, isCloseHidden, isTransactionComplete, isError, }: { isInescapable: boolean isCloseHidden: boolean isTransactionComplete: boolean isError: boolean }) => { if (isTransactionComplete || isError) { return true } if (isInescapable || isCloseHidden) { return false } return true } type Props = { state: TransactionModalState networkExplorerTxUrl?: string contextId: string stepId: string onSuccessClick: VoidFunction onCloseClick: VoidFunction isInescapable?: boolean } export const TransactionalModalTemplate = ({ state, networkExplorerTxUrl, contextId, stepId, onSuccessClick, onCloseClick, isInescapable = false, }: Props) => { const showCloseButton = shouldShowCloseButton({ isInescapable, isCloseHidden: state.steps[state.currentStepIndex]?.isCloseHidden || false, isTransactionComplete: state.isTransactionComplete, isError: Boolean(state.error), }) const heading = state.isTransactionComplete ? state.successHeading : state.steps[state.currentStepIndex]?.label const description = state.isTransactionComplete ? state.successBody : state.steps[state.currentStepIndex]?.description return (