import { Icon, Loader } from '@vegaprotocol/ui-toolkit';
import { ReactNode } from 'react';
import {
TransactionState,
VegaTxStatus,
} from '../../hooks/use-vega-transaction';
import { OrderEvent_busEvents_event_Order } from '@vegaprotocol/graphql';
import { formatNumber } from '@vegaprotocol/react-helpers';
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 (
{JSON.stringify(transaction.error, null, 2)})} ); } // Pending consensus if (!finalizedOrder) { return (
Tx hash: {transaction.hash}
)} ); } // Order on network but was rejected if (finalizedOrder.status === 'Rejected') { return (Reason: {finalizedOrder.rejectionReason}
); } return (Status: {finalizedOrder.status}
Market: {finalizedOrder.market.name}
Type: {finalizedOrder.type}
Amount: {finalizedOrder.size}
{finalizedOrder.type === 'Limit' && (Price:{' '} {formatNumber( finalizedOrder.price, finalizedOrder.market.decimalPlaces )}
)} ); }; interface OrderDialogWrapperProps { children: ReactNode; icon: ReactNode; title: string; } const OrderDialogWrapper = ({ children, icon, title, }: OrderDialogWrapperProps) => { return (