Skip to content

Commit

Permalink
Merge branch 'develop' into feature/EGCETSII#13-Votings-API
Browse files Browse the repository at this point in the history
  • Loading branch information
JSnow11 authored Jan 4, 2022
2 parents cb3c547 + c5583f4 commit 9b0ee6f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
19 changes: 19 additions & 0 deletions decide/administration/frontend/src/api/censusApiUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { axios } from "api/axios";
import { Census } from "types/census";


const censusApi = {
//Bulk operation
getCensuss: () => axios.get("/census"),
deleteCensuss: () => axios.delete(`/census`),


//Individual operations
getCensus: (id: string) => axios.get(`/census/${id}`),
createCensus: (census: Census) => axios.post("/census/", census),
updateCensus: (census: Census) => axios.put(`/census/${census.id}`, census),
deleteCensus: (id: string) => axios.delete(`/census/${id}`),
};


export default censusApi;
57 changes: 57 additions & 0 deletions decide/administration/frontend/src/api/votingApiUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { axios } from "api/axios";
import { Question, Voting } from "types/voting";


const votingApi = {

//QUESTION API
//Bulk Operations
getQuestions: () => axios.get("/voting/question"),
deleteQuestions: (idList: any) => axios.delete("/voting/questions", idList),
deleteAllQuestions: () => axios.delete(`/voting/question`),

//Individual Operations
getQuestion: (question_id: number) => axios.get(`/voting/question/${question_id}`),
createQuestion: (question: Question) => axios.post("/voting/question/", question),
updateQuestion: (question: Question, question_id: number) => axios.put(`/voting/question/${question_id}`, question),
deleteQuestion: (question_id: number) => axios.delete(`/voting/question/${question_id}`),


//VOTING API
//Bulk Operations
getVotings:() => axios.get(`/votings`),
deleteVotings: (idList: any) => axios.delete("/votings", idList),
deleteAllVotings: () => axios.delete(`/votings`),

startVotings:(
idList:number[]
) =>
axios.put("/votings", {
idList: idList,
action: "start",
}),

stopVotings:(
idList:number[]
) =>
axios.put("/votings", {
idList: idList,
action: "stop",
}),

tallyVotings:(
idList:number[]
) =>
axios.put("/votings", {
idList: idList,
action: "tally",
}),

//Individual Operations
getVoting: (voting_id: number) => axios.get(`/votings/${voting_id}`),
createVoting: (voting: Voting) => axios.post("/votings", voting),
deleteVoting: (voting_id: number) => axios.delete(`/votings/${voting_id}`),
};

export default votingApi;

5 changes: 5 additions & 0 deletions decide/administration/frontend/src/types/census.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type Census = {
id : number;
voting_Id : number;
voter_Id : number;
};

0 comments on commit 9b0ee6f

Please sign in to comment.