import { fetchPropertyLatest } from "@/services/payload/property";
import CardProperty from "./CardProperty";

export default async function ListOfFeaturedProperty() {
  const latestProperties = await fetchPropertyLatest();

  return (
    <>
      <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5">
        {latestProperties.formattedData.map((pr, idx) => (
          <CardProperty key={idx} data={pr} />
        ))}
      </div>
      {latestProperties.formattedData.length > 0 && (
        <div className="text-center mt-10!">
          <a className="button button-primary" href="/listings-for-sale">
            View all properties
          </a>
        </div>
      )}
    </>
  );
}
