import React from 'react';

import classNames from 'classnames';

import commonStyles from '../common.less';
import styles from './index.less';

const Unknown = ({ message, confirmRead }) => {
  let content = '';
  try {
    const type = typeof message.infoContent;
    switch (type) {
      case 'object':
        content = JSON.stringify(message.infoContent);
        break;
      case 'string':
        content = message.infoContent;
        break;
      default:
        break;
    }
  } catch (e) {
    // i
  }
  return (
    <div
      className={classNames(styles.unknown, commonStyles.messageContainer)}
      title="点击查看详情"
    >
      <div className={commonStyles.title}>
        <span>消息</span>
        <img
          className={commonStyles.confirm}
          title="点击标为已读"
          onClick={e => {
            e.stopPropagation();
            confirmRead(false, [message.id]);
          }}
          src="https://panda-water.cn/Web4/assets/images/message/%E5%8B%BE%E6%B5%85.png"
          alt=""
        />
      </div>
      <div className={commonStyles.content}>
        <p>{content}</p>
        <p className={commonStyles.messageTime}>{message.time}</p>
      </div>
    </div>
  );
};

export default Unknown;
