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)

30 lines (29 loc) 871 B
import { useState as f, useCallback as n, useEffect as u } from "../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js"; import { isFunction as y } from "../utils/value/is.js"; const w = ({ records: s, hasCustomColumn: r = !1, onDataRetrieve: e, mergeCustomData: a }) => { const [l, o] = f(s), [d, c] = f(!1), i = n(async () => { try { if (r && y(e)) { const t = await e(s); if (Array.isArray(t)) o(a({ records: s, retrievedData: t?.filter(Boolean) || [] })); else throw new Error("Retrieved data should be an array"); } else o(s); } catch (t) { o(s), console.error(t); } finally { c(!1); } }, [r, e, a, s]); return u(() => { r && e && c(!0), i(); }, [r, i, e]), { customRecords: l, loadingCustomRecords: d }; }; export { w as useCustomColumnsData };