import {Profile} from "@/store";
import {Image, Text, View} from "@tarojs/components";
import styles from "@/pages/my/my.module.scss";
import avatar from "@/static/img/avatar.png"
import blacktriang from "@/static/img/blacktriangle.png"

const Header = ({showCompany}:{showCompany:()=> void}) => {
  const {token,user,company,empty} = Profile.useContainer()

  return (
    <View className={styles.header}>
      <View className='flex'>
        {
          token ?
            <Image src={user?.avatar || avatar} className={styles.avatar}/>:
            <Image src={avatar} className={styles.avatar}/>
        }
        { token ?
          <View className='flex-1'>
            <View className='font-32'>{user?.name}</View>

            <View className='flex align-center mt-2' onClick={()=>{
              showCompany()
            }}>
              <Text style={{fontSize:'24rpx',fontWeight:'500',color:'#323635'}}>{company?.name}</Text>
              <Image src={blacktriang} style={{width:'20rpx',height:'20rpx'}}></Image>
            </View>
          </View>:
          <View className='flex-1'>
            <View className='font-32 mt-2' onClick={()=>{
              empty()
            }}>注册/登录</View>
          </View>
        }

          {/*<View className='login font-24 mt-2 text-secondary flex justify-between content-start'>*/}
          {/*  <Text>手机号：{user?.phone_number}</Text>*/}
          {/*</View>*/}
      </View>
    </View>
  )
}

export default Header
