mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
person: add validation on relationship between person
This commit is contained in:
@@ -1,50 +1,5 @@
|
||||
import { splitId } from './vis-network'
|
||||
|
||||
/**
|
||||
* @function makeFetch
|
||||
* @param method
|
||||
* @param url
|
||||
* @param body
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
const makeFetch = (method, url, body) => {
|
||||
return fetch(url, {
|
||||
method: method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
},
|
||||
body: (body !== null) ? JSON.stringify(body) : null
|
||||
})
|
||||
.then(response => {
|
||||
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
if (response.status === 422) {
|
||||
return response.json().then(violations => {
|
||||
throw ValidationException(violations)
|
||||
});
|
||||
}
|
||||
|
||||
throw {
|
||||
msg: 'Error while updating AccompanyingPeriod Course.',
|
||||
sta: response.status,
|
||||
txt: response.statusText,
|
||||
err: new Error(),
|
||||
body: response.body
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param violations
|
||||
* @constructor
|
||||
*/
|
||||
const ValidationException = (violations) => {
|
||||
this.violations = violations
|
||||
this.name = 'ValidationException'
|
||||
}
|
||||
import { splitId } from './vis-network';
|
||||
import {makeFetch} from 'ChillMainAssets/lib/api/apiMethods.js';
|
||||
|
||||
/**
|
||||
* @function getFetch
|
||||
@@ -136,7 +91,7 @@ const getRelationsList = () => {
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
const postRelationship = (relationship) => {
|
||||
//console.log(relationship)
|
||||
//console.log(relationship);
|
||||
return postFetch(
|
||||
`/api/1.0/relations/relationship.json`,
|
||||
{
|
||||
|
Reference in New Issue
Block a user