Skip to content

Commit

Permalink
feat: replace Trees with Captures and refactor code (#99)
Browse files Browse the repository at this point in the history
* feat: replace Trees with Captures and refactor code

* chore: fix build error

* chore: fix broken test

* chore: fix find and replace error
  • Loading branch information
nmcharlton authored May 26, 2021
1 parent 8366554 commit 7513e71
Show file tree
Hide file tree
Showing 36 changed files with 725 additions and 2,277 deletions.
26 changes: 13 additions & 13 deletions src/api/treeTrackerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { handleResponse, handleError, getOrganization } from './apiUtils';
import { session } from '../models/auth';

export default {
getTreeImages({
getCaptureImages({
skip,
rowsPerPage,
orderBy = 'id',
Expand Down Expand Up @@ -44,7 +44,7 @@ export default {
.catch(handleError);
},

approveTreeImage(id, morphology, age, captureApprovalTag, speciesId) {
approveCaptureImage(id, morphology, age, captureApprovalTag, speciesId) {
const query = `${
process.env.REACT_APP_API_ROOT
}/api/${getOrganization()}trees/${id}`;
Expand All @@ -70,7 +70,7 @@ export default {
.then(handleResponse)
.catch(handleError);
},
rejectTreeImage(id, rejectionReason) {
rejectCaptureImage(id, rejectionReason) {
const query = `${
process.env.REACT_APP_API_ROOT
}/api/${getOrganization()}trees/${id}`;
Expand All @@ -95,7 +95,7 @@ export default {
/*
* to rollback from a wrong approving
*/
undoTreeImage(id) {
undoCaptureImage(id) {
const query = `${
process.env.REACT_APP_API_ROOT
}/api/${getOrganization()}trees/${id}`;
Expand All @@ -114,7 +114,7 @@ export default {
.then(handleResponse)
.catch(handleError);
},
getUnverifiedTreeCount() {
getUnverifiedCaptureCount() {
const query = `${
process.env.REACT_APP_API_ROOT
}/api/${getOrganization()}trees/count?where[approved]=false&where[active]=true`;
Expand All @@ -126,13 +126,13 @@ export default {
.then(handleResponse)
.catch(handleError);
},
getTreeCount(filter) {
getCaptureCount(filter) {
const query = `${
process.env.REACT_APP_API_ROOT
}/api/${getOrganization()}trees/count?where=${JSON.stringify(
filter.getWhereObj(),
)}`;
// console.log('getTreeCount --- ', filter)
// console.log('getCaptureCount --- ', filter)
return fetch(query, {
headers: {
Authorization: session.token,
Expand All @@ -141,7 +141,7 @@ export default {
.then(handleResponse)
.catch(handleError);
},
getTreeById(id) {
getCaptureById(id) {
const query = `${
process.env.REACT_APP_API_ROOT
}/api/${getOrganization()}trees/${id}`;
Expand Down Expand Up @@ -263,7 +263,7 @@ export default {
/*
* get tree count by species
*/
getTreeCountPerSpecies(speciesId) {
getCaptureCountPerSpecies(speciesId) {
const query = `${
process.env.REACT_APP_API_ROOT
}/api/${getOrganization()}trees/count?&where[speciesId]=${speciesId}`;
Expand Down Expand Up @@ -331,7 +331,7 @@ export default {
/*
* create new tree tags
*/
async createTreeTags(treeId, tags) {
async createCaptureTags(captureId, tags) {
return tags.map((t) => {
const query = `${process.env.REACT_APP_API_ROOT}/api/tree_tags`;
return fetch(query, {
Expand All @@ -341,7 +341,7 @@ export default {
Authorization: session.token,
},
body: JSON.stringify({
treeId,
treeId: captureId,
tagId: t.id,
}),
})
Expand All @@ -352,9 +352,9 @@ export default {
/*
* get tags for a given tree
*/
getTreeTags({ treeId, tagId }) {
getCaptureTags({ captureId, tagId }) {
const filterString =
(treeId ? `filter[where][treeId]=${treeId}` : '') +
(captureId ? `filter[where][treeId]=${captureId}` : '') +
(tagId ? `&filter[where][tagId]=${tagId}` : '');
const query = `${process.env.REACT_APP_API_ROOT}/api/tree_tags?${filterString}`;
return fetch(query, {
Expand Down
160 changes: 0 additions & 160 deletions src/components/AppDrawer.js

This file was deleted.

Loading

0 comments on commit 7513e71

Please sign in to comment.