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-874] site profile non monitoring partner #253

Merged
merged 21 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
414695b
[TM-874] add component map and panel in Site overview
dottyy Jun 12, 2024
f471747
[TM-874] estid style in Site Area
dottyy Jun 12, 2024
e34dca4
[TM-874] edit style in Site Area
dottyy Jun 12, 2024
1352823
start merging map to reuse
egrojMonroy Jun 12, 2024
68a8123
[TM-874] edit style in map overview site
dottyy Jun 12, 2024
a5c3272
[TM-874] add site map
egrojMonroy Jun 12, 2024
a654979
[TM-874] remove unused code
cesarLima1 Jun 12, 2024
ef9a676
Merge branch 'staging' into feat/TM-874-Site-Profile-Non-Monitoring-P…
cesarLima1 Jun 12, 2024
6649591
[TM-874] add constant with statusEnum
cesarLima1 Jun 12, 2024
ae5bdad
[TM-874] edit value items in mapSidePanel stories
dottyy Jun 12, 2024
88460a4
[TM-874] remove console.log
cesarLima1 Jun 12, 2024
84687e6
[TM-874] remove logs
cesarLima1 Jun 12, 2024
8a0e590
[TM-874] solved PR - add transifex
dottyy Jun 12, 2024
a6d7941
[TM-874] solved PR - add transifex
dottyy Jun 12, 2024
eacd9de
[TM-874] solved PR - add transifex and remove mocked data
dottyy Jun 12, 2024
5f38294
[TM-874] solved PR - add transifex and remove mocked data
dottyy Jun 12, 2024
02249ca
[TM-874] solved PR - add transifex and change ??
dottyy Jun 12, 2024
02017fc
[TM-874] solved PR - add transifex and remove mocked data
dottyy Jun 12, 2024
7968367
[TM-874] solved PR - add transifex and remove mocked data
dottyy Jun 13, 2024
67e4a10
[TM-874] download site geojson
cesarLima1 Jun 13, 2024
1a6e37f
Merge branch 'feat/TM-874-Site-Profile-Non-Monitoring-Partner' of htt…
cesarLima1 Jun 13, 2024
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
6 changes: 5 additions & 1 deletion src/components/elements/Map-mapbox/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ export const MapContainer = ({
};

return (
<div ref={mapContainer} className={twMerge("h-[500px] wide:h-[700px]", className)} id="mapContainer">
<div
ref={mapContainer}
className={twMerge("h-[500px] wide:h-[700px]", className)}
id={`id_map_${Math.random().toString(36).substr(2, 9)}`}
>
<When condition={hasControls}>
<When condition={polygonFromMap?.isOpen}>
<ControlGroup position="top-center">
Expand Down
2 changes: 2 additions & 0 deletions src/components/elements/Map-mapbox/hooks/useMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export const useMap = (onSave?: (geojson: any, record: any) => void) => {

const initMap = () => {
if (map.current) return;

console.log("map.current", map.current);
roguenet marked this conversation as resolved.
Show resolved Hide resolved
map.current = new mapboxgl.Map({
container: mapContainer.current as HTMLDivElement,
style: MAP_STYLE,
Expand Down
14 changes: 14 additions & 0 deletions src/components/elements/Map-mapbox/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createElement } from "react";
import { createRoot } from "react-dom/client";

import { layersList } from "@/constants/layers";
import { fetchGetV2TypeEntity } from "@/generated/apiComponents";
import { SitePolygon, SitePolygonsDataResponse } from "@/generated/apiSchemas";

import { BBox, FeatureCollection } from "./GeoJSON";
Expand Down Expand Up @@ -275,3 +276,16 @@ export function mapPolygonData(sitePolygonData: SitePolygonsDataResponse | undef
return acc;
}, {});
}

export function getPolygonsData(uuid: string, statusFilter: string, sortOrder: string, type: string, cb: Function) {
fetchGetV2TypeEntity({
queryParams: {
uuid: uuid,
type: type,
status: statusFilter,
[`sort[${sortOrder}]`]: sortOrder === "created_at" ? "desc" : "asc"
}
}).then(result => {
cb(result);
});
}
152 changes: 152 additions & 0 deletions src/components/elements/MapPolygonPanel/AttributeInformation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import Dropdown from "@/components/elements/Inputs/Dropdown/Dropdown";
import Input from "@/components/elements/Inputs/Input/Input";

import Text from "../Text/Text";

const dropdownOptionsRestoration = [
{
title: "Tree Planting",
value: 1
},
{
title: "Direct Seeding",
value: 2
},
{
title: "Assisted Natural Regeneration",
value: 3
}
];
const dropdownOptionsTarget = [
{
title: "Agroforest",
value: 1
},
{
title: "Natural Forest",
value: 2
},
{
title: "Mangrove",
value: 3
},
{
title: "Peatland",
value: 4
},
{
title: "Riparian Area or Wetland",
value: 5
},
{
title: "Silvopasture",
value: 6
},
{
title: "Woodlot or Plantation",
value: 7
},
{
title: "Urban Forest",
value: 8
}
];

const dropdownOptionsTree = [
{
title: "Single Line",
value: 1
},
{
title: "Partial",
value: 2
},
{
title: "Full",
value: 3
}
];
const AttributeInformation = () => {
return (
<div className="flex flex-col gap-4">
<Input
label="Polygon Name"
roguenet marked this conversation as resolved.
Show resolved Hide resolved
labelClassName="capitalize text-white"
labelVariant="text-14-light"
placeholder="Input Polygon Name"
type="text"
name=""
/>
<label className="flex flex-col gap-2">
<Text variant="text-14-light" className="text-white">
Plant Start Date
</Text>
<input
type="date"
className="rounded-lg border-neutral-200 focus:border-primary focus:shadow-none focus:ring-transparent"
placeholder="Input Plant Start Date"
/>
</label>
<label className="flex flex-col gap-2">
<Text variant="text-14-light" className="text-white">
Plant End Date
</Text>
<input
type="date"
className="rounded-lg border-neutral-200 focus:border-primary focus:shadow-none focus:ring-transparent"
placeholder="Input Plant Start Date"
/>
</label>
<Dropdown
multiSelect
label="Restoration Practice"
labelClassName="capitalize text-white"
labelVariant="text-14-light"
placeholder="Select Restoration Practice"
options={dropdownOptionsRestoration}
value={["Planting Complete"]}
onChange={() => {}}
className="bg-white"
/>
<Dropdown
label="Target Land Use System"
labelClassName="capitalize text-white"
labelVariant="text-14-light"
placeholder="Select Target Land Use System"
options={dropdownOptionsTarget}
value={["Planting Complete"]}
onChange={() => {}}
className="bg-white"
/>
<Dropdown
multiSelect
label="Tree Distribution"
labelClassName="capitalize text-white"
labelVariant="text-14-light"
placeholder="Select Tree Distribution"
options={dropdownOptionsTree}
value={["Planting Complete"]}
onChange={() => {}}
className="bg-white"
/>
<Input
label="Trees Planted"
labelClassName="capitalize text-white"
labelVariant="text-14-light"
placeholder="Input Trees Planted"
type="text"
name=""
/>
<Input
label="Estimated Area"
labelClassName="capitalize text-white"
labelVariant="text-14-light"
placeholder="Input Estimated Area"
type="text"
name=""
/>
</div>
);
};

export default AttributeInformation;
82 changes: 82 additions & 0 deletions src/components/elements/MapPolygonPanel/ChecklistInformation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import Icon, { IconNames } from "@/components/extensive/Icon/Icon";
import ModalWithMap from "@/components/extensive/Modal/ModalWithMap";
import { useModalContext } from "@/context/modal.provider";

import Button from "../Button/Button";
import Text from "../Text/Text";

const ChecklistInformation = () => {
const { openModal, closeModal } = useModalContext();
const openFormModalHandlerRequestPolygonSupport = () => {
openModal(
<ModalWithMap
title="Request Support"
roguenet marked this conversation as resolved.
Show resolved Hide resolved
onClose={closeModal}
content="Faja Lobi Project&nbsp;&nbsp;•&nbsp;&nbsp;Priceless Planet Coalition"
roguenet marked this conversation as resolved.
Show resolved Hide resolved
primaryButtonText="Submit"
primaryButtonProps={{ className: "px-8 py-3", variant: "primary", onClick: closeModal }}
></ModalWithMap>
);
};
return (
<div className="text-white">
<Text variant="text-14-bold">3 out 14</Text>
<Text variant="text-14-light">Validation criteria are not met</Text>
<Button variant="primary" className="mt-4" onClick={openFormModalHandlerRequestPolygonSupport}>
request support
</Button>
<div className="mt-3 grid gap-3">
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.CHECK_PROGRESSBAR} className="h-4 w-4 text-green-400 lg:h-5 lg:w-5" />
GeoJSON Format
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.CHECK_PROGRESSBAR} className="h-4 w-4 text-green-400 lg:h-5 lg:w-5" />
WGS84 Projection
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.IC_ERROR} className="h-5 w-5 lg:h-6 lg:w-6" />
Earth Location
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.IC_ERROR} className="h-5 w-5 lg:h-6 lg:w-6" />
Country
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.CHECK_PROGRESSBAR} className="h-4 w-4 text-green-400 lg:h-5 lg:w-5" />
Reasonable Size Self-Intersecting Topology
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.IC_ERROR} className="h-5 w-5 lg:h-6 lg:w-6" />
Overlapping Polygons
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.CHECK_PROGRESSBAR} className="h-4 w-4 text-green-400 lg:h-5 lg:w-5" />
Spike
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.CHECK_PROGRESSBAR} className="h-4 w-4 text-green-400 lg:h-5 lg:w-5" />
Polygon Integrity
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.CHECK_PROGRESSBAR} className="h-4 w-4 text-green-400 lg:h-5 lg:w-5" />
GeoJSON Format
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.CHECK_PROGRESSBAR} className="h-4 w-4 text-green-400 lg:h-5 lg:w-5" />
WGS84 Projection
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.IC_ERROR} className="h-5 w-5 lg:h-6 lg:w-6" />
Earth Location
</Text>
<Text variant="text-14-light" className="flex items-center gap-2">
<Icon name={IconNames.IC_ERROR} className="h-5 w-5 lg:h-6 lg:w-6" />
Country
</Text>
</div>
</div>
);
};

