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)

37 lines (36 loc) 1.23 kB
import I from "../../../../hooks/useAnalytics/useFilterAnalyticsEvent.js"; import { useMemo as a, useCallback as i, useState as v, useRef as u, useEffect as p } from "../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js"; const k = ({ availableCurrencies: c, eventCategory: g, eventSubCategory: h, eventLabel: R, onUpdateSelection: f, selectedCurrency: n }) => { const { logEvent: d } = I({ category: g, subCategory: h, label: R }), S = a( () => Object.freeze(c?.map((t) => ({ id: t, name: t })) ?? []), [c] ), o = i( (t) => { const s = t ? c?.findIndex((E) => E === t) ?? -1 : -1; return c?.[s]; }, [c] ), [e, y] = v(() => o(n)), r = u(), m = u(c), A = u(n), x = i( ({ target: t }) => { const s = o(t?.value); s && (r.current = e, y(s)); }, [o, e] ); return p(() => { (m.current !== c || A.current !== n) && (m.current = c, A.current = n, r.current = void 0, y(o(n))); }, [o, n, c]), p(() => { const t = r.current; t !== e && (r.current = e, t && e && d?.("update", e), f?.(e)); }, [e, d, f]), { activeCurrency: e, currencySelectionOptions: S, onCurrencySelection: x }; }; export { k as default };