import {
ArrowRightOutlined,
CheckCircleOutlined,
CloseOutlined,
LoadingOutlined,
PauseCircleOutlined,
} from '@ant-design/icons'
import { Col, Row, Typography } from 'antd'
import { renderProcessError, renderProcessMessage } from '../../../../services/processRenderer'
import { formatTokenAmount } from '../../../../services/utils'
import { Execution, Step, Token } from '../../../../types'
interface EtherspotStepProps {
stakingStep?: Step
isSwapping: boolean
etherspotStepExecution?: Execution
index: number
previousStepInfo: { token?: Token; amount?: string }
alternativeToToken?: Token
}
export const MinimalEtherspotStep = ({
etherspotStepExecution,
isSwapping,
previousStepInfo,
stakingStep,
alternativeToToken,
}: EtherspotStepProps) => {
const parseEtherspotExecution = () => {
if (!etherspotStepExecution) {
return <>>
}
const isDone = etherspotStepExecution?.status === 'DONE'
const isFailed = etherspotStepExecution?.status === 'FAILED'
const isLoading = isSwapping && etherspotStepExecution?.status === 'PENDING'
const isPaused = !isSwapping && etherspotStepExecution?.status === 'PENDING'
const color = isDone
? 'green'
: isFailed
? 'red'
: etherspotStepExecution.status !== 'DONE'
? 'blue'
: 'gray'
return (
<>
{isLoading ? (
) : isPaused ? (
) : isDone ? (
) : isFailed ? (
) : null}
{' '}
{renderProcessMessage(
etherspotStepExecution.process[etherspotStepExecution.process.length - 1],
)}
{isFailed && (
{renderProcessError(
etherspotStepExecution.process[etherspotStepExecution.process.length - 1],
)}
)}
>
)
}
const parseMinimalEtherspotStep = () => {
return (
{formatTokenAmount(previousStepInfo.token!, previousStepInfo.amount)}{' '}
{' '}
{!!stakingStep
? formatTokenAmount(
alternativeToToken || stakingStep.action.toToken,
stakingStep.estimate.toAmountMin,
)
: 'Loading...'}
{parseEtherspotExecution()}
)
}
return parseMinimalEtherspotStep()
}