Skip to content

Commit

Permalink
Merge pull request #255 from wri/feat/TM-872_Site_0_state_display
Browse files Browse the repository at this point in the history
[TM-872] site 0 state display
  • Loading branch information
cesarLima1 authored Jun 17, 2024
2 parents b71d6cd + 5189b78 commit 33fd0bf
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/components/elements/Map-mapbox/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { BBox } from "./GeoJSON";
import type { TooltipType } from "./Map.d";
import CheckPolygonControl from "./MapControls/CheckPolygonControl";
import EditControl from "./MapControls/EditControl";
import EmptyStateDisplay from "./MapControls/EmptyStateDisplay";
import { FilterControl } from "./MapControls/FilterControl";
import ImageControl from "./MapControls/ImageControl";
import PolygonCheck from "./MapControls/PolygonCheck";
Expand Down Expand Up @@ -78,6 +79,7 @@ interface MapProps extends Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>
mapFunctions?: any;
tooltipType?: TooltipType;
sitePolygonData?: SitePolygonsDataResponse;
polygonsExists?: boolean;
}

export const MapContainer = ({
Expand All @@ -102,6 +104,7 @@ export const MapContainer = ({
showLegend = false,
mapFunctions,
tooltipType = "view",
polygonsExists = true,
...props
}: MapProps) => {
const [viewImages, setViewImages] = useState(false);
Expand Down Expand Up @@ -291,6 +294,9 @@ export const MapContainer = ({
<PolygonCheck />
</ControlGroup>
</When>
<When condition={!polygonsExists}>
<EmptyStateDisplay />
</When>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useT } from "@transifex/react";

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

const EmptyStateDisplay = () => {
const t = useT();
return (
<div className="absolute left-[56%] top-[43%] z-30 grid gap-2" id="emptystatedisplay">
<div className="rounded-lg bg-[#ffffff26] py-3 px-11 text-center text-white backdrop-blur-md">
<Text variant="text-10-light">
{t("Polygons have not been")}
<br />
{t("created for this site")}
</Text>
</div>
</div>
);
};

export default EmptyStateDisplay;
17 changes: 16 additions & 1 deletion src/pages/project/[uuid]/components/OverviewMapArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MapContainer } from "@/components/elements/Map-mapbox/Map";
import { getPolygonsData } from "@/components/elements/Map-mapbox/utils";
import MapSidePanel from "@/components/elements/MapSidePanel/MapSidePanel";
import { APPROVED, DRAFT, NEEDS_MORE_INFORMATION, SUBMITTED } from "@/constants/statuses";
import { fetchGetV2DashboardCountryCountry } from "@/generated/apiComponents";
import { SitePolygonsDataResponse } from "@/generated/apiSchemas";
import { useDate } from "@/hooks/useDate";

Expand All @@ -30,7 +31,19 @@ const OverviewMapArea = ({ entityModel, type }: EntityAreaProps) => {
setEntityBbox(result.bbox as BBox);
}
};

const callCountryBBox = async () => {
let currentCountry = entityModel?.country;
if (type === "sites") {
currentCountry = entityModel?.project?.country;
}
const countryBbox = await fetchGetV2DashboardCountryCountry({
pathParams: { country: currentCountry }
});
if (Array.isArray(countryBbox.bbox) && countryBbox.bbox.length > 1) {
const bboxFormat = countryBbox.bbox[1] as unknown as BBox;
setEntityBbox(bboxFormat);
}
};
useEffect(() => {
if (entityModel?.uuid) {
const statusFilter = checkedValues.join(",");
Expand All @@ -55,6 +68,7 @@ const OverviewMapArea = ({ entityModel, type }: EntityAreaProps) => {
[NEEDS_MORE_INFORMATION]: [],
[DRAFT]: []
});
callCountryBBox();
}
}, [polygonsData]);

Expand Down Expand Up @@ -94,6 +108,7 @@ const OverviewMapArea = ({ entityModel, type }: EntityAreaProps) => {
showLegend
siteData={true}
className="flex-1 rounded-r-lg"
polygonsExists={polygonsData.length > 0}
/>
</>
);
Expand Down

0 comments on commit 33fd0bf

Please sign in to comment.