ThreeCard.tsx 2.03 KB
import React from 'react';
import Link from 'next/link';
import Image from 'next/image';

// 假设这是从 somewhere 引入的 hook 或者 store
// import { useCategoryStore, useProductListStore } from 'somewhere';
const MATERIALS = [
  { name: 'Energy materials', imageUrl: '/imgs/pc/home/materials/1.jpg', href: '/products' },
  {
    name: 'Laboratory consumables',
    imageUrl: '/imgs/pc/home/materials/2.png',
    href: '/products'
  },
  {
    name: 'Low-dimensional materials',
    imageUrl: '/imgs/pc/home/materials/3.png',
    href: '/products'
  }
]

const ThreeCard = async ({ title, desc }) => {

  // const categoryStore = useCategoryStore();
  // const productStore = useProductListStore();

  // 模拟更新类别和子类别的逻辑
  const updateCategory = (item) => {
    // categoryStore.updateCategory(item.name);
    // const find = categoryStore.list.find(c => c.categoryDisplayName === item.name);
    // categoryStore.updateSubCategory(find.list[0].id);
    // productStore.updatePageNo(1);
    // 路由逻辑
  };

  return (
    <div>
      <div className='text-primary-blue text-center mb-4 font-bold text-6xl'>
        {title}
      </div>
      <div className="text-body-1 max-w-[600px] mx-auto mb-8">
        <span className="mb-16 max-w-[600px] mx-auto  text-gray ">{desc}</span>
      </div>
      <div className="grid grid-cols-3 lg:grid-cols-3 md:grid-cols-3 sm:grid-cols-2 gap-4">
        {(MATERIALS || []).map((item, index) => (
          //  onClick={() => updateCategory(item)}
          <div key={index} className="cursor-pointer">
            <div className="shadow-lg hover:shadow-2xl transition-shadow duration-300 ease-in-out text-center ">
              {item.imageUrl && (
                <Image src={item.imageUrl} alt={item.name} width={200} height={200} />
              )}
              <div className="text-center bg-primary-blue text-white w-full h-9 leading-9">
                {item.name}
              </div>
            </div>
          </div>
        ))}
      </div>
    </div>
  );
}

export default ThreeCard;