import moment from "moment";
import {getDocumentIcon} from "./DocumentHelper";

export const fromWiaasProcessStep = (step) => {
    return {
        actionCode: step.action_code,
        fullDesc: step.full_desc,
        idOrder: step.order_id,
        idProcess: step.process_id, //not sure about this
        idProcessStep: step.step_id,        //not sure about this
        isNewCommentVisible: 1,             //TODO : get this from backend
        isVisibleForCustomer: 1,            //TODO : get this from backend
        now: moment().format("Do MMM YY"),
        shortDesc: step.short_desc,
        status: step.status,
    }
};

export const fromWiaasCustomerAcceptance = cData => {

    return {
        actionId: cData['action_id'],
        expiration: cData.expiration,
        declineReason: cData['decline_reason'],
        status: cData.status,
        documents: cData.documents ? cData.documents.map(document => {
            document.icon = getDocumentIcon(document.extension);
            return document;
        }) : []
    };
};

export const fromWiaasCustomerQuestionnaire = cData => {
    const document = cData.document;
    document.icon = getDocumentIcon(document.extension);
    return {
        actionId: cData['action_id'],
        orderItemId: cData['item_id'],
        document,
        status: cData.status,
        orderId: cData['order_id'],
        comments: cData.comments
    };
};