import axios from 'axios';

function transf(json) {
    return {
        name: json.name,
        salary: json.salary,
        company: json.company,
        city: json.city,
        exp: json.work_year,
        class: json.job_category,
        edu: json.education,
        num: json.num,
        time: json.updated_at,
        address: json.address,
        desc: json.description,
        intro: json.introduce
    };
}

export async function getJobInfo(jobID) {
    const res = await axios.get(`/jobs/${jobID}.json`);
    return transf(res.data.job);
}

export async function getJobPlain(jobID){
    return (await axios.get(`/jobs/${jobID}.json`)).data.job;
}

export async function applyProfile(JobID) {
    await axios.post(`/jobs/${JobID}/apply`)
    return;
}

export const mock = {
    intro: "big comp",
    address: "开瓶器",
    desc: "need someone",
    name: "Java开发",
    salary: "10-12k",
    company: "Tencent",
    city: "Shanghai",
    class: "全职",
    edu: "本科",
    num: 1,
    time: "2020-2-2"
};