diff --git a/src/pages/ConsultingBooking.tsx b/src/pages/ConsultingBooking.tsx index 9522b7d..ff13e8f 100644 --- a/src/pages/ConsultingBooking.tsx +++ b/src/pages/ConsultingBooking.tsx @@ -336,7 +336,7 @@ export default function ConsultingBooking() { const { error: slotsError } = await supabase.from('consulting_slots').insert(slotsToInsert); if (slotsError) throw slotsError; - // Call edge function to create payment (avoids CORS) + // Call edge function to create payment with QR code const { data: paymentData, error: paymentError } = await supabase.functions.invoke('create-payment', { body: { order_id: order.id, @@ -351,12 +351,8 @@ export default function ConsultingBooking() { throw new Error(paymentError.message || 'Gagal membuat pembayaran'); } - if (paymentData?.success && paymentData?.data?.payment_url) { - // Redirect to payment page - window.location.href = paymentData.data.payment_url; - } else { - throw new Error('Gagal membuat URL pembayaran'); - } + // Navigate to order detail page to show QR code + navigate(`/orders/${order.id}`); } catch (error: any) { toast({ title: 'Error', description: error.message, variant: 'destructive' }); } finally { diff --git a/src/pages/admin/AdminOrders.tsx b/src/pages/admin/AdminOrders.tsx index 3a733c8..6aa1f8d 100644 --- a/src/pages/admin/AdminOrders.tsx +++ b/src/pages/admin/AdminOrders.tsx @@ -297,12 +297,12 @@ export default function AdminOrders() { const csvData = (ordersData as Order[]).map((order) => ({ "Order ID": order.id, "Email": order.profile?.email || "", - "Total": formatExportIDR(order.total_amount), + "Total": order.total_amount / 100, // Raw number in IDR (no formatting) "Status": getPaymentStatusLabel(order.payment_status), "Metode Pembayaran": order.payment_method || "", "Referensi": order.payment_reference || "", "Tanggal": formatExportDate(order.created_at), - "Refund Amount": order.refunded_amount ? formatExportIDR(order.refunded_amount) : "", + "Refund Amount": order.refunded_amount ? order.refunded_amount / 100 : "", "Refund Reason": order.refund_reason || "", "Refunded At": order.refunded_at ? formatExportDate(order.refunded_at) : "", })); diff --git a/src/pages/member/OrderDetail.tsx b/src/pages/member/OrderDetail.tsx index 8efd9e3..17d112b 100644 --- a/src/pages/member/OrderDetail.tsx +++ b/src/pages/member/OrderDetail.tsx @@ -476,8 +476,107 @@ export default function OrderDetail() { {/* Smart Item/Service Display */} - {order.order_items.length > 0 ? ( - // === Product Orders === + {consultingSlots.length > 0 ? ( + // === Consulting Orders (NO order_items, has consulting_slots) === + <> + + + + + + + {/* Summary Card */} +
+
+
+

Waktu Konsultasi

+

+ {consultingSlots[0].start_time.substring(0,5)} - {consultingSlots[consultingSlots.length-1].end_time.substring(0,5)} +

+

+ {consultingSlots.length} blok ({consultingSlots.length * 45} menit) +

+
+ +
+

Tanggal

+

+ {new Date(consultingSlots[0].date).toLocaleDateString("id-ID", { + weekday: "long", + year: "numeric", + month: "long", + day: "numeric" + })} +

+
+ + {consultingSlots[0]?.meet_link && ( +
+

Google Meet Link

+ + {consultingSlots[0].meet_link.substring(0, 40)}... + +
+ )} +
+
+ + {/* Status Alert */} + {order.payment_status === "paid" ? ( + + + ) : ( + + + + Selesaikan pembayaran untuk mengkonfirmasi jadwal sesi konsultasi. + + + )} + + {/* Total */} +
+ Total Pembayaran + {formatIDR(order.total_amount)} +
+
+
+ + {/* Consulting Slots Detail */} + + + Detail Jadwal + + +
+ {consultingSlots.map((slot, index) => ( +
+
+

Blok {index + 1}

+

{slot.start_time.substring(0, 5)} - {slot.end_time.substring(0, 5)} WIB

+
+ + {slot.status === "confirmed" ? "Terkonfirmasi" : slot.status} + +
+ ))} +
+
+
+ + ) : order.order_items.length > 0 ? ( + // === Product Orders (has order_items) === @@ -518,127 +617,8 @@ export default function OrderDetail() { - ) : consultingSlots.length > 0 ? ( - // === Consulting Orders === - - - - - - - {/* Summary Card */} -
-
-
-

Waktu Konsultasi

-

- {consultingSlots[0].start_time.substring(0,5)} - {consultingSlots[consultingSlots.length-1].end_time.substring(0,5)} -

-

- {consultingSlots.length} blok ({consultingSlots.length * 45} menit) -

-
- - {consultingSlots[0]?.meet_link && ( -
-

Google Meet Link

- - {consultingSlots[0].meet_link.substring(0, 40)}... - -
- )} -
-
- - {/* Status Alert */} - {order.payment_status === "paid" ? ( - - - ) : ( - - - - Selesaikan pembayaran untuk mengkonfirmasi jadwal sesi konsultasi. - - - )} -
-
) : null} - {/* Consulting Slots Detail */} - {consultingSlots.length > 0 && ( - - - - - - -
- {consultingSlots.map((slot) => ( -
-
-
-
- - {slot.status === "confirmed" ? "Terkonfirmasi" : slot.status} - -
-

- {new Date(slot.date).toLocaleDateString("id-ID", { - weekday: "long", - year: "numeric", - month: "long", - day: "numeric" - })} -

-

- {slot.start_time.substring(0, 5)} - {slot.end_time.substring(0, 5)} WIB -

-
- {slot.meet_link && order.payment_status === "paid" && ( - - )} - {slot.meet_link && order.payment_status !== "paid" && ( -

- Link tersedia setelah pembayaran -

- )} - {!slot.meet_link && ( -

- Link akan dikirim via email -

- )} -
-
- ))} -
-
-
- )} - {/* Access Info */} {order.payment_status === "paid" && (