import {FC, useEffect, useState} from "react";
import {Image, Swiper, SwiperItem, View} from "@tarojs/components";
import {brandApi, BrandRecord} from "@/api";
import Taro, {useRouter} from "@tarojs/taro";

type Params = {
  id: number
}
const MeetingsConfig: FC = () => {
  const {id} = useRouter().params as unknown as Params
  const [brandInfo, setBrandInfo] = useState<BrandRecord>()

  useEffect(() => {
    getData()
  }, [id])

  const getData = async () => {
    try {
      const data = await brandApi.info(id)
      Taro.setNavigationBarTitle({title:data.name})
      setBrandInfo(data)
    } catch (e) {
    }
  }


  return (
    <View className='p-2'>
      {
        // brands.length ? brands.map((d) =>
        //     <View onClick={() => jumpInfo(d.id)} className={styles.box} key={d.id}>
        //       <Image src={d.brand_album?.[0]} mode='aspectFill' className={styles.image}/>
        //       <View className={styles.rightBox}>
        //         <View className='font-weight mb-2 font-28'>{d.name}</View>
        //         <View className={styles.desc}>{d.graphic_introduction.repeat(30)}</View>
        //       </View>
        //     </View>)
        // : <Empty name='空空如也'/>
        <Swiper
          className='test-h'
          indicatorColor='#999'
          indicatorActiveColor='#333'
          indicatorDots
          >
          { brandInfo?.brand_album?.length
            && brandInfo?.brand_album?.map((d) =>
            <SwiperItem>
              <Image src={d}></Image>
            </SwiperItem>)
          }
        </Swiper>
      }
    </View>
  );
}

export default MeetingsConfig
