balls
This commit is contained in:
@@ -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}`);
|
||||
|
||||
@@ -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]">
|
||||
|
||||
Reference in New Issue
Block a user