c5e0bcfb0e
* View party now opens member modal * Clicking member in header opens member detail modal * Began sticky header * Added sleep * Removed extra inbox and added name styles * Lint fixes * Added member filter * Added task counts * Updated quest start modal * Updated members modal style * Fixed editing party * Updated tavern * Updated my guilds * More guild styles * Many challenge styles and fixes * Fixed notification menu display * Added initial styles to groupplans * Added syncing with inbox * Fixed lint * Added new edit profile layout * Added initial achievement layout * Began adding new stats layout * Removed duplicate: * fix(CI): attempt to address Travis Mongo connection issue * fix(CI): don't strand us in Mongo shell * Travis updates * Try percise
76 lines
2.1 KiB
JavaScript
76 lines
2.1 KiB
JavaScript
import axios from 'axios';
|
|
import omit from 'lodash/omit';
|
|
|
|
export async function createChallenge (store, payload) {
|
|
let response = await axios.post('/api/v3/challenges', {
|
|
data: payload.challenge,
|
|
});
|
|
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function joinChallenge (store, payload) {
|
|
let response = await axios.post(`/api/v3/challenges/${payload.challengeId}/join`);
|
|
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function leaveChallenge (store, payload) {
|
|
let response = await axios.post(`/api/v3/challenges/${payload.challengeId}/leave`, {
|
|
data: {
|
|
keep: payload.keep,
|
|
},
|
|
});
|
|
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function getUserChallenges () {
|
|
let response = await axios.get('/api/v3/challenges/user');
|
|
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function getGroupChallenges (store, payload) {
|
|
let response = await axios.get(`/api/v3/challenges/groups/${payload.groupId}`);
|
|
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function getChallenge (store, payload) {
|
|
let response = await axios.get(`/api/v3/challenges/${payload.challengeId}`);
|
|
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function exportChallengeCsv (store, payload) {
|
|
let response = await axios.get(`/api/v3/challenges/challenges/${payload.challengeId}/export/csv`);
|
|
|
|
return response.data.data;
|
|
}
|
|
|
|
|
|
export async function updateChallenge (store, payload) {
|
|
let challengeDataToSend = omit(payload.challenge, ['tasks', 'habits', 'todos', 'rewards', 'group']);
|
|
|
|
if (challengeDataToSend.leader && challengeDataToSend.leader._id) challengeDataToSend.leader = challengeDataToSend.leader._id;
|
|
|
|
let response = await axios.post(`/api/v3/challenges/${payload.challenge._id}`, {
|
|
data: challengeDataToSend,
|
|
});
|
|
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function deleteChallenge (store, payload) {
|
|
let response = await axios.delete(`/api/v3/challenges/challenges/${payload.challengeId}`);
|
|
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function selectChallengeWinner (store, payload) {
|
|
let response = await axios.post(`/api/v3/challenges/challenges/${payload.challengeId}/selectWinner/${payload.winnerId}`);
|
|
|
|
return response.data.data;
|
|
}
|