diff --git a/cypress/tests/integration/nockRoutes.js b/cypress/tests/integration/nockRoutes.js
index bef4d5050..86c9b38a6 100644
--- a/cypress/tests/integration/nockRoutes.js
+++ b/cypress/tests/integration/nockRoutes.js
@@ -1,6 +1,5 @@
import grower100 from '../../../doc/examples/growers/100.json';
import organization1 from '../../../doc/examples/organizations/1.json';
-import planter940 from '../../../doc/examples/planters/940.json';
import { defaultConfig } from '../../../src/context/configContext';
import capture1 from '../../fixtures/capture.json';
import leader from '../../fixtures/countries/leader.json';
@@ -10,31 +9,21 @@ export function getNockRoutes(
props = {
tree: {},
organization: {},
- planter: {},
grower: {},
capture: {},
},
) {
const organization = { ...organization1, ...props.organization };
- const planter = { ...planter940, ...props.planter };
const grower = { ...grower100, ...props.grower };
const tree = { ...tree186734, ...props.tree };
const capture = { ...capture1, ...props.capture };
return [
- {
- method: 'GET',
- path: `/planters/${planter.id}`,
- statusCode: 200,
- body: planter,
- },
-
{
method: 'GET',
path: `/growers/${grower.id}`,
statusCode: 200,
body: grower,
},
-
{
method: 'GET',
path: '/trees/featured',
@@ -43,58 +32,24 @@ export function getNockRoutes(
trees: [tree],
},
},
-
{
method: 'GET',
path: `/trees/${tree.id}`,
statusCode: 200,
body: tree,
},
-
- {
- method: 'GET',
- path: `/planters/${planter.planter_id}`,
- statusCode: 200,
- body: planter,
- },
-
{
method: 'GET',
path: `/growers/${grower.grower_id}`,
statusCode: 200,
body: grower,
},
-
{
method: 'GET',
path: `/organizations/${organization.id}`,
statusCode: 200,
body: organization,
},
-
- {
- method: 'GET',
- path: planter.links.species,
- statusCode: 200,
- body: {
- species: [tree],
- },
- },
- {
- method: 'GET',
- path: planter.links.associated_organizations,
- statusCode: 200,
- body: { organizations: [organization] },
- },
- {
- method: 'GET',
- path: planter.links.featured_trees,
- statusCode: 200,
- body: {
- trees: [tree],
- },
- },
-
{
method: 'GET',
path: grower.links.species,
@@ -117,7 +72,6 @@ export function getNockRoutes(
trees: [tree],
},
},
-
{
method: 'GET',
path: organization.links.species,
@@ -126,12 +80,6 @@ export function getNockRoutes(
species: [tree],
},
},
- {
- method: 'GET',
- path: organization.links.associated_planters,
- statusCode: 200,
- body: { planters: [planter] },
- },
{
method: 'GET',
path: organization.links.associated_growers,
diff --git a/cypress/tests/integration/planters/[planterid].cy.js b/cypress/tests/integration/planters/[planterid].cy.js
deleted file mode 100644
index beab11379..000000000
--- a/cypress/tests/integration/planters/[planterid].cy.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import planter from '../../../../doc/examples/planters/940.json';
-import { prepareNocks, clearNocks } from '../nockRoutes';
-
-beforeEach(() => {
- clearNocks();
-});
-
-describe('Planter page', () => {
- it('getServerSideProps return mocks', () => {
- const path = `/planters/${planter.id}`;
- prepareNocks({ planter });
- cy.visit(path);
- cy.get('.MuiTypography-h2').contains(/sebastian g/i);
- cy.screenshot();
- });
-});
diff --git a/doc/examples/planters/940.json b/doc/examples/planters/940.json
deleted file mode 100644
index 83eb9e5dc..000000000
--- a/doc/examples/planters/940.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "id": 940,
- "first_name": "Sebastian ",
- "last_name": "Gaertner",
- "image_url": "https://treetracker-dev-images.s3.eu-central-1.amazonaws.com/2020.10.19.09.47.53_-5.508107173727935_38.981361706266256_39f0cc9d-0f13-4547-8142-150f15cabb67_IMG_20201019_094513_6614320100195503436.jpg",
- "trees_planted": 4,
- "about": "Greenway is a Youth-Driven Environmental Protection Organization providing alternative solutions to single-use plastic and planting carbon-sucking trees for socio-economic development and reducing climate crisis. Our social work includes reforestation, landscape restoration, climate education, awareness campaign, conducting research, outreach activities, and collaborating with key stakeholders to implement sustainable solutions.",
- "mission": "To combat climate change, desertification, land degradation, carbon emission by inspiring healthier communities affected by severe climate disorder and modestly reducing pollution by 2050.",
- "created_time": "2018-01-01",
- "country": "Tanzania",
- "links": {
- "featured_trees": "/trees?planter_id=940&limit=4",
- "associated_organizations": "/organizations?planter_id=940",
- "species": "/species?planter_id=940"
- }
-}
diff --git a/doc/examples/planters/940/organizations.json b/doc/examples/planters/940/organizations.json
deleted file mode 100644
index e69de29bb..000000000
diff --git a/doc/examples/planters/940/trees.json b/doc/examples/planters/940/trees.json
deleted file mode 100644
index 72c518aab..000000000
--- a/doc/examples/planters/940/trees.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "summary": {
- "total": "0"
- },
- "trees": [{}]
-}
diff --git a/package-lock.json b/package-lock.json
index 07d05357e..6d9ea7bfb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "client",
- "version": "2.6.0-v2.5",
+ "version": "2.6.0-v2.9",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "client",
- "version": "2.6.0-v2.5",
+ "version": "2.6.0-v2.9",
"dependencies": {
"@emotion/cache": "^11.5.0",
"@emotion/react": "^11.5.0",
diff --git a/src/mocks/handlers.js b/src/mocks/handlers.js
index 0f9e47231..a9f167334 100644
--- a/src/mocks/handlers.js
+++ b/src/mocks/handlers.js
@@ -1,8 +1,8 @@
import { rest } from 'msw';
import mockTree from '../../cypress/fixtures/tree186734.json';
import leader from '../../doc/examples/countries/leader.json';
+import grower from '../../doc/examples/growers/100.json';
import organization from '../../doc/examples/organizations/1.json';
-import planter from '../../doc/examples/planters/940.json';
import species from '../../doc/examples/species/1.json';
const trees = { trees: [mockTree, mockTree, mockTree] };
@@ -20,18 +20,20 @@ const handlers = [
rest.get(`${host}/trees*`, (req, res, ctx) =>
res(ctx.status(200, 'success'), ctx.json(trees)),
),
- rest.get(`${host}/planters/featured`, (req, res, ctx) =>
+
+ rest.get(`${host}/growers/featured`, (req, res, ctx) =>
res(
ctx.status(200, 'success'),
ctx.json({
- planters: [planter, planter, planter],
+ growers: [grower, grower, grower],
}),
),
),
- rest.get(`${host}/planters/:id`, (req, res, ctx) =>
- res(ctx.status(200, 'success'), ctx.json(planter)),
+ rest.get(`${host}/growers/:id`, (req, res, ctx) =>
+ res(ctx.status(200, 'success'), ctx.json(grower)),
),
+
rest.get(`${host}/organizations/featured`, (req, res, ctx) =>
res(
ctx.status(200, 'success'),
@@ -40,6 +42,7 @@ const handlers = [
}),
),
),
+
rest.get(`${host}/organizations/:id`, (req, res, ctx) =>
res(ctx.status(200, 'success'), ctx.json(organization)),
),
@@ -57,4 +60,5 @@ const handlers = [
res(ctx.status(200, 'success'), ctx.json(leader)),
),
];
+
export default handlers;
diff --git a/src/models/api.js b/src/models/api.js
index 817e4a80e..3a53a5ecb 100644
--- a/src/models/api.js
+++ b/src/models/api.js
@@ -101,20 +101,6 @@ export async function getCountryByLatLon(lat, lon) {
}
}
-export async function getPlanterById(id) {
- try {
- const url = apiPaths.planters(id);
- const begin = Date.now();
- const res = await axios.get(url);
- const data = await res.data;
- log.warn('url:', url, 'took:', Date.now() - begin);
- return data;
- } catch (err) {
- log.error(err.message);
- throw err;
- }
-}
-
export async function getGrowerById(id) {
try {
const url = apiPaths.growers(id);
diff --git a/src/models/api.spec.js b/src/models/api.spec.js
index 5b33e8952..d5c956b41 100644
--- a/src/models/api.spec.js
+++ b/src/models/api.spec.js
@@ -4,11 +4,16 @@ import {
getFeaturedTrees,
getOrganizationById,
getOrgLinks,
- getPlanterById,
+ getGrowerById,
getTreeById,
} from './api';
import organization from '../../doc/examples/organizations/1.json';
-import mockPlanter from '../../doc/examples/planters/940.json';
+
+it('should get grower by id', async () => {
+ const grower = await getGrowerById(100);
+ expect(grower).toBeDefined();
+ expect(grower.first_name).toBeDefined();
+});
it('should get featured trees', async () => {
const trees = await getFeaturedTrees();
diff --git a/src/models/utils.js b/src/models/utils.js
index dbb26ff05..7b77bdca2 100644
--- a/src/models/utils.js
+++ b/src/models/utils.js
@@ -198,7 +198,7 @@ const optimizeThemeFonts = (theme) => {
return temp;
};
-function getPlanterName(firstName, lastName) {
+function getGrowerName(firstName, lastName) {
return `${firstName} ${(lastName && lastName.slice(0, 1)) || ''}`;
}
@@ -322,7 +322,7 @@ export {
debounce,
loadFonts,
optimizeThemeFonts,
- getPlanterName,
+ getGrowerName,
convertFontObjToFontArr,
nextPathBaseDecode,
nextPathBaseEncode,
diff --git a/src/pages/growers/[growerid].js b/src/pages/growers/[growerid].js
index a00366d07..6e9623859 100644
--- a/src/pages/growers/[growerid].js
+++ b/src/pages/growers/[growerid].js
@@ -24,7 +24,7 @@ import Icon from 'components/common/CustomIcon';
import Info from 'components/common/Info';
import { useDrawerContext } from 'context/DrawerContext';
import { useMobile } from 'hooks/globalHooks';
-import planterBackground from 'images/background.png';
+import growerBackground from 'images/background.png';
import CalendarIcon from 'images/icons/calendar.svg';
import LocationIcon from 'images/icons/location.svg';
import PeopleIcon from 'images/icons/people.svg';
@@ -34,7 +34,7 @@ import { useMapContext } from 'mapContext';
import { getGrowerById, getOrgLinks } from 'models/api';
import { makeStyles } from 'models/makeStyles';
import * as pathResolver from 'models/pathResolver';
-import { getLocationString, getPlanterName, wrapper } from 'models/utils';
+import { getLocationString, getGrowerName, wrapper } from 'models/utils';
// make styles for component with material-ui
const useStyles = makeStyles()((theme) => ({
@@ -86,7 +86,7 @@ export default function Grower(props) {
// try to find first tree image or default image return
const backgroundPic =
grower?.featuredTrees?.trees?.[0]?.image_url ||
- `${router.basePath}${planterBackground}`;
+ `${router.basePath}${growerBackground}`;
useEffect(() => {
setTitlesData({
@@ -135,10 +135,7 @@ export default function Grower(props) {
return (
<>
@@ -228,7 +222,7 @@ export default function Grower(props) {
}}
>
- {getPlanterName(grower.first_name, grower.last_name)}
+ {getGrowerName(grower.first_name, grower.last_name)}
({
- imageContainer: {
- position: 'relative',
- flexGrow: 1,
- width: '100%',
- marginTop: 20,
- borderRadius: 16,
- overflow: 'hidden',
- },
- treeSlider: {
- marginTop: theme.spacing(10),
- },
- divider: {
- marginTop: theme.spacing(20),
- marginBottom: theme.spacing(20),
- [theme.breakpoints.down('md')]: {
- marginTop: theme.spacing(14),
- marginBottom: theme.spacing(14),
- },
- },
- profileImg: {
- maxHeight: '764px',
- borderRadius: '16px',
- [theme.breakpoints.down('md')]: {
- height: '332px',
- },
- },
-}));
-
-const placeholderText = `Lorem ipsum dolor sit amet consectetur adipisicing elit. Culpa iusto
- nesciunt quasi praesentium non cupiditate ratione nihil. Perferendis,
- velit ipsa illo, odit unde atque doloribus tempora distinctio facere
- dolorem expedita error. Natus, provident. Tempore harum repellendus
- reprehenderit vitae temporibus, consequuntur blanditiis officia
- excepturi, natus explicabo laborum delectus repudiandae placeat
- eligendi.`;
-export default function Planter(props) {
- log.warn('props for planter page:', props);
- const { planter, nextExtraIsEmbed } = props;
-
- const { featuredTrees } = planter;
- const treeCount = featuredTrees?.total;
- const mapContext = useMapContext();
- const isMobile = useMobile();
-
- const router = useRouter();
-
- const [isPlanterTab, setIsPlanterTab] = useState(true);
-
- const { setTitlesData } = useDrawerContext();
-
- const { classes } = useStyles();
-
- // try to find first tree image or default image return
- const backgroundPic =
- planter?.featuredTrees?.trees?.[0]?.image_url ||
- `${router.basePath}${planterBackground}`;
-
- useEffect(() => {
- setTitlesData({
- firstName: planter.first_name,
- lastName: planter.last_name,
- createdTime: planter.created_time,
- });
- }, [
- planter.created_time,
- planter.first_name,
- planter.last_name,
- setTitlesData,
- ]);
-
- useEffect(() => {
- async function reload() {
- // manipulate the map
- const { map } = mapContext;
- if (map && planter) {
- // map.flyTo(tree.lat, tree.lon, 16);
- await map.setFilters({
- userid: planter.id,
- });
- const bounds = pathResolver.getBounds(router);
- if (bounds) {
- log.warn('goto bounds found in url');
- await map.gotoBounds(bounds);
- } else {
- const view = await map.getInitialView();
- map.gotoView(view.center.lat, view.center.lon, view.zoomLevel);
- }
- }
- }
- reload();
- }, [mapContext, planter]);
-
- const BadgeSection = useMemo(
- () => (
- <>
- }
- badgeName="Verified Planter"
- />
-
- >
- ),
- [],
- );
-
- return (
- <>
-
- [t.spacing(0, 4), 6],
- width: 1,
- boxSizing: 'border-box',
- },
- nextExtraIsEmbed && {
- padding: (t) => [t.spacing(0, 4), 4],
- },
- ]}
- >
- {/*
-
- */}
- {/*
-
- */}
- {!isMobile && (
-
- ,
- name: 'Home',
- url: '/',
- },
- {
- icon: planter.image_url,
- name: `${getPlanterName(
- planter.first_name,
- planter.last_name,
- )}`,
- },
- ]}
- />
-
-
-
-
- )}
-
-
-
-
-
- {isMobile && (
- document.getElementById('drawer-title-container')}
- >
-
-
- {getPlanterName(planter.first_name, planter.last_name)}
-
-
-
- Planter since
-
- >
- }
- />
-
-
-
-
-
- {BadgeSection}
-
-
-
- )}
- {isMobile && (
-
- document.getElementById('drawer-title-container-min')
- }
- >
-
-
- {planter.first_name}{' '}
- {planter.last_name && planter.last_name.slice(0, 1)}.
-
-
-
- )}
-
- {!isMobile && (
-
-
- {planter.first_name}{' '}
- {planter.last_name && planter.last_name.slice(0, 1)}.
-
-
-
- Planter since
-
- >
- }
- />
-
-
-
-
-
- {BadgeSection}
-
-
- )}
-
-
-
- Featured trees by {planter.first_name}
-
- `/planters/${planter.id}/trees/${item.id}`}
- />
-
-
-
-
- setIsPlanterTab(true)}
- iconURI={TreeIcon}
- iconProps={{
- sx: {
- '& path': {
- fill: ({ palette }) => palette.primary.main,
- },
- },
- }}
- title="Trees Planted"
- text={treeCount}
- disabled={!isPlanterTab}
- />
-
-
- setIsPlanterTab(false)
- : undefined
- }
- iconURI={PeopleIcon}
- iconProps={{
- sx: {
- '& path': {
- fill: ({ palette }) => palette.text.primary,
- },
- },
- }}
- title="Associated Orgs"
- text={
- planter.associatedOrganizations.organizations.length || (
-
- Individual planter
-
- )
- }
- disabled={isPlanterTab}
- />
-
-
-
- {planter.continent_name && (
-
-
-
- )}
-
-
- Species of trees planted
-
-
- {planter.species.species.map((species) => (
-
- ))}
-
- {(!planter.species.species ||
- planter.species.species.length === 0) && (
- NO DATA YET
- )}
-
-
- {planter.associatedOrganizations.organizations.map((org) => (
- <>
-
-
- >
- ))}
-
-
-
- About the Planter
-
-
-
-
-
-
-
-
- {nextExtraIsEmbed && (
- document.getElementById('embed-logo-container')}
- >
-
-
- )}
- >
- );
-}
-
-async function serverSideData(params) {
- const id = params.planterid;
- const planter = await getPlanterById(id);
- const data = await getOrgLinks(planter.links);
- return {
- planter: { ...planter, ...data },
- };
-}
-
-const getStaticProps = wrapper(async ({ params }) => {
- const props = await serverSideData(params);
- return {
- props,
- revalidate: Number(process.env.NEXT_CACHE_REVALIDATION_OVERRIDE) || 30,
- };
-});
-
-// eslint-disable-next-line
-const getStaticPaths = async () => {
- return {
- paths: [],
- fallback: 'blocking',
- };
-};
-
-export { getStaticProps, getStaticPaths };
diff --git a/src/pages/tokens/[tokenid].js b/src/pages/tokens/[tokenid].js
index df67a04c4..228e74c75 100644
--- a/src/pages/tokens/[tokenid].js
+++ b/src/pages/tokens/[tokenid].js
@@ -39,7 +39,7 @@ import TreeIcon from 'images/icons/tree.svg';
import imagePlaceholder from 'images/image-placeholder.png';
import SearchIcon from 'images/search.svg';
import { useMapContext } from 'mapContext';
-import { getWalletById, getTokenById, getPlanterById } from 'models/api';
+import { getWalletById, getTokenById, getGrowerById } from 'models/api';
import { makeStyles } from 'models/makeStyles';
import * as pathResolver from 'models/pathResolver';
import { wrapper } from 'models/utils';
@@ -60,8 +60,7 @@ function handleShare() {}
export default function Token(props) {
log.warn('props:', props);
- const { token, wallet, transactions, nextExtraIsEmbed, tree, planter } =
- props;
+ const { token, wallet, transactions, nextExtraIsEmbed, tree, grower } = props;
const theme = useTheme();
const { classes } = useStyles();
const mapContext = useMapContext();
@@ -535,10 +534,10 @@ export default function Token(props) {
p: [2, 4],
}}
>
-
+
@@ -697,14 +696,14 @@ async function serverSideData(params, query) {
`${process.env.NEXT_PUBLIC_API}/transactions?token_id=${token.id}`,
);
const { data: transactions } = res;
- const planter = await getPlanterById(tree.planter_id);
+ const grower = await getGrowerById(tree.planter_id);
result = {
token,
wallet,
transactions,
tree,
- planter,
+ grower,
};
} else {
const token = await getTokenById(tokenid);
@@ -722,14 +721,14 @@ async function serverSideData(params, query) {
);
tree = res2.data;
}
- const planter = await getPlanterById(tree.planter_id);
+ const grower = await getGrowerById(tree.planter_id);
result = {
token,
wallet,
transactions,
tree,
- planter,
+ grower,
};
}
diff --git a/src/pages/trees/[treeid].js b/src/pages/trees/[treeid].js
index 8a2617bb5..d45cb2af8 100644
--- a/src/pages/trees/[treeid].js
+++ b/src/pages/trees/[treeid].js
@@ -41,7 +41,6 @@ import { useMapContext } from 'mapContext';
import {
getCaptures,
getOrganizationById,
- getPlanterById,
getTreeById,
getCapturesByTreeId,
getGrowerById,
@@ -235,8 +234,8 @@ export default function Tree({
]}
>
{/*
-
- */}
+
+ */}
{isMobile && (
document.getElementById('drawer-title-container')}
@@ -577,10 +576,10 @@ export default function Tree({
)}
{/* */}
+ imageUrl={tree.image_url}
+ timeCreated={tree.time_created}
+ treeId={tree.id}
+ /> */}
{organization && (