import dayjs from "dayjs";
import { PRICING_FEE } from "./contant";

export function getProductType(value) {
  switch (parseInt(value)) {
    case 1:
      return "观点包";
    case 2:
      return "观点";
    case 7:
      return "投资组合";
    case 8:
      return "股票池";
    case 9:
      return "套餐产品";
    case 21:
      return "增值产品";
    // case 22:
    //   return "课程"
    case 23:
      return "ETF专区";
    case 24:
      return "选股工具";
    case 25:
      return "小飞机理财";
    case 31:
      return "投资课堂";
    case 32:
      return "课程";
  }
}

export function dateFormat(value, format) {
  return value === null || value == "null" || value == ""
    ? "--"
    : dayjs(value).format(format);
}

export function getPrice(value) {
  if (value) {
    if (value.period === 99) {
      return `${value.payPrice / 100}元`;
    } else {
      return `${value.payPrice / 100}元/${PRICING_FEE[value.productPeriod]}`;
    }
  }
  return "";
}
