-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/Vizzuality/tnc-blue-carbon-c…
…ost-tool into feature/TBCCT-123-implement-custom-projects-page
- Loading branch information
Showing
45 changed files
with
714 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
api/src/modules/custom-projects/dto/project-assumptions.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { IsNumber } from 'class-validator'; | ||
|
||
export class CustomProjectAssumptionsDto { | ||
@IsNumber() | ||
verificationFrequency: number; | ||
|
||
@IsNumber() | ||
discountRate: number; | ||
|
||
@IsNumber() | ||
carbonPriceIncrease: number; | ||
|
||
@IsNumber() | ||
buffer: number; | ||
|
||
@IsNumber() | ||
baselineReassessmentFrequency: number; | ||
|
||
@IsNumber() | ||
restorationRate: number; | ||
|
||
@IsNumber() | ||
restorationProjectLength: number; | ||
} |
60 changes: 60 additions & 0 deletions
60
api/src/modules/custom-projects/dto/project-cost-inputs.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { CustomProject } from '@shared/entities/custom-project.entity'; | ||
import { IsNumber } from 'class-validator'; | ||
|
||
export class CustomProjectCapexCostInputsDto { | ||
@IsNumber() | ||
feasibilityAnalisys: number; | ||
|
||
@IsNumber() | ||
conservationPlanningAndAdmin: number; | ||
|
||
@IsNumber() | ||
dataCollectionAndFieldCost: number; | ||
|
||
@IsNumber() | ||
communityRepresentation: number; | ||
|
||
@IsNumber() | ||
blueCarbonProjectPlanning: number; | ||
|
||
@IsNumber() | ||
establishingCarbonRights: number; | ||
|
||
@IsNumber() | ||
validation: number; | ||
|
||
@IsNumber() | ||
implementationLabor: number; | ||
} | ||
|
||
export class CustomProjectOpexCostInputsDto { | ||
@IsNumber() | ||
monitoring: number; | ||
|
||
@IsNumber() | ||
maintenance: number; | ||
|
||
@IsNumber() | ||
communityBenefitShsharingFund: number; | ||
|
||
@IsNumber() | ||
carbonStandardFees: number; | ||
|
||
@IsNumber() | ||
baselineReassessment: number; | ||
|
||
@IsNumber() | ||
mrv: number; | ||
|
||
@IsNumber() | ||
longTermProjectOperating: number; | ||
} | ||
|
||
export class CustomProjectCostInputsDto { | ||
@IsNumber() | ||
financingCost: number; | ||
|
||
capexCostInputs: CustomProjectCapexCostInputsDto; | ||
|
||
opexCostInputs: CustomProjectOpexCostInputsDto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,5 @@ | ||
"use client"; | ||
import Overview from "@/containers/overview"; | ||
|
||
import { useMap } from "react-map-gl"; | ||
|
||
import { motion } from "framer-motion"; | ||
import { useAtomValue } from "jotai"; | ||
|
||
import { LAYOUT_TRANSITIONS } from "@/app/(overview)/constants"; | ||
import { projectsUIState } from "@/app/(overview)/store"; | ||
|
||
import ProjectsFilters, { | ||
FILTERS_SIDEBAR_WIDTH, | ||
} from "@/containers/projects/filters"; | ||
import ProjectsHeader from "@/containers/projects/header"; | ||
import ProjectsMap from "@/containers/projects/map"; | ||
|
||
import { | ||
ResizableHandle, | ||
ResizablePanel, | ||
ResizablePanelGroup, | ||
} from "@/components/ui/resizable"; | ||
import { useSidebar } from "@/components/ui/sidebar"; | ||
import ProjectsTable from "src/containers/projects/table"; | ||
|
||
const PANEL_MIN_SIZE = 25; | ||
const PANEL_DEFAULT_SIZE = 50; | ||
|
||
export default function Projects() { | ||
const { filtersOpen } = useAtomValue(projectsUIState); | ||
const { open: navOpen } = useSidebar(); | ||
const { default: map } = useMap(); | ||
|
||
const onResizeMapPanel = () => { | ||
if (!map) return; | ||
|
||
map.resize(); | ||
}; | ||
|
||
return ( | ||
<motion.div | ||
layout | ||
layoutDependency={navOpen} | ||
className="flex flex-1" | ||
transition={LAYOUT_TRANSITIONS} | ||
> | ||
<motion.aside | ||
layout | ||
initial={filtersOpen ? "open" : "closed"} | ||
animate={filtersOpen ? "open" : "closed"} | ||
variants={{ | ||
open: { | ||
width: FILTERS_SIDEBAR_WIDTH, | ||
}, | ||
closed: { | ||
width: 0, | ||
}, | ||
}} | ||
transition={LAYOUT_TRANSITIONS} | ||
className="overflow-hidden" | ||
> | ||
<ProjectsFilters /> | ||
</motion.aside> | ||
<div className="mx-3 flex flex-1 flex-col"> | ||
<ProjectsHeader /> | ||
<ResizablePanelGroup | ||
direction="vertical" | ||
className="grid flex-grow grid-rows-2" | ||
> | ||
<ResizablePanel | ||
className="flex flex-1 flex-col" | ||
minSize={PANEL_MIN_SIZE} | ||
onResize={onResizeMapPanel} | ||
defaultSize={PANEL_DEFAULT_SIZE} | ||
> | ||
<ProjectsMap /> | ||
</ResizablePanel> | ||
<ResizableHandle withHandle /> | ||
<ResizablePanel | ||
className="mb-4 flex flex-1 flex-col" | ||
minSize={PANEL_MIN_SIZE} | ||
defaultSize={PANEL_DEFAULT_SIZE} | ||
> | ||
<ProjectsTable /> | ||
</ResizablePanel> | ||
</ResizablePanelGroup> | ||
</div> | ||
</motion.div> | ||
); | ||
export default function OverviewPage() { | ||
return <Overview />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
import { MapMouseEvent } from "react-map-gl"; | ||
|
||
import { atom } from "jotai"; | ||
|
||
export const projectsUIState = atom<{ | ||
filtersOpen: boolean; | ||
}>({ | ||
filtersOpen: false, | ||
}); | ||
|
||
export const popupAtom = atom<{ | ||
lngLat: MapMouseEvent["lngLat"]; | ||
features: MapMouseEvent["features"]; | ||
} | null>(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { PropsWithChildren } from "react"; | ||
import * as React from "react"; | ||
|
||
import { Popup } from "react-map-gl"; | ||
|
||
import { useAtom } from "jotai"; | ||
import { XIcon } from "lucide-react"; | ||
|
||
import { popupAtom } from "@/app/(overview)/store"; | ||
|
||
export default function MapPopup({ children }: PropsWithChildren) { | ||
const [popup, setPopup] = useAtom(popupAtom); | ||
|
||
if (!popup || !popup.features?.length) { | ||
return null; | ||
} | ||
|
||
const closePopup = () => { | ||
setPopup(null); | ||
}; | ||
|
||
return ( | ||
<Popup | ||
longitude={popup.lngLat.lng} | ||
latitude={popup.lngLat.lat} | ||
closeOnClick={false} | ||
onClose={closePopup} | ||
className="bg-transparent text-sm" | ||
maxWidth="320" | ||
> | ||
<div className="flex flex-col"> | ||
<button type="button" onClick={closePopup} className="self-end"> | ||
<XIcon className="h-4 w-4 text-foreground hover:text-muted-foreground" /> | ||
</button> | ||
{children} | ||
</div> | ||
</Popup> | ||
); | ||
} |
Oops, something went wrong.