Fix consulting order detail to show slots and QR code
Fixed isConsultingOrder detection: - Now checks consultingSlots.length > 0 instead of only checking order_items - Consulting orders don't have order_items, only consulting_slots Always fetch consulting slots: - Removed conditional check that only fetched slots for consulting products - Now always queries consulting_slots table for any order - This ensures consulting booking info displays correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,8 +68,8 @@ export default function OrderDetail() {
|
||||
? new Date(order.qr_expires_at) < new Date()
|
||||
: false;
|
||||
|
||||
// Check if this is a consulting order
|
||||
const isConsultingOrder = order?.order_items?.some(
|
||||
// Check if this is a consulting order (has consulting_slots OR order_items with consulting type)
|
||||
const isConsultingOrder = consultingSlots.length > 0 || order?.order_items?.some(
|
||||
(item: OrderItem) => item.products.type === "consulting"
|
||||
) || false;
|
||||
|
||||
@@ -123,21 +123,15 @@ export default function OrderDetail() {
|
||||
} else {
|
||||
setOrder(data);
|
||||
|
||||
// Fetch consulting slots if this is a consulting order
|
||||
const hasConsultingProduct = data.order_items.some(
|
||||
(item: OrderItem) => item.products.type === "consulting"
|
||||
);
|
||||
// Always fetch consulting slots for this order (consulting orders don't have order_items)
|
||||
const { data: slots } = await supabase
|
||||
.from("consulting_slots")
|
||||
.select("*")
|
||||
.eq("order_id", id)
|
||||
.order("date", { ascending: true });
|
||||
|
||||
if (hasConsultingProduct) {
|
||||
const { data: slots } = await supabase
|
||||
.from("consulting_slots")
|
||||
.select("*")
|
||||
.eq("order_id", id)
|
||||
.order("date", { ascending: true });
|
||||
|
||||
if (slots) {
|
||||
setConsultingSlots(slots as ConsultingSlot[]);
|
||||
}
|
||||
if (slots && slots.length > 0) {
|
||||
setConsultingSlots(slots as ConsultingSlot[]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user