update config

This commit is contained in:
NotII
2025-03-23 21:00:49 +00:00
parent b06e2ca0b1
commit dc51901c5c
2 changed files with 14 additions and 26 deletions

View File

@@ -129,6 +129,8 @@ export default function OrderTable() {
const queryParams = new URLSearchParams({ const queryParams = new URLSearchParams({
page: currentPage.toString(), page: currentPage.toString(),
limit: itemsPerPage.toString(), limit: itemsPerPage.toString(),
sortBy: sortConfig.column,
sortOrder: sortConfig.direction,
...(statusFilter !== "all" && { status: statusFilter }), ...(statusFilter !== "all" && { status: statusFilter }),
}); });
@@ -143,7 +145,7 @@ export default function OrderTable() {
} finally { } finally {
setLoading(false); setLoading(false);
} }
}, [currentPage, statusFilter, itemsPerPage]); }, [currentPage, statusFilter, itemsPerPage, sortConfig]);
useEffect(() => { useEffect(() => {
fetchOrders(); fetchOrders();
@@ -169,27 +171,8 @@ export default function OrderTable() {
(order) => statusFilter === "all" || order.status === statusFilter (order) => statusFilter === "all" || order.status === statusFilter
); );
const sortedOrders = [...filteredOrders].sort((a, b) => { // Use the orders directly as they're already sorted by the server
const aValue = a[sortConfig.column]; const paginatedOrders = filteredOrders;
const bValue = b[sortConfig.column];
if (typeof aValue === "string" && typeof bValue === "string") {
return sortConfig.direction === "asc"
? aValue.localeCompare(bValue)
: bValue.localeCompare(aValue);
}
if (typeof aValue === "number" && typeof bValue === "number") {
return sortConfig.direction === "asc" ? aValue - bValue : bValue - aValue;
}
return 0;
});
const paginatedOrders = sortedOrders.slice(
(currentPage - 1) * itemsPerPage,
currentPage * itemsPerPage
);
// Handlers // Handlers
const handleSort = (column: SortableColumns) => { const handleSort = (column: SortableColumns) => {
@@ -197,6 +180,7 @@ export default function OrderTable() {
column, column,
direction: prev.column === column && prev.direction === "asc" ? "desc" : "asc" direction: prev.column === column && prev.direction === "asc" ? "desc" : "asc"
})); }));
setCurrentPage(1); // Reset to first page when changing sort order
}; };
const toggleSelection = (orderId: string) => { const toggleSelection = (orderId: string) => {
@@ -361,7 +345,7 @@ export default function OrderTable() {
<TableRow> <TableRow>
<TableHead className="w-12"> <TableHead className="w-12">
<Checkbox <Checkbox
checked={selectedOrders.size === orders.length && orders.length > 0} checked={selectedOrders.size === paginatedOrders.length && paginatedOrders.length > 0}
onCheckedChange={toggleAll} onCheckedChange={toggleAll}
/> />
</TableHead> </TableHead>
@@ -382,7 +366,7 @@ export default function OrderTable() {
</TableRow> </TableRow>
</TableHeader> </TableHeader>
<TableBody> <TableBody>
{orders.map((order) => { {paginatedOrders.map((order) => {
const StatusIcon = statusConfig[order.status as keyof typeof statusConfig]?.icon || XCircle; const StatusIcon = statusConfig[order.status as keyof typeof statusConfig]?.icon || XCircle;
return ( return (

View File

@@ -9,14 +9,18 @@ const nextConfig = {
{ {
protocol: "https", protocol: "https",
hostname: "telegram.org", hostname: "telegram.org",
} },
{
protocol: "https",
hostname: "internal-api.inboxi.ng",
},
], ],
}, },
async rewrites() { async rewrites() {
return [ return [
{ {
source: '/api/:path*', source: '/api/:path*',
destination: 'https://internal-api.inboxi.ng/api/:path*', // Replace with your external domain URL destination: 'https://internal-api.inboxi.ng/api/:path*',
}, },
]; ];
}, },