Generateurv2/frontend/requests/requests.room.js

165 lines
3.3 KiB
JavaScript
Raw Normal View History

2022-05-18 10:15:54 +02:00
import { roomInstance } from "../apis/roomInstance.intance.js";
export const createRoom = async (data) => {
return await roomInstance
.request({
method: "POST",
url: "room/",
data: {...data}
})
.then((res) => res.data.data);
};
export const joinRoom = async (data) => {
return await roomInstance
.request({
method: "PATCH",
url: "room/",
data: {...data}
})
.then((res) => res.data.data);
};
export const getRoom = async (code, clientId) => {
return await roomInstance
.request({
method: "GET",
url: "room/",
params: { code: code, clientId: clientId },
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});;
};
export const checkRoom = async (code) => {
return await roomInstance
.request({
method: "GET",
url: "room/" + code,
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});;
};
export const delRoom = async (code) => {
return await roomInstance
.request({
method: "DELETE",
url: "room/",
data: { code: code },
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});;
};
export const createParcours = async (data) => {
return await roomInstance
.request({
method: "POST",
url: "parcours/",
data: { ...data },
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});
};
export const editParcours = async (data) => {
return await roomInstance
.request({
method: "PUT",
url: "parcours/",
data: { ...data },
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});
};
export const getParcoursChallenge = async (id_code, user_code) => {
return await roomInstance
.request({
method: "GET",
url: "challenge/",
params: { code: id_code, user_code: user_code },
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});
};
export const getParcoursInfos = async (id_code, user_code) => {
return await roomInstance
.request({
method: "GET",
url: "parcours/",
params: { code: id_code, user_code: user_code },
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});
};
export const challengeParcours = async (data) => {
return await roomInstance
.request({
method: "POST",
url: "challenge/",
data: {...data },
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});
};
export const correctParcours = async (data) => {
return await roomInstance
.request({
method: "PUT",
url: "challenge/",
data: {...data },
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});
};
export const deleteParcours = async (data) => {
return await roomInstance
.request({
method: "DELETE",
url: "parcours/",
data: {...data}
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});
};
export const getCorrectionInfo = async (data) => {
return await roomInstance
.request({
method: "GET",
url: "correct/",
params: {...data}
})
.then((res) => res.data.data)
.catch((err) => {
throw err;
});
};