@alphapoint/apex-web 5.7.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apex.integration.test.js +435 -0
- package/lib/apex.js +37 -1
- package/lib/apex.test.js +138 -0
- package/lib/components/2FA/PasskeyOption.js +126 -0
- package/lib/components/2FA/TwoFactorAuthComponent.js +24 -5
- package/lib/components/2FA/TwoFactorAuthComponent.test.js +94 -0
- package/lib/components/2FA/TwoFactorAuthContainer.js +94 -16
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +412 -0
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.js +34 -6
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.test.js +298 -0
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalComponent.js +26 -4
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalContainer.js +4 -1
- package/lib/components/EnableTwoFactorAuth/Disable2FAForm.js +22 -7
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.js +15 -5
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.test.js +460 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAModalContainer.js +108 -16
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +3 -2
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.css +13 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.js +246 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.test.js +521 -0
- package/lib/components/Login/LoginFormComponent.js +1 -1
- package/lib/components/OrderEntryComponents/advancedForm/AdvancedOrderFormContainer.js +2 -0
- package/lib/components/OrderEntryComponents/common/FormAmountFields.js +5 -0
- package/lib/components/OrderEntryComponents/common/TwapScheduleFields.js +98 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.js +86 -39
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.test.js +326 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryContainer.js +10 -2
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.test.js +99 -0
- package/lib/components/OrderHistoryComponents/InactiveOrders/InactiveOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/OpenOrders/OpenOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.test.js +113 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.css +108 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.test.js +983 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCardComponent.js +500 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/index.js +9 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +4 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +29 -17
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.test.js +135 -0
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +23 -1
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthForm.test.js +475 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormComponent.js +26 -5
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormContainer.js +50 -32
- package/lib/components/common/APAutoTabInput/APAutoTabInput.js +5 -2
- package/lib/components/common/APSelect/APSelect.js +3 -1
- package/lib/config/CONFIG.md +4 -0
- package/lib/config/configDefault.json +2 -1
- package/lib/constants/sendOrder/orderEntryFormConstants.js +23 -4
- package/lib/constants/sendOrder/timeInForceConstants.js +3 -1
- package/lib/constants/sendOrder/twapRejectReasons.js +26 -0
- package/lib/helpers/orderHistoryHelper.js +13 -1
- package/lib/helpers/orderHistoryHelper.test.js +58 -13
- package/lib/helpers/passkeyApi.js +228 -0
- package/lib/helpers/passkeyApi.test.js +171 -0
- package/lib/helpers/placeOrderHelper.js +76 -61
- package/lib/helpers/placeOrderHelper.test.js +169 -10
- package/lib/helpers/recalculateOrderHelper.js +4 -1
- package/lib/helpers/recalculateOrderHelper.test.js +88 -2
- package/lib/helpers/twapOrderHelper.js +265 -0
- package/lib/helpers/twapOrderHelper.test.js +467 -0
- package/lib/helpers/webauthnHelper.js +300 -0
- package/lib/helpers/webauthnHelper.test.js +199 -0
- package/lib/hocs/withOneSubmission.js +168 -0
- package/lib/redux/actions/apiActions.js +52 -1
- package/lib/redux/actions/apiActions.test.js +135 -0
- package/lib/redux/actions/authActions.js +514 -198
- package/lib/redux/actions/authActions.test.js +627 -47
- package/lib/redux/actions/depositActions.js +1 -1
- package/lib/redux/actions/depositActions.test.js +100 -30
- package/lib/redux/actions/fusionAuthActions.test.js +265 -84
- package/lib/redux/actions/modalActions.js +1 -0
- package/lib/redux/actions/orderEntryActions.blockTrade.test.js +306 -0
- package/lib/redux/actions/orderEntryActions.js +74 -22
- package/lib/redux/actions/orderEntryActions.test.js +63 -11
- package/lib/redux/actions/orderHistoryActions.js +9 -4
- package/lib/redux/actions/orderHistoryActions.test.js +63 -0
- package/lib/redux/actions/userActions.js +314 -177
- package/lib/redux/actions/userActions.test.js +844 -268
- package/lib/redux/margin/actions/marginActions.js +6 -3
- package/lib/redux/margin/actions/marginActions.test.js +166 -0
- package/lib/redux/middlewares/authMiddleware.js +5 -0
- package/lib/redux/middlewares/authMiddleware.test.js +88 -29
- package/lib/redux/reducers/authReducer.js +1 -0
- package/lib/redux/reducers/authReducer.test.js +38 -0
- package/lib/redux/selectors/orderEntrySelector.js +19 -8
- package/lib/redux/selectors/orderEntrySelector.test.js +209 -0
- package/lib/redux/selectors/orderTotalSelector.test.js +40 -1
- package/lib/services/fms/fms.js +2 -0
- package/lib/services/fms/fms.test.js +35 -0
- package/package.json +4 -4
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _reactRedux = require("react-redux");
|
|
4
|
+
var _orderEntryActions = require("../../redux/actions/orderEntryActions");
|
|
5
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
6
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
7
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
8
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
9
|
+
jest.mock('react-redux', function () {
|
|
10
|
+
return {
|
|
11
|
+
connect: jest.fn(function () {
|
|
12
|
+
return function (Component) {
|
|
13
|
+
return Component;
|
|
14
|
+
};
|
|
15
|
+
})
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
jest.mock('./ConfirmBlockTradeModalComponent', function () {
|
|
19
|
+
return 'ConfirmBlockTradeModalComponent';
|
|
20
|
+
});
|
|
21
|
+
jest.mock('../../hocs/modalDecorator', function () {
|
|
22
|
+
return jest.fn(function () {
|
|
23
|
+
return function (Component) {
|
|
24
|
+
return Component;
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
jest.mock('../../redux/actions/modalActions', function () {
|
|
29
|
+
return {
|
|
30
|
+
MODAL_TYPES: {
|
|
31
|
+
CONFIRM_BLOCK_REPORT: 'CONFIRM_BLOCK_REPORT'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
jest.mock('../../redux/actions/orderEntryActions', function () {
|
|
36
|
+
return {
|
|
37
|
+
ORDER_SUBMIT_FAILED: 'ORDER_SUBMIT_FAILED',
|
|
38
|
+
placeOrder: jest.fn(),
|
|
39
|
+
clearOrderForm: jest.fn(function () {
|
|
40
|
+
return {
|
|
41
|
+
type: 'CLEAR_ORDER_FORM'
|
|
42
|
+
};
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
jest.mock('../../redux/actions/snackbarActions', function () {
|
|
47
|
+
return {
|
|
48
|
+
showSnack: jest.fn(function (payload) {
|
|
49
|
+
return {
|
|
50
|
+
type: 'ADD_SNACK',
|
|
51
|
+
payload: payload
|
|
52
|
+
};
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
jest.mock('../../redux/selectors/orderEntrySelector', function () {
|
|
57
|
+
return {
|
|
58
|
+
orderTotalSelector: jest.fn()
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
jest.mock('../../redux/selectors/instrumentPositionSelectors', function () {
|
|
62
|
+
return {
|
|
63
|
+
selectedInstrumentSelector: jest.fn()
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Importing the container registers the connect() call we read mapDispatchToProps back out of.
|
|
68
|
+
require('./ConfirmBlockTradeModalContainer');
|
|
69
|
+
var mapDispatchToProps = _reactRedux.connect.mock.calls[0][1];
|
|
70
|
+
describe('ConfirmBlockTradeModalContainer confirmReport', function () {
|
|
71
|
+
var dispatch;
|
|
72
|
+
var confirmReport;
|
|
73
|
+
beforeEach(function () {
|
|
74
|
+
jest.clearAllMocks();
|
|
75
|
+
jest.spyOn(console, 'error').mockImplementation(function () {});
|
|
76
|
+
dispatch = jest.fn(function (action) {
|
|
77
|
+
return action;
|
|
78
|
+
});
|
|
79
|
+
confirmReport = mapDispatchToProps(dispatch, {
|
|
80
|
+
useNewForm: false
|
|
81
|
+
}).confirmReport;
|
|
82
|
+
});
|
|
83
|
+
afterEach(function () {
|
|
84
|
+
console.error.mockRestore();
|
|
85
|
+
});
|
|
86
|
+
var resolvePlaceOrderWith = function resolvePlaceOrderWith(result) {
|
|
87
|
+
return _orderEntryActions.placeOrder.mockReturnValue(Promise.resolve(result));
|
|
88
|
+
};
|
|
89
|
+
it('clears the form when the block trade is accepted', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
90
|
+
return _regenerator().w(function (_context) {
|
|
91
|
+
while (1) switch (_context.n) {
|
|
92
|
+
case 0:
|
|
93
|
+
resolvePlaceOrderWith({
|
|
94
|
+
status: 'Accepted'
|
|
95
|
+
});
|
|
96
|
+
_context.n = 1;
|
|
97
|
+
return confirmReport({});
|
|
98
|
+
case 1:
|
|
99
|
+
expect(_orderEntryActions.clearOrderForm).toHaveBeenCalledWith('reportBlockTrade');
|
|
100
|
+
case 2:
|
|
101
|
+
return _context.a(2);
|
|
102
|
+
}
|
|
103
|
+
}, _callee);
|
|
104
|
+
})));
|
|
105
|
+
it('shows the rejection detail when the server rejects the block trade', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
106
|
+
return _regenerator().w(function (_context2) {
|
|
107
|
+
while (1) switch (_context2.n) {
|
|
108
|
+
case 0:
|
|
109
|
+
resolvePlaceOrderWith({
|
|
110
|
+
result: false,
|
|
111
|
+
detail: 'Block trade rejected'
|
|
112
|
+
});
|
|
113
|
+
_context2.n = 1;
|
|
114
|
+
return confirmReport({});
|
|
115
|
+
case 1:
|
|
116
|
+
expect(_orderEntryActions.clearOrderForm).not.toHaveBeenCalled();
|
|
117
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
118
|
+
type: 'ADD_SNACK',
|
|
119
|
+
payload: {
|
|
120
|
+
id: 'confirmBlockTradeFail',
|
|
121
|
+
text: 'Block trade rejected',
|
|
122
|
+
type: 'warning'
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
case 2:
|
|
126
|
+
return _context2.a(2);
|
|
127
|
+
}
|
|
128
|
+
}, _callee2);
|
|
129
|
+
})));
|
|
130
|
+
it('falls back to the errorcode/errormsg pair when a rejection carries no detail', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
131
|
+
return _regenerator().w(function (_context3) {
|
|
132
|
+
while (1) switch (_context3.n) {
|
|
133
|
+
case 0:
|
|
134
|
+
// Most SubmitBlockTrade rejections come back as { result: false, errormsg, errorcode } with
|
|
135
|
+
// no detail, which showSnack would drop as empty text.
|
|
136
|
+
resolvePlaceOrderWith({
|
|
137
|
+
result: false,
|
|
138
|
+
errormsg: 'Quantity was not specified.',
|
|
139
|
+
errorcode: 79,
|
|
140
|
+
detail: null
|
|
141
|
+
});
|
|
142
|
+
_context3.n = 1;
|
|
143
|
+
return confirmReport({});
|
|
144
|
+
case 1:
|
|
145
|
+
expect(_orderEntryActions.clearOrderForm).not.toHaveBeenCalled();
|
|
146
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
147
|
+
type: 'ADD_SNACK',
|
|
148
|
+
payload: {
|
|
149
|
+
id: 'confirmBlockTradeFail',
|
|
150
|
+
text: '79: Quantity was not specified.',
|
|
151
|
+
type: 'warning'
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
case 2:
|
|
155
|
+
return _context3.a(2);
|
|
156
|
+
}
|
|
157
|
+
}, _callee3);
|
|
158
|
+
})));
|
|
159
|
+
it('shows the errormsg when the OMS rejects an order leg', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
160
|
+
return _regenerator().w(function (_context4) {
|
|
161
|
+
while (1) switch (_context4.n) {
|
|
162
|
+
case 0:
|
|
163
|
+
// A refused order leg comes back as { status: 'Rejected', errormsg } with no `result` field.
|
|
164
|
+
resolvePlaceOrderWith({
|
|
165
|
+
status: 'Rejected',
|
|
166
|
+
errormsg: 'Not_Enough_Funds'
|
|
167
|
+
});
|
|
168
|
+
_context4.n = 1;
|
|
169
|
+
return confirmReport({});
|
|
170
|
+
case 1:
|
|
171
|
+
expect(_orderEntryActions.clearOrderForm).not.toHaveBeenCalled();
|
|
172
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
173
|
+
type: 'ADD_SNACK',
|
|
174
|
+
payload: {
|
|
175
|
+
id: 'confirmBlockTradeFail',
|
|
176
|
+
text: 'Not_Enough_Funds',
|
|
177
|
+
type: 'warning'
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
case 2:
|
|
181
|
+
return _context4.a(2);
|
|
182
|
+
}
|
|
183
|
+
}, _callee4);
|
|
184
|
+
})));
|
|
185
|
+
it('falls back to a generic message when an OMS rejection carries an empty errormsg', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
186
|
+
return _regenerator().w(function (_context5) {
|
|
187
|
+
while (1) switch (_context5.n) {
|
|
188
|
+
case 0:
|
|
189
|
+
resolvePlaceOrderWith({
|
|
190
|
+
status: 'Rejected',
|
|
191
|
+
errormsg: ''
|
|
192
|
+
});
|
|
193
|
+
_context5.n = 1;
|
|
194
|
+
return confirmReport({});
|
|
195
|
+
case 1:
|
|
196
|
+
expect(_orderEntryActions.clearOrderForm).not.toHaveBeenCalled();
|
|
197
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
198
|
+
type: 'ADD_SNACK',
|
|
199
|
+
payload: {
|
|
200
|
+
id: 'confirmBlockTradeFail',
|
|
201
|
+
text: 'Your block trade was not reported. Please try again.',
|
|
202
|
+
type: 'warning'
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
case 2:
|
|
206
|
+
return _context5.a(2);
|
|
207
|
+
}
|
|
208
|
+
}, _callee5);
|
|
209
|
+
})));
|
|
210
|
+
it('falls back to a generic message when a rejection carries no detail, errormsg or errorcode', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
211
|
+
return _regenerator().w(function (_context6) {
|
|
212
|
+
while (1) switch (_context6.n) {
|
|
213
|
+
case 0:
|
|
214
|
+
resolvePlaceOrderWith({
|
|
215
|
+
result: false
|
|
216
|
+
});
|
|
217
|
+
_context6.n = 1;
|
|
218
|
+
return confirmReport({});
|
|
219
|
+
case 1:
|
|
220
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
221
|
+
type: 'ADD_SNACK',
|
|
222
|
+
payload: {
|
|
223
|
+
id: 'confirmBlockTradeFail',
|
|
224
|
+
text: 'Your block trade was not reported. Please try again.',
|
|
225
|
+
type: 'warning'
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
case 2:
|
|
229
|
+
return _context6.a(2);
|
|
230
|
+
}
|
|
231
|
+
}, _callee6);
|
|
232
|
+
})));
|
|
233
|
+
it('leaves the form filled in and adds no second snackbar when the submission threw', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
234
|
+
return _regenerator().w(function (_context7) {
|
|
235
|
+
while (1) switch (_context7.n) {
|
|
236
|
+
case 0:
|
|
237
|
+
resolvePlaceOrderWith(_orderEntryActions.ORDER_SUBMIT_FAILED);
|
|
238
|
+
_context7.n = 1;
|
|
239
|
+
return confirmReport({});
|
|
240
|
+
case 1:
|
|
241
|
+
expect(_orderEntryActions.clearOrderForm).not.toHaveBeenCalled();
|
|
242
|
+
expect(dispatch).not.toHaveBeenCalledWith(expect.objectContaining({
|
|
243
|
+
type: 'ADD_SNACK'
|
|
244
|
+
}));
|
|
245
|
+
case 2:
|
|
246
|
+
return _context7.a(2);
|
|
247
|
+
}
|
|
248
|
+
}, _callee7);
|
|
249
|
+
})));
|
|
250
|
+
it.each([undefined, 0, ''])('shows the generic snackbar and keeps the form when placeOrder resolves with %p', /*#__PURE__*/function () {
|
|
251
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(result) {
|
|
252
|
+
return _regenerator().w(function (_context8) {
|
|
253
|
+
while (1) switch (_context8.n) {
|
|
254
|
+
case 0:
|
|
255
|
+
resolvePlaceOrderWith(result);
|
|
256
|
+
_context8.n = 1;
|
|
257
|
+
return expect(confirmReport({})).resolves.toBeUndefined();
|
|
258
|
+
case 1:
|
|
259
|
+
expect(_orderEntryActions.clearOrderForm).not.toHaveBeenCalled();
|
|
260
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
261
|
+
type: 'ADD_SNACK',
|
|
262
|
+
payload: {
|
|
263
|
+
id: 'confirmBlockTradeFail',
|
|
264
|
+
text: 'Your block trade was not reported. Please try again.',
|
|
265
|
+
type: 'warning'
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
case 2:
|
|
269
|
+
return _context8.a(2);
|
|
270
|
+
}
|
|
271
|
+
}, _callee8);
|
|
272
|
+
}));
|
|
273
|
+
return function (_x) {
|
|
274
|
+
return _ref8.apply(this, arguments);
|
|
275
|
+
};
|
|
276
|
+
}());
|
|
277
|
+
it('surfaces a snackbar when the submission rejects', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
278
|
+
return _regenerator().w(function (_context9) {
|
|
279
|
+
while (1) switch (_context9.n) {
|
|
280
|
+
case 0:
|
|
281
|
+
_orderEntryActions.placeOrder.mockReturnValue(Promise.reject(new Error('websocket closed')));
|
|
282
|
+
_context9.n = 1;
|
|
283
|
+
return expect(confirmReport({})).resolves.toBeUndefined();
|
|
284
|
+
case 1:
|
|
285
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
286
|
+
type: 'ADD_SNACK',
|
|
287
|
+
payload: {
|
|
288
|
+
id: 'confirmBlockTradeFail',
|
|
289
|
+
text: 'Your block trade was not reported. Please try again.',
|
|
290
|
+
type: 'warning'
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
case 2:
|
|
294
|
+
return _context9.a(2);
|
|
295
|
+
}
|
|
296
|
+
}, _callee9);
|
|
297
|
+
})));
|
|
298
|
+
});
|
|
@@ -12,12 +12,14 @@ var _cssClassesHelper = require("../../helpers/cssClassesHelper");
|
|
|
12
12
|
var _orderEntryFormConstants = require("../../constants/sendOrder/orderEntryFormConstants");
|
|
13
13
|
var _numberFormatter = require("../../helpers/numberFormatter");
|
|
14
14
|
var _orderHelper = require("../../helpers/orderHelper");
|
|
15
|
+
var _twapOrderHelper = require("../../helpers/twapOrderHelper");
|
|
16
|
+
var _dateHelper = require("../../helpers/dateHelper");
|
|
15
17
|
require("./ConfirmOrderModalComponent.css");
|
|
16
18
|
var _pegPriceTypeConstants = require("../../constants/sendOrder/pegPriceTypeConstants");
|
|
17
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
18
20
|
var bemClasses = (0, _cssClassesHelper.getBEMClasses)('confirm-order-modal');
|
|
19
21
|
var ConfirmOrderModalComponent = function ConfirmOrderModalComponent(props) {
|
|
20
|
-
var _formObj$values$fee, _formObj$values$fee2;
|
|
22
|
+
var _twapSchedule$slices, _formObj$values$fee, _formObj$values$fee2;
|
|
21
23
|
var _useTranslation = (0, _reactI18next.useTranslation)('order'),
|
|
22
24
|
t = _useTranslation.t;
|
|
23
25
|
var formObj = props.formObj,
|
|
@@ -40,10 +42,15 @@ var ConfirmOrderModalComponent = function ConfirmOrderModalComponent(props) {
|
|
|
40
42
|
valueDP = props.valueDP,
|
|
41
43
|
futuresAmount = props.futuresAmount,
|
|
42
44
|
futuresValue = props.futuresValue,
|
|
43
|
-
futuresOrderCost = props.futuresOrderCost
|
|
45
|
+
futuresOrderCost = props.futuresOrderCost,
|
|
46
|
+
twapSchedule = props.twapSchedule;
|
|
44
47
|
var Product1Symbol = selectedInstrument.Product1Symbol,
|
|
45
48
|
Product2Symbol = selectedInstrument.Product2Symbol;
|
|
46
49
|
var isBuySide = formObj.values.side === _orderEntryFormConstants.buyValue;
|
|
50
|
+
var isTwap = (0, _twapOrderHelper.isTwapOrderType)(formObj.values.orderType);
|
|
51
|
+
var twapEndTime = isTwap ? (0, _twapOrderHelper.getTwapEndTime)(formObj.values.durationMinutes) : null;
|
|
52
|
+
// A TWAP buy without a limit price is sized by its Order Total (Value); its quantity is an estimate.
|
|
53
|
+
var isTwapByValue = isTwap && !!(twapSchedule !== null && twapSchedule !== void 0 && twapSchedule.byValue);
|
|
47
54
|
var isMarketByValue = formObj.values.anchoredField === 'value';
|
|
48
55
|
var _ref = futuresFormValues || {},
|
|
49
56
|
futuresOrderSide = _ref.side,
|
|
@@ -69,13 +76,13 @@ var ConfirmOrderModalComponent = function ConfirmOrderModalComponent(props) {
|
|
|
69
76
|
text: formObj.values.orderType
|
|
70
77
|
}, {
|
|
71
78
|
label: "".concat(t('Quantity'), ":"),
|
|
72
|
-
text: "".concat((0, _numberFormatter.formatNumberToLocale)(formObj.values.quantity, product1DecimalPlaces), " ").concat(Product1Symbol)
|
|
79
|
+
text: "".concat(isTwapByValue ? '≈ ' : '').concat((0, _numberFormatter.formatNumberToLocale)(formObj.values.quantity, product1DecimalPlaces), " ").concat(Product1Symbol)
|
|
73
80
|
}, isTrailing ? {
|
|
74
81
|
label: "".concat(t('Trailing Amount'), ":"),
|
|
75
82
|
text: "".concat((0, _numberFormatter.formatNumberToLocale)(formObj.values.trailingAmount, product2DecimalPlaces), " ").concat(Product2Symbol)
|
|
76
83
|
} : {
|
|
77
84
|
label: formObj.values.orderType === 'Stop Market' || formObj.values.orderType === 'Stop Limit' ? "".concat(t('Stop Price'), ":") : "".concat(t('Price'), ":"),
|
|
78
|
-
text: isMarginActive && formObj.values.orderType === 'Market Order' ? 'Market' : "".concat((0, _numberFormatter.formatNumberToLocale)(price, product2DecimalPlaces), " ").concat(Product2Symbol)
|
|
85
|
+
text: isMarginActive && formObj.values.orderType === 'Market Order' || isTwap && !(twapSchedule !== null && twapSchedule !== void 0 && twapSchedule.isLimit) ? t('Market') : "".concat((0, _numberFormatter.formatNumberToLocale)(price, product2DecimalPlaces), " ").concat(Product2Symbol)
|
|
79
86
|
}, formObj.values.orderType === 'Stop Limit' && {
|
|
80
87
|
label: "".concat(t('Limit Price'), ":"),
|
|
81
88
|
text: isMarginActive && formObj.values.orderType === 'Market Order' ? 'Market' : "".concat((0, _numberFormatter.formatNumberToLocale)(formObj.values.limitPrice, product2DecimalPlaces), " ").concat(Product2Symbol)
|
|
@@ -85,6 +92,21 @@ var ConfirmOrderModalComponent = function ConfirmOrderModalComponent(props) {
|
|
|
85
92
|
}, isTrailing && {
|
|
86
93
|
label: "".concat(t('Peg Price'), ":"),
|
|
87
94
|
text: _pegPriceTypeConstants.pegPriceTypesNames[formObj.values.pegPriceType]
|
|
95
|
+
}, isTwap && {
|
|
96
|
+
label: "".concat(t('Duration'), ":"),
|
|
97
|
+
text: "".concat((0, _numberFormatter.formatNumberToLocale)(formObj.values.durationMinutes, 0), " ").concat(t('min'))
|
|
98
|
+
}, isTwap && {
|
|
99
|
+
label: "".concat(t('Number of Slices'), ":"),
|
|
100
|
+
text: "".concat((_twapSchedule$slices = twapSchedule === null || twapSchedule === void 0 ? void 0 : twapSchedule.slices) !== null && _twapSchedule$slices !== void 0 ? _twapSchedule$slices : '-')
|
|
101
|
+
}, isTwap && {
|
|
102
|
+
label: "".concat(t('Interval'), ":"),
|
|
103
|
+
text: (0, _twapOrderHelper.formatTwapInterval)(twapSchedule === null || twapSchedule === void 0 ? void 0 : twapSchedule.intervalSeconds, t)
|
|
104
|
+
}, isTwap && {
|
|
105
|
+
label: "".concat(t('Est. Slice Size'), ":"),
|
|
106
|
+
text: (twapSchedule === null || twapSchedule === void 0 ? void 0 : twapSchedule.sliceSize) != null ? "".concat((0, _numberFormatter.formatNumberToLocale)(twapSchedule.sliceSize, twapSchedule.sliceDecimalPlaces), " ").concat(twapSchedule.sliceSymbol) : '-'
|
|
107
|
+
}, isTwap && {
|
|
108
|
+
label: "".concat(t('Ends'), ":"),
|
|
109
|
+
text: twapEndTime ? (0, _dateHelper.formatDateTime)(twapEndTime) : '-'
|
|
88
110
|
}, {
|
|
89
111
|
label: "".concat(t('Fee'), ":"),
|
|
90
112
|
text: "".concat((0, _numberFormatter.formatNumberToLocale)((_formObj$values$fee = formObj.values.fee) === null || _formObj$values$fee === void 0 ? void 0 : _formObj$values$fee.OrderFee, feeSymbol), " ").concat(feeSymbol)
|
|
@@ -86,7 +86,10 @@ var mapStateToProps = function mapStateToProps(state, props) {
|
|
|
86
86
|
valueDP: valueDP,
|
|
87
87
|
futuresValue: futuresValue,
|
|
88
88
|
futuresValueDecimalPlaces: futuresValueDecimalPlaces,
|
|
89
|
-
futuresOrderCost: futuresOrderCost
|
|
89
|
+
futuresOrderCost: futuresOrderCost,
|
|
90
|
+
twapSchedule: (0, _orderEntrySelector.selectTwapSchedule)(state, {
|
|
91
|
+
formName: ORDER_ENTRY_FORM_ID
|
|
92
|
+
})
|
|
90
93
|
};
|
|
91
94
|
};
|
|
92
95
|
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
|
|
@@ -12,6 +12,7 @@ var _cssClassesHelper = require("../../helpers/cssClassesHelper");
|
|
|
12
12
|
var _APAutoTabInput = _interopRequireDefault(require("../common/APAutoTabInput/APAutoTabInput"));
|
|
13
13
|
var _APInput = _interopRequireDefault(require("../common/APInput/APInput"));
|
|
14
14
|
var _formValidations = require("../../helpers/formValidations");
|
|
15
|
+
var _PasskeyOption = require("../2FA/PasskeyOption");
|
|
15
16
|
require("./Disable2FAModal.css");
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -23,19 +24,26 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
23
24
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
24
25
|
var baseClasses = (0, _cssClassesHelper.getBEMClasses)('disable-2fa-modal');
|
|
25
26
|
var Disable2FAForm = function Disable2FAForm(props) {
|
|
26
|
-
var _useTranslation = (0, _reactI18next.useTranslation)(
|
|
27
|
+
var _useTranslation = (0, _reactI18next.useTranslation)('auth'),
|
|
27
28
|
t = _useTranslation.t;
|
|
28
29
|
var _useState = (0, _react.useState)(false),
|
|
29
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
30
31
|
isUsingYubikey = _useState2[0],
|
|
31
32
|
setIsUsingYubikey = _useState2[1];
|
|
32
|
-
var handleSubmit = props.handleSubmit
|
|
33
|
+
var handleSubmit = props.handleSubmit,
|
|
34
|
+
onPasskey = props.onPasskey,
|
|
35
|
+
passkeyOnly = props.passkeyOnly,
|
|
36
|
+
answering = props.answering;
|
|
33
37
|
return /*#__PURE__*/_react["default"].createElement("form", {
|
|
34
38
|
onSubmit: handleSubmit,
|
|
35
39
|
className: baseClasses()
|
|
36
40
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
37
41
|
className: baseClasses('text-item')
|
|
38
|
-
}, t(
|
|
42
|
+
}, t('Do you want to turn off Two-Factor Authentication for this account?')), passkeyOnly ? /*#__PURE__*/_react["default"].createElement(_PasskeyOption.PasskeyOnlyStep, {
|
|
43
|
+
onPasskey: onPasskey,
|
|
44
|
+
disabled: answering,
|
|
45
|
+
dataTest: "disable-2fa-passkey"
|
|
46
|
+
}) : isUsingYubikey ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_APInput["default"], {
|
|
39
47
|
name: "otp",
|
|
40
48
|
autoFocus: true,
|
|
41
49
|
validate: [_formValidations.required],
|
|
@@ -48,8 +56,8 @@ var Disable2FAForm = function Disable2FAForm(props) {
|
|
|
48
56
|
return setIsUsingYubikey(false);
|
|
49
57
|
},
|
|
50
58
|
className: "link --small-font"
|
|
51
|
-
}, t(
|
|
52
|
-
label: t(
|
|
59
|
+
}, t('Click here to switch back.')))) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_APAutoTabInput["default"], {
|
|
60
|
+
label: t('Type Authentication Code Here'),
|
|
53
61
|
name: "code",
|
|
54
62
|
type: "number",
|
|
55
63
|
numberOfInputs: 6,
|
|
@@ -62,13 +70,20 @@ var Disable2FAForm = function Disable2FAForm(props) {
|
|
|
62
70
|
return setIsUsingYubikey(true);
|
|
63
71
|
},
|
|
64
72
|
className: "link --small-font"
|
|
65
|
-
}, t(
|
|
73
|
+
}, t('Click here to use a Yubikey instead.'))), /*#__PURE__*/_react["default"].createElement(_PasskeyOption.PasskeyOption, {
|
|
74
|
+
onPasskey: onPasskey,
|
|
75
|
+
disabled: answering,
|
|
76
|
+
dataTest: "disable-2fa-passkey"
|
|
77
|
+
})));
|
|
66
78
|
};
|
|
67
79
|
Disable2FAForm.defaultProps = {
|
|
68
80
|
handleSubmit: function handleSubmit() {},
|
|
69
81
|
submitting: false
|
|
70
82
|
};
|
|
71
83
|
Disable2FAForm.propTypes = {
|
|
72
|
-
handleSubmit: _propTypes["default"].func
|
|
84
|
+
handleSubmit: _propTypes["default"].func,
|
|
85
|
+
onPasskey: _propTypes["default"].func,
|
|
86
|
+
passkeyOnly: _propTypes["default"].bool,
|
|
87
|
+
answering: _propTypes["default"].bool
|
|
73
88
|
};
|
|
74
89
|
var _default = exports["default"] = Disable2FAForm;
|
|
@@ -11,16 +11,19 @@ var _Modal = _interopRequireDefault(require("../common/Modal/Modal"));
|
|
|
11
11
|
var _Disable2FAForm = _interopRequireDefault(require("./Disable2FAForm"));
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
13
|
var Disable2FAModal = function Disable2FAModal(props) {
|
|
14
|
-
var _useTranslation = (0, _reactI18next.useTranslation)(
|
|
14
|
+
var _useTranslation = (0, _reactI18next.useTranslation)('auth'),
|
|
15
15
|
t = _useTranslation.t;
|
|
16
16
|
var handleSubmit = props.handleSubmit,
|
|
17
17
|
submitting = props.submitting,
|
|
18
18
|
isOpen = props.isOpen,
|
|
19
19
|
close = props.close,
|
|
20
|
-
changeFieldValue = props.changeFieldValue
|
|
20
|
+
changeFieldValue = props.changeFieldValue,
|
|
21
|
+
onPasskey = props.onPasskey,
|
|
22
|
+
passkeyOnly = props.passkeyOnly,
|
|
23
|
+
answering = props.answering;
|
|
21
24
|
return /*#__PURE__*/_react["default"].createElement(_Modal["default"], {
|
|
22
25
|
isOpen: isOpen,
|
|
23
|
-
title: t(
|
|
26
|
+
title: t('Disable Two-Factor Authentication'),
|
|
24
27
|
onCancel: function onCancel() {
|
|
25
28
|
close();
|
|
26
29
|
changeFieldValue('enableTwoFactorAuth', 'use2FA', true);
|
|
@@ -28,7 +31,10 @@ var Disable2FAModal = function Disable2FAModal(props) {
|
|
|
28
31
|
close: close
|
|
29
32
|
}, /*#__PURE__*/_react["default"].createElement(_Disable2FAForm["default"], {
|
|
30
33
|
handleSubmit: handleSubmit,
|
|
31
|
-
submitting: submitting
|
|
34
|
+
submitting: submitting,
|
|
35
|
+
onPasskey: onPasskey,
|
|
36
|
+
passkeyOnly: passkeyOnly,
|
|
37
|
+
answering: answering
|
|
32
38
|
}));
|
|
33
39
|
};
|
|
34
40
|
Disable2FAModal.defaultProps = {
|
|
@@ -37,6 +43,10 @@ Disable2FAModal.defaultProps = {
|
|
|
37
43
|
};
|
|
38
44
|
Disable2FAModal.propTypes = {
|
|
39
45
|
close: _propTypes["default"].func.isRequired,
|
|
40
|
-
handleSubmit: _propTypes["default"].func
|
|
46
|
+
handleSubmit: _propTypes["default"].func,
|
|
47
|
+
onPasskey: _propTypes["default"].func,
|
|
48
|
+
passkeyOnly: _propTypes["default"].bool,
|
|
49
|
+
// an answer (a code or a passkey) is on its way
|
|
50
|
+
answering: _propTypes["default"].bool
|
|
41
51
|
};
|
|
42
52
|
var _default = exports["default"] = Disable2FAModal;
|