Skip to content

Commit 941f70b

Browse files
committed
fix: remove comments and unused code
1 parent 5b25248 commit 941f70b

File tree

6 files changed

+17
-102
lines changed

6 files changed

+17
-102
lines changed

src/components/Captures/CaptureGallery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { CapturesContext } from '../../context/CapturesContext';
1818
import { SpeciesContext } from '../../context/SpeciesContext';
1919
import { TagsContext } from '../../context/TagsContext';
2020

21-
const log = require('loglevel').getLogger('../components/Verify');
21+
const log = require('loglevel').getLogger('../components/CaptureGallery');
2222

2323
const useStyles = makeStyles(styles);
2424

@@ -99,7 +99,7 @@ const CaptureGallery = ({
9999
const speciesId = await speciesContext.getSpeciesId();
100100
if (speciesId) {
101101
approveAction.speciesId = speciesId;
102-
console.log('species id:', speciesId);
102+
log.debug('species id:', speciesId);
103103
}
104104

105105
// create/retrieve tags

src/components/Captures/CaptureGallery.test.js

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,14 @@
11
import React from 'react';
2-
import { BrowserRouter } from 'react-router-dom';
3-
import {
4-
act,
5-
render,
6-
screen,
7-
within,
8-
cleanup,
9-
waitForElementToBeRemoved,
10-
} from '@testing-library/react';
11-
import userEvent from '@testing-library/user-event';
12-
import captureApi from '../../api/treeTrackerApi';
2+
import { act, render, screen, within, cleanup } from '@testing-library/react';
133
import theme from '../common/theme';
144
import { ThemeProvider } from '@material-ui/core/styles';
15-
import { AppProvider } from '../../context/AppContext';
165
import { CapturesContext } from '../../context/CapturesContext';
17-
import { GrowerContext } from '../../context/GrowerContext';
186
import { SpeciesContext } from '../../context/SpeciesContext';
197
import { TagsContext } from '../../context/TagsContext';
208
import CaptureGallery from './CaptureGallery';
219
import {
22-
CAPTURE,
2310
CAPTURES,
24-
GROWER,
25-
ORGS,
26-
TAG,
27-
TAGS,
28-
SPECIES,
2911
capturesValues,
30-
growerValues,
3112
tagsValues,
3213
speciesValues,
3314
} from '../tests/fixtures';
@@ -49,45 +30,10 @@ describe('Captures', () => {
4930
return Promise.resolve({ count: 4 });
5031
};
5132

52-
// mock the treeTrackerApi
53-
// let captureApi = require('../../api/treeTrackerApi').default;
54-
55-
// captureApi.getCaptureById = (_id) => {
56-
// log.debug('mock getCaptureById:');
57-
// return Promise.resolve(CAPTURE);
58-
// };
59-
// captureApi.getSpecies = () => {
60-
// log.debug('mock getSpecies:');
61-
// return Promise.resolve(SPECIES);
62-
// };
63-
// captureApi.getSpeciesById = (_id) => {
64-
// log.debug('mock getSpeciesById:');
65-
// return Promise.resolve(SPECIES[0]);
66-
// };
67-
// captureApi.getCaptureCountPerSpecies = () => {
68-
// log.debug('mock getCaptureCountPerSpecies:');
69-
// return Promise.resolve({ count: 7 });
70-
// };
71-
// captureApi.getTags = () => {
72-
// log.debug('mock getTags:');
73-
// return Promise.resolve(TAGS);
74-
// };
75-
// captureApi.getTagById = (_id) => {
76-
// log.debug('mock getTagById:');
77-
// return Promise.resolve(TAG);
78-
// };
79-
// captureApi.getOrganizations = () => {
80-
// log.debug('mock getOrganizations:');
81-
// return Promise.resolve(ORGS);
82-
// };
83-
8433
describe('with default values', () => {
8534
beforeEach(async () => {
8635
render(
8736
<ThemeProvider theme={theme}>
88-
{/* <BrowserRouter> */}
89-
{/* <AppProvider value={{ orgList: ORGS }}> */}
90-
{/* <GrowerContext.Provider value={growerValues}> */}
9137
<CapturesContext.Provider value={capturesValues}>
9238
<SpeciesContext.Provider value={speciesValues}>
9339
<TagsContext.Provider value={tagsValues}>
@@ -99,9 +45,6 @@ describe('Captures', () => {
9945
</TagsContext.Provider>
10046
</SpeciesContext.Provider>
10147
</CapturesContext.Provider>
102-
{/* </GrowerContext.Provider> */}
103-
{/* </AppProvider> */}
104-
{/* </BrowserRouter> */}
10548
</ThemeProvider>
10649
);
10750

src/components/Captures/CaptureTable.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ import {
1414
import { GetApp } from '@material-ui/icons';
1515
import IconButton from '@material-ui/core/IconButton';
1616
import ImageIcon from '@material-ui/icons/Image';
17-
// import Map from '@material-ui/icons/Map';
1817
import Nature from '@material-ui/icons/Nature';
1918
import Person from '@material-ui/icons/Person';
20-
// import TableChartIcon from '@material-ui/icons/TableChart';
2119
import { getDateTimeStringLocale } from '../../common/locale';
2220
import { countToLocaleString } from '../../common/numbers';
2321
import { getVerificationStatus } from '../../common/utils';
@@ -336,7 +334,6 @@ export const formatCell = (
336334
title={`View/Edit Capture details`}
337335
style={{ padding: '0 4px 2px' }}
338336
>
339-
{/* <Typography color="primary">{capture[attr]}</Typography> */}
340337
<Nature color="primary" />
341338
</IconButton>
342339
<LinkToWebmap value={'Map'} type={'tree'} />
@@ -352,7 +349,6 @@ export const formatCell = (
352349
title={`View/Edit Grower details`}
353350
style={{ padding: '0 2px 2px 0' }}
354351
>
355-
{/* <Typography color="primary">{capture[attr]}</Typography> */}
356352
<Person color="primary" />
357353
</IconButton>
358354
<LinkToWebmap value={'Map'} type={'user'} />

src/context/CapturesContext.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,13 @@ export function CapturesProvider(props) {
176176

177177
const paramString = `filter=${JSON.stringify(lbFilter)}`;
178178
log.debug('load page with params:', paramString);
179-
const { data } = await queryCapturesApi({ paramString }).catch((err) =>
180-
console.error(`ERROR: Failed to get captures: ${err}`)
181-
);
182-
log.debug('loaded captures:', data.length);
183-
setCaptures(data);
184-
setIsLoading(false);
179+
await queryCapturesApi({ paramString })
180+
.then(({ data }) => {
181+
log.debug('loaded captures:', data.length);
182+
setCaptures(data);
183+
setIsLoading(false);
184+
})
185+
.catch((err) => console.error(`ERROR: Failed to get captures: ${err}`));
185186
};
186187

187188
const getCaptureExports = async (filterInfo = {}) => {
@@ -254,7 +255,6 @@ export function CapturesProvider(props) {
254255
};
255256

256257
const clickCapture = (payload) => {
257-
//{{{
258258
const { captureId, isShift, isCmd, isCtrl } = payload;
259259
if (!isShift && !isCmd && !isCtrl) {
260260
setCapturesSelected([captureId]);
@@ -298,7 +298,6 @@ export function CapturesProvider(props) {
298298
}
299299
setCapturesSelected(selectedImages);
300300
}
301-
//}}}
302301
};
303302

304303
const approve = async ({ approveAction, id }) => {
@@ -339,13 +338,10 @@ export function CapturesProvider(props) {
339338
try {
340339
for (let i = 0; i < total; i++) {
341340
const captureId = capturesSelected[i];
342-
const captureImage = captures.reduce((a, c) => {
343-
if (c && c.id === captureId) {
344-
return c;
345-
} else {
346-
return a;
347-
}
348-
}, undefined);
341+
const captureImage = captures.reduce(
342+
(a, c) => (c && c.id === captureId ? c : a),
343+
undefined
344+
);
349345
log.debug('approve:%d', captureImage.id);
350346
log.trace('approve:%d', captureImage.id);
351347
await approve({
@@ -373,8 +369,9 @@ export function CapturesProvider(props) {
373369

374370
const undoneCaptureImage = (captureId) => {
375371
//put the capture back, from undo list, sort by id
376-
const captureUndo = capturesUndo.reduce((a, c) =>
377-
c.id === captureId ? c : a
372+
const captureUndo = capturesUndo.reduce(
373+
(a, c) => (c.id === captureId ? c : a),
374+
undefined
378375
);
379376
const undoneImages = capturesUndo.filter(
380377
(capture) => capture.id !== captureId

src/views/CapturesView.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Grid } from '@material-ui/core';
44
import CaptureDetailDialog from '../components/CaptureDetailDialog';
55
import GrowerDetail from '../components/GrowerDetail';
66
import CaptureGallery from '../components/Captures/CaptureGallery';
7-
// import SidePanel from '../components/SidePanel';
87
import CaptureTable from '../components/Captures/CaptureTable';
98
import { CaptureDetailProvider } from '../context/CaptureDetailContext';
109
import { CapturesProvider } from '../context/CapturesContext';

src/views/CapturesView.test.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,6 @@ jest.mock('../api/growers');
3232
jest.mock('../api/treeTrackerApi');
3333

3434
describe.skip('Captures View', () => {
35-
//mock the growers api
36-
// let growerApi = require('../api/growers').default;
37-
38-
// growerApi.getCount = () => {
39-
// log.debug('mock getCount:');
40-
// return Promise.resolve({ count: 2 });
41-
// };
42-
// growerApi.getGrower = () => {
43-
// log.debug('mock getGrower:');
44-
// return Promise.resolve(GROWER);
45-
// };
46-
// growerApi.getGrowerRegistrations = () => {
47-
// log.debug('mock getGrowerRegistrations:');
48-
// return Promise.resolve([]);
49-
// };
50-
// growerApi.getGrowerSelfies = (id) => {
51-
// log.debug('mock getGrowerSelfies:');
52-
// return Promise.resolve([{ planterPhotoUrl: '' }, { planterPhotoUrl: '' }]);
53-
// };
54-
5535
// mock the treeTrackerApi
5636
let captureApi = require('../api/treeTrackerApi').default;
5737

0 commit comments

Comments
 (0)