diff --git a/app/properties/page.jsx b/app/properties/page.jsx index a58b447..d78e2e1 100644 --- a/app/properties/page.jsx +++ b/app/properties/page.jsx @@ -4,13 +4,16 @@ import Pagination from '@/components/Pagination'; import Property from '@/models/Property'; import connectDB from '@/config/database'; -const PropertiesPage = async ({ searchParams: { pageSize = 3, page = 1 } }) => { +const PropertiesPage = async ({ searchParams: { pageSize = 9, page = 1 } }) => { await connectDB(); const skip = (page - 1) * pageSize; const total = await Property.countDocuments({}); const properties = await Property.find({}).skip(skip).limit(pageSize); + // Calculate if pagination is needed + const showPagination = total > pageSize; + return ( <>
@@ -30,11 +33,13 @@ const PropertiesPage = async ({ searchParams: { pageSize = 3, page = 1 } }) => { ))} )} - + {showPagination && ( + + )}