This commit is contained in:
NotII
2025-03-18 18:51:51 +01:00
parent 2715d3a0e7
commit 22bfa73b14
2 changed files with 8 additions and 7 deletions

View File

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

View File

@@ -399,7 +399,7 @@ export default function ChatDetail({ chatId }: { chatId: string }) {
</div> </div>
</div> </div>
<BuyerOrderInfo buyerId={chat.buyerId} /> <BuyerOrderInfo buyerId={chat.buyerId} chatId={chatId} />
</div> </div>
<div className="flex-1 overflow-y-auto p-2 space-y-2 pb-[80px]"> <div className="flex-1 overflow-y-auto p-2 space-y-2 pb-[80px]">