fix(trading): order stopped misleading message (#4455)
This commit is contained in:
parent
45283161aa
commit
fde49e5446
@ -7,6 +7,7 @@ import {
|
||||
} from './utils';
|
||||
import * as Types from '@vegaprotocol/types';
|
||||
|
||||
describe('WithdrawalsTable', () => {
|
||||
describe('getOrderToastTitle', () => {
|
||||
it('should return the correct title', () => {
|
||||
expect(getOrderToastTitle(Types.OrderStatus.STATUS_ACTIVE)).toBe(
|
||||
@ -15,9 +16,9 @@ describe('getOrderToastTitle', () => {
|
||||
expect(getOrderToastTitle(Types.OrderStatus.STATUS_FILLED)).toBe(
|
||||
'Order filled'
|
||||
);
|
||||
expect(getOrderToastTitle(Types.OrderStatus.STATUS_PARTIALLY_FILLED)).toBe(
|
||||
'Order partially filled'
|
||||
);
|
||||
expect(
|
||||
getOrderToastTitle(Types.OrderStatus.STATUS_PARTIALLY_FILLED)
|
||||
).toBe('Order partially filled');
|
||||
expect(getOrderToastTitle(Types.OrderStatus.STATUS_PARKED)).toBe(
|
||||
'Order parked'
|
||||
);
|
||||
@ -45,14 +46,14 @@ describe('getOrderToastIntent', () => {
|
||||
expect(getOrderToastIntent(Types.OrderStatus.STATUS_EXPIRED)).toBe(
|
||||
Intent.Warning
|
||||
);
|
||||
expect(getOrderToastIntent(Types.OrderStatus.STATUS_PARTIALLY_FILLED)).toBe(
|
||||
Intent.Warning
|
||||
);
|
||||
expect(
|
||||
getOrderToastIntent(Types.OrderStatus.STATUS_PARTIALLY_FILLED)
|
||||
).toBe(Intent.Warning);
|
||||
expect(getOrderToastIntent(Types.OrderStatus.STATUS_REJECTED)).toBe(
|
||||
Intent.Danger
|
||||
);
|
||||
expect(getOrderToastIntent(Types.OrderStatus.STATUS_STOPPED)).toBe(
|
||||
Intent.Danger
|
||||
Intent.Warning
|
||||
);
|
||||
expect(getOrderToastIntent(Types.OrderStatus.STATUS_FILLED)).toBe(
|
||||
Intent.Success
|
||||
@ -127,3 +128,4 @@ describe('timeInForceLabel', () => {
|
||||
expect(timeInForceLabel('')).toBe('');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -36,7 +36,7 @@ export const getRejectionReason = (
|
||||
default:
|
||||
return order.rejectionReason
|
||||
? t(Schema.OrderRejectionReasonMapping[order.rejectionReason])
|
||||
: null;
|
||||
: '';
|
||||
}
|
||||
};
|
||||
|
||||
@ -79,9 +79,9 @@ export const getOrderToastIntent = (
|
||||
case Schema.OrderStatus.STATUS_PARKED:
|
||||
case Schema.OrderStatus.STATUS_EXPIRED:
|
||||
case Schema.OrderStatus.STATUS_PARTIALLY_FILLED:
|
||||
case Schema.OrderStatus.STATUS_STOPPED:
|
||||
return Intent.Warning;
|
||||
case Schema.OrderStatus.STATUS_REJECTED:
|
||||
case Schema.OrderStatus.STATUS_STOPPED:
|
||||
return Intent.Danger;
|
||||
case Schema.OrderStatus.STATUS_FILLED:
|
||||
case Schema.OrderStatus.STATUS_ACTIVE:
|
||||
|
@ -52,6 +52,7 @@ import type { Side } from '@vegaprotocol/types';
|
||||
import { OrderStatusMapping } from '@vegaprotocol/types';
|
||||
import { Size } from '@vegaprotocol/datagrid';
|
||||
import { useWithdrawalApprovalDialog } from './withdrawal-approval-dialog';
|
||||
import * as Schema from '@vegaprotocol/types';
|
||||
|
||||
const intentMap: { [s in VegaTxStatus]: Intent } = {
|
||||
Default: Intent.Primary,
|
||||
@ -508,17 +509,27 @@ const VegaTxCompleteToastsContent = ({ tx }: VegaTxToastContentProps) => {
|
||||
}
|
||||
|
||||
if (tx.order && tx.order.rejectionReason) {
|
||||
const rejectionReason =
|
||||
getRejectionReason(tx.order) || tx.order.rejectionReason || '';
|
||||
const rejectionReason = getRejectionReason(tx.order);
|
||||
return (
|
||||
<>
|
||||
<ToastHeading>{getOrderToastTitle(tx.order.status)}</ToastHeading>
|
||||
{rejectionReason ? (
|
||||
<p>
|
||||
{t('Your order has been rejected because: %s', [rejectionReason])}
|
||||
{t('Your order has been %s because: %s', [
|
||||
tx.order.status === Schema.OrderStatus.STATUS_STOPPED
|
||||
? 'stopped'
|
||||
: 'rejected',
|
||||
rejectionReason,
|
||||
])}
|
||||
</p>
|
||||
) : (
|
||||
<p>{t('Your order has been rejected.')}</p>
|
||||
<p>
|
||||
{t('Your order has been %s.', [
|
||||
tx.order.status === Schema.OrderStatus.STATUS_STOPPED
|
||||
? 'stopped'
|
||||
: 'rejected',
|
||||
])}
|
||||
</p>
|
||||
)}
|
||||
{tx.txHash && (
|
||||
<p className="break-all">
|
||||
|
@ -18,6 +18,7 @@ const generateJsx = (props: TypedDataAgGrid<WithdrawalFieldsFragment>) => (
|
||||
</MockedProvider>
|
||||
);
|
||||
|
||||
describe('Withdrawals', () => {
|
||||
describe('renders the correct columns', () => {
|
||||
it('incomplete withdrawal', async () => {
|
||||
const withdrawal = generateWithdrawal();
|
||||
@ -69,7 +70,9 @@ describe('renders the correct columns', () => {
|
||||
'1.00',
|
||||
'123456…123456',
|
||||
getTimeFormat().format(new Date(withdrawal.createdTimestamp as string)),
|
||||
getTimeFormat().format(new Date(withdrawal.withdrawnTimestamp as string)),
|
||||
getTimeFormat().format(
|
||||
new Date(withdrawal.withdrawnTimestamp as string)
|
||||
),
|
||||
'Completed',
|
||||
'0x1234…121314',
|
||||
];
|
||||
@ -124,3 +127,4 @@ describe('StatusCell', () => {
|
||||
expect(screen.getByText('Rejected')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user