diff --git a/components/tables/order-table.tsx b/components/tables/order-table.tsx
index 9dd2c7f..55ce509 100644
--- a/components/tables/order-table.tsx
+++ b/components/tables/order-table.tsx
@@ -129,6 +129,8 @@ export default function OrderTable() {
const queryParams = new URLSearchParams({
page: currentPage.toString(),
limit: itemsPerPage.toString(),
+ sortBy: sortConfig.column,
+ sortOrder: sortConfig.direction,
...(statusFilter !== "all" && { status: statusFilter }),
});
@@ -143,7 +145,7 @@ export default function OrderTable() {
} finally {
setLoading(false);
}
- }, [currentPage, statusFilter, itemsPerPage]);
+ }, [currentPage, statusFilter, itemsPerPage, sortConfig]);
useEffect(() => {
fetchOrders();
@@ -169,27 +171,8 @@ export default function OrderTable() {
(order) => statusFilter === "all" || order.status === statusFilter
);
- const sortedOrders = [...filteredOrders].sort((a, b) => {
- const aValue = a[sortConfig.column];
- 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
- );
+ // Use the orders directly as they're already sorted by the server
+ const paginatedOrders = filteredOrders;
// Handlers
const handleSort = (column: SortableColumns) => {
@@ -197,6 +180,7 @@ export default function OrderTable() {
column,
direction: prev.column === column && prev.direction === "asc" ? "desc" : "asc"
}));
+ setCurrentPage(1); // Reset to first page when changing sort order
};
const toggleSelection = (orderId: string) => {
@@ -361,7 +345,7 @@ export default function OrderTable() {
0}
+ checked={selectedOrders.size === paginatedOrders.length && paginatedOrders.length > 0}
onCheckedChange={toggleAll}
/>
@@ -382,7 +366,7 @@ export default function OrderTable() {
- {orders.map((order) => {
+ {paginatedOrders.map((order) => {
const StatusIcon = statusConfig[order.status as keyof typeof statusConfig]?.icon || XCircle;
return (
diff --git a/next.config.mjs b/next.config.mjs
index 851867e..33c8003 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -9,14 +9,18 @@ const nextConfig = {
{
protocol: "https",
hostname: "telegram.org",
- }
+ },
+ {
+ protocol: "https",
+ hostname: "internal-api.inboxi.ng",
+ },
],
},
async rewrites() {
return [
{
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*',
},
];
},