diff --git a/src/components/layouts/Footer.tsx b/src/components/layouts/Footer.tsx index 61fac2c..33b6881 100644 --- a/src/components/layouts/Footer.tsx +++ b/src/components/layouts/Footer.tsx @@ -1,6 +1,21 @@ +"use client"; +import React, { useEffect, useState } from "react"; import Image from "next/image"; +import { useLatestPropertyQuery } from "../../services/hooks/property"; export default function Footer() { + const { data, _fetch } = useLatestPropertyQuery(); + const [isDataFetched, setIsDataFetched] = useState(false); + + useEffect(() => { + if (!isDataFetched) { + _fetch(); + setIsDataFetched(true); + } + }, [isDataFetched, _fetch]); + + const latestProperties = data ? data.slice(0, 2) : []; + return ( <>
@@ -10,36 +25,34 @@ export default function Footer() {

Latest Properties

- -
- -
-
-
- - Retail Store Southwest 186th Street - -
-
- From $120/month -
-
-
- -
- -
-
-
- - Apartment Building with Subunits - -
-
- From $120/month -
-
-
+ {latestProperties && latestProperties.length > 0 ? ( + latestProperties.map((property, index) => ( + +
+ 0 + ? property.images[0].url + : "/images/featured-properties-17-480x287.jpg" + } + alt={property.title} + width={161} + height={136} + /> +
+
+
+ {property.title} +
+
+ From ${property.price}/month +
+
+
+ )) + ) : ( +
Data Not Available
+ )}

diff --git a/src/services/hooks/property.ts b/src/services/hooks/property.ts index 39ae8d8..1e9ff13 100644 --- a/src/services/hooks/property.ts +++ b/src/services/hooks/property.ts @@ -1,3 +1,4 @@ +"use client"; import { CardPropertyData } from "@/schema/property"; import { useState } from "react"; import { fetchLatestPropertyREST } from "../rest/property";