import apollo from "../../lib/apollo.js";

async function GetCarrerS1(token="") {
	var res = await apollo.query(
		`
        query {
            carrers(where: {category: "S1"})
                {
                    id
                    name
                    description
                    img{
                    url
                    }
                    start_regis
                    until_regis
                    name_description
                }
            }`,
		token
	);
	return res;
}

async function GetCarrerD3(token="") {
	var res = await apollo.query(
		`
        query {
            carrers(where: {category: "D3"})
                {
                    id
                    name
                    description
                    img{
                    url
                    }
                    start_regis
                    until_regis
                    name_description
                }
            }`,
		token
	);
	return res;
}

async function GetCarrerSMA(token="") {
	var res = await apollo.query(
		`
        query {
            carrers(where: {category: "SMA"})
                {
                    id
                    name
                    description
                    img{
                    url
                    }
                    start_regis
                    until_regis
                    name_description
                }
            }`,
		token
	);
	return res;
}

async function GetDetailCarrer(id, token="") {
	var res = await apollo.query(
		`
        query($input: ID!){
            carrers(where:{id:$input})
            {
                name
                description
                category
                img{
                    url
                }
                start_regis
                until_regis
                name_description
            }
        }		
        `,
        token, 
        {	
            "input": id
        }
    );
	return res;
}

module.exports = {
    GetCarrerS1:GetCarrerS1,
    GetCarrerD3:GetCarrerD3,
    GetCarrerSMA:GetCarrerSMA,
    GetDetailCarrer:GetDetailCarrer,
};