i hope this fixed it

This commit is contained in:
NotII
2025-03-23 23:18:17 +00:00
parent 64ee9b842e
commit f6a2a69ac4
4 changed files with 209 additions and 165 deletions

View File

@@ -11,7 +11,7 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
import { getCookie } from "@/lib/client-utils";
import axios from "axios";
import { clientFetch } from "@/lib/client-utils";
import { useRouter } from "next/navigation";
interface Order {
@@ -62,27 +62,13 @@ export default function BuyerOrderInfo({ buyerId, chatId }: BuyerOrderInfoProps)
setLoading(true);
try {
const authToken = getCookie("Authorization");
// Use clientFetch instead of direct axios calls
// This ensures the request goes through Next.js API rewrites
const response = await clientFetch(`/chats/${chatId}/orders?limit=10`);
if (!authToken) {
isFetchingRef.current = false;
setLoading(false);
return;
}
const authAxios = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_URL,
headers: {
Authorization: `Bearer ${authToken}`
}
});
// Use the new endpoint that works with sub-users
const response = await authAxios.get(`/chats/${chatId}/orders?limit=10`); // Limit to fewer orders for faster response
if (response.data && response.data.orders) {
setOrders(response.data.orders);
setHasOrders(response.data.orders.length > 0);
if (response && response.orders) {
setOrders(response.orders);
setHasOrders(response.orders.length > 0);
} else {
setHasOrders(false);
}