import React, { useState } from 'react'; import { format } from 'date-fns'; import { useTranslation } from 'react-i18next'; import { Avatar, Badge, ToggleButton, ToggleButtonGroup, List, ListItem, ListItemText, ListItemIcon, Grid, Tooltip, IconButton, Accordion, AccordionSummary, AccordionDetails, Typography, } from '@mui/material'; import { pn } from '../utils/prettyNumbers'; import { saveAsJson } from '../utils/saveFile'; // Icons import FlagWithProps from './FlagWithProps'; import ScheduleIcon from '@mui/icons-material/Schedule'; import PriceChangeIcon from '@mui/icons-material/PriceChange'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import DownloadIcon from '@mui/icons-material/Download'; import AccountBalanceIcon from '@mui/icons-material/AccountBalance'; import RouteIcon from '@mui/icons-material/Route'; import AccountBoxIcon from '@mui/icons-material/AccountBox'; import LockOpenIcon from '@mui/icons-material/LockOpen'; import LinkIcon from '@mui/icons-material/Link'; import { RoboSatsNoTextIcon, SendReceiveIcon, BitcoinIcon } from './Icons'; interface Item { id: string; name: string; } type Props = { isMaker: boolean; makerNick: string; takerNick: string; currencyCode: string; makerSummary: Record; takerSummary: Record; platformSummary: Record; orderId: number; }; const TradeSummary = ({ isMaker, makerNick, takerNick, currencyCode, makerSummary, takerSummary, platformSummary, orderId, }: Props): JSX.Element => { const { t, i18n } = useTranslation(); const [buttonValue, setButtonValue] = useState(isMaker ? 0 : 2); var userSummary = buttonValue == 0 ? makerSummary : takerSummary; const contractTimestamp = new Date(platformSummary.contract_timestamp); const total_time = platformSummary.contract_total_time; const hours = parseInt(total_time / 3600); const mins = parseInt((total_time - hours * 3600) / 60); const secs = parseInt(total_time - hours * 3600 - mins * 60); return ( }> {t('Trade Summary')}
setButtonValue(0)}>   {t('Maker')} setButtonValue(1)}> setButtonValue(2)}> {t('Taker')}   saveAsJson(`order${orderId}-summary.json`, { order_id: orderId, currency: currencyCode, maker: makerSummary, taker: takerSummary, platform: platformSummary, }) } >
{/* Maker/Taker Summary */}
{userSummary.is_buyer ? ( ) : ( )}
} >
{userSummary.is_swap ? ( ) : null} {t('Unlocked')}} /> {/* Platform Summary */}
); }; export default TradeSummary;