diff --git a/components/dashboard/BuyerOrderInfo.tsx b/components/dashboard/BuyerOrderInfo.tsx index a88e78f..708570a 100644 --- a/components/dashboard/BuyerOrderInfo.tsx +++ b/components/dashboard/BuyerOrderInfo.tsx @@ -30,16 +30,17 @@ interface Order { interface BuyerOrderInfoProps { buyerId: string; + chatId: string; } -export default function BuyerOrderInfo({ buyerId }: BuyerOrderInfoProps) { +export default function BuyerOrderInfo({ buyerId, chatId }: BuyerOrderInfoProps) { const router = useRouter(); const [loading, setLoading] = useState(true); const [orders, setOrders] = useState([]); useEffect(() => { - // Only load if we have a buyerId - if (!buyerId) return; + // Only load if we have a chatId + if (!chatId) return; const fetchBuyerOrders = async () => { try { @@ -54,8 +55,8 @@ export default function BuyerOrderInfo({ buyerId }: BuyerOrderInfoProps) { } }); - // Fetch orders for this specific buyer - const response = await authAxios.get(`/orders/buyer/${buyerId}?limit=5`); + // Use the new endpoint that works with sub-users + const response = await authAxios.get(`/chats/${chatId}/orders?limit=250`); if (response.data && response.data.orders) { setOrders(response.data.orders); @@ -69,7 +70,7 @@ export default function BuyerOrderInfo({ buyerId }: BuyerOrderInfoProps) { }; fetchBuyerOrders(); - }, [buyerId]); + }, [chatId]); const handleViewOrder = (orderId: string) => { router.push(`/dashboard/orders/${orderId}`); diff --git a/components/dashboard/ChatDetail.tsx b/components/dashboard/ChatDetail.tsx index b902bf4..15ee4a9 100644 --- a/components/dashboard/ChatDetail.tsx +++ b/components/dashboard/ChatDetail.tsx @@ -399,7 +399,7 @@ export default function ChatDetail({ chatId }: { chatId: string }) { - +