Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles

This commit is contained in:
2022-03-01 16:14:00 +01:00
19 changed files with 211 additions and 81 deletions

View File

@@ -72,7 +72,7 @@ section.chill-entity {
}
}
p {
// display: inline-block;
display: inline-block;
margin: 0 0 0 1.5em;
text-indent: -1.5em;

View File

@@ -1,7 +1,7 @@
/**
* Generic api method that can be adapted to any fetch request
*/
const makeFetch = (method, url, body) => {
const makeFetch = (method, url, body) => {
return fetch(url, {
method: method,
headers: {
@@ -11,19 +11,20 @@
})
.then(response => {
if (response.ok) {
console.log('200 error')
return response.json();
}
if (response.status === 422) {
console.log('422 error')
return response.json().then(response => {
throw ValidationException(response)
});
}
if (response.status === 403) {
return response.json().then(() => {
throw AccessException();
});
console.log('403 error')
throw AccessException(response);
}
throw {
@@ -88,14 +89,13 @@ const ValidationException = (response) => {
error.violations = response.violations.map((violation) => `${violation.title}: ${violation.propertyPath}`);
error.titles = response.violations.map((violation) => violation.title);
error.propertyPaths = response.violations.map((violation) => violation.propertyPath);
return error;
}
const AccessException = () => {
const AccessException = (response) => {
const error = {};
error.name = 'AccessException';
error.violations = ['You are no longer permitted to perform this action'];
error.violations = ['You are not allowed to perform this action'];
return error;
}