import React from 'react';
import { Cell, CellGroup } from '@antmjs/vantui';
import { View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { getDtStr } from '@/utils/date';
import style from './style.module.less';

export default (props) => {

  const { dataset } = props;

  const dateStr = React.useMemo(() => dataset?.createDate ? getDtStr(dataset.createDate) : '-', [dataset]);

  const onClick = () => {
    Taro.navigateTo({
      url: `/pages/notice/detail/index?id=${dataset.noticeId}`
    })
  }

  return (
    <View className={style['notice-card-wrapper']}>
      <CellGroup>
        <Cell
          isLink
          size="large"
          style={{ color: 'var(--main-bg-color)' }}
          onClick={() => onClick()}
          renderTitle={(
            <View className={style['notice-card-title']}>{dataset?.title}</View>
          )}
        />
        <Cell
          renderTitle={(<>
            <View className={style['notice-card-title2']}>日期： </View>
            <View className={style['notice-card-title2']}>{dateStr}</View>
          </>
          )}
        />
      </CellGroup>
    </View>
  )
}