import { Icon, Loader } from '@vegaprotocol/ui-toolkit'; import type { ReactNode } from 'react'; import type { OrderEvent_busEvents_event_Order } from './__generated__/OrderEvent'; import { formatNumber, t } from '@vegaprotocol/react-helpers'; import type { TransactionState } from '@vegaprotocol/wallet'; import { VegaTxStatus } from '@vegaprotocol/wallet'; interface OrderDialogProps { transaction: TransactionState; finalizedOrder: OrderEvent_busEvents_event_Order | null; } export const OrderDialog = ({ transaction, finalizedOrder, }: OrderDialogProps) => { // TODO: When wallets support confirming transactions return UI for 'awaiting confirmation' step // Rejected by wallet if (transaction.status === VegaTxStatus.Rejected) { return ( } > {transaction.error && (
            {JSON.stringify(transaction.error, null, 2)}
          
)}
); } // Pending consensus if (!finalizedOrder) { return ( } > {transaction.hash && (

{t(`Tx hash: ${transaction.hash}`)}

)}
); } // Order on network but was rejected if (finalizedOrder.status === 'Rejected') { return ( } >

{t(`Reason: ${finalizedOrder.rejectionReason}`)}

); } return ( } >

{t(`Status: ${finalizedOrder.status}`)}

{finalizedOrder.market && (

{t(`Market: {finalizedOrder.market.name}`)}

)}

{t(`Type: ${finalizedOrder.type}`)}

{t(`Amount: ${finalizedOrder.size}`)}

{finalizedOrder.type === 'Limit' && finalizedOrder.market && (

{t( `Price: ${formatNumber( finalizedOrder.price, finalizedOrder.market.decimalPlaces )}` )}

)}
); }; interface OrderDialogWrapperProps { children: ReactNode; icon: ReactNode; title: string; } const OrderDialogWrapper = ({ children, icon, title, }: OrderDialogWrapperProps) => { return (
{icon}

{title}

{children}
); };