import type { TypographyProps } from '@mui/material' import { Typography } from '@mui/material' import type { OpenOceanStepExtended } from '@openocean.finance/widget-sdk' import { useTranslation } from 'react-i18next' import { getStepFeeCostsBreakdown } from '../../utils/fees.js' export const StepFees: React.FC< TypographyProps & { step: OpenOceanStepExtended } > = ({ step, ...other }) => { const { t } = useTranslation() const isDone = step.execution?.status === 'DONE' const gasCosts = step.execution?.gasCosts ?? step.estimate.gasCosts const feeCosts = step.execution?.feeCosts ?? step.estimate.feeCosts let fees = 0 if (gasCosts) { const { amountUSD } = getStepFeeCostsBreakdown(gasCosts) fees += amountUSD } if (feeCosts) { const filteredfeeCosts = feeCosts?.filter((fee) => !fee.included) if (filteredfeeCosts?.length) { const { amountUSD } = getStepFeeCostsBreakdown(filteredfeeCosts) fees += amountUSD } } return ( {t('format.currency', { value: fees })}{' '} {isDone ? t('main.fees.paid') : t('main.fees.estimated')} ) }