Finished answered request layout (#9)

Also:
- rearranged API calls to be in alphabetical order (except the bearer
stuff at the top)
- modified the API base URL and Auth0 renewal URLs to be derived from
the browser's location (localhost / prod both work now with no change)
This commit is contained in:
Daniel J. Summers
2017-10-22 22:50:26 -05:00
parent a1ce40ee83
commit 3c3f0a7981
8 changed files with 171 additions and 52 deletions
+29 -24
View File
@@ -1,7 +1,7 @@
import axios from 'axios'
const http = axios.create({
baseURL: 'http://localhost:3000/api/'
baseURL: `${location.protocol}//${location.host}/api/`
})
/**
@@ -20,11 +20,6 @@ export default {
*/
removeBearer: () => delete http.defaults.headers.common['authorization'],
/**
* Get all prayer requests and their most recent updates
*/
journal: () => http.get('journal/'),
/**
* Add a note for a prayer request
* @param {string} requestId The Id of the request to which the note applies
@@ -39,19 +34,9 @@ export default {
addRequest: requestText => http.post('request/', { requestText }),
/**
* Update a prayer request
* @param request The request (should have requestId, status, and updateText properties)
* Get all answered requests, along with the text they had when it was answered
*/
updateRequest: request => http.post(`request/${request.requestId}/history`, {
status: request.status,
updateText: request.updateText
}),
/**
* Get a prayer request (journal-style; only latest update)
* @param {string} requestId The Id of the request to retrieve
*/
getRequest: requestId => http.get(`request/${requestId}`),
getAnsweredRequests: () => http.get('request/answered'),
/**
* Get a prayer request (full; includes all history)
@@ -59,15 +44,35 @@ export default {
*/
getFullRequest: requestId => http.get(`request/${requestId}/full`),
/**
* Get all answered requests, along with the text they had when it was answered
*/
getAnsweredRequests: () => http.get('request/answered'),
/**
* Get past notes for a prayer request
* @param {string} requestId The Id of the request for which notes should be retrieved
*/
getNotes: requestId => http.get(`request/${requestId}/notes`)
getNotes: requestId => http.get(`request/${requestId}/notes`),
/**
* Get a prayer request (journal-style; only latest update)
* @param {string} requestId The Id of the request to retrieve
*/
getRequest: requestId => http.get(`request/${requestId}`),
/**
* Get a complete request; equivalent of "full" and "notes" combined
*/
getRequestComplete: requestId => http.get(`request/${requestId}/complete`),
/**
* Get all prayer requests and their most recent updates
*/
journal: () => http.get('journal/'),
/**
* Update a prayer request
* @param request The request (should have requestId, status, and updateText properties)
*/
updateRequest: request => http.post(`request/${request.requestId}/history`, {
status: request.status,
updateText: request.updateText
})
}