diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-status.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-status.tsx deleted file mode 100644 index 08b92e48b..000000000 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-status.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import { useCallback, useMemo } from 'react'; -import type { ReactNode } from 'react'; -import type { VegaTxState } from '@vegaprotocol/wallet'; -import { - WalletError, - useVegaWallet, - useVegaWalletDialogStore, - ClientErrors, -} from '@vegaprotocol/wallet'; -import * as Schema from '@vegaprotocol/types'; -import { Button, Icon, Intent } from '@vegaprotocol/ui-toolkit'; -import { t } from '@vegaprotocol/react-helpers'; - -interface ErrorContentProps { - transaction: VegaTxState; - reset: () => void; -} - -export const ErrorContent = ({ transaction, reset }: ErrorContentProps) => { - const { openVegaWalletDialog } = useVegaWalletDialogStore((store) => ({ - openVegaWalletDialog: store.openVegaWalletDialog, - })); - const { disconnect } = useVegaWallet(); - const reconnect = useCallback(async () => { - reset(); - await disconnect(); - openVegaWalletDialog(); - }, [reset, disconnect, openVegaWalletDialog]); - return useMemo(() => { - const { error } = transaction; - if (error) { - if ( - error instanceof WalletError && - error.code === ClientErrors.NO_SERVICE.code - ) { - return ( - - ); - } - return ( -

- {error.message}{' '} - {error instanceof WalletError ? `: ${error.data}` : null} -

- ); - } - return null; - }, [transaction, reconnect]); -}; - -export const getOrderDialogTitle = ( - status?: Schema.OrderStatus -): string | undefined => { - if (!status) { - return; - } - - switch (status) { - case Schema.OrderStatus.STATUS_ACTIVE: - return t('Order submitted'); - case Schema.OrderStatus.STATUS_FILLED: - return t('Order filled'); - case Schema.OrderStatus.STATUS_PARTIALLY_FILLED: - return t('Order partially filled'); - case Schema.OrderStatus.STATUS_PARKED: - return t('Order parked'); - case Schema.OrderStatus.STATUS_STOPPED: - return t('Order stopped'); - case Schema.OrderStatus.STATUS_CANCELLED: - return t('Order cancelled'); - case Schema.OrderStatus.STATUS_EXPIRED: - return t('Order expired'); - case Schema.OrderStatus.STATUS_REJECTED: - return t('Order rejected'); - default: - return t('Submission failed'); - } -}; - -export const getOrderDialogIntent = ( - status?: Schema.OrderStatus -): Intent | undefined => { - if (!status) { - return; - } - switch (status) { - case Schema.OrderStatus.STATUS_PARKED: - case Schema.OrderStatus.STATUS_EXPIRED: - case Schema.OrderStatus.STATUS_PARTIALLY_FILLED: - return Intent.Warning; - case Schema.OrderStatus.STATUS_REJECTED: - case Schema.OrderStatus.STATUS_STOPPED: - case Schema.OrderStatus.STATUS_CANCELLED: - return Intent.Danger; - case Schema.OrderStatus.STATUS_FILLED: - case Schema.OrderStatus.STATUS_ACTIVE: - return Intent.Success; - default: - return; - } -}; - -export const getOrderDialogIcon = ( - status?: Schema.OrderStatus -): ReactNode | undefined => { - if (!status) { - return; - } - - switch (status) { - case Schema.OrderStatus.STATUS_PARKED: - case Schema.OrderStatus.STATUS_EXPIRED: - return ; - case Schema.OrderStatus.STATUS_REJECTED: - case Schema.OrderStatus.STATUS_STOPPED: - case Schema.OrderStatus.STATUS_CANCELLED: - return ; - default: - return; - } -}; diff --git a/libs/deal-ticket/src/components/deal-ticket/index.ts b/libs/deal-ticket/src/components/deal-ticket/index.ts index fb8b9481b..e28d29132 100644 --- a/libs/deal-ticket/src/components/deal-ticket/index.ts +++ b/libs/deal-ticket/src/components/deal-ticket/index.ts @@ -1,7 +1,6 @@ export * from './deal-ticket-amount'; export * from './deal-ticket-container'; export * from './deal-ticket-limit-amount'; -export * from './deal-ticket-status'; export * from './deal-ticket-market-amount'; export * from './deal-ticket'; export * from './expiry-selector'; diff --git a/libs/positions/src/lib/positions-manager.tsx b/libs/positions/src/lib/positions-manager.tsx index 69ed43ca0..40ee9d37d 100644 --- a/libs/positions/src/lib/positions-manager.tsx +++ b/libs/positions/src/lib/positions-manager.tsx @@ -1,9 +1,8 @@ import { useRef } from 'react'; -import { AsyncRenderer, Icon, Intent } from '@vegaprotocol/ui-toolkit'; +import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { usePositionsData, PositionsTable } from '../'; import type { AgGridReact } from 'ag-grid-react'; import * as Schema from '@vegaprotocol/types'; -import type { TransactionResult } from '@vegaprotocol/wallet'; import { useVegaTransactionStore } from '@vegaprotocol/wallet'; import { t } from '@vegaprotocol/react-helpers'; @@ -60,43 +59,3 @@ export const PositionsManager = ({ partyId }: PositionsManagerProps) => { ); }; - -export const getDialogIntent = (transactionResult?: TransactionResult) => { - if (!transactionResult) { - return; - } - - if ( - transactionResult && - 'error' in transactionResult && - transactionResult.error - ) { - return Intent.Danger; - } - - return Intent.Success; -}; - -export const getDialogIcon = (transactionResult?: TransactionResult) => { - if (!transactionResult) { - return; - } - - if (transactionResult.status) { - return ; - } - - return ; -}; - -export const getDialogTitle = (transactionResult?: TransactionResult) => { - if (!transactionResult) { - return; - } - - if (transactionResult.status) { - return t('Position closed'); - } - - return t('Position not closed'); -};