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 {
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<Order[]>([]);
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}`);

View File

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