diff --git a/attached_assets/image_1755030363409.png b/attached_assets/image_1755030363409.png new file mode 100644 index 0000000..a4c87e7 Binary files /dev/null and b/attached_assets/image_1755030363409.png differ diff --git a/client/src/components/Layout.tsx b/client/src/components/Layout.tsx index 2b0697e..13f954c 100644 --- a/client/src/components/Layout.tsx +++ b/client/src/components/Layout.tsx @@ -90,7 +90,7 @@ export default function Layout({ children }: LayoutProps) { {/* Desktop Sidebar */} {!isMobile && } -
{/* Header with store selector for admin */} diff --git a/client/src/hooks/usePagination.ts b/client/src/hooks/usePagination.ts new file mode 100644 index 0000000..d3971e6 --- /dev/null +++ b/client/src/hooks/usePagination.ts @@ -0,0 +1,30 @@ +import { useState, useMemo, useEffect } from 'react'; + +export function usePagination(data: T[], initialItemsPerPage: number = 10) { + const [currentPage, setCurrentPage] = useState(1); + const [itemsPerPage, setItemsPerPage] = useState(initialItemsPerPage); + + const totalItems = data.length; + const totalPages = Math.ceil(totalItems / itemsPerPage); + + // Reset to first page when data changes + useEffect(() => { + setCurrentPage(1); + }, [data.length, itemsPerPage]); + + const paginatedData = useMemo(() => { + const startIndex = (currentPage - 1) * itemsPerPage; + const endIndex = startIndex + itemsPerPage; + return data.slice(startIndex, endIndex); + }, [data, currentPage, itemsPerPage]); + + return { + currentPage, + setCurrentPage, + itemsPerPage, + setItemsPerPage, + totalPages, + totalItems, + paginatedData, + }; +} \ No newline at end of file diff --git a/client/src/pages/CustomerOrders.tsx b/client/src/pages/CustomerOrders.tsx index 90de1f7..f67baa4 100644 --- a/client/src/pages/CustomerOrders.tsx +++ b/client/src/pages/CustomerOrders.tsx @@ -674,8 +674,8 @@ export default function CustomerOrders() { } = usePagination(sortedOrders, 10); return ( -
-
+
+
{/* Header */}
diff --git a/client/src/pages/Dashboard.tsx b/client/src/pages/Dashboard.tsx index 50dcea4..b460a14 100644 --- a/client/src/pages/Dashboard.tsx +++ b/client/src/pages/Dashboard.tsx @@ -218,8 +218,8 @@ export default function Dashboard() { }; return ( -
-
+
+
{/* Header */}
diff --git a/client/src/pages/Deliveries.tsx b/client/src/pages/Deliveries.tsx index 8eb73df..8e89f94 100644 --- a/client/src/pages/Deliveries.tsx +++ b/client/src/pages/Deliveries.tsx @@ -4,7 +4,8 @@ import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Badge } from "@/components/ui/badge"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; -import { Pagination, usePagination } from "@/components/ui/pagination"; +import { Pagination } from "@/components/ui/pagination"; +import { usePagination } from "@/hooks/usePagination"; import { useAuthUnified } from "@/hooks/useAuthUnified"; import { useStore } from "@/components/Layout"; import { useToast } from "@/hooks/use-toast"; @@ -255,8 +256,8 @@ export default function Deliveries() { const canValidate = permissions.canValidate('deliveries'); return ( -
-
+
+
{/* Header */}
diff --git a/client/src/pages/Orders.tsx b/client/src/pages/Orders.tsx index d336410..c5adca3 100644 --- a/client/src/pages/Orders.tsx +++ b/client/src/pages/Orders.tsx @@ -4,7 +4,8 @@ import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Badge } from "@/components/ui/badge"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; -import { Pagination, usePagination } from "@/components/ui/pagination"; +import { Pagination } from "@/components/ui/pagination"; +import { usePagination } from "@/hooks/usePagination"; import { useAuthUnified } from "@/hooks/useAuthUnified"; import { useStore } from "@/components/Layout"; import { useToast } from "@/hooks/use-toast"; @@ -226,8 +227,8 @@ export default function Orders() { const canDelete = permissions.canDelete('orders'); return ( -
-
+
+
{/* Header */}