From 1057959d31df8d3aa5250bbd795c01e313bfe136 Mon Sep 17 00:00:00 2001 From: JORGE Date: Mon, 17 Jun 2024 16:14:44 -0400 Subject: [PATCH] [TM-978] remove unused component --- .../MapPolygonPanel/MapPolygonSitePanel.tsx | 187 ------------------ src/generated/apiComponents.ts | 55 ++++++ src/generated/apiSchemas.ts | 6 + .../site/[uuid]/components/MockedData.ts | 29 --- 4 files changed, 61 insertions(+), 216 deletions(-) delete mode 100644 src/components/elements/MapPolygonPanel/MapPolygonSitePanel.tsx diff --git a/src/components/elements/MapPolygonPanel/MapPolygonSitePanel.tsx b/src/components/elements/MapPolygonPanel/MapPolygonSitePanel.tsx deleted file mode 100644 index 84553a5f2..000000000 --- a/src/components/elements/MapPolygonPanel/MapPolygonSitePanel.tsx +++ /dev/null @@ -1,187 +0,0 @@ -import { useT } from "@transifex/react"; -import { Dispatch, Fragment, SetStateAction, useEffect, useRef, useState } from "react"; -import { When } from "react-if"; - -import Icon, { IconNames } from "@/components/extensive/Icon/Icon"; -import List from "@/components/extensive/List/List"; -import { PolygonData } from "@/pages/site/[uuid]/components/MockedData"; - -import Checkbox from "../Inputs/Checkbox/Checkbox"; -import { MenuItem } from "../MenuItem/MenuItem"; -import Text from "../Text/Text"; -import MapMenuPanelItem, { MapMenuPanelItemProps } from "./MapMenuPanelItem"; - -export interface MapPolygonSitePanelProps { - emptyText?: string; - onLoadMore: () => void; - onSelectItem: (item: MapMenuPanelItemProps) => void; - setEditPolygon: Dispatch>; - selected: MapMenuPanelItemProps | undefined; - setSelected: Dispatch>; -} - -const MapPolygonSitePanel = ({ - emptyText, - onLoadMore, - onSelectItem, - setEditPolygon, - selected, - setSelected -}: MapPolygonSitePanelProps) => { - const t = useT(); - const menuRef = useRef(null); - const [openMenu, setOpenMenu] = useState(false); - const refContainer = useRef(null); - const [openSubMenu, setOpenSubMenu] = useState(false); - const checkboxRefs = useRef([]); - - useEffect(() => { - const handleClickOutside = (event: MouseEvent) => { - if (menuRef.current && !menuRef.current?.contains(event.target as Node)) { - setOpenMenu(false); - } - }; - document.addEventListener("mousedown", handleClickOutside); - return () => { - document.removeEventListener("mousedown", handleClickOutside); - }; - }); - - useEffect(() => { - const handleChange = () => { - const checked = checkboxRefs.current.some(ref => ref.checked); - setOpenSubMenu(checked); - }; - - const checkbox = checkboxRefs.current; - - checkbox.forEach(ref => { - if (ref) { - ref.addEventListener("change", handleChange); - } - }); - - handleChange(); - - return () => { - checkbox.forEach(ref => { - if (ref) { - ref.removeEventListener("change", handleChange); - } - }); - }; - }, [openMenu]); - - return ( - <> -
- - -   {t("new Polygon")} - -
-
-
setOpenMenu(!openMenu)}> - -
- -
- ref && checkboxRefs.current.push(ref as HTMLInputElement)} - name="" - label={t("Draft")} - className="flex w-full flex-row-reverse items-center justify-end gap-3" - textClassName="text-10-semibold" - /> - - ref && checkboxRefs.current.push(ref as HTMLInputElement)} - name="" - label={t("Submitted")} - className="flex w-full flex-row-reverse items-center justify-end gap-3" - textClassName="text-10-semibold" - /> - ref && checkboxRefs.current.push(ref as HTMLInputElement)} - name="" - label={t("Approved")} - className="flex w-full flex-row-reverse items-center justify-end gap-3" - textClassName="text-10-semibold" - /> - ref && checkboxRefs.current.push(ref as HTMLInputElement)} - name="" - label={t("Needs More Info")} - className="flex w-full flex-row-reverse items-center justify-end gap-3" - textClassName="text-10-semibold" - /> - -
- { - setOpenSubMenu(false); - }} - > - { - setOpenSubMenu(false); - }} - > -
-
-
-
-
-
- -
-
-
- -
- {PolygonData.length === 0 && ( - - {emptyText ?? t("No result")} - - )} -
{ - //@ts-ignore - const bottom = e.target.scrollHeight - e.target.scrollTop === e.target.clientHeight; - if (bottom) onLoadMore(); - }} - > - ( - { - setSelected(item); - onSelectItem(item); - }} - isSelected={selected?.uuid === item.uuid} - refContainer={refContainer} - setClickedButton={() => {}} - type="sites" - status="draft" - /> - )} - /> -
-
- - ); -}; - -export default MapPolygonSitePanel; diff --git a/src/generated/apiComponents.ts b/src/generated/apiComponents.ts index 0fcef67e9..ca073a813 100644 --- a/src/generated/apiComponents.ts +++ b/src/generated/apiComponents.ts @@ -33742,6 +33742,56 @@ export const useGetV2DashboardProjectDataUuid = ; + +export type GetV2DashboardViewProjectUuidResponse = { + data?: { + allowed?: boolean; + }; +}; + +export type GetV2DashboardViewProjectUuidVariables = { + pathParams: GetV2DashboardViewProjectUuidPathParams; +} & ApiContext["fetcherOptions"]; + +export const fetchGetV2DashboardViewProjectUuid = ( + variables: GetV2DashboardViewProjectUuidVariables, + signal?: AbortSignal +) => + apiFetch< + GetV2DashboardViewProjectUuidResponse, + GetV2DashboardViewProjectUuidError, + undefined, + {}, + {}, + GetV2DashboardViewProjectUuidPathParams + >({ url: "/v2/dashboard/view-project/{uuid}", method: "get", ...variables, signal }); + +export const useGetV2DashboardViewProjectUuid = ( + variables: GetV2DashboardViewProjectUuidVariables, + options?: Omit< + reactQuery.UseQueryOptions, + "queryKey" | "queryFn" + > +) => { + const { fetcherOptions, queryOptions, queryKeyFn } = useApiContext(options); + return reactQuery.useQuery( + queryKeyFn({ path: "/v2/dashboard/view-project/{uuid}", operationId: "getV2DashboardViewProjectUuid", variables }), + ({ signal }) => fetchGetV2DashboardViewProjectUuid({ ...fetcherOptions, ...variables }, signal), + { + ...options, + ...queryOptions + } + ); +}; + export type GetV2TerrafundPolygonGeojsonUuidPathParams = { /** * The UUID of the polygon geometry to retrieve. @@ -34623,6 +34673,11 @@ export type QueryOperation = operationId: "getV2DashboardProjectDataUuid"; variables: GetV2DashboardProjectDataUuidVariables; } + | { + path: "/v2/dashboard/view-project/{uuid}"; + operationId: "getV2DashboardViewProjectUuid"; + variables: GetV2DashboardViewProjectUuidVariables; + } | { path: "/v2/terrafund/polygon/geojson/{uuid}"; operationId: "getV2TerrafundPolygonGeojsonUuid"; diff --git a/src/generated/apiSchemas.ts b/src/generated/apiSchemas.ts index 3e05005c8..b1426962b 100644 --- a/src/generated/apiSchemas.ts +++ b/src/generated/apiSchemas.ts @@ -23512,3 +23512,9 @@ export type SitePolygonResource = { export type SiteCheckApproveResponse = { can_approve?: boolean; }; + +export type DashboardProjectViewResponse = { + data?: { + allowed?: boolean; + }; +}; diff --git a/src/pages/site/[uuid]/components/MockedData.ts b/src/pages/site/[uuid]/components/MockedData.ts index 82f67b376..975db7d8a 100644 --- a/src/pages/site/[uuid]/components/MockedData.ts +++ b/src/pages/site/[uuid]/components/MockedData.ts @@ -1,5 +1,4 @@ import { MapPolygonCheckPanelItemProps } from "@/components/elements/MapPolygonPanel/MapPolygonCheckPanelItem"; -import { MapPolygonPanelItemProps } from "@/components/elements/MapPolygonPanel/MapPolygonPanelItem"; export const uploadImageData = [ { id: "1", name: "Images5.png", status: "We are processing your image", isVerified: true }, @@ -44,34 +43,6 @@ export const commentariesItems = [ } ]; -export const PolygonData: MapPolygonPanelItemProps[] = [ - { - uuid: "1", - title: "Polygon 1", - subtitle: "Created 15/12/2023" - }, - { - uuid: "2", - title: "Polygon 2", - subtitle: "Created 15/12/2023" - }, - { - uuid: "3", - title: "Polygon 3", - subtitle: "Created 15/12/2023" - }, - { - uuid: "4", - title: "Polygon 4", - subtitle: "Created 15/12/2023" - }, - { - uuid: "5", - title: "Polygon 5", - subtitle: "Created 15/12/2023" - } -]; - export const PolygonAvailableData: MapPolygonCheckPanelItemProps[] = [ { uuid: "1",