Skip to content

Commit

Permalink
Merge pull request #245 from wri/feat/TM-911-seedings-counts
Browse files Browse the repository at this point in the history
[TM-911] Display seeding counts on project, site and their report admin pages.
  • Loading branch information
roguenet authored Jun 10, 2024
2 parents 27fee21 + 12207f2 commit 49e203d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ const HighLevelMetics: FC = () => {
<Labeled label="Trees Planted" sx={inlineLabelSx}>
<NumberField source="trees_planted_count" emptyText="0" />
</Labeled>
<When condition={record?.framework_key === "ppc"}>
<Labeled label="Seeds Planted" sx={inlineLabelSx}>
<NumberField source="seeds_planted_count" emptyText="0" />
</Labeled>
</When>
</Stack>
</Card>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const HighLevelMetics: FC = () => {
};

const isTerraFund = record.framework_key === "terrafund";
const isPPC = record.framework_key === "ppc";
const workdaysType = resource === "projectReport" ? "Project" : resource === "siteReport" ? "Site" : null;

return (
Expand Down Expand Up @@ -48,6 +49,14 @@ const HighLevelMetics: FC = () => {
emptyText="0"
/>
</Labeled>
<When condition={isPPC && (resource === "projectReport" || resource === "siteReport")}>
<Labeled label="Total Number Of Seeds Planted" sx={inlineLabelSx}>
<NumberField
source={record.seeds_planted_count ? "trees_planted_count" : "total_seeds_planted_count"}
emptyText="0"
/>
</Labeled>
</When>
<When condition={isTerraFund}>
<Labeled label="Total Number Of Seedlings" sx={inlineLabelSx}>
<NumberField source="seedlings_grown" emptyText="0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Box, Card, Divider, Stack, SxProps, Theme, Typography } from "@mui/material";
import { Box, Card, Stack, SxProps, Theme } from "@mui/material";
import { FC } from "react";
import { Labeled, NumberField, useShowContext } from "react-admin";
import { When } from "react-if";

import Text from "@/components/elements/Text/Text";
const HighLevelMetics: FC = () => {
const { record } = useShowContext();

Expand All @@ -14,15 +15,12 @@ const HighLevelMetics: FC = () => {
const isPPC = record.framework_key === "ppc";

return (
<Card>
<Box paddingX={3.75} paddingY={2}>
<Typography variant="h5">High Level Metrics</Typography>
</Box>

<Divider />

<Card className="!shadow-none">
<Box paddingX={3.75} paddingY={2}>
<Stack gap={3}>
<Text variant="text-16-semibold" className="text-darkCustom">
High Level Metrics
</Text>
<When condition={isPPC}>
<Labeled label="Workdays Created (Old Calculation)" sx={inlineLabelSx}>
<NumberField source="self_reported_workday_count" emptyText="0" />
Expand All @@ -31,10 +29,15 @@ const HighLevelMetics: FC = () => {
<NumberField source="workday_count" emptyText="0" />
</Labeled>
</When>
<Labeled label="Total Number Of Trees Planted" sx={inlineLabelSx}>
<Labeled label="Total Number Of Trees Planted" sx={inlineLabelSx} className="label-field-aside">
<NumberField source="trees_planted_count" emptyText="0" />
</Labeled>
<Labeled label="Hectares Under Restoration" sx={inlineLabelSx}>
<When condition={isPPC}>
<Labeled label="Total Number Of Seeds Planted" sx={inlineLabelSx} className="label-field-aside">
<NumberField source="seeds_planted_count" emptyText="0" />
</Labeled>
</When>
<Labeled label="Hectares Under Restoration" sx={inlineLabelSx} className="label-field-aside">
<NumberField source="hectares_to_restore_goal" emptyText="0" />
</Labeled>
</Stack>
Expand Down

0 comments on commit 49e203d

Please sign in to comment.