Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add people who grows this tree list on /trees/{id} #1704

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/models/apiPaths.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kabszac Good job so far, One thing that you might want to is reverse these changes because the host already consists of /v2 you don't need to change that

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const apiPaths = {
countriesLatLon: (lat = '', lon = '') =>
urlJoin(host, `/countries?lat=${lat}&lon=${lon}`),
leaders: urlJoin(host, '/countries/leaderboard'),
trees: (id = '') => urlJoin(host, `/trees/${id}`),
trees: (id = '') => urlJoin(host, `trees/${id}`),
captures: (id = '') => urlJoin(host, `captures/${id}`),
growers: (id = '') => urlJoin(host, `growers/${id}`),
planters: (id = '') => urlJoin(host, `growers/${id}`),
Expand Down
50 changes: 32 additions & 18 deletions src/pages/trees/[treeid].js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import moment from 'moment';
import { useRouter } from 'next/router';
import { useEffect, useMemo } from 'react';
import Badge from 'components/Badge';
import FeaturedPlantersSlider from 'components/FeaturedPlantersSlider';
import HeadTag from 'components/HeadTag';
import InformationCard1 from 'components/InformationCard1';
import LikeButton from 'components/LikeButton';
Expand All @@ -23,7 +24,7 @@ import Icon from 'components/common/CustomIcon';
import TagList from 'components/common/TagList';
import TreeTag from 'components/common/TreeTag';
import { useDrawerContext } from 'context/DrawerContext';
import { useMobile, useEmbed } from 'hooks/globalHooks';
import { useMobile, useEmbed, useFullscreen } from 'hooks/globalHooks';
import { usePageLoading } from 'hooks/usePageLoading';
import AccuracyIcon from 'images/icons/accuracy.svg';
import CalendarIcon from 'images/icons/calendar.svg';
Expand All @@ -36,13 +37,20 @@ import TokenIcon from 'images/icons/token.svg';
import imagePlaceholder from 'images/image-placeholder.png';
import SearchIcon from 'images/search.svg';
import { useMapContext } from 'mapContext';
import { getOrganizationById, getPlanterById, getTreeById } from 'models/api';
import {
getOrganizationById,
getPlanterById,
getTreeById,
getCapturesById,
getGrowerById,
} from 'models/api';
import * as pathResolver from 'models/pathResolver';
import * as utils from 'models/utils';

export default function Tree({
tree,
planter,
growers,
organization,
nextExtraIsEmbed,
nextExtraKeyword,
Expand All @@ -59,6 +67,7 @@ export default function Tree({
});
const isMobile = useMobile();
const isEmbed = useEmbed();
const isFullscreen = useFullscreen();
const isPlanterContext = context && context.name === 'planters';
const isOrganizationContext = context && context.name === 'organizations';

Expand Down Expand Up @@ -583,22 +592,23 @@ export default function Tree({
/>
</Box>
)}
<Box
sx={{
mt: [4, 10],
}}
>
<InformationCard1
entityName={`${planter.first_name} ${planter.last_name}`}
entityType="Planter"
buttonText="Meet the Planter"
cardImageSrc={planter?.image_url || imagePlaceholder}
rotation={planter?.image_rotation}
link={`/planters/${planter.id}?keyword=${nextExtraKeyword}${
isEmbed ? '&embed=true' : ''
}`}
/>
</Box>
{growers.length > 0 && (
<>
<Box
sx={{
mt: 8,
}}
>
<Typography variant="h4">Featured planters this week</Typography>
</Box>
<FeaturedPlantersSlider
link={(id) => `/planters/${id}`}
color="secondary"
planters={growers}
isMobile={isFullscreen}
/>
</>
)}
<Typography
variant="h4"
sx={[
Expand Down Expand Up @@ -742,8 +752,10 @@ export default function Tree({
async function serverSideData(params) {
const { treeid } = params;
const tree = await getTreeById(treeid);
const captures = await getCapturesById(treeid);
const { planter_id, planting_organization_id } = tree;
const planter = await getPlanterById(planter_id);
const growers = await getGrowerById(planting_organization_id);
let organization = null;
if (planting_organization_id) {
log.warn('load org from planting_orgniazation_id');
Expand All @@ -757,7 +769,9 @@ async function serverSideData(params) {

return {
tree,
captures,
planter,
growers,
organization,
};
}
Expand Down
Loading