diff --git a/src/app/(main)/listings-for-rent/[slug]/page.tsx b/src/app/(main)/listings-for-rent/[slug]/page.tsx index 92fef63..ee5b825 100644 --- a/src/app/(main)/listings-for-rent/[slug]/page.tsx +++ b/src/app/(main)/listings-for-rent/[slug]/page.tsx @@ -1,48 +1,41 @@ import CardProperty from "@/components/CardProperty"; import HeroImage from "@/components/HeroImage"; -import { CardPropertyData } from "@/schema/property"; -import { formatCurrency } from "@/utils/general"; +import { fetchPropertyDetail, fetchPropertySuggestion } from "@/services/payload/property"; +import { RichText } from "@payloadcms/richtext-lexical/react"; +import { headers } from "next/headers"; +import Image from "next/image"; +import { notFound } from "next/navigation"; -const similarPropertiesData: CardPropertyData[] = [ - { - 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", - }, - { - 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", - }, -]; +export default async function ListingsForRentDetail({ params }: { params: Promise<{ slug: string }> }) { + const slug = (await params).slug; + const propertyDetail = await fetchPropertyDetail({ slug }); + if (!propertyDetail) return notFound(); + + const { data, formattedData } = propertyDetail; + const isEmbedMapUrlValid = !!data?.embed_map_url && data.embed_map_url.includes("www.google.com/maps/embed"); + const headersList = await headers(); + const fullUrl = headersList.get("x-full-url"); + const shareUrl = { + facebook: `https://www.facebook.com/sharer/sharer.php?u=${fullUrl}`, + linkedin: `https://www.linkedin.com/sharing/share-offsite/?url=${fullUrl}`, + twitter: `https://twitter.com/intent/tweet?url=${fullUrl}`, + }; + + const similarPropertiesData = await fetchPropertySuggestion(); -export default function ListingsForRentDetail() { return ( <> - +
-
$5000\mo
+
+ {formattedData.price} + {data.property_type === "rent" && "/mo"} +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {formattedData.images.map((img, idx) => ( +
+
+ {img.alt} +
+
+ ))}
    -
  • - - 2 Bathrooms -
  • -
  • - - 2 Bedrooms -
  • -
  • - - 480 Sq Ft -
  • + {!!data?.aboutGroup?.bathrooms_count && ( +
  • + + {data.aboutGroup.bathrooms_count} Bathrooms +
  • + )} + {!!data?.aboutGroup?.bedrooms_count && ( +
  • + + {data.aboutGroup.bedrooms_count} Bedrooms +
  • + )} + {!!data?.aboutGroup?.area && ( +
  • + + {data.aboutGroup.area} Sq Ft +
  • + )}
-

- Choose this property if you are looking for a modern house near the ocean shore. With 2 bathrooms and 2 - bedrooms as well as a single garage, it is a perfect option for a small family. -

-

- This home has been completely renovated within the past year and features amazing views and sunsets of - the local lake, solid wood cabinets (and loads of them), granite counters with colored glass backsplash, - sliding glass doors across the entire family room allowing beautiful views of the lake etc. Its - affordable price serves as a great bonus for a family looking for an opportunity to save money on Miami - MyHome. -

+ +
+ +
Address:
-
Biscayne Blvd
+
{data?.addressGroup?.address ?? ""}
State/County:
-
Florida
+
{data?.addressGroup?.state_code ?? ""}
City:
-
Miami
+
{data?.addressGroup?.city_code ?? ""}
Zip:
-
8322
-
-
-
Country:
-
United States
-
-
-
Area:
-
Lake Worth
+
{data?.addressGroup?.zip_code ?? ""}
@@ -237,101 +199,97 @@ export default function ListingsForRentDetail() { >
    -
  • 2 Stories
  • -
  • Basketball Court
  • -
  • Lawn
  • -
  • Gym
  • -
  • Fireplace
  • -
  • Sprinklers
  • -
  • Private Space
  • -
  • Balcony
  • -
  • Laundry
  • -
  • Ocean View
  • + {Array.isArray(data.features) && + data.features.length > 0 && + data.features.map((ft, idx) =>
  • {typeof ft !== "number" && ft.name}
  • )}
-
-
- -
-
-
-
-
Base Rent
-
{formatCurrency(2700)}
-
-
-
-
-
Smart Home
-
{formatCurrency(20)}
-
-
-
-
-
Utility Service
-
{formatCurrency(5)}
-
-
-
-
-
Est. total monthly*
-
{formatCurrency(2900)}
-
-
-
-
-
-
-
-

Property Map

-
-
-