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 m, useMemo as r } from "../external/preact/hooks/dist/hooks.module.js"; import { capitalize as x } from "../utils/value/string.js"; const z = (e) => { const [d, o] = s(0), f = m(() => o(0), [o]), p = r(() => e == null ? void 0 : e[d], [e, d]), B = r( () => e && e.length > 1 ? Object.freeze(e.map(({ description: i, id: t }) => ({ id: t, name: x(i) }))) : void 0, [e] ), S = m( ({ target: i }) => { const t = i == null ? void 0 : i.value, n = e == null ? void 0 : e.findIndex(({ id: l }) => l === t); n >= 0 && o(n); }, [e, o] ); return { activeBalanceAccount: p, balanceAccountSelectionOptions: B, onBalanceAccountSelection: S, resetBalanceAccountSelection: f }; }; export { z as default };