import { Form } from '@components/common/form/Form.js'; import { NumberField } from '@components/common/form/NumberField.js'; import { useAlertContext } from '@components/common/modal/Alert.js'; import RenderIfTrue from '@components/common/RenderIfTrue.js'; import { Button } from '@components/common/ui/Button.js'; import { CardContent } from '@components/common/ui/Card.js'; import { toast } from '@components/common/ui/Sonner.js'; import { _ } from '@evershop/evershop/lib/locale/translate/_'; import React from 'react'; interface RefundButtonProps { order: { canRefund: boolean; refundApi: string; grandTotal: { value: number; currency: string; }; }; } /** * The one refund button, owned by core (OMS), not by any payment module. It is * shown automatically for every payment method whose `Order.canRefund` is true * (capability + refundable status), and posts to the single core refund route. * No per-gateway button, no per-gateway route. */ export default function RefundButton({ order: { canRefund, refundApi, grandTotal } }: RefundButtonProps) { const { openAlert, closeAlert, dispatchAlert } = useAlertContext(); const [loading, setLoading] = React.useState(false); return (
); } export const layout = { areaId: 'orderPaymentActions', sortOrder: 10 }; export const query = ` query Query { order(uuid: getContextValue("orderId")) { canRefund refundApi grandTotal { value currency } } } `;