

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: "#f5a83d", text: "處理中" })
        case "reviewed":
            return getStatusTag({ color: "#f5a83d", text: "處理中" })
        case "confirmed":
            if (creditor)
                return getStatusTag({ color: "#22a13f", text: "待發佈" })
            else
                return getStatusTag({ color: "#22a13f", text: "待付款" })
        case "published":
            return getStatusTag({ color: "#22a13f", text: "待付款" })
        case "paid":
            return getStatusTag({ color: "#22a13f", text: "待發佈" })
        case "completed":
            return getStatusTag({ color: "#4D4D4D", text: "已完成" })
        case "notAccepted":
            return getStatusTag({ color: "#d9372b", text: "不接受" })
        case "resubmit":
            return getStatusTag({ color: "#757373", text: "需重新提交" })
        case "cancelled":
            return getStatusTag({ color: "#909497", text: "已取消" })
        case "withdrawn":
            return getStatusTag({ color: "#6E14CC", text: "已撤銷" })
        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: "#F1C40F", text: "Submitted" })
        case "reviewed":
            return getStatusTag({ color: "#0C489E", text: "Reviewed" })
        case "confirmed":
            if (creditor)
                return getStatusTag({ color: "#3498DB", text: "Pending Publish" })
            else
                return getStatusTag({ color: "#F39C12", text: "Pending Payment" })
        case "published":
            return getStatusTag({ color: "#F39C12", text: "Pending Payment" })
        case "paid":
            return getStatusTag({ color: "#3498DB", text: "Pending Publish" })
        case "completed":
            return getStatusTag({ color: "#4D4D4D", text: "Completed" })
        case "notAccepted":
            return getStatusTag({ color: "#d9372b", text: "Not Accepted" })
        case "resubmit":
            return getStatusTag({ color: "#757373", text: "Re-Submit Required" })
        case "cancelled":
            return getStatusTag({ color: "#8a8784", text: "Cancelled" })
        case "withdrawn":
            return getStatusTag({ color: "#6E14CC", text: "Withdrawn" })
        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: "#F1C40F", text: intl.formatMessage({id: 'processing'}) })
        case "reviewed":
            return getStatusTag({ color: "#F1C40F", text: intl.formatMessage({id: 'processing'}) })
        case "confirmed":
            if (creditor)
                return getStatusTag({ color: "#3498DB", text: intl.formatMessage({id: 'pendingPublish'}) })
            else
                return getStatusTag({ color: "#F39C12", text: intl.formatMessage({id: 'pendingPayment'}) })
        case "published":
            return getStatusTag({ color: "#F39C12", text: intl.formatMessage({id: 'pendingPayment'}) })
        case "paid":
            return getStatusTag({ color: "#3498DB", text: intl.formatMessage({id: 'pendingPublish'}) })
        case "completed":
            return getStatusTag({ color: "#4D4D4D", text: intl.formatMessage({id: 'completed'}) })
        case "notAccepted":
            return getStatusTag({ color: "#d9372b", text: intl.formatMessage({id: 'notAccepted'}) })
        case "resubmit":
            return getStatusTag({ color: "#757373", text: intl.formatMessage({id: 'resubmit'}) })
        case "cancelled":
            return getStatusTag({ color: "#8a8784", text: intl.formatMessage({id: 'cancelled'}) })
        case "withdrawn":
            return getStatusTag({ color: "#6E14CC", text: intl.formatMessage({id: 'withdrawn'}) })
        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 ""
    }
}
