Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:ARKultur/sidious into feature/guides
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximePayant committed Jan 4, 2024
2 parents 1b9a55e + 0c2a191 commit a1ea9ee
Show file tree
Hide file tree
Showing 52 changed files with 6,636 additions and 21,095 deletions.
18,493 changes: 0 additions & 18,493 deletions package-lock.json

This file was deleted.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.4.0",
"draft-convert": "^2.1.13",
"draft-js": "^0.11.7",
"i18next": "^22.4.9",
"leaflet": "^1.9.4",
"material-ui-image": "^3.3.2",
"moment": "^2.30.1",
"react": "^18.2.0",
"react-cookie": "^4.1.1",
"react-dom": "^18.2.0",
"react-draft-wysiwyg": "^1.15.0",
"react-i18next": "^12.1.4",
"react-leaflet": "^4.2.1",
"react-redux": "^8.0.5",
Expand Down
127 changes: 127 additions & 0 deletions src/API/Journey.js
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;
34 changes: 28 additions & 6 deletions src/API/Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,40 @@ export const getOrganisationMarkers = async (token) => {
}
};

export const addMarkerToDB = async (marker) => {

export const getJourneyMarkers = async (token, uuid) => {
const URL = API_URL + `/api/nodes/parkour/${uuid}`;
const params = {
headers: { Authorization: `Bearer ${token}` },
};

try {
const response = await axios.get(URL, params);
return response.data;
} catch (e) {
console.log(e);
}
};

export const addMarkerToDB = async (marker, parkourUuid) => {
const URL = API_URL + "/api/nodes";
const token = localStorage.getItem("token");
const jsonBody = {
name: marker.name,
longitude: Number(marker.longitude),
latitude: Number(marker.latitude),
description: marker.description,
altitude: Number(marker.altitude),
description: marker.description,
model: marker.model,
texture: marker.texture,
status: marker.status,
parkours: [{parkourId: parkourUuid, order: Number(marker.order)}]
};

const params = {
headers: { Authorization: `Bearer ${token}` },
};

console.log(URL, jsonBody, params)
try {
const response = await axios.post(URL, jsonBody, params);
} catch (e) {
Expand All @@ -48,8 +67,8 @@ export const editMarkerToDB = async (marker) => {
const token = localStorage.getItem("token");
const jsonBody = {
name: marker.name,
longitude: marker.longitude,
latitude: marker.latitude,
longitude: parseInt(marker.longitude),
latitude: parseInt(marker.latitude),
address: null,
organisation: null,
description: marker.description,
Expand All @@ -75,7 +94,9 @@ export const deleteMarkerToDB = async (marker) => {
Authorization: `Bearer ${token}`,
},
data: {
name: marker.name,
node_id: marker.nodeId,
parkour_id: marker.parkourId,
name: marker.node.name,
},
});
} catch (e) {
Expand All @@ -86,6 +107,7 @@ export const deleteMarkerToDB = async (marker) => {
const MarkerService = {
getMarkers,
getOrganisationMarkers,
getJourneyMarkers,
addMarkerToDB,
editMarkerToDB,
deleteMarkerToDB,
Expand Down
73 changes: 73 additions & 0 deletions src/API/Suggestions.js
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 [];
}
};
22 changes: 17 additions & 5 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.App {
}
}

.App-logo {
height: 40vmin;
Expand Down Expand Up @@ -38,11 +38,10 @@
opacity: 0;
}
100% {
opacity: 1;
opacity: 1;
}
}


body {
animation: fadeInAnimation ease 2s;
animation-iteration-count: 1;
Expand All @@ -51,9 +50,22 @@ body {

@keyframes fadeInAnimation {
0% {
opacity: 0;
opacity: 0;
}
100% {
opacity: 1;
opacity: 1;
}
}

.wrapper-class {
padding: 1rem;
border: 1px solid #ccc;
}
.editor-class {
background-color: lightgray;
padding: 1rem;
border: 1px solid #ccc;
}
.toolbar-class {
border: 1px solid #ccc;
}
Loading

0 comments on commit a1ea9ee

Please sign in to comment.