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

[TM-911] Display seeding counts on project, site and their report admin pages. #245

Merged
merged 1 commit into from
Jun 10, 2024
Merged
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
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