import { View, Image } from '@tarojs/components'
import style from './index.module.less'
import Taro from '@tarojs/taro'
import { TContactItem } from '@/types/contact';

import { AvatarMedia } from '@/components/AvatarMedia';
import IconCertificateColor from "@/components/icon/icon-certificate-color";
interface Props {
  data: TContactItem
  deleteable?: boolean
  refresh: () => void
  fromContact?: boolean
  className?: string
}
const Index = ({data, deleteable, className, refresh, fromContact}: Props)=> {
  const handleClick = (data: TContactItem)=>{
    console.log(data, fromContact)
    Taro.navigateTo({
      url: "/pages/profile/index?agentId=" + data.agentId,
    });
  }
  

  return (
    <View className={`${style.contactCard} ${className}`} onClick={()=>{handleClick(data)}}>
      <View className={style.avatar}>
        <AvatarMedia source={data.avatarUrl || ''} mode="aspectFill" className={style.avatar}></AvatarMedia>
      </View>
      <View className={style.infoColumn}>
        <View className={style.nameRow}>
          <View className={style.nickName}>{data.name}</View>
          {data.isEnt && <IconCertificateColor></IconCertificateColor>}
        </View>
        <View className='flex items-center w-full'>
          <View className={`flex-1 ${style.subInfo}`}>{data.lastChatMsg}</View>
          {(!!data?.tipCnt) && <View className={style.tipCnt}>{data.tipCnt} </View>}
        </View>
        
      </View>
    </View>
  )
}

export default Index