-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:ARKultur/sidious into feature/guides
- Loading branch information
Showing
52 changed files
with
6,636 additions
and
21,095 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import axios from "axios"; | ||
import { API_URL } from "../config/API"; | ||
|
||
export const getJourneys = async (token) => { | ||
const URL = API_URL + "/api/parkours"; | ||
const params = { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}; | ||
try { | ||
const response = await axios.get(URL, params); | ||
return response.data; | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}; | ||
|
||
export const getOrganisationJourneys = async (token, id) => { | ||
const URL = API_URL + `/api/parkours/orga/${id}`; | ||
const params = { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}; | ||
|
||
try { | ||
const response = await axios.get(URL, params); | ||
return response.data; | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}; | ||
|
||
export const getOrganisationJourneysByAdmin = async (token, id) => { | ||
const URL = API_URL + `/api/parkours/admin/orga/${id}`; | ||
const params = { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}; | ||
|
||
try { | ||
const response = await axios.get(URL, params); | ||
return response.data; | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}; | ||
|
||
export const addJourneyToDB = async (journey, organisationId) => { | ||
const URL = API_URL + "/api/parkours"; | ||
const token = localStorage.getItem("token"); | ||
const jsonBody = { | ||
name: journey.name, | ||
description: journey.description, | ||
status: journey.status, | ||
organisationId: Number(organisationId) | ||
//parkours: [{parkourId: "0", order: marker.order}] | ||
}; | ||
|
||
const params = { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}; | ||
|
||
try { | ||
const response = await axios.post(URL, jsonBody, params); | ||
} catch (e) { | ||
throw e; | ||
} | ||
}; | ||
|
||
export const editJourneyToDB = async (journey, id) => { | ||
const URL = API_URL + `/api/parkours/${id}`; | ||
const token = localStorage.getItem("token"); | ||
const jsonBody = { | ||
name: journey.name, | ||
description: journey.description, | ||
status: journey.description, | ||
organisation_id: journey.OrganisationId, | ||
}; | ||
const params = { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}; | ||
|
||
try { | ||
const response = await axios.patch(URL, jsonBody, params); | ||
} catch (e) { | ||
throw e; | ||
} | ||
}; | ||
|
||
export const deleteJourneyToDB = async (journey, id) => { | ||
const URL = API_URL + `/api/parkours/${id}`; | ||
const token = localStorage.getItem("token"); | ||
|
||
try { | ||
const response = await axios.delete(URL, { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
} catch (e) { | ||
throw e; | ||
} | ||
}; | ||
|
||
export const deleteJourneyByAdminToDB = async (journey, id) => { | ||
const URL = API_URL + `/api/parkours/admin/${id}`; | ||
const token = localStorage.getItem("token"); | ||
|
||
try { | ||
const response = await axios.delete(URL, { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
} catch (e) { | ||
throw e; | ||
} | ||
}; | ||
|
||
const JourneyService = { | ||
getJourneys, | ||
getOrganisationJourneys, | ||
getOrganisationJourneysByAdmin, | ||
addJourneyToDB, | ||
editJourneyToDB, | ||
deleteJourneyToDB, | ||
deleteJourneyByAdminToDB, | ||
}; | ||
|
||
export default JourneyService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import axios from 'axios'; | ||
import { API_URL } from '../config/API'; | ||
|
||
export const getSuggestions = async () => { | ||
try { | ||
const response = await axios.get(API_URL + '/api/suggestion', { | ||
headers: { | ||
Authorization: `Bearer ${localStorage.getItem('token')}`, | ||
}, | ||
}); | ||
|
||
return response.data; | ||
} catch (e) { | ||
return []; | ||
} | ||
}; | ||
|
||
export const addSuggestions = async (suggestion) => { | ||
try { | ||
const response = await axios.post( | ||
API_URL + '/api/suggestion', | ||
{ | ||
...suggestion, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${localStorage.getItem('token')}`, | ||
}, | ||
} | ||
); | ||
|
||
return response.data; | ||
} catch (e) { | ||
return []; | ||
} | ||
}; | ||
|
||
export const editSuggestions = async (suggestion) => { | ||
try { | ||
const response = await axios.post( | ||
API_URL + `/api/suggestion/${suggestion.uuid}`, | ||
{ | ||
...suggestion, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${localStorage.getItem('token')}`, | ||
}, | ||
} | ||
); | ||
|
||
return response.data; | ||
} catch (e) { | ||
return []; | ||
} | ||
}; | ||
|
||
export const deleteSuggestions = async (suggestionid) => { | ||
try { | ||
const response = await axios.delete( | ||
API_URL + `/api/suggestion/${suggestionid}`, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${localStorage.getItem('token')}`, | ||
}, | ||
} | ||
); | ||
|
||
return response.data; | ||
} catch (e) { | ||
return []; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.