import services from '@/services';
import { useRequest } from 'ahooks';
import { useEffect } from 'react';
import styles from './index.less';
import TopItem from './TopItem';

export default ({ items }: { items: any }) => {
  const { data, runAsync } = useRequest(
    services.Physicalsign.getlistTopNItems,
    { manual: true },
  );
  useEffect(() => {
    if (!items) return;
    runAsync({
      objectId: 1,
      indexId: items.id,
      n: 5,
      indexType: 1,
      physicalSignType: 1
    });
  }, [items]);
  // const data = {
  //   data: [
  //     {
  //       image: 'https://xct.cdhncy.cn/file/zgf/2024/10/10/e1d7cf31199b47528085fffd93af2bee_1728549037097.jpg',
  //       name: '过街天桥破损',
  //       fullName: '安全-道路桥梁安全-桥梁安全',
  //       percentage: '41',
  //       count: '16',
  //       deduction: '0.5',
  //       weight: '0.86'
  //     },
  //     {
  //       image: 'https://xct.cdhncy.cn/file/zgf/2024/10/10/e1d7cf31199b47528085fffd93af2bee_1728549037097.jpg',
  //       name: '过街天桥破损',
  //       fullName: '安全-道路桥梁安全-桥梁安全',
  //       percentage: '41',
  //       count: '16',
  //       deduction: '0.5',
  //       weight: '0.86'
  //     },
  //     {
  //       image: 'https://xct.cdhncy.cn/file/zgf/2024/10/10/e1d7cf31199b47528085fffd93af2bee_1728549037097.jpg',
  //       name: '过街天桥破损',
  //       fullName: '安全-道路桥梁安全-桥梁安全',
  //       percentage: '41',
  //       count: '16',
  //       deduction: '0.5',
  //       weight: '0.86'
  //     },
  //     {
  //       image: 'https://xct.cdhncy.cn/file/zgf/2024/10/10/e1d7cf31199b47528085fffd93af2bee_1728549037097.jpg',
  //       name: '过街天桥破损',
  //       fullName: '安全-道路桥梁安全-桥梁安全',
  //       percentage: '41',
  //       count: '16',
  //       deduction: '0.5',
  //       weight: '0.86'
  //     },
  //     {
  //       image: 'https://xct.cdhncy.cn/file/zgf/2024/10/10/e1d7cf31199b47528085fffd93af2bee_1728549037097.jpg',
  //       name: '过街天桥破损',
  //       fullName: '安全-道路桥梁安全-桥梁安全',
  //       percentage: '41',
  //       count: '16',
  //       deduction: '0.5',
  //       weight: '0.86'
  //     }
  //   ]
  // }
  return (
    <div className={styles.container}>
      {data?.data?.map((item, index) => {
        return <TopItem key={index} data={item} level={index + 1} />;
      })}
    </div>
  );
};
