@adyen/adyen-platform-experience-web
Version:

19 lines (18 loc) • 773 B
JavaScript
import { useState as s, useCallback as f, useMemo as m } from "../external/preact/hooks/dist/hooks.module.js";
import { capitalize as x } from "../utils/value/string.js";
const u = (e) => {
const [d, t] = s(0), r = f(() => t(0), [t]), p = m(() => e == null ? void 0 : e[d], [e, d]), B = m(
() => e && e.length > 1 ? Object.freeze(e.map(({ description: i, id: o }) => ({ id: o, name: x(i) }))) : void 0,
[e]
), S = f(
({ target: i }) => {
const o = i == null ? void 0 : i.value, n = e == null ? void 0 : e.findIndex(({ id: l }) => l === o);
n >= 0 && t(n);
},
[e, t]
);
return { activeBalanceAccount: p, balanceAccountSelectionOptions: B, onBalanceAccountSelection: S, resetBalanceAccountSelection: r };
};
export {
u as default
};