/**
 * Payment modal – wraps PaymentCore in a WordPress Modal.
 */
import { __ } from '@wordpress/i18n';
import { Modal } from '@wordpress/components';
import type { GenericPaymentResponse } from '../../../types';
import {PaymentCore }from '..';
import { PaymentOrderResponse } from '../../../types/payment';

export interface PaymentModalProps {
	paymentOrder: PaymentOrderResponse;
	onRequestClose: () => void;
	onPaymentSuccess: (response: GenericPaymentResponse, paymentOrder: PaymentOrderResponse) => void;
}

export default function PaymentModal({
	paymentOrder,
	onRequestClose,
	onPaymentSuccess,
}: PaymentModalProps) {
	return (
		<Modal
			size="large"
			title={__('Confirm Payment', 'parcel2go-shipping')}
			onRequestClose={onRequestClose}
			isDismissible={true}
			aria-describedby={__('Payment modal', 'parcel2go-shipping')}
			shouldCloseOnClickOutside={false}
		>
			<PaymentCore
				paymentOrder={paymentOrder}
				onSuccess={onPaymentSuccess}
			/>
		</Modal>
	);
}
