@sb1/ffe-account-selector-react
Version:
Selector for bank accounts with autocomplete.
22 lines (21 loc) • 1.1 kB
JavaScript
;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccountsWithCustomAccounts = void 0;
var getAccountsWithCustomAccounts = function (_a) {
var accounts = _a.accounts, selectedAccount = _a.selectedAccount, inputValue = _a.inputValue;
var shouldAddSelectedAccountNotFoundInList = selectedAccount &&
selectedAccount.name === inputValue &&
!accounts.find(function (account) { return account.accountNumber === selectedAccount.accountNumber; });
return shouldAddSelectedAccountNotFoundInList
? __spreadArray(__spreadArray([], accounts, true), [selectedAccount], false) : accounts;
};
exports.getAccountsWithCustomAccounts = getAccountsWithCustomAccounts;