diff --git a/src/Admin/Filters.js b/src/Admin/Filters.js index 743e95525682123b3139e3d5b515e5c3ca977a36..f519d245fbe74d09c1a2ba3e928c9d507763bea8 100644 --- a/src/Admin/Filters.js +++ b/src/Admin/Filters.js @@ -28,6 +28,11 @@ export function GetOneOfAllUrl(type , filter){ return (api) } +export function MethodsToComplain(type , id, meth){ + const api = `${apiUrl}/${type}/${id}/${meth}`; + return (api) +} + export function GetAll(type){ const api = `${apiUrl}/${type}` return (api) diff --git a/src/Admin/Services.js b/src/Admin/Services.js index f1b79ad57e3ab042d6733ade98c0aa11c76c7004..bce02eb72a414c7f04cbbdb8e0acbec383ca2fd6 100644 --- a/src/Admin/Services.js +++ b/src/Admin/Services.js @@ -127,12 +127,46 @@ export function Create(api, body) { }) } +export function HandleComplain(api) { + return new Promise(resolve => { + axios({ + method: 'post', + url: api, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8', + 'access-token': sessionStorage.getItem('@portalmec/accessToken'), + 'client': sessionStorage.getItem('@portalmec/clientToken'), + 'uid': sessionStorage.getItem('@portalmec/uid'), + 'If-None-Match': null + }, + }).then(response => { + if (response.status === 200) { + resolve(true) + } else { + resolve(false) + } + SaveNewHeaders(response) + }).catch(err =>{ + resolve(false) + }) + }) +} + export function GetFullList(api, headers) { + return new Promise(resolve => { axios({ method: 'get', url: api, - headers: headers + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8', + 'access-token': sessionStorage.getItem('@portalmec/accessToken'), + 'client': sessionStorage.getItem('@portalmec/clientToken'), + 'uid': sessionStorage.getItem('@portalmec/uid'), + 'If-None-Match': null + }, }).then((res) => { console.log(res) if (res.status === 200) { @@ -146,9 +180,7 @@ export function GetFullList(api, headers) { data: {} }) } - if (headers !== undefined) { - SaveNewHeaders(res) - } + SaveNewHeaders(res) }).catch((err) => { resolve({ state: false, @@ -163,7 +195,14 @@ export function GetSpecificData(api, headers) { axios({ method: 'get', url: api, - headers: headers + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8', + 'access-token': sessionStorage.getItem('@portalmec/accessToken'), + 'client': sessionStorage.getItem('@portalmec/clientToken'), + 'uid': sessionStorage.getItem('@portalmec/uid'), + 'If-None-Match': null + }, }).then((res) => { console.log(res) if (res.status === 200) { @@ -177,9 +216,7 @@ export function GetSpecificData(api, headers) { data: {} }) } - if (headers !== undefined) { - SaveNewHeaders(res) - } + SaveNewHeaders(res) }).catch((err) => { resolve({ state: false, diff --git a/src/env.js b/src/env.js index 2450da0f16d3d4bfd1d340b927cc7d0838f510df..0c39363dc4fa5dae6c9a387e4628d8fa75d63a84 100644 --- a/src/env.js +++ b/src/env.js @@ -25,6 +25,7 @@ var simcaqAPIDomain = 'https://www.simcaq.c3sl.ufpr.br/api', apiVersion = 'v1', simcaqAPIurl = simcaqAPIDomain + '/' + apiVersion + export {apiUrl}; export {apiDomain}; export {simcaqAPIurl}