

import {getStatusTag} from "utils/statusUtils/Base";

export function getStatus(params) {
    return getStatusByText(params.row.status,  params.row.creditor);
}

export function getStatusByText(status, creditor) {
  switch (status) {
    case "submitted":
      return getStatusTag({ color: "#8F7200", text: "處理中" }) // was #f5a83d

    case "reviewed":
      return getStatusTag({ color: "#8F7200", text: "處理中" }) // was #f5a83d

    case "confirmed":
      if (creditor)
        return getStatusTag({ color: "#1D8735", text: "待發佈" }) // was #22a13f
      else
        return getStatusTag({ color: "#1D8735", text: "待付款" }) // was #22a13f

    case "published":
      return getStatusTag({ color: "#1D8735", text: "待付款" }) // was #22a13f

    case "paid":
      return getStatusTag({ color: "#1D8735", text: "待發佈" }) // was #22a13f

    case "completed":
      return getStatusTag({ color: "#4D4D4D", text: "已完成" }) // unchanged (already AA)

    case "notAccepted":
      return getStatusTag({ color: "#d9372b", text: "不接受" }) // unchanged (already AA)

    case "resubmit":
      return getStatusTag({ color: "#757373", text: "需重新提交" }) // unchanged (already AA)

    case "cancelled":
      return getStatusTag({ color: "#737679", text: "已取消" }) // was #909497

    case "withdrawn":
      return getStatusTag({ color: "#6E14CC", text: "已撤銷" }) // unchanged (already AA)

    default:
      return getStatusTag({ text: status })
  }
}

export function getStatusEng(params) {
    return getStatusByTextEng(params.row.status, params.row.creditor);
}
export function getStatusByTextEng(status, creditor) {
    switch (status) {
        case "submitted":
            return getStatusTag({ color: "#8F7200", text: "Submitted" }) // was #F1C40F
        case "reviewed":
            return getStatusTag({ color: "#0C489E", text: "Reviewed" }) // unchanged
        case "confirmed":
            if (creditor)
                return getStatusTag({ color: "#217CBA", text: "Pending Publish" }) // was #3498DB
            else
                return getStatusTag({ color: "#B45309", text: "Pending Payment" }) // was #F39C12
        case "published":
            return getStatusTag({ color: "#B45309", text: "Pending Payment" }) // was #F39C12
        case "paid":
            return getStatusTag({ color: "#217CBA", text: "Pending Publish" }) // was #3498DB
        case "completed":
            return getStatusTag({ color: "#4D4D4D", text: "Completed" }) // unchanged
        case "notAccepted":
            return getStatusTag({ color: "#d9372b", text: "Not Accepted" }) // unchanged
        case "resubmit":
            return getStatusTag({ color: "#757373", text: "Re-Submit Required" }) // unchanged
        case "cancelled":
            return getStatusTag({ color: "#797674", text: "Cancelled" }) // was #8a8784
        case "withdrawn":
            return getStatusTag({ color: "#6E14CC", text: "Withdrawn" }) // unchanged
        default:
            return getStatusTag({ text: status })
    }
}

export function getStatusIntl(params, intl) {
    return getStatusByTextIntl(params.row.status,  params.row.creditor, intl);
}

export function getStatusByTextIntl(status, creditor, intl) {
    switch (status) {
        case "submitted":
            return getStatusTag({ color: "#8F7200", text: intl.formatMessage({id: 'processing'}) }) // was #F1C40F
        case "reviewed":
            return getStatusTag({ color: "#8F7200", text: intl.formatMessage({id: 'processing'}) }) // was #F1C40F
        case "confirmed":
            if (creditor)
                return getStatusTag({ color: "#217CBA", text: intl.formatMessage({id: 'pendingPublish'}) }) // was #3498DB
            else
                return getStatusTag({ color: "#B45309", text: intl.formatMessage({id: 'pendingPayment'}) }) // was #F39C12
        case "published":
            return getStatusTag({ color: "#B45309", text: intl.formatMessage({id: 'pendingPayment'}) }) // was #F39C12
        case "paid":
            return getStatusTag({ color: "#217CBA", text: intl.formatMessage({id: 'pendingPublish'}) }) // was #3498DB
        case "completed":
            return getStatusTag({ color: "#4D4D4D", text: intl.formatMessage({id: 'completed'}) }) // unchanged
        case "notAccepted":
            return getStatusTag({ color: "#d9372b", text: intl.formatMessage({id: 'notAccepted'}) }) // unchanged
        case "resubmit":
            return getStatusTag({ color: "#757373", text: intl.formatMessage({id: 'resubmit'}) }) // unchanged
        case "cancelled":
            return getStatusTag({ color: "#797674", text: intl.formatMessage({id: 'cancelled'}) }) // was #8a8784
        case "withdrawn":
            return getStatusTag({ color: "#6E14CC", text: intl.formatMessage({id: 'withdrawn'}) }) // unchanged
        default:
            return getStatusTag({ text: status })
    }
}

export function getModeEng(params) {
    return getModeByTextEng(params.row.mode);
}
export function getModeByTextEng(mode) {
    switch (mode) {
        case "offline":
            return "Offline"
        case "online":
            return "Online"
        default:
            return ""
    }
}

export function getModeIntl(params,intl) {
    return getModeByTextIntl(params.row.mode, intl);
}
export function getModeByTextIntl(mode, intl) {
    switch (mode) {
        case "offline":
            return intl.formatMessage({id: 'applicationModeOffline'})
        default:
            return ""
    }
}
