import HeroImage from "@/components/HeroImage"; import Pagination from "@/components/Pagination"; import CardProperty from "@/components/properties/CardProperty"; import FilterProperty from "@/components/properties/FilterProperty"; import { FetchPropertyParams } from "@/schema/services/property"; import { fetchProperty } from "@/services/payload/property"; import { getDefaultMetadata } from "@/utils/metadata"; import { sanitizeNumber, sanitizePageNumber } from "@/utils/sanitize"; import { Metadata } from "next"; const metaDesc = "Explore the latest properties on the Dynamic Realty."; export async function generateMetadata(): Promise { const metadata = await getDefaultMetadata(); metadata.title = `Listings For Sale - ${metadata.openGraph?.siteName}`; metadata.description = metaDesc; return metadata; } 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({ property_type: "sell", 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; return ( <>
{isEmpty && (

No Properties Found

Looks like we couldn’t find any listings that match your search.

)} {!isEmpty && (
{propertiesData.formattedData.map((p, idx) => ( ))}
)}
{/* Pagination */} {propertiesData.totalPages > 1 && (
)} {/* End Pagination */}
); }