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.avatarContainer}>
        <AvatarMedia source={data.avatarUrl || ''} mode="aspectFill" className={style.avatar}></AvatarMedia>
        {(!!data?.tipCnt) && <View className={style.tipCnt}>{data.tipCnt}</View>}
      </View>
      <View className={`${style.infoColumn} truncate`}>
        <View className={`${style.nameRow} truncate`}>
          <View className={`${style.nickName} truncate`}>{data.name}</View>
          {data.isEnt && <View className={style.certificationContainer}><IconCertificateColor></IconCertificateColor></View>}
        </View>
        <View className='flex flex-col w-full gap-8 truncate'>
          <View className={`flex items-center flex-1 ${style.subInfo} truncate`}>
            <View className='max-w-156 truncate'>{!!data.entName?.length ? data.entName : '暂无企业名称'}</View>
            <View className='px-4'>|</View>
            <View className='truncate'>{!!data.position?.length ? data.position : '暂无职位名称'}</View>
          </View>
          <View className={`flex-1 ${style.lastMsg} truncate`}>{data.lastChatMsg}</View>
        </View>
        
      </View>
    </View>
  )
}

export default Index