import { View, Text } from "@tarojs/components";
import IconCertificateColor from "@/components/icon/icon-certificate-color";
export interface DigitalCardBasicProps {
  certificated?: boolean;
  name: string;
  position: string;
  entName?: string|null;
}

const DigitalCardBasic = ({
  name,
  position,
  entName,
  certificated,
}: DigitalCardBasicProps) => {
  const hasEntName = !!entName?.length
  const hasPosition = !!position?.length
  const renderPosition = ()=> {
    return <>
        {(hasPosition && hasEntName) && <>&nbsp;|&nbsp;</>}
        {hasPosition && <>{position}</>}
    </>
  }
  return (
    <View className="flex items-start">
      <View className="flex flex-col flex-1 justify-center min-h-40">
        <View className="text-16 font-medium leading-24 font-pingfangSCMedium">{name}</View>
        {/* inline-flex flex-nowrap break-normal items-center */}
        {(hasPosition || hasEntName) && <View className="text-12 leading-20 text-gray-4 gap-4">
          {entName || ''}{renderPosition()}{!!certificated && <>&nbsp;<View className="certification-container transform translate-y-2"><IconCertificateColor /></View></>}
        </View>}
      </View>
    </View>
  );
};

export default DigitalCardBasic;
