Skip to content

Commit

Permalink
fix: requested revisions, make work with api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynndp committed Mar 3, 2022
1 parent 91a8aa6 commit 2ec1cc0
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REACT_APP_WEBMAP_DOMAIN=http://dev.treetracker.org
REACT_APP_API_ROOT=https://dev-k8s.treetracker.org/api/admin
REACT_APP_EARNINGS_ROOT=https://dev-k8s.treetracker.org/earnings
REACT_APP_MESSAGING_ROOT=http://localhost:3004
REACT_APP_MESSAGING_ROOT=https://dev-k8s.treetracker.org/messaging
REACT_APP_QUERY_API_ROOT=https://dev-k8s.treetracker.org/query
REACT_APP_REPORTING_API_ROOT=https://dev-k8s.treetracker.org/reporting
REACT_APP_TREETRACKER_API_ROOT=https://dev-k8s.treetracker.org/treetracker
Expand Down
13 changes: 6 additions & 7 deletions src/api/apiUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { session } from '../models/auth';
const log = require('loglevel');

export async function handleResponse(response) {
if (response.status === 204) return {};
Expand All @@ -7,19 +8,17 @@ export async function handleResponse(response) {
// server-side validation error occurred.
// Server side validation returns a string error message, so parse as text instead of json.
const error = await response.text();
console.log('handleResponse error ---', error);
log.debug('handleResponse error ---', error);

if (response.status === 400) {
throw new Error(error);
}
if (response.status === 500 && error.includes('author')) {
// server-side error occurred. Author account not found.
// throw new Error(
// "The account wasn't found. Please contact the administrator."
// );
response.json({
error: "The account wasn't found. Please contact the administrator.",
});
return {
error: true,
message: "The author account wasn't found.",
};
}
throw new Error('Network response was not ok.');
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export default {
.then(handleResponse)
.catch(handleError);
},
getMessages(author_handle) {
const query = `${process.env.REACT_APP_MESSAGING_ROOT}/message?author_handle=${author_handle}`;
getMessages(handle) {
const query = `${process.env.REACT_APP_MESSAGING_ROOT}/message?handle=${handle}`;

return fetch(query).then(handleResponse).catch(handleError);
},
Expand Down
7 changes: 3 additions & 4 deletions src/components/Messaging/Inbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,11 @@ const Inbox = ({ threads, selectedIndex, handleListItemClick }) => {
) : thread.messages[0].type === 'announce' ? (
<Announcement color="inherit" />
) : (
<>
<Ballot color="inherit" />
</>
<Ballot color="inherit" />
)}
</ListItemAvatar>
{thread.messages[0].type === 'survey' ? (
{thread.messages[0].type === 'survey' ||
thread.messages[0].type === 'announce' ? (
<ListItemText
primary={thread.messages[0].subject}
secondary={
Expand Down
Loading

0 comments on commit 2ec1cc0

Please sign in to comment.