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

Feat/[TM-1607] progress goals #864

Merged
merged 18 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ee1f3d5
[TM-1605] add component to progress and goals pie chart
LimberHope Jan 28, 2025
e9bdd3a
[TM-1607] Merge branch 'TM-1605_site_landing_page_progress_goals' int…
egrojMonroy Jan 28, 2025
6d81d5c
Merge branch 'staging' into TM-1605_site_landing_page_progress_goals
LimberHope Jan 28, 2025
e7c5e4a
[TM-1607] add charts
egrojMonroy Jan 28, 2025
d09a264
[TM-1605] add mapping to data charts
LimberHope Jan 28, 2025
c7141a0
[TM-1607] Merge branch 'TM-1605_site_landing_page_progress_goals' int…
egrojMonroy Jan 29, 2025
94db4cf
[TM-1605] add params to chartData component
LimberHope Jan 29, 2025
0ec8563
[TM-1607] Merge branch 'TM-1605_site_landing_page_progress_goals' int…
egrojMonroy Jan 29, 2025
85b9d1c
[TM-1605] add external component to progress and goals site
LimberHope Jan 29, 2025
ffe8435
[TM-1605] update name chartData
LimberHope Jan 29, 2025
38a0b33
[TM-1607] Merge branch 'TM-1605_site_landing_page_progress_goals' int…
egrojMonroy Jan 29, 2025
6c23e3c
[TM-1607] add pie chart with component and data for PPc
egrojMonroy Jan 29, 2025
8c269ff
[TM-1607] Merge branch 'TM-1605_site_landing_page_progress_goals' int…
egrojMonroy Jan 30, 2025
0bd5af8
[TM-1607] Merge branch 'staging' into feat/TM-1607-progress-goals
egrojMonroy Jan 30, 2025
2f53c05
[TM-1607] modify pie chart style
cesarLima1 Jan 30, 2025
e15d460
[TM-1607] Merge branch 'staging' into feat/TM-1607-progress-goals
LimberHope Jan 30, 2025
72590c6
[TM-1607] improve code to GoalsAndProgressEntity component
LimberHope Jan 31, 2025
4d3a250
[TM-1607] update snapshots
LimberHope Jan 31, 2025
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 @@ -13,6 +13,7 @@ export interface ProgressGoalsData {
interface ProgressGoalsDoughnutChartProps {
data?: ProgressGoalsData;
}

const percentage = (current: number, total: number) => {
const percentValue = Math.min((current / total) * 100, 100);
return percentValue.toFixed(0);
Expand All @@ -33,6 +34,7 @@ const ProgressGoalsDoughnutChart: React.FC<ProgressGoalsDoughnutChartProps> = ({
{ value: currentValue, isProgress: true },
{ value: remainingValue, isProgress: false }
];

const COLORS = ["#27A9E0", "#DFF2FB"];

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const GoalProgressCard: FC<GoalProgressCardProps> = ({
<Text variant={labelVariant ?? "text-16-light"} className={classNames("mb-1 w-full", classNameLabel)}>
{label}
</Text>
{graph ? chart : null}
{graph ? <div className="flex w-[calc(33.33%-16px)] min-w-[200px] items-center">{chart}</div> : null}
<Text variant="text-24-bold" className={classNames("flex w-full items-baseline", classNameLabelValue)}>
{value?.toLocaleString()}&nbsp;
<When condition={!!limit || !!totalValue}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ exports[`Storyshots Components/Elements/Cards/GoalProgressCard/Card No Progress
>
Hectors Restored
</p>
<div
className="flex w-[calc(33.33%-16px)] min-w-[200px] items-center"
/>
<p
className="flex w-full items-baseline text-24-bold"
data-testid="txt"
Expand Down Expand Up @@ -57,6 +60,9 @@ exports[`Storyshots Components/Elements/Cards/GoalProgressCard/Card Progress And
>
Trees Restored
</p>
<div
className="flex w-[calc(33.33%-16px)] min-w-[200px] items-center"
/>
<p
className="flex w-full items-baseline text-24-bold"
data-testid="txt"
Expand Down Expand Up @@ -182,6 +188,9 @@ exports[`Storyshots Components/Elements/Cards/GoalProgressCard/Card Progress No
>
Workday (PPC)
</p>
<div
className="flex w-[calc(33.33%-16px)] min-w-[200px] items-center"
/>
<p
className="flex w-full items-baseline text-24-bold"
data-testid="txt"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/project/[uuid]/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import ProjectHeader from "@/pages/project/[uuid]/components/ProjectHeader";
import StatusBar from "@/pages/project/[uuid]/components/StatusBar";
import ProjectDetailTab from "@/pages/project/[uuid]/tabs/Details";
import GalleryTab from "@/pages/project/[uuid]/tabs/Gallery";
import GoalsAndProgressTab from "@/pages/project/[uuid]/tabs/GoalsAndProgress";
import ProjectOverviewTab from "@/pages/project/[uuid]/tabs/Overview";
import ProjectNurseriesTab from "@/pages/project/[uuid]/tabs/ProjectNurseries";
import ProjectSitesTab from "@/pages/project/[uuid]/tabs/ProjectSites";
import ReportingTasksTab from "@/pages/project/[uuid]/tabs/ReportingTasks";

import AuditLog from "./tabs/AuditLog";
import GoalsAndProgressTab from "./tabs/GoalsAndProgress";

const ButtonStates = {
PROJECTS: 0,
Expand Down
94 changes: 3 additions & 91 deletions src/pages/project/[uuid]/tabs/GoalsAndProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import PageRow from "@/components/extensive/PageElements/Row/PageRow";
import TreeSpeciesTablePD from "@/components/extensive/Tables/TreeSpeciesTablePD";
import { ContextCondition } from "@/context/ContextCondition";
import { Framework } from "@/context/framework.provider";
import GoalsAndProgressEntityTab from "@/pages/site/[uuid]/components/GoalsAndProgressEntityTab";

interface GoalsAndProgressProps {
project: any;
Expand Down Expand Up @@ -295,97 +296,8 @@ const GoalsAndProgressTab = ({ project }: GoalsAndProgressProps) => {
return (
<PageBody className="text-darkCustom">
<PageRow>
<PageCard title={t("Progress & Goals")}>
<div className="flex w-full flex-wrap items-start justify-between gap-8">
<GoalProgressCard
frameworksShow={[Framework.TF]}
label={t("JOBS CREATED")}
value={205}
totalValue={300}
classNameLabel="text-neutral-650 uppercase mb-3"
labelVariant="text-14"
classNameCard="text-center flex flex-col items-center"
classNameLabelValue="justify-center"
/>
<GoalProgressCard
frameworksShow={[Framework.HBF]}
label={t("workdays CREATED")}
value={205}
classNameLabel="text-neutral-650 uppercase mb-3"
labelVariant="text-14"
classNameCard="text-center flex flex-col items-center"
classNameLabelValue="justify-center"
/>
<GoalProgressCard
label={t("Hectares RESTORED")}
value={129}
totalValue={"300 ha"}
classNameLabel="text-neutral-650 uppercase mb-3"
labelVariant="text-14"
classNameCard="text-center flex flex-col items-center"
classNameLabelValue="justify-center"
/>
<GoalProgressCard
label={t("Trees Restored")}
frameworksHide={[Framework.HBF]}
value={113250}
totalValue={"300,000"}
classNameLabel="text-neutral-650 uppercase mb-3"
labelVariant="text-14"
classNameCard="text-center flex flex-col items-center"
classNameLabelValue="justify-center"
/>
<GoalProgressCard
label={t("saplings Restored ")}
frameworksShow={[Framework.HBF]}
value={113250}
totalValue={"300,000"}
classNameLabel="text-neutral-650 uppercase mb-3"
labelVariant="text-14"
classNameCard="text-center flex flex-col items-center"
classNameLabelValue="justify-center"
/>
<GoalProgressCard
frameworksShow={[Framework.PPC]}
label={t("workdays CREATED")}
value={project.combined_workday_count}
classNameLabel="text-neutral-650 uppercase mb-3"
labelVariant="text-14"
classNameCard="text-center flex flex-col items-center"
classNameLabelValue="justify-center"
/>

<GoalProgressCard
label={t("Trees restored")}
value={project.trees_restored_count}
limit={project.trees_grown_goal}
hasProgress={false}
items={[
{
iconName: IconNames.TREE_CIRCLE_PD,
label: t("Trees Planted:"),
variantLabel: "text-14",
classNameLabel: " text-neutral-650 uppercase",
value: project.trees_planted_count
},
{
iconName: IconNames.LEAF_CIRCLE_PD,
label: t("Seeds Planted:"),
variantLabel: "text-14",
classNameLabel: " text-neutral-650 uppercase",
value: project.seeds_planted_count
},
{
iconName: IconNames.REFRESH_CIRCLE_PD,
label: t("Trees Regenerating:"),
variantLabel: "text-14",
classNameLabel: " text-neutral-650 uppercase",
value: project.regenerated_trees_count
}
]}
className="pr-[41px] lg:pr-[150px]"
/>
</div>
<PageCard title={t("Project Progress & Goals")}>
<GoalsAndProgressEntityTab entity={project} project />
</PageCard>
</PageRow>

Expand Down
47 changes: 2 additions & 45 deletions src/pages/project/[uuid]/tabs/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Link from "next/link";
import { useRouter } from "next/router";

import Button from "@/components/elements/Button/Button";
import GoalProgressCard from "@/components/elements/Cards/GoalProgressCard/GoalProgressCard";
import ItemMonitoringCards from "@/components/elements/Cards/ItemMonitoringCard/ItemMonitoringCards";
import Dropdown from "@/components/elements/Inputs/Dropdown/Dropdown";
import OverviewMapArea from "@/components/elements/Map-mapbox/components/OverviewMapArea";
Expand All @@ -13,7 +12,7 @@ import PageBody from "@/components/extensive/PageElements/Body/PageBody";
import PageCard from "@/components/extensive/PageElements/Card/PageCard";
import PageColumn from "@/components/extensive/PageElements/Column/PageColumn";
import PageRow from "@/components/extensive/PageElements/Row/PageRow";
import { Framework } from "@/context/framework.provider";
import GoalsAndProgressEntityTab from "@/pages/site/[uuid]/components/GoalsAndProgressEntityTab";

interface ProjectOverviewTabProps {
project: any;
Expand All @@ -40,49 +39,7 @@ const ProjectOverviewTab = ({ project }: ProjectOverviewTabProps) => {
</Button>
}
>
<div className="flex w-full text-darkCustom">
<div className="grid w-[55%] grid-cols-2 gap-x-8 gap-y-7 pr-20">
<GoalProgressCard
frameworksShow={[Framework.PPC]}
label={t("Workday Count (PPC)")}
value={project.combined_workday_count}
/>
<GoalProgressCard
frameworksHide={[Framework.PPC]}
label={t("Jobs Created")}
value={project.total_jobs_created}
limit={project.jobs_created_goal}
/>
<GoalProgressCard
label={t("Trees Restored")}
value={project.trees_restored_count}
limit={project.trees_grown_goal}
className="flex-1"
/>
<div></div>
<GoalProgressCard
label={t("Hectares Under Restoration")}
value={project.total_hectares_restored_sum}
limit={project.total_hectares_restored_goal}
/>
</div>
<div>
<GoalProgressCard
label={t("Hectares Restored")}
hasProgress={false}
items={[
{ iconName: IconNames.TREE_CIRCLE, label: t("Trees Planted"), value: project.trees_planted_count },
{ iconName: IconNames.LEAF_CIRCLE, label: t("Seeds Planted"), value: project.seeds_planted_count },
{
iconName: IconNames.REFRESH_CIRCLE,
label: t("Trees Regenerating"),
value: project.regenerated_trees_count
}
]}
className="flex-1"
/>
</div>
</div>
<GoalsAndProgressEntityTab entity={project} project />
</PageCard>
</PageRow>
<PageRow>
Expand Down
Loading