forked from Greenstand/treetracker-admin-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: admin messaging (Greenstand#236)
* feat: unresolved-messaging * feat: unresolved-messaging * feat(messaging): unresolved survey and announce * feat(messaging): unresolved survey and announce * feat(messaging): unresolved survey and announce * fix: message to grower context issue * fix: messaging context * fix: pr review fixes Co-authored-by: Nick Charlton <[email protected]>
- Loading branch information
1 parent
d04d1cf
commit 2117f9b
Showing
15 changed files
with
1,471 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { handleResponse, handleError } from './apiUtils'; | ||
import { session } from '../models/auth'; | ||
|
||
export default { | ||
getRegion() { | ||
const query = `${process.env.REACT_APP_MESSAGING_ROOT}/region`; | ||
|
||
return fetch(query, { | ||
method: 'GET', | ||
headers: { | ||
'content-type': 'application/json', | ||
Authorization: session.token, | ||
}, | ||
}) | ||
.then(handleResponse) | ||
.catch(handleError); | ||
}, | ||
postRegion(payload) { | ||
const query = `${process.env.REACT_APP_MESSAGING_ROOT}/region`; | ||
const { id, name, description, created_at } = payload; | ||
|
||
return fetch(query, { | ||
method: 'POST', | ||
headers: { | ||
'content-type': 'application/json', | ||
Authorization: session.token, | ||
}, | ||
body: JSON.stringify({ id, name, description, created_at }), | ||
}) | ||
.then(handleResponse) | ||
.catch(handleError); | ||
}, | ||
getRegionById(region_id) { | ||
const query = `${process.env.REACT_APP_MESSAGING_ROOT}/region/${region_id}`; | ||
|
||
return fetch(query, { | ||
headers: { | ||
Authorization: session.token, | ||
}, | ||
}) | ||
.then(handleResponse) | ||
.catch(handleError); | ||
}, | ||
getMessage(author_handle) { | ||
const query = `${process.env.REACT_APP_MESSAGING_ROOT}/message?author_handle=${author_handle}`; | ||
|
||
return fetch(query).then(handleResponse).catch(handleError); | ||
}, | ||
postMessage(payload) { | ||
const query = `${process.env.REACT_APP_MESSAGING_ROOT}/message`; | ||
|
||
return fetch(query, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: session.token, | ||
}, | ||
body: JSON.stringify({ ...payload }), | ||
}) | ||
.then(handleResponse) | ||
.catch(handleError); | ||
}, | ||
postMessageSend(payload) { | ||
const query = `${process.env.REACT_APP_MESSAGING_ROOT}/message/send`; | ||
|
||
return fetch(query, { | ||
method: 'POST', | ||
headers: { | ||
'content-type': 'application/json', | ||
Authorization: session.token, | ||
}, | ||
body: JSON.stringify(payload), | ||
}) | ||
.then(handleResponse) | ||
.catch(handleError); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.