@alphapoint/apex-web 5.5.6 → 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 +139 -27
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +627 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.css +6 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.js +6 -2
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.test.js +43 -0
- package/lib/components/AccountsDropdown/AccountsDropdownContainer.js +3 -1
- package/lib/components/BalancesList/BalancesListContainer.js +4 -1
- 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/DigitalAssets/digitalAssetsPriceLabel.test.js +238 -0
- 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/EnableTwoFactorAuthComponent.js +7 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +105 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +15 -3
- 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/InstrumentPositions/InstrumentPositionsContainer.js +4 -1
- package/lib/components/Login/LoginFormComponent.js +1 -1
- package/lib/components/MarginBalances/MarginDepositWithdraw/MarginDepositModal/MarginDepositFormContainer.js +2 -1
- package/lib/components/NoAccountBanner/NoAccountBanner.css +9 -0
- package/lib/components/NoAccountBanner/NoAccountBanner.js +58 -0
- package/lib/components/NoAccountBanner/index.js +16 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.css +31 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.js +33 -0
- package/lib/components/NoAccountPlaceholder/index.js +9 -0
- 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.js +12 -4
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +268 -0
- 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/components/common/ErrorBoundary/ErrorBoundary.css +35 -0
- package/lib/components/common/ErrorBoundary/ErrorBoundary.js +87 -0
- 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/errorTextFormatter.js +13 -4
- package/lib/helpers/errorTextFormatter.test.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/twoFactorAuthCancellation.js +38 -0
- package/lib/helpers/webauthnHelper.js +300 -0
- package/lib/helpers/webauthnHelper.test.js +199 -0
- package/lib/hocs/forAccount.js +33 -0
- package/lib/hocs/forAccount.test.js +50 -0
- package/lib/hocs/forVerified.js +16 -2
- package/lib/hocs/withAuthentication.js +3 -1
- package/lib/hocs/withOneSubmission.js +168 -0
- package/lib/index.js +3 -2
- package/lib/layouts/HeaderLayout/HeaderLayout.js +2 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.js +3 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.test.js +84 -0
- package/lib/redux/actions/apiActions.js +77 -9
- package/lib/redux/actions/apiActions.test.js +233 -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/interestAccountActions.js +12 -3
- package/lib/redux/actions/interestAccountActions.test.js +73 -0
- 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 +20 -8
- package/lib/redux/actions/orderHistoryActions.test.js +63 -0
- package/lib/redux/actions/userActions.js +379 -179
- package/lib/redux/actions/userActions.test.js +925 -234
- package/lib/redux/actions/withdrawActions.js +62 -29
- package/lib/redux/actions/withdrawActions.test.js +246 -73
- package/lib/redux/actions/withdrawActions.travelRule.test.js +17 -3
- 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/reducers/userReducer.js +10 -0
- package/lib/redux/reducers/userReducer.test.js +29 -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/redux/selectors/recentActivitySelector.js +8 -2
- package/lib/redux/selectors/recentActivitySelector.v2.test.js +33 -0
- package/lib/redux/selectors/userSelectors.js +6 -1
- package/lib/redux/selectors/userSelectors.test.js +28 -0
- 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
|
+
});
|
|
@@ -7,6 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _reactRedux = require("react-redux");
|
|
8
8
|
var _instrumentPositionSelectors = require("../../redux/selectors/instrumentPositionSelectors");
|
|
9
9
|
var _InstrumentPositionsComponent = _interopRequireDefault(require("./InstrumentPositionsComponent"));
|
|
10
|
+
var _forAccount = _interopRequireDefault(require("../../hocs/forAccount"));
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
12
|
var mapStateToProps = function mapStateToProps(state) {
|
|
12
13
|
var positions = (0, _instrumentPositionSelectors.instrumentPositionsSelector)(state);
|
|
@@ -16,4 +17,6 @@ var mapStateToProps = function mapStateToProps(state) {
|
|
|
16
17
|
fetching: fetching
|
|
17
18
|
};
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
+
|
|
21
|
+
// Positions are never fetched without an account, so fetching would stay true.
|
|
22
|
+
var _default = exports["default"] = (0, _forAccount["default"])((0, _reactRedux.connect)(mapStateToProps)(_InstrumentPositionsComponent["default"]));
|
|
@@ -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(),
|
|
@@ -9,6 +9,7 @@ var _MarginDepositForm = _interopRequireDefault(require("./MarginDepositForm"));
|
|
|
9
9
|
var _modalActions = require("../../../../redux/actions/modalActions");
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
11
|
var mapStateToProps = function mapStateToProps(state) {
|
|
12
|
+
var _user$accounts$;
|
|
12
13
|
var product = state.apexCore.product,
|
|
13
14
|
user = state.user,
|
|
14
15
|
modal = state.modal;
|
|
@@ -25,7 +26,7 @@ var mapStateToProps = function mapStateToProps(state) {
|
|
|
25
26
|
products: product.products,
|
|
26
27
|
selectedProductId: selectedProduct.ProductId,
|
|
27
28
|
accounts: user.accounts,
|
|
28
|
-
accountTo: user.accounts[0]
|
|
29
|
+
accountTo: (_user$accounts$ = user.accounts[0]) === null || _user$accounts$ === void 0 ? void 0 : _user$accounts$.AccountId
|
|
29
30
|
};
|
|
30
31
|
};
|
|
31
32
|
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
@import '../Notifications/Notifications.css';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* The banner is static, so keep its background on hover. The extra class outranks
|
|
5
|
+
* .notification-item:hover, which Notifications.js can inject again after this file.
|
|
6
|
+
*/
|
|
7
|
+
.notification-item.no-account-banner:hover {
|
|
8
|
+
background-color: var(--nav-header__bg-color);
|
|
9
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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.NoAccountBannerComponent = exports.NoAccountBanner = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactRedux = require("react-redux");
|
|
10
|
+
var _reactI18next = require("react-i18next");
|
|
11
|
+
var _NotificationItem = require("../Notifications/NotificationItem");
|
|
12
|
+
var _APIcon = _interopRequireDefault(require("../common/APIcon"));
|
|
13
|
+
var _Button = require("../form/Button/Button");
|
|
14
|
+
var _userSelectors = require("../../redux/selectors/userSelectors");
|
|
15
|
+
require("./NoAccountBanner.css");
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
|
+
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); }
|
|
18
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
19
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
21
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
22
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
23
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
24
|
+
/**
|
|
25
|
+
* Shown when the account fetch has settled and the user has no trading
|
|
26
|
+
* account. Explains why the account-scoped areas of the site are empty
|
|
27
|
+
* without blocking navigation.
|
|
28
|
+
*/
|
|
29
|
+
var NoAccountBannerComponent = exports.NoAccountBannerComponent = function NoAccountBannerComponent(_ref) {
|
|
30
|
+
var hasNoAccounts = _ref.hasNoAccounts;
|
|
31
|
+
var _useTranslation = (0, _reactI18next.useTranslation)('core'),
|
|
32
|
+
t = _useTranslation.t;
|
|
33
|
+
var _useState = (0, _react.useState)(false),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
dismissed = _useState2[0],
|
|
36
|
+
setDismissed = _useState2[1];
|
|
37
|
+
if (!hasNoAccounts || dismissed) return null;
|
|
38
|
+
return /*#__PURE__*/_react["default"].createElement(_NotificationItem.NotificationItem, {
|
|
39
|
+
className: "no-account-banner",
|
|
40
|
+
icon: /*#__PURE__*/_react["default"].createElement(_APIcon["default"], {
|
|
41
|
+
name: "danger",
|
|
42
|
+
customClass: "no-account-banner-icon"
|
|
43
|
+
}),
|
|
44
|
+
actions: /*#__PURE__*/_react["default"].createElement(_Button.Button, {
|
|
45
|
+
variant: "primary",
|
|
46
|
+
size: "md",
|
|
47
|
+
onClick: function onClick() {
|
|
48
|
+
return setDismissed(true);
|
|
49
|
+
}
|
|
50
|
+
}, t('Dismiss'))
|
|
51
|
+
}, /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("h5", null, t('No trading account available')), /*#__PURE__*/_react["default"].createElement("p", null, t('This login is not associated with a trading account, so balances, positions and orders will be empty. Please contact support to have an account assigned.'))));
|
|
52
|
+
};
|
|
53
|
+
var mapStateToProps = function mapStateToProps(state) {
|
|
54
|
+
return {
|
|
55
|
+
hasNoAccounts: (0, _userSelectors.hasNoAccountsSelector)(state)
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
var NoAccountBanner = exports.NoAccountBanner = (0, _reactRedux.connect)(mapStateToProps)(NoAccountBannerComponent);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _NoAccountBanner = require("./NoAccountBanner");
|
|
7
|
+
Object.keys(_NoAccountBanner).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _NoAccountBanner[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _NoAccountBanner[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|