export default ChecklistInformation;
95 changes: 95 additions & 0 deletions src/components/elements/MapPolygonPanel/MapEditPolygonPanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { t } from "@transifex/native";
import classNames from "classnames";
import { Dispatch, SetStateAction } from "react";
import { When } from "react-if";

import Icon, { IconNames } from "@/components/extensive/Icon/Icon";

import Button from "../Button/Button";
import Text from "../Text/Text";
import AttributeInformation from "./AttributeInformation";
import ChecklistInformation from "./ChecklistInformation";
import VersionInformation from "./VersionInformation";

export interface MapEditPolygonPanelProps {
setEditPolygon: Dispatch<SetStateAction<boolean>>;
tabEditPolygon: string;
setTabEditPolygon: Dispatch<SetStateAction<string>>;
setPreviewVersion: Dispatch<SetStateAction<boolean>>;
}

const MapEditPolygonPanel = ({
setEditPolygon,
tabEditPolygon,
setTabEditPolygon,
setPreviewVersion
}: MapEditPolygonPanelProps) => {
return (
roguenet marked this conversation as resolved.
Show resolved Hide resolved
<>
<div className="flex items-start justify-between gap-4">
<div>
<Text variant="text-12-light" className="text-white ">
Faja Lobi Project
</Text>
<Text variant="text-20-bold" className="mb-4 text-white">
Iseme Site
roguenet marked this conversation as resolved.
Show resolved Hide resolved
</Text>
</div>

<Button variant="text" onClick={() => setEditPolygon(false)} className="text-white hover:text-primary">
<Icon name={IconNames.CLEAR} className="h-4 w-4" />
</Button>
</div>
<div className="flex rounded-lg bg-white">
<button
className={classNames(
"text-12-semibold w-1/3 rounded-l-lg border border-neutral-300 p-3 hover:bg-neutral-100",
tabEditPolygon === "Attributes"
? "border-0 border-b-4 border-primary bg-blueCustom-10 pb-2"
: "border border-neutral-300"
)}
onClick={() => {
setTabEditPolygon("Attributes");
}}
>
{t("Attributes")}
</button>
<button
className={classNames(
"text-12-semibold w-1/3 border border-neutral-300 p-3 hover:bg-neutral-100",
tabEditPolygon === "Checklist"
? "border-0 border-b-4 border-primary bg-blueCustom-10 pb-2"
: "border border-neutral-300"
)}
onClick={() => {
setTabEditPolygon("Checklist");
}}
>
{t("Checklist")}
</button>
<button
className={classNames(
"text-12-semibold w-1/3 rounded-r-lg border border-neutral-300 p-3 hover:bg-neutral-100",
tabEditPolygon === "Version"
? "border-0 border-b-4 border-primary bg-blueCustom-10 pb-2"
: "border border-neutral-300"
)}
onClick={() => {
setTabEditPolygon("Version");
}}
>
{t("Version")}
</button>
</div>
<div className="mr-[-10px] mt-4 h-[calc(100%-132px)] overflow-y-auto pr-2">
<When condition={tabEditPolygon === "Attributes"}>{AttributeInformation}</When>
<When condition={tabEditPolygon === "Checklist"}>{ChecklistInformation}</When>
<When condition={tabEditPolygon === "Version"}>
<VersionInformation setPreviewVersion={setPreviewVersion} />
</When>
</div>
</>
);
};

export default MapEditPolygonPanel;
Loading