import {View} from '@tarojs/components'
import WemetaRadio from '@/components/WemetaRadio/index'
import style from './index.module.less'


export type TRadioItem = {
  text: string
  checked: boolean
}

interface Props {
  text: string
  checked?: boolean
  last?: boolean
  extra?: () => JSX.Element | JSX.Element[]
}
const index = ({ text, checked = false, last, extra }: Props) => {
  const renderExtraContent = () => {
    if(extra){
      return <View>{extra()}</View>
    }
    return 
  }  
  return (
    <View className={`${style.radioCardItem} ${checked ? style.checked :''}'`}>
      <View className={`${style.radioCardRow} ${last ? style.lastChild : ''}`}>
        <View className={style.radioContent}>
          <View className={style.radioText}>{text}</View>
          {renderExtraContent()}
        </View>
        <View className={style.radioColumn}>
          <WemetaRadio checked={checked}></WemetaRadio>
        </View>
      </View>
    </View>
  )
}
export default index