const typeMap = {
  order: '预约提醒',
  queue: '排队提醒',
  visit: '就诊提醒',
  report: '报告提醒',
  pay: '缴费提醒',
  medicine: '取药提醒',
};

/**
 * 提醒类型
 */
const getTypeName = type => (
  typeMap[type] || '预约提醒'
);

const getName = (item) => {
  const names = [];
  const { type, depName, object } = item;
  const typeName = getTypeName(type);
  if (typeName) names.push(typeName);
  if (depName) names.push(depName);
  if (object) names.push(object);
  return names.join(' | ');
};

/*
* 是否为显示排队
* */
const isShowQueue = (item) => {
  const { type, status } = item;
  return (type === 'queue' || type === 'visit') && (status === 'queuing' || status === 'expired');
};

/**
 *   获取排队状态对应的样式
 */
const statusMap = {
  ringing: 'ringing',
  queuing: 'in-line',
  expired: 'cross-sign',
};
const getQueueStatus = (item) => {
  const { type, status } = item;
  const defaultClassName = 'normal';
  const isQueue = type === 'queue' || type === 'visit';
  const className = isQueue ? statusMap[status] : '';
  return className || defaultClassName;
};

/*
* 获取显示内容
* */
const getContent = (item) => {
  const { type, description } = item;
  const descTypes = ['order', 'visit', 'queue', 'medicine'];
  if (descTypes.indexOf(type)) return description;
};

/*
* 是否显示去哪里链接
* */
const showLinkUrl = (item) => {
  const { type } = item;
  return type !== 'report' && type !== 'pay';
};

const showGrade = (isLogin, openNotify, list, loading) => {
  /* 如果没有登录 */
  if (!isLogin) {
    return true;
  } else {
    if (loading) return false;
    return !list.length && !openNotify;
  }
};

export default {
  getName,
  isShowQueue,
  getContent,
  showLinkUrl,
  showGrade,
  getQueueStatus,
};
