import React from "react";
import Link from "next/link";
import Image from "next/image";
import { SingleAd } from "types/PropInterfaces";

function SingleAd({ slug, picture, name, price, key, intprice }: SingleAd) {
  return (
    <Link href={"/ad/" + slug} key={key} className="cursor-pointer" passHref>
      <a className="single-ads-product w-full">
        <div className="cursor-pointer border shadow-md rounded-md">
          <div className="h-[180px] sm:h-[200px] md:h-[170px] lg:h-[160px] w-full relative">
            {picture && (
              <Image
                layout="fill"
                src={picture}
                alt={name}
                placeholder="blur"
                blurDataURL="/assets/images/preloader/preloader-static6.png"
              />
            )}
          </div>
          <div className="p-2">
            <p className="font-bold text-sm text-gray-700 h-12 mb-2">
              {name?.slice(0, 30)}
            </p>
            {intprice && (
              <p className="font-normal text-green-500 mt-2">GHC {price}</p>
            )}
          </div>
        </div>
      </a>
    </Link>
  );
}

export default SingleAd;
