Skip to content

Commit

Permalink
[TM-1626] add conditional to show trees to be planted (#816)
Browse files Browse the repository at this point in the history
* [TM-1626] add conditional to show trees to be planted

* [TM-1626] update snapshot
  • Loading branch information
LimberHope authored Jan 21, 2025
1 parent c6f2203 commit 327f6bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const TreeSpeciesInput = (props: TreeSpeciesInputProps) => {
const handleBaseEntityTrees =
props.withPreviousCounts && (isReport || (isEntity && ["sites", "nurseries"].includes(entityName)));
const displayPreviousCounts = props.withPreviousCounts && isReport;
const hasCountActive = props.withNumbers;

const entity = (handleBaseEntityTrees ? entityName : undefined) as EstablishmentEntityType;
const uuid = handleBaseEntityTrees ? entityUuid : undefined;
Expand Down Expand Up @@ -303,10 +304,14 @@ const TreeSpeciesInput = (props: TreeSpeciesInputProps) => {
</div>
<div className={classNames({ "border-r pr-6": displayPreviousCounts })} ref={refPlanted}>
<Text variant="text-14-bold" className="uppercase text-black">
{isReport ? t("TOTAL PLANTED THIS REPORT:") : t("TREES TO BE PLANTED:")}
{isReport ? t("TOTAL PLANTED THIS REPORT:") : hasCountActive ? t("TREES TO BE PLANTED:") : ""}
</Text>
<Text variant="text-20-bold" className="text-primary">
{props.withNumbers ? props.value.reduce((total, v) => total + (v.amount || 0), 0).toLocaleString() : "0"}
{hasCountActive
? props.value.reduce((total, v) => total + (v.amount || 0), 0).toLocaleString()
: isReport
? "0"
: ""}
</Text>
</div>
<When condition={displayPreviousCounts}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,11 @@ exports[`Storyshots Components/Elements/Inputs/TreeSpeciesInput Default 1`] = `
<p
className="uppercase text-black text-14-bold"
data-testid="txt"
>
TREES TO BE PLANTED:
</p>
/>
<p
className="text-primary text-20-bold"
data-testid="txt"
>
0
</p>
/>
</div>
</div>
<div
Expand Down

0 comments on commit 327f6bc

Please sign in to comment.