"use client";

import React, { useEffect, useState } from "react";
import Title from "../lib_components/title";
import Text from "../lib_components/text";
import { Asphalt, Ekskavator, Forklift, Kran, Truck } from "@/assets";
import type { productFilterTypes, ProductTypes } from "@/types";
import {
  allProducts,
} from "@/data";
import ProductCard from "../cards/productCard";

export default function Products() {

  const [cars, setCars] = useState(allProducts);

  return (
    <div dir="ltr" className="max-w-[1200px] w-full mx-auto">
      {/* title part */}
      <div className="flex flex-col mb-10">
        <div className="flex items-center justify-center w-full ">
          <div className="text-secondary px-2 text-[18px] font-semibold ">
            <Text txt="katalog" />
          </div>
        </div>
        <Title text="pricing-h2" />
      </div>

      {/* product filters */}
      {/* <div className="flex flex-wrap gap-1 gap-y-4 items-center justify-center mb-10 ">
        {productFilterTypesMainPage.map((item, index) => (
          <button
            key={index}
            onClick={() => setProductFilter(item.name)}
            className={`${
              productFilter === item.name ? "bg-secondary" : ""
            } flex items-center gap-2 h-[58px] hover:bg-secondary border-gray-300 hover:border-secondary border-[1px] px-7 text-2xl rounded-tr-full rounded-bl-full `}
          >
            <Text txt={item.name} />
            {item.image && (
              <Image
                src={item.image}
                alt="Truck images"
                width={50}
                height={50}
                className="object-cover"
              />
            )}
          </button>
        ))}
      </div> */}

      {/* products */}
      <div className="px-4 grid gap-5 grid-cols-1 place-content-center min-[500px]:grid-cols-2 min-lg:grid-cols-4 min-[1210px]:grid-cols-4">
        {cars.map((item: ProductTypes, index: number) => (
          <div key={index}>
            <ProductCard data={item} />
          </div>
        ))}
      </div>
    </div>
  );
}
