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