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)

88 lines (87 loc) 2.98 kB
import { jsx as g } from "../../../../../external/preact/jsx-runtime/dist/jsxRuntime.module.js"; import { memo as D } from "../../../../../external/preact/compat/dist/compat.module.js"; import { createContext as E } from "../../../../../external/preact/dist/preact.module.js"; import { useContext as F } from "../../../../../external/preact/hooks/dist/hooks.module.js"; import { REFUND_REASONS as N } from "../constants.js"; import { useRefundContextActions as U } from "./hooks/useRefundContextActions.js"; import { useRefundContextAmount as _ } from "./hooks/useRefundContextAmount.js"; import { useRefundContextLineItems as O } from "./hooks/useRefundContextLineItems.js"; import { useRefundContextReason as S } from "./hooks/useRefundContextReason.js"; import Y from "../../../../../hooks/useMutation/useMutation.js"; import { RefundMode as j } from "../types.js"; import { useConfigContext as q } from "../../../../../core/ConfigContext/context.js"; import { noop as t } from "../../../../../utils/common.js"; import { EMPTY_ARRAY as f } from "../../../../../utils/value/constants.js"; const d = E({ amount: 0, availableAmount: 0, availableItems: f, clearItems: t, currency: "", interactionsDisabled: !1, items: f, primaryAction: t, refundMode: j.FULL_AMOUNT, refundReason: N[0], secondaryAction: t, setAmount: t, setRefundReason: t, transactionId: "", updateItems: t }), $ = D( ({ availableAmount: s, children: c, currency: e, lineItems: p, refreshTransaction: R, refundMode: n, setActiveView: A, setPrimaryAction: l, setSecondaryAction: x, transactionId: r }) => { const { isLoading: m, mutate: C } = Y({ queryFn: q().endpoints.initiateRefund }), { availableItems: I, clearItems: v, items: a, updateItems: T } = O({ currency: e, lineItems: p }), o = m, [i, b] = _({ availableAmount: s, currency: e, interactionsDisabled: o, items: a, refundMode: n }), [u, y] = S({ interactionsDisabled: o, refundMode: n }), { value: L } = i, { primaryAction: M, secondaryAction: P } = U({ interactionsDisabled: o, refreshTransaction: R, refundAmount: i, refundInProgress: m, refundReason: u, refundTransaction: C, setActiveView: A, setPrimaryAction: l, setSecondaryAction: x, transactionId: r }); return /* @__PURE__ */ g( d.Provider, { value: { amount: L, availableAmount: s, availableItems: I, clearItems: v, currency: e, interactionsDisabled: o, items: a, primaryAction: M, refundMode: n, refundReason: u, secondaryAction: P, setAmount: b, setRefundReason: y, transactionId: r, updateItems: T }, children: c } ); } ), tt = () => F(d); export { $ as TransactionRefundProvider, tt as default, tt as useTransactionRefundContext };