@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,521 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
5
|
+
var _client = require("react-dom/client");
|
|
6
|
+
var _UnlinkOAuthIdentityModal = require("./UnlinkOAuthIdentityModal");
|
|
7
|
+
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); }
|
|
8
|
+
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 }; })(); }
|
|
9
|
+
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); }
|
|
10
|
+
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); }
|
|
11
|
+
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); }); }; }
|
|
12
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
|
+
jest.mock('react-i18next', function () {
|
|
14
|
+
return {
|
|
15
|
+
useTranslation: function useTranslation() {
|
|
16
|
+
return {
|
|
17
|
+
t: function t(key) {
|
|
18
|
+
return key;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
global.IS_REACT_ACT_ENVIRONMENT = true;
|
|
25
|
+
var REFUSAL = 'The password is incorrect. If you have never set a password for this account, reset it first.';
|
|
26
|
+
var NOT_COMPLETED = 'SSO confirmation was not completed. Please try again.';
|
|
27
|
+
var SSO_PARAMS = {
|
|
28
|
+
code: 'the-code',
|
|
29
|
+
state: 'the-state'
|
|
30
|
+
};
|
|
31
|
+
var STATE_KEY = 'fusionAuthState';
|
|
32
|
+
var VERIFIER_KEY = 'fusionAuthCodeVerifier';
|
|
33
|
+
|
|
34
|
+
// what prepareFusionAuthAuthorizeUrl leaves behind for the popup it opens
|
|
35
|
+
var armSession = function armSession(state) {
|
|
36
|
+
var verifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "".concat(state, "-verifier");
|
|
37
|
+
sessionStorage.setItem(STATE_KEY, state);
|
|
38
|
+
sessionStorage.setItem(VERIFIER_KEY, verifier);
|
|
39
|
+
};
|
|
40
|
+
var render = function render(props) {
|
|
41
|
+
var container = document.createElement('div');
|
|
42
|
+
document.body.appendChild(container);
|
|
43
|
+
var root = (0, _client.createRoot)(container);
|
|
44
|
+
(0, _react.act)(function () {
|
|
45
|
+
root.render(/*#__PURE__*/_react["default"].createElement(_UnlinkOAuthIdentityModal.UnlinkOAuthIdentityModal, _extends({
|
|
46
|
+
isOpen: true,
|
|
47
|
+
close: jest.fn(),
|
|
48
|
+
confirmWithSso: jest.fn().mockResolvedValue(SSO_PARAMS),
|
|
49
|
+
doUnlink: jest.fn()
|
|
50
|
+
}, props)));
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
unmount: function unmount() {
|
|
54
|
+
(0, _react.act)(function () {
|
|
55
|
+
return root.unmount();
|
|
56
|
+
});
|
|
57
|
+
container.remove();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
var typePassword = /*#__PURE__*/function () {
|
|
62
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
|
|
63
|
+
var input;
|
|
64
|
+
return _regenerator().w(function (_context2) {
|
|
65
|
+
while (1) switch (_context2.n) {
|
|
66
|
+
case 0:
|
|
67
|
+
input = document.body.querySelector('input[name="password"]');
|
|
68
|
+
_context2.n = 1;
|
|
69
|
+
return (0, _react.act)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
70
|
+
return _regenerator().w(function (_context) {
|
|
71
|
+
while (1) switch (_context.n) {
|
|
72
|
+
case 0:
|
|
73
|
+
// React listens for `input`; set the value through the native setter so React notices the change
|
|
74
|
+
Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set.call(input, value);
|
|
75
|
+
input.dispatchEvent(new Event('input', {
|
|
76
|
+
bubbles: true
|
|
77
|
+
}));
|
|
78
|
+
case 1:
|
|
79
|
+
return _context.a(2);
|
|
80
|
+
}
|
|
81
|
+
}, _callee);
|
|
82
|
+
})));
|
|
83
|
+
case 1:
|
|
84
|
+
return _context2.a(2);
|
|
85
|
+
}
|
|
86
|
+
}, _callee2);
|
|
87
|
+
}));
|
|
88
|
+
return function typePassword(_x) {
|
|
89
|
+
return _ref.apply(this, arguments);
|
|
90
|
+
};
|
|
91
|
+
}();
|
|
92
|
+
var submit = /*#__PURE__*/function () {
|
|
93
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
94
|
+
var form;
|
|
95
|
+
return _regenerator().w(function (_context4) {
|
|
96
|
+
while (1) switch (_context4.n) {
|
|
97
|
+
case 0:
|
|
98
|
+
form = document.body.querySelector('form.unlink-oauth-identity-modal__form');
|
|
99
|
+
_context4.n = 1;
|
|
100
|
+
return (0, _react.act)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
101
|
+
return _regenerator().w(function (_context3) {
|
|
102
|
+
while (1) switch (_context3.n) {
|
|
103
|
+
case 0:
|
|
104
|
+
form.dispatchEvent(new Event('submit', {
|
|
105
|
+
bubbles: true,
|
|
106
|
+
cancelable: true
|
|
107
|
+
}));
|
|
108
|
+
case 1:
|
|
109
|
+
return _context3.a(2);
|
|
110
|
+
}
|
|
111
|
+
}, _callee3);
|
|
112
|
+
})));
|
|
113
|
+
case 1:
|
|
114
|
+
return _context4.a(2);
|
|
115
|
+
}
|
|
116
|
+
}, _callee4);
|
|
117
|
+
}));
|
|
118
|
+
return function submit() {
|
|
119
|
+
return _ref3.apply(this, arguments);
|
|
120
|
+
};
|
|
121
|
+
}();
|
|
122
|
+
var clickClose = /*#__PURE__*/function () {
|
|
123
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
124
|
+
return _regenerator().w(function (_context6) {
|
|
125
|
+
while (1) switch (_context6.n) {
|
|
126
|
+
case 0:
|
|
127
|
+
_context6.n = 1;
|
|
128
|
+
return (0, _react.act)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
129
|
+
return _regenerator().w(function (_context5) {
|
|
130
|
+
while (1) switch (_context5.n) {
|
|
131
|
+
case 0:
|
|
132
|
+
document.body.querySelector('.ap-modal__close-icon').dispatchEvent(new MouseEvent('click', {
|
|
133
|
+
bubbles: true
|
|
134
|
+
}));
|
|
135
|
+
case 1:
|
|
136
|
+
return _context5.a(2);
|
|
137
|
+
}
|
|
138
|
+
}, _callee5);
|
|
139
|
+
})));
|
|
140
|
+
case 1:
|
|
141
|
+
return _context6.a(2);
|
|
142
|
+
}
|
|
143
|
+
}, _callee6);
|
|
144
|
+
}));
|
|
145
|
+
return function clickClose() {
|
|
146
|
+
return _ref5.apply(this, arguments);
|
|
147
|
+
};
|
|
148
|
+
}();
|
|
149
|
+
var errorText = function errorText() {
|
|
150
|
+
var el = document.body.querySelector('.unlink-oauth-identity-modal__error');
|
|
151
|
+
return el && el.textContent;
|
|
152
|
+
};
|
|
153
|
+
describe('UnlinkOAuthIdentityModal', function () {
|
|
154
|
+
var mounted;
|
|
155
|
+
beforeEach(function () {
|
|
156
|
+
jest.clearAllMocks();
|
|
157
|
+
sessionStorage.clear();
|
|
158
|
+
});
|
|
159
|
+
afterEach(function () {
|
|
160
|
+
if (mounted) mounted.unmount();
|
|
161
|
+
mounted = null;
|
|
162
|
+
});
|
|
163
|
+
it('confirms with SSO, then sends the popup params and the password, and closes on success', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
164
|
+
var close, confirmWithSso, doUnlink;
|
|
165
|
+
return _regenerator().w(function (_context7) {
|
|
166
|
+
while (1) switch (_context7.n) {
|
|
167
|
+
case 0:
|
|
168
|
+
close = jest.fn();
|
|
169
|
+
confirmWithSso = jest.fn().mockResolvedValue(SSO_PARAMS);
|
|
170
|
+
doUnlink = jest.fn().mockResolvedValue({
|
|
171
|
+
Unlinked: true,
|
|
172
|
+
SessionsLoggedOff: 1
|
|
173
|
+
});
|
|
174
|
+
mounted = render({
|
|
175
|
+
close: close,
|
|
176
|
+
confirmWithSso: confirmWithSso,
|
|
177
|
+
doUnlink: doUnlink
|
|
178
|
+
});
|
|
179
|
+
_context7.n = 1;
|
|
180
|
+
return typePassword('hunter2');
|
|
181
|
+
case 1:
|
|
182
|
+
_context7.n = 2;
|
|
183
|
+
return submit();
|
|
184
|
+
case 2:
|
|
185
|
+
expect(confirmWithSso).toHaveBeenCalledTimes(1);
|
|
186
|
+
expect(doUnlink).toHaveBeenCalledWith(SSO_PARAMS, 'hunter2');
|
|
187
|
+
expect(close).toHaveBeenCalled();
|
|
188
|
+
expect(errorText()).toBeNull();
|
|
189
|
+
case 3:
|
|
190
|
+
return _context7.a(2);
|
|
191
|
+
}
|
|
192
|
+
}, _callee7);
|
|
193
|
+
})));
|
|
194
|
+
it('shows the gateway refusal verbatim and stays open', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
195
|
+
var close, doUnlink;
|
|
196
|
+
return _regenerator().w(function (_context8) {
|
|
197
|
+
while (1) switch (_context8.n) {
|
|
198
|
+
case 0:
|
|
199
|
+
close = jest.fn();
|
|
200
|
+
doUnlink = jest.fn().mockResolvedValue({
|
|
201
|
+
Unlinked: false,
|
|
202
|
+
errormsg: REFUSAL
|
|
203
|
+
});
|
|
204
|
+
mounted = render({
|
|
205
|
+
close: close,
|
|
206
|
+
doUnlink: doUnlink
|
|
207
|
+
});
|
|
208
|
+
_context8.n = 1;
|
|
209
|
+
return typePassword('wrong');
|
|
210
|
+
case 1:
|
|
211
|
+
_context8.n = 2;
|
|
212
|
+
return submit();
|
|
213
|
+
case 2:
|
|
214
|
+
expect(close).not.toHaveBeenCalled();
|
|
215
|
+
expect(errorText()).toBe(REFUSAL);
|
|
216
|
+
// the field is usable again for another attempt
|
|
217
|
+
expect(document.body.querySelector('input[name="password"]').disabled).toBe(false);
|
|
218
|
+
case 3:
|
|
219
|
+
return _context8.a(2);
|
|
220
|
+
}
|
|
221
|
+
}, _callee8);
|
|
222
|
+
})));
|
|
223
|
+
it('stays open with an error and skips the gateway when the popup is closed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
224
|
+
var close, confirmWithSso, doUnlink;
|
|
225
|
+
return _regenerator().w(function (_context9) {
|
|
226
|
+
while (1) switch (_context9.n) {
|
|
227
|
+
case 0:
|
|
228
|
+
close = jest.fn();
|
|
229
|
+
confirmWithSso = jest.fn().mockResolvedValue(null);
|
|
230
|
+
doUnlink = jest.fn();
|
|
231
|
+
mounted = render({
|
|
232
|
+
close: close,
|
|
233
|
+
confirmWithSso: confirmWithSso,
|
|
234
|
+
doUnlink: doUnlink
|
|
235
|
+
});
|
|
236
|
+
_context9.n = 1;
|
|
237
|
+
return typePassword('hunter2');
|
|
238
|
+
case 1:
|
|
239
|
+
_context9.n = 2;
|
|
240
|
+
return submit();
|
|
241
|
+
case 2:
|
|
242
|
+
expect(doUnlink).not.toHaveBeenCalled();
|
|
243
|
+
expect(close).not.toHaveBeenCalled();
|
|
244
|
+
expect(errorText()).toBe(NOT_COMPLETED);
|
|
245
|
+
case 3:
|
|
246
|
+
return _context9.a(2);
|
|
247
|
+
}
|
|
248
|
+
}, _callee9);
|
|
249
|
+
})));
|
|
250
|
+
it('stays open with the same error when the SSO provider reports a cancelled sign-in', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
251
|
+
var doUnlink;
|
|
252
|
+
return _regenerator().w(function (_context0) {
|
|
253
|
+
while (1) switch (_context0.n) {
|
|
254
|
+
case 0:
|
|
255
|
+
doUnlink = jest.fn().mockResolvedValue({
|
|
256
|
+
Unlinked: false,
|
|
257
|
+
cancelled: true
|
|
258
|
+
});
|
|
259
|
+
mounted = render({
|
|
260
|
+
doUnlink: doUnlink
|
|
261
|
+
});
|
|
262
|
+
_context0.n = 1;
|
|
263
|
+
return typePassword('hunter2');
|
|
264
|
+
case 1:
|
|
265
|
+
_context0.n = 2;
|
|
266
|
+
return submit();
|
|
267
|
+
case 2:
|
|
268
|
+
expect(errorText()).toBe(NOT_COMPLETED);
|
|
269
|
+
case 3:
|
|
270
|
+
return _context0.a(2);
|
|
271
|
+
}
|
|
272
|
+
}, _callee0);
|
|
273
|
+
})));
|
|
274
|
+
|
|
275
|
+
// each code is single use, so a retry must not reuse the refused attempt's code
|
|
276
|
+
it('opens a fresh SSO popup on every submit', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
277
|
+
var confirmWithSso, doUnlink;
|
|
278
|
+
return _regenerator().w(function (_context1) {
|
|
279
|
+
while (1) switch (_context1.n) {
|
|
280
|
+
case 0:
|
|
281
|
+
confirmWithSso = jest.fn().mockResolvedValueOnce({
|
|
282
|
+
code: 'first-code',
|
|
283
|
+
state: 's1'
|
|
284
|
+
}).mockResolvedValueOnce({
|
|
285
|
+
code: 'second-code',
|
|
286
|
+
state: 's2'
|
|
287
|
+
});
|
|
288
|
+
doUnlink = jest.fn().mockResolvedValueOnce({
|
|
289
|
+
Unlinked: false,
|
|
290
|
+
errormsg: REFUSAL
|
|
291
|
+
}).mockResolvedValueOnce({
|
|
292
|
+
Unlinked: true
|
|
293
|
+
});
|
|
294
|
+
mounted = render({
|
|
295
|
+
confirmWithSso: confirmWithSso,
|
|
296
|
+
doUnlink: doUnlink
|
|
297
|
+
});
|
|
298
|
+
_context1.n = 1;
|
|
299
|
+
return typePassword('wrong');
|
|
300
|
+
case 1:
|
|
301
|
+
_context1.n = 2;
|
|
302
|
+
return submit();
|
|
303
|
+
case 2:
|
|
304
|
+
_context1.n = 3;
|
|
305
|
+
return typePassword('right');
|
|
306
|
+
case 3:
|
|
307
|
+
_context1.n = 4;
|
|
308
|
+
return submit();
|
|
309
|
+
case 4:
|
|
310
|
+
expect(confirmWithSso).toHaveBeenCalledTimes(2);
|
|
311
|
+
expect(doUnlink).toHaveBeenNthCalledWith(1, {
|
|
312
|
+
code: 'first-code',
|
|
313
|
+
state: 's1'
|
|
314
|
+
}, 'wrong');
|
|
315
|
+
expect(doUnlink).toHaveBeenNthCalledWith(2, {
|
|
316
|
+
code: 'second-code',
|
|
317
|
+
state: 's2'
|
|
318
|
+
}, 'right');
|
|
319
|
+
case 5:
|
|
320
|
+
return _context1.a(2);
|
|
321
|
+
}
|
|
322
|
+
}, _callee1);
|
|
323
|
+
})));
|
|
324
|
+
it('does not unlink, and drops the code, when the dialog is cancelled while the popup is open', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
325
|
+
var finishPopup, confirmWithSso, doUnlink;
|
|
326
|
+
return _regenerator().w(function (_context11) {
|
|
327
|
+
while (1) switch (_context11.n) {
|
|
328
|
+
case 0:
|
|
329
|
+
confirmWithSso = jest.fn(function () {
|
|
330
|
+
armSession('the-state');
|
|
331
|
+
return new Promise(function (resolve) {
|
|
332
|
+
return finishPopup = resolve;
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
doUnlink = jest.fn();
|
|
336
|
+
mounted = render({
|
|
337
|
+
confirmWithSso: confirmWithSso,
|
|
338
|
+
doUnlink: doUnlink
|
|
339
|
+
});
|
|
340
|
+
_context11.n = 1;
|
|
341
|
+
return typePassword('hunter2');
|
|
342
|
+
case 1:
|
|
343
|
+
_context11.n = 2;
|
|
344
|
+
return submit();
|
|
345
|
+
case 2:
|
|
346
|
+
_context11.n = 3;
|
|
347
|
+
return clickClose();
|
|
348
|
+
case 3:
|
|
349
|
+
_context11.n = 4;
|
|
350
|
+
return (0, _react.act)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
351
|
+
return _regenerator().w(function (_context10) {
|
|
352
|
+
while (1) switch (_context10.n) {
|
|
353
|
+
case 0:
|
|
354
|
+
finishPopup(SSO_PARAMS);
|
|
355
|
+
case 1:
|
|
356
|
+
return _context10.a(2);
|
|
357
|
+
}
|
|
358
|
+
}, _callee10);
|
|
359
|
+
})));
|
|
360
|
+
case 4:
|
|
361
|
+
expect(doUnlink).not.toHaveBeenCalled();
|
|
362
|
+
expect(sessionStorage.getItem(STATE_KEY)).toBeNull();
|
|
363
|
+
expect(sessionStorage.getItem(VERIFIER_KEY)).toBeNull();
|
|
364
|
+
expect(errorText()).toBeNull();
|
|
365
|
+
case 5:
|
|
366
|
+
return _context11.a(2);
|
|
367
|
+
}
|
|
368
|
+
}, _callee11);
|
|
369
|
+
})));
|
|
370
|
+
|
|
371
|
+
// Cancel leaves the popup open, and the next submit reuses the same named window, so the
|
|
372
|
+
// abandoned attempt and the new one both receive the callback. The abandoned one settles
|
|
373
|
+
// first and must leave the new attempt's keys alone.
|
|
374
|
+
it('keeps the newer attempt’s keys when an abandoned popup attempt settles on the same callback', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
375
|
+
var settles, confirmWithSso, keysAtUnlink, doUnlink;
|
|
376
|
+
return _regenerator().w(function (_context14) {
|
|
377
|
+
while (1) switch (_context14.n) {
|
|
378
|
+
case 0:
|
|
379
|
+
settles = [];
|
|
380
|
+
confirmWithSso = jest.fn(function () {
|
|
381
|
+
return new Promise(function (resolve) {
|
|
382
|
+
return settles.push(resolve);
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
doUnlink = jest.fn(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
386
|
+
return _regenerator().w(function (_context12) {
|
|
387
|
+
while (1) switch (_context12.n) {
|
|
388
|
+
case 0:
|
|
389
|
+
keysAtUnlink = [sessionStorage.getItem(STATE_KEY), sessionStorage.getItem(VERIFIER_KEY)];
|
|
390
|
+
return _context12.a(2, {
|
|
391
|
+
Unlinked: true
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}, _callee12);
|
|
395
|
+
})));
|
|
396
|
+
mounted = render({
|
|
397
|
+
confirmWithSso: confirmWithSso,
|
|
398
|
+
doUnlink: doUnlink
|
|
399
|
+
});
|
|
400
|
+
armSession('first-state');
|
|
401
|
+
_context14.n = 1;
|
|
402
|
+
return typePassword('hunter2');
|
|
403
|
+
case 1:
|
|
404
|
+
_context14.n = 2;
|
|
405
|
+
return submit();
|
|
406
|
+
case 2:
|
|
407
|
+
_context14.n = 3;
|
|
408
|
+
return clickClose();
|
|
409
|
+
case 3:
|
|
410
|
+
armSession('second-state');
|
|
411
|
+
_context14.n = 4;
|
|
412
|
+
return typePassword('hunter2');
|
|
413
|
+
case 4:
|
|
414
|
+
_context14.n = 5;
|
|
415
|
+
return submit();
|
|
416
|
+
case 5:
|
|
417
|
+
_context14.n = 6;
|
|
418
|
+
return (0, _react.act)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
419
|
+
return _regenerator().w(function (_context13) {
|
|
420
|
+
while (1) switch (_context13.n) {
|
|
421
|
+
case 0:
|
|
422
|
+
settles[0]({
|
|
423
|
+
code: 'the-code',
|
|
424
|
+
state: 'second-state'
|
|
425
|
+
});
|
|
426
|
+
settles[1]({
|
|
427
|
+
code: 'the-code',
|
|
428
|
+
state: 'second-state'
|
|
429
|
+
});
|
|
430
|
+
case 1:
|
|
431
|
+
return _context13.a(2);
|
|
432
|
+
}
|
|
433
|
+
}, _callee13);
|
|
434
|
+
})));
|
|
435
|
+
case 6:
|
|
436
|
+
expect(doUnlink).toHaveBeenCalledTimes(1);
|
|
437
|
+
expect(keysAtUnlink).toEqual(['second-state', 'second-state-verifier']);
|
|
438
|
+
case 7:
|
|
439
|
+
return _context14.a(2);
|
|
440
|
+
}
|
|
441
|
+
}, _callee14);
|
|
442
|
+
})));
|
|
443
|
+
it('ignores a refusal that arrives after the dialog was cancelled', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
444
|
+
var close, settle, doUnlink;
|
|
445
|
+
return _regenerator().w(function (_context16) {
|
|
446
|
+
while (1) switch (_context16.n) {
|
|
447
|
+
case 0:
|
|
448
|
+
close = jest.fn();
|
|
449
|
+
doUnlink = jest.fn(function () {
|
|
450
|
+
return new Promise(function (resolve) {
|
|
451
|
+
return settle = resolve;
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
mounted = render({
|
|
455
|
+
close: close,
|
|
456
|
+
doUnlink: doUnlink
|
|
457
|
+
});
|
|
458
|
+
_context16.n = 1;
|
|
459
|
+
return typePassword('wrong');
|
|
460
|
+
case 1:
|
|
461
|
+
_context16.n = 2;
|
|
462
|
+
return submit();
|
|
463
|
+
case 2:
|
|
464
|
+
_context16.n = 3;
|
|
465
|
+
return clickClose();
|
|
466
|
+
case 3:
|
|
467
|
+
_context16.n = 4;
|
|
468
|
+
return (0, _react.act)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
469
|
+
return _regenerator().w(function (_context15) {
|
|
470
|
+
while (1) switch (_context15.n) {
|
|
471
|
+
case 0:
|
|
472
|
+
settle({
|
|
473
|
+
Unlinked: false,
|
|
474
|
+
errormsg: REFUSAL
|
|
475
|
+
});
|
|
476
|
+
case 1:
|
|
477
|
+
return _context15.a(2);
|
|
478
|
+
}
|
|
479
|
+
}, _callee15);
|
|
480
|
+
})));
|
|
481
|
+
case 4:
|
|
482
|
+
expect(close).toHaveBeenCalledTimes(1);
|
|
483
|
+
expect(errorText()).toBeNull();
|
|
484
|
+
expect(document.body.querySelector('input[name="password"]').disabled).toBe(false);
|
|
485
|
+
case 5:
|
|
486
|
+
return _context16.a(2);
|
|
487
|
+
}
|
|
488
|
+
}, _callee16);
|
|
489
|
+
})));
|
|
490
|
+
it('clears the password and error when cancelled', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
491
|
+
var close, doUnlink;
|
|
492
|
+
return _regenerator().w(function (_context17) {
|
|
493
|
+
while (1) switch (_context17.n) {
|
|
494
|
+
case 0:
|
|
495
|
+
close = jest.fn();
|
|
496
|
+
doUnlink = jest.fn().mockResolvedValue({
|
|
497
|
+
Unlinked: false,
|
|
498
|
+
errormsg: REFUSAL
|
|
499
|
+
});
|
|
500
|
+
mounted = render({
|
|
501
|
+
close: close,
|
|
502
|
+
doUnlink: doUnlink
|
|
503
|
+
});
|
|
504
|
+
_context17.n = 1;
|
|
505
|
+
return typePassword('wrong');
|
|
506
|
+
case 1:
|
|
507
|
+
_context17.n = 2;
|
|
508
|
+
return submit();
|
|
509
|
+
case 2:
|
|
510
|
+
_context17.n = 3;
|
|
511
|
+
return clickClose();
|
|
512
|
+
case 3:
|
|
513
|
+
expect(close).toHaveBeenCalled();
|
|
514
|
+
expect(document.body.querySelector('input[name="password"]').value).toBe('');
|
|
515
|
+
expect(errorText()).toBeNull();
|
|
516
|
+
case 4:
|
|
517
|
+
return _context17.a(2);
|
|
518
|
+
}
|
|
519
|
+
}, _callee17);
|
|
520
|
+
})));
|
|
521
|
+
});
|
|
@@ -76,7 +76,7 @@ var LoginFormComponent = exports.LoginFormComponent = function LoginFormComponen
|
|
|
76
76
|
className: "".concat(baseClasses('form'), " ").concat(loginFormClasses('form'))
|
|
77
77
|
}, errorMsg && /*#__PURE__*/_react["default"].createElement("p", {
|
|
78
78
|
className: baseClasses('error')
|
|
79
|
-
}, errorMsg), /*#__PURE__*/_react["default"].createElement(_APInput["default"], {
|
|
79
|
+
}, t(errorMsg)), /*#__PURE__*/_react["default"].createElement(_APInput["default"], {
|
|
80
80
|
type: "text",
|
|
81
81
|
name: "username",
|
|
82
82
|
customClass: loginFormClasses(),
|
|
@@ -41,6 +41,8 @@ var makeSelectOrderInitialValues = function makeSelectOrderInitialValues() {
|
|
|
41
41
|
pegPriceType: '1',
|
|
42
42
|
price: '',
|
|
43
43
|
timeInForce: '1',
|
|
44
|
+
durationMinutes: '',
|
|
45
|
+
slices: '',
|
|
44
46
|
anchoredField: '',
|
|
45
47
|
side: side !== null && side !== void 0 ? side : _orderEntryFormConstants.buyValue
|
|
46
48
|
};
|
|
@@ -17,6 +17,7 @@ var _Slider = require("../../common/Slider/Slider");
|
|
|
17
17
|
var _useMoneyFields2 = require("../hooks/useMoneyFields");
|
|
18
18
|
var _useValidators2 = require("../../../constants/useValidators");
|
|
19
19
|
var _StrategiesSelection = require("./StrategiesSelection/StrategiesSelection");
|
|
20
|
+
var _TwapScheduleFields = require("./TwapScheduleFields");
|
|
20
21
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
21
22
|
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); }
|
|
22
23
|
var breakpoints = [0, 25, 50, 75, 100];
|
|
@@ -121,6 +122,10 @@ var FormAmountFields = exports.FormAmountFields = function FormAmountFields(_ref
|
|
|
121
122
|
value: sliderValue,
|
|
122
123
|
breakpoints: breakpoints,
|
|
123
124
|
step: "0.01"
|
|
125
|
+
}), (0, _placeOrderHelper.isTwapScheduleFieldInForm)(orderType) && /*#__PURE__*/_react["default"].createElement(_TwapScheduleFields.TwapScheduleFields, {
|
|
126
|
+
baseClass: baseClass,
|
|
127
|
+
formName: formName,
|
|
128
|
+
fieldLayout: fieldLayout
|
|
124
129
|
}), (0, _placeOrderHelper.isTimeInForceFieldInForm)(orderType) && /*#__PURE__*/_react["default"].createElement(_StrategiesSelection.StrategiesSelection, {
|
|
125
130
|
formName: formName,
|
|
126
131
|
timeInForceOptions: [{
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.TwapScheduleFields = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactI18next = require("react-i18next");
|
|
10
|
+
var _reactRedux = require("react-redux");
|
|
11
|
+
var _FormItem = require("../../form/FormItem");
|
|
12
|
+
var _NumberInput = require("../../form/NumberInput");
|
|
13
|
+
var _APLabelWithText = _interopRequireDefault(require("../../common/APLabelWithText"));
|
|
14
|
+
var _useValidators2 = require("../../../constants/useValidators");
|
|
15
|
+
var _numberFormatter = require("../../../helpers/numberFormatter");
|
|
16
|
+
var _decimalPlacesHelper = require("../../../helpers/decimalPlaces/decimalPlacesHelper");
|
|
17
|
+
var _twapOrderHelper = require("../../../helpers/twapOrderHelper");
|
|
18
|
+
var _orderEntrySelector = require("../../../redux/selectors/orderEntrySelector");
|
|
19
|
+
var _instrumentPositionSelectors = require("../../../redux/selectors/instrumentPositionSelectors");
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
21
|
+
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); }
|
|
22
|
+
var toErrorText = function toErrorText(t, error) {
|
|
23
|
+
return error ? t(error.key, error.vars) : undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The TWAP schedule inputs (duration in minutes, number of slices) and what they imply: the slice
|
|
28
|
+
* the engine will release and how often. The engine releases slice 0 on entry and the rest at
|
|
29
|
+
* equal intervals until the duration ends; see helpers/twapOrderHelper.js for the mapping to the
|
|
30
|
+
* SendOrder fields.
|
|
31
|
+
*/
|
|
32
|
+
var TwapScheduleFields = exports.TwapScheduleFields = function TwapScheduleFields(_ref) {
|
|
33
|
+
var _schedule$sliceSymbol, _schedule$sliceSymbol2;
|
|
34
|
+
var baseClass = _ref.baseClass,
|
|
35
|
+
formName = _ref.formName,
|
|
36
|
+
fieldLayout = _ref.fieldLayout;
|
|
37
|
+
var _useTranslation = (0, _reactI18next.useTranslation)('order'),
|
|
38
|
+
t = _useTranslation.t;
|
|
39
|
+
var _useValidators = (0, _useValidators2.useValidators)(),
|
|
40
|
+
requiredNumeric = _useValidators.requiredNumeric;
|
|
41
|
+
var instrument = (0, _reactRedux.useSelector)(_instrumentPositionSelectors.selectedInstrumentSelector);
|
|
42
|
+
var schedule = (0, _reactRedux.useSelector)(function (state) {
|
|
43
|
+
return (0, _orderEntrySelector.selectTwapSchedule)(state, {
|
|
44
|
+
formName: formName
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
var validateDuration = (0, _react.useCallback)(function (value) {
|
|
48
|
+
return toErrorText(t, (0, _twapOrderHelper.getTwapDurationError)(value));
|
|
49
|
+
}, [t]);
|
|
50
|
+
|
|
51
|
+
// Validates against the other form values so it stays stable across renders: redux-form
|
|
52
|
+
// re-registers a Field whenever its validators change identity.
|
|
53
|
+
var validateSlices = (0, _react.useCallback)(function (value, allValues) {
|
|
54
|
+
return toErrorText(t, (0, _twapOrderHelper.getTwapSlicesError)(value, allValues, instrument, instrument ? (0, _decimalPlacesHelper.convertIncrementToIntDecimalPlaces)(instrument.QuantityIncrement) : 0));
|
|
55
|
+
}, [t, instrument]);
|
|
56
|
+
var sliceSizeText = schedule.sliceSize === null ? '-' : "".concat((0, _numberFormatter.formatNumberToLocale)(schedule.sliceSize, schedule.sliceDecimalPlaces), " ").concat((_schedule$sliceSymbol = schedule.sliceSymbol) !== null && _schedule$sliceSymbol !== void 0 ? _schedule$sliceSymbol : '');
|
|
57
|
+
// The slice size is rounded up to the instrument's increment, so the engine may run fewer slices
|
|
58
|
+
// than entered; the schedule is then shown as the engine runs it.
|
|
59
|
+
var sliceCountText = schedule.slices !== null && schedule.slices !== schedule.requestedSlices ? t('{{size}} × {{n}} slices', {
|
|
60
|
+
size: sliceSizeText,
|
|
61
|
+
n: schedule.slices
|
|
62
|
+
}) : sliceSizeText;
|
|
63
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_FormItem.RFormInputItem, {
|
|
64
|
+
size: "small",
|
|
65
|
+
component: _NumberInput.MoneyInput,
|
|
66
|
+
name: "durationMinutes",
|
|
67
|
+
placeholder: "0",
|
|
68
|
+
className: baseClass,
|
|
69
|
+
label: t('Duration'),
|
|
70
|
+
symbol: t('min'),
|
|
71
|
+
decimalPlaces: 0,
|
|
72
|
+
validate: [requiredNumeric, validateDuration],
|
|
73
|
+
layout: fieldLayout,
|
|
74
|
+
"data-test": "TWAP Duration"
|
|
75
|
+
}), /*#__PURE__*/_react["default"].createElement(_FormItem.RFormInputItem, {
|
|
76
|
+
size: "small",
|
|
77
|
+
component: _NumberInput.MoneyInput,
|
|
78
|
+
name: "slices",
|
|
79
|
+
placeholder: "0",
|
|
80
|
+
className: baseClass,
|
|
81
|
+
label: t('Number of Slices'),
|
|
82
|
+
decimalPlaces: 0,
|
|
83
|
+
validate: [requiredNumeric, validateSlices],
|
|
84
|
+
layout: fieldLayout,
|
|
85
|
+
"data-test": "TWAP Slices"
|
|
86
|
+
}), /*#__PURE__*/_react["default"].createElement(_APLabelWithText["default"], {
|
|
87
|
+
label: t('Est. Slice Size'),
|
|
88
|
+
text: sliceCountText,
|
|
89
|
+
customClass: baseClass,
|
|
90
|
+
tooltip: schedule.byValue ? t('A TWAP buy at market is sized by Order Total, so each slice is a value in {{symbol}}', {
|
|
91
|
+
symbol: (_schedule$sliceSymbol2 = schedule.sliceSymbol) !== null && _schedule$sliceSymbol2 !== void 0 ? _schedule$sliceSymbol2 : ''
|
|
92
|
+
}) : undefined
|
|
93
|
+
}), /*#__PURE__*/_react["default"].createElement(_APLabelWithText["default"], {
|
|
94
|
+
label: t('Interval'),
|
|
95
|
+
text: (0, _twapOrderHelper.formatTwapInterval)(schedule.intervalSeconds, t),
|
|
96
|
+
customClass: baseClass
|
|
97
|
+
}));
|
|
98
|
+
};
|