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

export default Unknown;
