UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

19 lines (18 loc) 773 B
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 };