diff --git a/package.json b/package.json
index c2f98df..d477a0c 100644
--- a/package.json
+++ b/package.json
@@ -25,6 +25,7 @@
"qs-esm": "^7.0.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
+ "react-select": "^5.10.1",
"swiper": "^11.2.6"
},
"devDependencies": {
diff --git a/src/app/(main)/listings-for-rent/[slug]/page.tsx b/src/app/(main)/listings-for-rent/[slug]/page.tsx
index a6dada7..92fef63 100644
--- a/src/app/(main)/listings-for-rent/[slug]/page.tsx
+++ b/src/app/(main)/listings-for-rent/[slug]/page.tsx
@@ -5,7 +5,6 @@ import { formatCurrency } from "@/utils/general";
const similarPropertiesData: CardPropertyData[] = [
{
- id: 1,
title: "401 Biscayne Boulevard, Miami",
slug: "401-biscayne-boulevard",
images: [
@@ -16,23 +15,20 @@ const similarPropertiesData: CardPropertyData[] = [
price: 5000,
propertyType: "rent",
posted_at: "",
- area: 480,
- bathrooms_count: 2,
- bedrooms_count: 2,
- is_available: true,
+ area: "480",
+ bathrooms_count: "2",
+ bedrooms_count: "2",
},
{
- id: 2,
title: "402 Biscayne Boulevard, Miami",
slug: "402-biscayne-boulevard",
images: [{ url: "/images/featured-properties-01-480x287.jpg", alt: "biscayne boulevard" }],
price: 5000,
propertyType: "rent",
posted_at: "",
- area: 480,
- bathrooms_count: 2,
- bedrooms_count: 2,
- is_available: true,
+ area: "480",
+ bathrooms_count: "2",
+ bedrooms_count: "2",
},
];
@@ -367,8 +363,8 @@ export default function ListingsForRentDetail() {
Similar Properties
- {similarPropertiesData.map((p) => (
-
+ {similarPropertiesData.map((p, idx) => (
+
))}
diff --git a/src/app/(main)/listings-for-rent/page.tsx b/src/app/(main)/listings-for-rent/page.tsx
index 107775c..bdd1cce 100644
--- a/src/app/(main)/listings-for-rent/page.tsx
+++ b/src/app/(main)/listings-for-rent/page.tsx
@@ -1,8 +1,12 @@
import CardProperty from "@/components/CardProperty";
import HeroImage from "@/components/HeroImage";
import Pagination from "@/components/Pagination";
-import { CardPropertyData } from "@/schema/property";
+import Select from "@/components/Select";
+import { FetchPropertyParams } from "@/schema/services/property";
+import { fetchProperty } from "@/services/payload/property";
import { getDefaultMetadata } from "@/utils/metadata";
+import { sanitizeNumber, sanitizePageNumber } from "@/utils/sanitize";
+import { State } from "country-state-city";
import { Metadata } from "next";
const metaDesc = "Explore the latest properties on the Dynamic Realty.";
@@ -15,66 +19,28 @@ export async function generateMetadata(): Promise {
return metadata;
}
-const propertiesData: CardPropertyData[] = [
- {
- id: 1,
- title: "401 Biscayne Boulevard, Miami",
- slug: "401-biscayne-boulevard",
- images: [
- { url: "/images/featured-properties-01-480x287.jpg", alt: "biscayne boulevard" },
- { url: "/images/featured-properties-01-480x287.jpg", alt: "biscayne boulevard" },
- { url: "/images/featured-properties-01-480x287.jpg", alt: "biscayne boulevard" },
- ],
- price: 5000,
- propertyType: "rent",
- posted_at: "",
- area: 480,
- bathrooms_count: 2,
- bedrooms_count: 2,
- is_available: true,
- },
- {
- id: 2,
- title: "402 Biscayne Boulevard, Miami",
- slug: "402-biscayne-boulevard",
- images: [{ url: "/images/featured-properties-01-480x287.jpg", alt: "biscayne boulevard" }],
- price: 5000,
- propertyType: "rent",
- posted_at: "",
- area: 480,
- bathrooms_count: 2,
- bedrooms_count: 2,
- is_available: true,
- },
- {
- id: 3,
- title: "403 Biscayne Boulevard, Miami",
- slug: "403-biscayne-boulevard",
- images: [{ url: "/images/featured-properties-01-480x287.jpg", alt: "biscayne boulevard" }],
- price: 5000,
- propertyType: "rent",
- posted_at: "",
- area: 480,
- bathrooms_count: 2,
- bedrooms_count: 2,
- is_available: true,
- },
- {
- id: 4,
- title: "404 Biscayne Boulevard, Miami",
- slug: "404-biscayne-boulevard",
- images: [{ url: "/images/featured-properties-01-480x287.jpg", alt: "biscayne boulevard" }],
- price: 5000,
- propertyType: "rent",
- posted_at: "",
- area: 480,
- bathrooms_count: 2,
- bedrooms_count: 2,
- is_available: true,
- },
-];
+export default async function ListingsForRent(props: {
+ searchParams?: Promise<{ [P in keyof FetchPropertyParams]: string }>;
+}) {
+ const searchParams = await props?.searchParams;
+ const page = sanitizePageNumber(searchParams?.page);
+ const minPrice = sanitizeNumber(searchParams?.min_price);
+ const maxPrice = sanitizeNumber(searchParams?.max_price);
+ const minArea = sanitizeNumber(searchParams?.min_area);
+ const maxArea = sanitizeNumber(searchParams?.max_area);
+
+ const propertiesData = await fetchProperty({
+ page,
+ name: searchParams?.name,
+ min_price: minPrice,
+ max_price: maxPrice,
+ min_area: minArea,
+ max_area: maxArea,
+ location: searchParams?.location,
+ });
+ const isEmpty = propertiesData.formattedData.length <= 0;
+ const statesData = State.getStatesOfCountry("US").map((st) => ({ value: st.name, label: st.name }));
-export default function ListingsForRent() {
return (
<>
@@ -85,67 +51,33 @@ export default function ListingsForRent() {
-
- -
-
-
-
-
-
-
-
-
-
-
+ {isEmpty && (
+
+
No Properties Found
+
Looks like we couldn’t find any listings that match your search.
+
+ )}
+ {!isEmpty && (
+
+ {propertiesData.formattedData.map((p, idx) => (
+
+ ))}
+
+ )}
-
-
- {propertiesData.map((p) => (
-
- ))}
+
+ {/* Pagination */}
+ {propertiesData.totalPages > 1 && (
+
-
-
+ )}
+ {/* End Pagination */}
@@ -153,125 +85,55 @@ export default function ListingsForRent() {