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)

41 lines (40 loc) 1.23 kB
import { useRefundAction as y } from "./useRefundAction.js"; import { useMemo as l, useCallback as p, useEffect as u } from "../../../../../../external/preact/hooks/dist/hooks.module.js"; import C from "../../../../../../core/Context/useCoreContext.js"; import { ButtonVariant as A } from "../../../../../internal/Button/types.js"; import { ActiveView as R } from "../../types.js"; const k = ({ interactionsDisabled: t, refundAmount: n, setActiveView: r, setPrimaryAction: i, setSecondaryAction: s, ...v }) => { const { refundAction: f, refundActionLabel: m } = y({ ...v, refundAmount: n, setActiveView: r }), { i18n: b } = C(), o = l(() => t || n.value <= 0, [n, t]), a = p(() => !o && f(), [o, f]), e = t, d = l(() => b.get("back"), [b]), c = p( () => void (!e && r(R.DETAILS)), [e, r] ); return u(() => { i( Object.freeze({ disabled: o, event: a, variant: A.PRIMARY, ...m }) ); }, [a, o, m, i]), u(() => { s( Object.freeze({ disabled: e, event: c, title: d, variant: A.SECONDARY }) ); }, [c, e, d, s]), { primaryAction: a, secondaryAction: c }; }; export { k as useRefundContextActions };