import {Cell} from '@nutui/nutui-react-taro'
import navTo from "@/utils/common";
import {View, Text} from '@tarojs/components'
import {ArrowRight, Reward, Setting} from '@nutui/icons-react-taro'
import {useUser} from '@/hooks/useUser'
import {useEffect} from "react";
import {useDealerUser} from "@/hooks/useDealerUser";

const UserCell = () => {
  const {isSuperAdmin} = useUser();
  const {dealerUser} = useDealerUser()

  useEffect(() => {

  }, [])

  /**
   * 管理中心
   */
  if (isSuperAdmin()) {
    return (
      <>
        <View className={'px-4'}>
          <Cell
            className="nutui-cell-clickable"
            style={{
              backgroundImage: 'linear-gradient(to right bottom, #e53e3e, #c53030)',
            }}
            title={
              <View style={{display: 'inline-flex', alignItems: 'center'}}>
                <Setting className={'text-white '} size={16}/>
                <Text style={{fontSize: '16px'}} className={'pl-3 text-white font-medium'}>管理中心</Text>
              </View>
            }
            extra={<ArrowRight color="#ffffff" size={18}/>}
            onClick={() => navTo('/admin/index', true)}
          />
        </View>
      </>
    )
  }

  /**
   * 分销中心
   */
  if (dealerUser) {
    return (
      <>
        <View className={'px-4'}>
          <Cell
            className="nutui-cell-clickable"
            style={{
              backgroundImage: 'linear-gradient(to right bottom, #54a799, #177b73)',
            }}
            title={
              <View style={{display: 'inline-flex', alignItems: 'center'}}>
                <Reward className={'text-orange-100 '} size={16}/>
                <Text style={{fontSize: '16px'}}
                      className={'pl-3 text-orange-100 font-medium'}>分销中心</Text>
                {/*<Text className={'text-white opacity-80 pl-3'}>门店核销</Text>*/}
              </View>
            }
            extra={<ArrowRight color="#cccccc" size={18}/>}
            onClick={() => navTo('/dealer/index', true)}
          />
        </View>
      </>
    )
  }

  /**
   * 普通用户
   */
  return (
    <>
      <View className={'px-4'}>
        <Cell
          className="nutui-cell-clickable"
          style={{
            backgroundImage: 'linear-gradient(to right bottom, #54a799, #177b73)',
          }}
          title={
            <View style={{display: 'inline-flex', alignItems: 'center'}}>
              <Reward className={'text-orange-100 '} size={16}/>
              <Text style={{fontSize: '16px'}} className={'pl-3 text-orange-100 font-medium'}>开通VIP</Text>
              <Text className={'text-white opacity-80 pl-3'}>享优惠</Text>
            </View>
          }
          extra={<ArrowRight color="#cccccc" size={18}/>}
          onClick={() => navTo('/dealer/apply/add', true)}
        />
      </View>
    </>
  )
}
export default UserCell
