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-1613] show data to seed planting progress tab #869

Merged
merged 1 commit into from
Jan 31, 2025
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
8 changes: 8 additions & 0 deletions src/components/extensive/Tables/TreeSpeciesTablePD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface TreeSpeciesTablePDProps {
modelName: string;
framework?: string;
setTotalCount?: React.Dispatch<React.SetStateAction<number>>;
setTotalSpecies?: React.Dispatch<React.SetStateAction<number>>;
headerName?: string;
collection?: string;
secondColumnWidth?: string;
Expand Down Expand Up @@ -57,6 +58,7 @@ const TreeSpeciesTablePD = ({
modelName,
framework,
setTotalCount,
setTotalSpecies,
collection,
headerName = "species Name",
secondColumnWidth = "",
Expand Down Expand Up @@ -136,6 +138,9 @@ const TreeSpeciesTablePD = ({
);
setTotalCount(total);
}
if (setTotalSpecies) {
setTotalSpecies(rows.length);
}
return rows.map(row => {
let speciesTypes = ["tree"];
if (!row.taxon_id) speciesTypes.push("non-scientific");
Expand Down Expand Up @@ -168,6 +173,9 @@ const TreeSpeciesTablePD = ({
const total = rows.reduce((sum, row) => sum + row.amount, 0);
setTotalCount(total);
}
if (setTotalSpecies) {
setTotalSpecies(rows.length);
}
return rows.map(row => {
let speciesTypes = ["tree"];
return {
Expand Down
77 changes: 18 additions & 59 deletions src/pages/site/[uuid]/tabs/GoalsAndProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,50 +39,15 @@ export const LABEL_LEGEND = [

const GoalsAndProgressTab = ({ site }: GoalsAndProgressTabProps) => {
const t = useT();
const [treeCount, setTreeCount] = React.useState(0);
const [speciesCount, setSpeciesCount] = React.useState(0);
const { data: dataAggregated } = useGetV2EntityUUIDAggregateReports({
pathParams: {
uuid: site.uuid,
entity: "site"
}
});

const dataSeedCount = [
{
name: ["Species scientific name", "tree"],
seedCount: "45,000"
},
{
name: ["Species scientific name", "Native species"],
seedCount: "45,000"
},
{
name: ["Species scientific name", "tree"],
seedCount: "10,350"
},
{
name: ["Species scientific name", "tree"],
seedCount: "7,500"
}
];
const dataNonTreeCount = [
{
name: ["Species scientific name", "tree"],
nonTreeCount: "45,000"
},
{
name: ["Species scientific name", "Native species"],
nonTreeCount: "45,000"
},
{
name: ["Species scientific name", "tree"],
nonTreeCount: "10,350"
},
{
name: ["Species scientific name", "tree"],
nonTreeCount: "7,500"
}
];

return (
<PageBody>
<PageRow>
Expand Down Expand Up @@ -191,23 +156,23 @@ const GoalsAndProgressTab = ({ site }: GoalsAndProgressTabProps) => {
variantLabel: "text-14" as TextVariants,
classNameLabel: " text-neutral-650 uppercase !w-auto",
classNameLabelValue: "!justify-start ml-2 !text-2xl",
value: 5250
value: site.seeds_planted_count.toLocaleString()
},
{
iconName: IconNames.SURVIVAL_RATE,
label: t("Estimated Survival Rate:"),
variantLabel: "text-14",
classNameLabel: " text-neutral-650 uppercase !w-auto",
classNameLabelValue: "!justify-start ml-2 !text-2xl",
value: "80% "
value: site.direct_seeding_survival_rate ? `${site.direct_seeding_survival_rate}%` : "-"
},
{
iconName: IconNames.LEAF_PLANTED_CIRCLE,
label: t("number of species PLANTED:"),
variantLabel: "text-14",
classNameLabel: " text-neutral-650 uppercase !w-auto",
classNameLabelValue: "!justify-start ml-2 !text-2xl",
value: 6
value: speciesCount
}
]}
/>
Expand All @@ -223,15 +188,15 @@ const GoalsAndProgressTab = ({ site }: GoalsAndProgressTabProps) => {
variantLabel: "text-14",
classNameLabel: " text-neutral-650 uppercase !w-auto",
classNameLabelValue: "!justify-start ml-2 !text-2xl",
value: 5250
value: treeCount.toLocaleString()
},
{
iconName: IconNames.LEAF_PLANTED_CIRCLE,
label: t("number of species PLANTED:"),
variantLabel: "text-14",
classNameLabel: " text-neutral-650 uppercase !w-auto",
classNameLabelValue: "!justify-start ml-2 !text-2xl",
value: "6"
value: speciesCount
}
]}
/>
Expand All @@ -247,46 +212,40 @@ const GoalsAndProgressTab = ({ site }: GoalsAndProgressTabProps) => {
variantLabel: "text-14",
classNameLabel: " text-neutral-650 uppercase !w-auto",
classNameLabelValue: "!justify-start ml-2 !text-2xl",
value: 5250
value: site.seeds_planted_count.toLocaleString()
},
{
iconName: IconNames.LEAF_PLANTED_CIRCLE,
label: t("number of species PLANTED:"),
variantLabel: "text-14",
classNameLabel: " text-neutral-650 uppercase !w-auto",
classNameLabelValue: "!justify-start ml-2 !text-2xl",
value: 6
},
{
iconName: IconNames.LEARF_NATIVE_CIRCLE_PD,
label: t("PERCENTAGE of Native species:"),
variantLabel: "text-14",
classNameLabel: " text-neutral-650 uppercase !w-auto",
classNameLabelValue: "!justify-start ml-2 !text-2xl",
value: "1%"
value: speciesCount
}
]}
/>
</When>
</div>
<div>
<If condition={site.framework_key === Framework.TF}>
<If condition={site.framework_key === Framework.TF || site.framework_key === Framework.HBF}>
<Then>
<TreeSpeciesTablePD
modelName="site"
data={dataNonTreeCount}
typeTable="nonTreeCount"
collection="non-tree"
modelUUID={site.uuid}
visibleRows={10}
visibleRows={5}
setTotalSpecies={setSpeciesCount}
setTotalCount={setTreeCount}
/>
</Then>
<Else>
<TreeSpeciesTablePD
modelName="site"
data={dataSeedCount}
typeTable="seedCount"
collection="seeding"
modelUUID={site.uuid}
visibleRows={10}
visibleRows={5}
setTotalCount={setTreeCount}
setTotalSpecies={setSpeciesCount}
/>
</Else>
</If>
Expand Down