@@ -36,14 +35,13 @@ export default function Checkout() {
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
- // Construct the payload structure requested by the user
const payload = {
name: formData.name,
email: formData.email,
phone: formData.phone,
address: formData.address,
- location_id: "98adc52b-966d-39db-809a-55902ee7228f", // hardcoded mock as requested
- payment_channel_id: "d48a46b6-3a18-3763-951d-66b7fdb284ae", // hardcoded mock
+ location_id: "98adc52b-966d-39db-809a-55902ee7228f",
+ payment_channel_id: "d48a46b6-3a18-3763-951d-66b7fdb284ae",
properties: {},
products: [
{
@@ -57,7 +55,6 @@ export default function Checkout() {
totalPrice: ticketState.totalPrice
};
- // Navigate to payment page with this payload
navigate('/payment', { state: { checkoutPayload: payload } });
};
diff --git a/src/pages/Payment.tsx b/src/pages/Payment.tsx
index 1a61b8a..12d90f4 100644
--- a/src/pages/Payment.tsx
+++ b/src/pages/Payment.tsx
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import QRCode from 'react-qr-code';
import { ArrowLeft, CheckCircle2 } from 'lucide-react';
+import BrutalAlert, { AlertType } from '../components/BrutalAlert';
export default function Payment() {
const location = useLocation();
@@ -9,9 +10,9 @@ export default function Payment() {
const checkoutPayload = location.state?.checkoutPayload;
const [transactionId, setTransactionId] = useState('');
const [isPaid, setIsPaid] = useState(false);
+ const [alert, setAlert] = useState<{show: boolean, message: string, type: AlertType}>({ show: false, message: '', type: 'info' });
useEffect(() => {
- // Generate a mock Xendit Transaction ID when component mounts
if (checkoutPayload && !transactionId) {
const randomStr = Math.random().toString(36).substring(2, 10).toUpperCase();
setTransactionId(`XND-QRIS-${randomStr}`);
@@ -32,10 +33,15 @@ export default function Payment() {
}
const handleSimulatePayment = () => {
- setIsPaid(true);
+ setAlert({ show: true, message: 'Validating Payment...', type: 'warning' });
+
setTimeout(() => {
- navigate('/events');
- }, 4000);
+ setAlert({ show: true, message: 'Payment Confirmed! Redirecting...', type: 'success' });
+ setIsPaid(true);
+ setTimeout(() => {
+ navigate('/events');
+ }, 3000);
+ }, 1500);
};
if (isPaid) {
@@ -69,7 +75,7 @@ export default function Payment() {
- {/* Header Xendit Mock */}
+
Merchant
@@ -122,6 +128,14 @@ export default function Payment() {
+
+ {alert.show && (
+
setAlert(prev => ({ ...prev, show: false }))}
+ />
+ )}
);
}