From 09475a404a6a62e5758b7ae2b63c50833b63a655 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Mon, 10 Jun 2024 01:56:21 -0400
Subject: [PATCH 01/29] add basic structure for audit log
---
src/admin/apiProvider/utils/entryFormat.ts | 2 +-
.../ResourceTabs/AuditLogTab/AuditLogTab.tsx | 157 +-
.../components/AuditLogSiteTab.tsx | 111 +
.../components/AuditLogSiteTabSelection.tsx | 37 +
.../AuditLogTab/components/AuditLogTable.tsx | 80 +
.../components/SiteAuditLogEntityStatus.tsx | 92 +
.../SiteAuditLogEntityStatusSide.tsx | 131 +
.../components/SiteAuditLogProjectStatus.tsx | 83 +
.../PolygonStatus/StatusDisplay.tsx | 108 +-
.../elements/CommentaryBox/CommentaryBox.tsx | 4 +-
.../elements/Inputs/Dropdown/Dropdown.tsx | 34 +-
.../elements/Notification/Notification.tsx | 34 +-
src/components/extensive/Modal/Modal.tsx | 15 +-
.../extensive/Modal/ModalConfirm.tsx | 13 +-
src/constants/entities.ts | 4 +
src/generated/apiComponents.ts | 2204 ++++++++++++++++-
src/generated/apiRequestBodies.ts | 58 +-
src/generated/apiSchemas.ts | 496 +++-
src/hooks/AuditStatus/useAuditLogActions.ts | 173 ++
src/hooks/AuditStatus/useLoadEntityList.ts | 114 +
src/utils/statusUtils.ts | 76 +
21 files changed, 3827 insertions(+), 199 deletions(-)
create mode 100644 src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
create mode 100644 src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
create mode 100644 src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx
create mode 100644 src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
create mode 100644 src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
create mode 100644 src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogProjectStatus.tsx
create mode 100644 src/constants/entities.ts
create mode 100644 src/hooks/AuditStatus/useAuditLogActions.ts
create mode 100644 src/hooks/AuditStatus/useLoadEntityList.ts
create mode 100644 src/utils/statusUtils.ts
diff --git a/src/admin/apiProvider/utils/entryFormat.ts b/src/admin/apiProvider/utils/entryFormat.ts
index 929eef6a5..e02829c6e 100644
--- a/src/admin/apiProvider/utils/entryFormat.ts
+++ b/src/admin/apiProvider/utils/entryFormat.ts
@@ -26,7 +26,7 @@ const isDateType = (value: any) => {
return isValid(parseISO(value));
};
-const convertDateFormat = (value: any) => {
+export const convertDateFormat = (value: any) => {
if (typeof value === "string") {
const dateObject = new Date(value);
const formattedDay = dateObject.getUTCDate().toString().padStart(2, "0");
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
index 691a02bd9..bc9c9c536 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
@@ -1,94 +1,105 @@
-import { Typography } from "@mui/material";
-import { FC } from "react";
-import {
- Datagrid,
- DateField,
- FunctionField,
- Pagination,
- ReferenceField,
- ReferenceManyField,
- TabbedShowLayout,
- TabProps,
- useShowContext
-} from "react-admin";
+import { Grid, Stack } from "@mui/material";
+import { FC, useEffect, useState } from "react";
+import { TabbedShowLayout, TabProps, useShowContext } from "react-admin";
import { When } from "react-if";
-import modules from "@/admin/modules";
-import { V2AdminUserRead } from "@/generated/apiSchemas";
+import { SITE } from "@/constants/entities";
+import useAuditLogActions from "@/hooks/AuditStatus/useAuditLogActions";
import { Entity } from "@/types/common";
+import AuditLogSiteTabSelection from "./components/AuditLogSiteTabSelection";
+import SiteAuditLogEntityStatus from "./components/SiteAuditLogEntityStatus";
+import SiteAuditLogEntityStatusSide from "./components/SiteAuditLogEntityStatusSide";
+import SiteAuditLogProjectStatus from "./components/SiteAuditLogProjectStatus";
+
interface IProps extends Omit {
label?: string;
entity?: Entity["entityName"];
}
-interface FeedbackProps {
- comment: string | undefined;
+export const ButtonStates = {
+ PROJECTS: 0,
+ SITE: 1,
+ POLYGON: 2
+};
+
+export interface EntityList {
+ poly_name?: string | undefined;
+ name?: string | undefined;
+ uuid?: string | undefined;
+ value?: string | undefined;
+ meta?: string | undefined;
+ status?: string | undefined;
}
-const Feedback: FC = ({ comment }) => {
- if (comment == null) {
- return <>->;
- }
+const AuditLogTab: FC = ({ label, entity, ...rest }) => {
+ const [buttonToogle, setButtonToogle] = useState(ButtonStates.PROJECTS);
+ const { record, isLoading } = useShowContext();
- return (
- <>
- {comment.split("\n").map(fragment => (
- <>
- {fragment}
-
- >
- ))}
- >
- );
-};
+ const {
+ mutateEntity,
+ valuesForStatus,
+ statusLabels,
+ entityType,
+ entityListItem,
+ loadEntityList,
+ selected,
+ setSelected,
+ auditLogData,
+ refetch,
+ checkPolygonsSite
+ } = useAuditLogActions({
+ record,
+ buttonToogle,
+ entityLevel: SITE
+ });
-const AuditLogTab: FC = ({ label, entity, ...rest }) => {
- const ctx = useShowContext();
- const resource = entity ?? ctx.resource;
+ useEffect(() => {
+ refetch();
+ loadEntityList();
+ }, [buttonToogle]);
return (
-
+
-
- Audit Log
-
- }
- reference={modules.audit.ResourceName}
- filter={{ entity: resource }}
- target="uuid"
- label=""
- >
-
-
-
- `${record?.first_name || ""} ${record?.last_name || ""}`}
- />
-
- {
- const str: string = record?.new_values?.status ?? record?.event ?? "";
-
- return str.replaceAll("-", " ");
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ loadEntityList();
+ refetch();
}}
+ record={selected}
+ polygonList={entityListItem}
+ selectedPolygon={selected}
+ setSelectedPolygon={setSelected}
+ auditLogData={auditLogData?.data}
+ checkPolygonsSite={checkPolygonsSite}
/>
- }
- />
-
-
+
+
);
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
new file mode 100644
index 000000000..a67b150be
--- /dev/null
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
@@ -0,0 +1,111 @@
+import { Grid, Stack } from "@mui/material";
+import { FC, useEffect, useState } from "react";
+import { Button, Link, TabbedShowLayout, TabProps, useBasename, useShowContext } from "react-admin";
+import { When } from "react-if";
+
+import modules from "@/admin/modules";
+import Text from "@/components/elements/Text/Text";
+import { SITE } from "@/constants/entities";
+import useAuditLogActions from "@/hooks/AuditStatus/useAuditLogActions";
+import { Entity } from "@/types/common";
+
+import SiteAuditLogEntityStatus from "../components/SiteAuditLogEntityStatus";
+import SiteAuditLogEntityStatusSide from "../components/SiteAuditLogEntityStatusSide";
+import AuditLogSiteTabSelection from "./AuditLogSiteTabSelection";
+
+interface IProps extends Omit {
+ label?: string;
+ entity?: Entity["entityName"];
+}
+
+export const ButtonStates = {
+ PROJECTS: 0,
+ SITE: 1,
+ POLYGON: 2
+};
+
+const AuditLogSiteTab: FC = ({ label, entity, ...rest }) => {
+ const { record, isLoading } = useShowContext();
+ const basename = useBasename();
+ const [buttonToogle, setButtonToogle] = useState(ButtonStates.PROJECTS);
+
+ const {
+ mutateEntity,
+ valuesForStatus,
+ statusLabels,
+ entityType,
+ entityListItem,
+ loadEntityList,
+ selected,
+ setSelected,
+ auditLogData,
+ refetch,
+ checkPolygonsSite
+ } = useAuditLogActions({
+ record,
+ buttonToogle,
+ entityLevel: SITE
+ });
+
+ useEffect(() => {
+ refetch();
+ loadEntityList();
+ }, [buttonToogle]);
+
+ return (
+
+
+
+
+
+
+
+ Project Status
+
+ Update the site status, view updates, or add comments
+
+
+
+
+
+
+
+
+
+ {
+ refetch();
+ loadEntityList();
+ }}
+ record={selected}
+ polygonList={entityListItem}
+ selectedPolygon={selected}
+ setSelectedPolygon={setSelected}
+ auditLogData={auditLogData?.data}
+ checkPolygonsSite={checkPolygonsSite}
+ />
+
+
+
+
+ );
+};
+
+export default AuditLogSiteTab;
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
new file mode 100644
index 000000000..7e6831049
--- /dev/null
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
@@ -0,0 +1,37 @@
+import { FC } from "react";
+
+import Button from "@/components/elements/Button/Button";
+
+import { ButtonStates } from "../AuditLogTab";
+
+interface AuditLogSiteTabSelectionProps {
+ buttonToogle: number;
+ setButtonToogle: (buttonToogle: number) => void;
+}
+
+const AuditLogSiteTabSelection: FC = ({ buttonToogle, setButtonToogle }) => {
+ return (
+
+
+
+
+
+ );
+};
+
+export default AuditLogSiteTabSelection;
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx
new file mode 100644
index 000000000..7b7a46d31
--- /dev/null
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx
@@ -0,0 +1,80 @@
+import { FC, Fragment } from "react";
+
+import { convertDateFormat } from "@/admin/apiProvider/utils/entryFormat";
+import Text from "@/components/elements/Text/Text";
+import { AuditStatusResponse, V2FileRead } from "@/generated/apiSchemas";
+
+const formattedTextStatus = (text: string) => {
+ return text.replace(/-/g, " ").replace(/\b\w/g, char => char.toUpperCase());
+};
+
+const getTextForActionTable = (item: { type: string; status: string; request_removed: boolean }): string => {
+ if (item.type === "comment") {
+ return "New Comment";
+ } else if (item.type === "status") {
+ return `New Status: ${formattedTextStatus(item.status)}`;
+ } else if (item.request_removed) {
+ return "Change Request Removed";
+ } else {
+ return "Change Requested Added";
+ }
+};
+
+const AuditLogTable: FC<{ auditLogData: { data: AuditStatusResponse[] } }> = ({ auditLogData }) => {
+ return (
+
+
+
+ Date
+
+
+ User
+
+
+ Action
+
+
+ Comments
+
+
+ Attachments
+
+
+
+ {auditLogData?.data?.map((item: AuditStatusResponse, index: number) => (
+
+
+ {convertDateFormat(item?.date_created)}
+
+
+ {`${item.first_name} ${item.last_name}`}
+
+
+ {getTextForActionTable(item as { type: string; status: string; request_removed: boolean })}
+
+
+ {item.comment || "-"}
+
+
+ {item?.attachments?.map((attachmentItem: V2FileRead) => (
+ {
+ attachmentItem.url && window.open(attachmentItem.url, "_blank");
+ }}
+ >
+ {attachmentItem.file_name}
+
+ ))}
+
+
+ ))}
+
+
+ );
+};
+
+export default AuditLogTable;
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
new file mode 100644
index 000000000..258deba30
--- /dev/null
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
@@ -0,0 +1,92 @@
+import Link from "next/link";
+import { FC } from "react";
+import { Link as RaLink, useBasename } from "react-admin";
+
+import modules from "@/admin/modules";
+import Text from "@/components/elements/Text/Text";
+import { AuditStatusResponse } from "@/generated/apiSchemas";
+
+import CommentarySection from "../../PolygonReviewTab/components/CommentarySection/CommentarySection";
+import AuditLogTable from "./AuditLogTable";
+
+export interface SiteAuditLogEntityStatusProps {
+ record?: SelectedItem | null;
+ auditLogData?: { data: AuditStatusResponse[] };
+ refresh?: () => void;
+ entityType?: number;
+ entityName?: string;
+ buttonToogle?: number;
+ buttonStates?: { PROJECTS: number; SITE: number; POLYGON: number };
+ viewPD?: boolean;
+}
+
+interface SelectedItem {
+ title?: string | undefined;
+ name?: string | undefined;
+ uuid?: string | undefined;
+ value?: string | undefined;
+ meta?: string | undefined;
+ status?: string | undefined;
+}
+
+const SiteAuditLogEntityStatus: FC = ({
+ record,
+ auditLogData,
+ refresh,
+ buttonToogle,
+ buttonStates,
+ viewPD = true
+}) => {
+ const entityType = buttonToogle === buttonStates?.POLYGON;
+ const isSite = buttonToogle === buttonStates?.SITE;
+ const basename = useBasename();
+ const title = () => {
+ if (!record?.title) {
+ return record?.name;
+ } else {
+ return record?.title;
+ }
+ };
+ const redirectTo = viewPD
+ ? `/site/${record?.uuid}?tab=audit-log`
+ : `${basename}/${modules.site.ResourceName}/${record?.uuid}/show/6`;
+ return (
+
+
+
+ {entityType ? "Polygon" : "Site"} Status and Comments
+
+
+ Update the {entityType ? "polygon" : "site"} status, view updates, or add comments
+
+
+
+
+ {!isSite && History and Discussion for {title()}}
+ {isSite && (
+
+ History and Discussion for{" "}
+ {viewPD ? (
+
+ {title()}
+
+ ) : (
+
+ {title()}
+
+ )}
+
+ )}
+
+ {auditLogData &&
}
+
+ );
+};
+
+export default SiteAuditLogEntityStatus;
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
new file mode 100644
index 000000000..9a3822c5c
--- /dev/null
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
@@ -0,0 +1,131 @@
+import classNames from "classnames";
+import { Dispatch, SetStateAction, useState } from "react";
+
+import Dropdown from "@/components/elements/Inputs/Dropdown/Dropdown";
+import Notification from "@/components/elements/Notification/Notification";
+import StepProgressbar from "@/components/elements/ProgressBar/StepProgressbar/StepProgressbar";
+import Text from "@/components/elements/Text/Text";
+import { usePostV2AuditStatus } from "@/generated/apiComponents";
+import { AuditStatusResponse } from "@/generated/apiSchemas";
+import { SelectedItem } from "@/hooks/AuditStatus/useLoadEntityList";
+import { recentRequestData } from "@/utils/statusUtils";
+
+import StatusDisplay from "../../PolygonReviewTab/components/PolygonStatus/StatusDisplay";
+
+const SiteAuditLogEntityStatusSide = ({
+ refresh,
+ record,
+ polygonList,
+ selectedPolygon,
+ setSelectedPolygon,
+ auditLogData,
+ recordType = "Polygon",
+ mutate,
+ getValueForStatus,
+ progressBarLabels,
+ tab,
+ checkPolygonsSite,
+ viewPD = false
+}: {
+ recordType?: "Polygon" | "Site" | "Project";
+ refresh?: () => void;
+ record?: any;
+ polygonList?: any[];
+ selectedPolygon?: SelectedItem | null;
+ setSelectedPolygon?: Dispatch> | null;
+ auditLogData?: AuditStatusResponse[];
+ mutate?: any;
+ getValueForStatus?: (status: string) => number;
+ progressBarLabels?: Array<{ id: string; label: string }>;
+ tab?: string;
+ checkPolygonsSite?: boolean | undefined;
+ viewPD?: boolean;
+}) => {
+ const [open, setOpen] = useState(false);
+ const recentRequest = auditLogData?.find(
+ (item: AuditStatusResponse) => item.type == "change-request" && item.is_active
+ );
+ const mutateUpload = recordType === "Project" ? usePostV2AuditStatus : usePostV2AuditStatus;
+ const { mutate: upload } = mutateUpload();
+
+ const deactivateRecentRequest = async () => {
+ upload?.(
+ {
+ //@ts-ignore swagger issue
+ body: {
+ // entity_uuid: record?.uuid,
+ status: record?.status,
+ // entity: recordType === "Polygon" ? "SitePolygon" : recordType,
+ comment: "",
+ type: "change-request",
+ // is_active: false,
+ request_removed: true
+ }
+ },
+ {
+ onSuccess: () => {
+ setOpen(true);
+ setTimeout(() => {
+ setOpen(false);
+ }, 3000);
+ refresh && refresh();
+ }
+ }
+ );
+ };
+
+ return (
+
+ {polygonList && polygonList?.length > 0 && (
+
{
+ console.log("onChange", e);
+ setSelectedPolygon && setSelectedPolygon(polygonList?.find(item => item?.uuid === e[0]));
+ }}
+ />
+ )}
+ {`${recordType} Status`}
+
+ {recentRequest && (
+
+
+
+ Change Requested
+
+
+
{recentRequestData(recentRequest)}
+
+
{recentRequest?.comment}
+
+ )}
+
+
+
+ );
+};
+
+export default SiteAuditLogEntityStatusSide;
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogProjectStatus.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogProjectStatus.tsx
new file mode 100644
index 000000000..cb391423b
--- /dev/null
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogProjectStatus.tsx
@@ -0,0 +1,83 @@
+import { FC } from "react";
+
+import Text from "@/components/elements/Text/Text";
+import { AuditStatusResponse, ProjectLiteRead } from "@/generated/apiSchemas";
+
+import CommentarySection from "../../PolygonReviewTab/components/CommentarySection/CommentarySection";
+import AuditLogTable from "./AuditLogTable";
+
+export interface SiteAuditLogProjectStatusProps {
+ record?: ProjectLiteRead | null;
+ refresh?: () => void;
+ auditLogData?: { data: AuditStatusResponse[] };
+}
+
+export const gridData = [
+ {
+ id: "1",
+ date: "28/11/2023 09.39",
+ user: "Jessica Chaimers",
+ site: null,
+ status: "Need More Information",
+ comentary: null
+ },
+ {
+ id: "2",
+ date: "28/11/2023 09.39",
+ user: "Teresa Muthoni",
+ site: null,
+ status: "Need More Information",
+ comentary:
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
+ },
+ {
+ id: "3",
+ date: "28/11/2023 09.39",
+ user: "Jessica Chaimers",
+ site: null,
+ status: "Awaiting Approval",
+ comentary: null
+ },
+ {
+ id: "4",
+ date: "28/11/2023 09.39",
+ user: "Jessica Chaimers",
+ site: null,
+ status: "Awaiting Approval",
+ comentary: null
+ },
+ {
+ id: "5",
+ date: "28/11/2023 09.39",
+ user: "Jessica Chaimers",
+ site: null,
+ status: "Awaiting Approval",
+ comentary: null
+ }
+];
+
+const SiteAuditLogProjectStatus: FC = ({ record, auditLogData, refresh }) => {
+ return (
+
+
+
+ Project Status and Comments
+
+
+ Update the project status, view updates, or add comments
+
+
+
+
History and Discussion for {record && record?.name}
+ {auditLogData &&
}
+
+ );
+};
+
+export default SiteAuditLogProjectStatus;
diff --git a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
index a5aae6936..34912298e 100644
--- a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
+++ b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
@@ -8,69 +8,87 @@ import ModalConfirm from "@/components/extensive/Modal/ModalConfirm";
import { useModalContext } from "@/context/modal.provider";
const menuPolygonOptions = [
+ {
+ title: "Draft",
+ status: "draft",
+ value: 1,
+ viewPd: false
+ },
{
title: "Submitted",
status: "submitted",
- value: 1
+ value: 2,
+ viewPd: true
},
{
title: "Needs More Information",
status: "needs-more-information",
- value: 2
+ value: 3,
+ viewPd: false
},
{
title: "Approved",
status: "approved",
- value: 3
+ value: 4,
+ viewPd: false
}
];
const menuSiteOptions = [
{
title: "Draft",
status: "draft",
- value: 1
+ value: 1,
+ viewPd: true
},
{
title: "Awaiting Approval",
status: "awaiting-approval",
- value: 2
+ value: 2,
+ viewPd: true
},
{
title: "Needs More Information",
status: "needs-more-information",
- value: 3
+ value: 3,
+ viewPd: false
},
{
title: "Planting in Progress",
status: "planting-in-progress",
- value: 4
+ value: 4,
+ viewPd: false
},
{
title: "Approved",
status: "approved",
- value: 5
+ value: 5,
+ viewPd: false
}
];
const menuProjectOptions = [
{
title: "Draft",
status: "draft",
- value: 1
+ value: 1,
+ viewPd: true
},
{
title: "Awaiting Approval",
status: "awaiting-approval",
- value: 2
+ value: 2,
+ viewPd: true
},
{
title: "Needs More Information",
status: "needs-more-information",
- value: 3
+ value: 3,
+ viewPd: false
},
{
title: "Approved",
status: "approved",
- value: 4
+ value: 4,
+ viewPd: false
}
];
@@ -78,10 +96,12 @@ export interface StatusProps {
titleStatus: "Site" | "Project" | "Polygon";
mutate?: any;
record?: any;
- refresh?: any;
+ refresh?: () => void;
name: any;
- refetchPolygon?: any;
- setSelectedPolygon?: any;
+ refetchPolygon?: () => void;
+ tab?: string;
+ checkPolygonsSite?: boolean | undefined;
+ viewPD?: boolean;
}
const menuOptionsMap = {
@@ -102,7 +122,16 @@ const DescriptionRequestMap = {
Project: "Provide an explanation for your change request for the project"
};
-const StatusDisplay = ({ titleStatus = "Polygon", mutate, refresh, name, record, setSelectedPolygon }: StatusProps) => {
+const StatusDisplay = ({
+ titleStatus = "Polygon",
+ mutate,
+ refresh,
+ name,
+ record,
+ checkPolygonsSite,
+ tab,
+ viewPD
+}: StatusProps) => {
const { refetch: reloadEntity } = useShowContext();
const [notificationStatus, setNotificationStatus] = useState<{
open: boolean;
@@ -127,20 +156,23 @@ const StatusDisplay = ({ titleStatus = "Polygon", mutate, refresh, name, record,
{DescriptionRequestMap[titleStatus]} {name}?
);
-
+ const filterViewPd = viewPD
+ ? menuOptionsMap[titleStatus].filter(option => option.viewPd === true)
+ : menuOptionsMap[titleStatus];
const openFormModalHandlerStatus = () => {
openModal(
{
const option = menuOptionsMap[titleStatus].find(option => option.value === opt[0]);
try {
- const response = await mutate({
+ await mutate({
pathParams: { uuid: record?.uuid },
body: {
status: option?.status,
@@ -148,9 +180,6 @@ const StatusDisplay = ({ titleStatus = "Polygon", mutate, refresh, name, record,
type: "status"
}
});
- if (response.poly_id) {
- setSelectedPolygon(response?.poly_id);
- }
setNotificationStatus({
open: true,
message: "Your Status Update was just saved!",
@@ -172,10 +201,19 @@ const StatusDisplay = ({ titleStatus = "Polygon", mutate, refresh, name, record,
type: "error",
title: "Error!"
});
+ setTimeout(() => {
+ setNotificationStatus({
+ open: false,
+ message: "",
+ type: "error",
+ title: "Error!"
+ });
+ }, 3000);
+ console.error(e);
} finally {
- refresh();
- reloadEntity();
- closeModal();
+ refresh && refresh();
+ reloadEntity && reloadEntity();
+ closeModal;
}
}}
/>
@@ -223,10 +261,19 @@ const StatusDisplay = ({ titleStatus = "Polygon", mutate, refresh, name, record,
type: "error",
title: "Error!"
});
+ setTimeout(() => {
+ setNotificationStatus({
+ open: false,
+ message: "",
+ type: "error",
+ title: "Error!"
+ });
+ }, 3000);
+ console.error(e);
} finally {
- refresh();
- reloadEntity();
- closeModal();
+ refresh && refresh();
+ reloadEntity && reloadEntity();
+ closeModal;
}
}}
/>
@@ -237,11 +284,12 @@ const StatusDisplay = ({ titleStatus = "Polygon", mutate, refresh, name, record,
diff --git a/src/components/elements/Inputs/Dropdown/__snapshots__/Dropdown.stories.storyshot b/src/components/elements/Inputs/Dropdown/__snapshots__/Dropdown.stories.storyshot
index 7d3a87fcf..da4d5faa8 100644
--- a/src/components/elements/Inputs/Dropdown/__snapshots__/Dropdown.stories.storyshot
+++ b/src/components/elements/Inputs/Dropdown/__snapshots__/Dropdown.stories.storyshot
@@ -43,7 +43,9 @@ exports[`Storyshots Components/Elements/Inputs/Dropdown Multi Select 1`] = `
+ >
+ placeholder
+
+ >
+ placeholder
+
+ >
+ placeholder
+
= {
export default meta;
type Story = StoryObj
;
+const client = new QueryClient();
+
export const Default: Story = {
render: (args: Props) => (
-
+
+
+
),
args: {
diff --git a/src/components/extensive/Modal/__snapshots__/Modal.stories.storyshot b/src/components/extensive/Modal/__snapshots__/Modal.stories.storyshot
index 95897210b..d363bc3c5 100644
--- a/src/components/extensive/Modal/__snapshots__/Modal.stories.storyshot
+++ b/src/components/extensive/Modal/__snapshots__/Modal.stories.storyshot
@@ -5,7 +5,7 @@ exports[`Storyshots Components/Extensive/Modal Default 1`] = `
className="flex items-center justify-center bg-primary-400 p-8"
>
0
- /255
- characters
+ /255 characters
diff --git a/src/hooks/useGetCustomFormSteps/__snapshots__/useGetCustomFormSteps.stories.storyshot b/src/hooks/useGetCustomFormSteps/__snapshots__/useGetCustomFormSteps.stories.storyshot
index ac78c56c0..c503535ee 100644
--- a/src/hooks/useGetCustomFormSteps/__snapshots__/useGetCustomFormSteps.stories.storyshot
+++ b/src/hooks/useGetCustomFormSteps/__snapshots__/useGetCustomFormSteps.stories.storyshot
@@ -419,7 +419,7 @@ exports[`Storyshots Components/Extensive/Form/Wizard With Get Form Step Hook 1`]
className="flex items-center gap-2"
>
Date: Wed, 12 Jun 2024 10:14:23 -0400
Subject: [PATCH 09/29] change const with enum
---
.../ResourceTabs/AuditLogTab/AuditLogTab.tsx | 16 ++++--------
.../components/AuditLogSiteTab.tsx | 14 +++--------
.../components/AuditLogSiteTabSelection.tsx | 14 +++++------
.../components/SiteAuditLogEntityStatus.tsx | 7 +++---
.../AuditLogTab/constants/enum.ts | 6 +++++
src/hooks/AuditStatus/useAuditLogActions.ts | 25 ++++++-------------
6 files changed, 32 insertions(+), 50 deletions(-)
create mode 100644 src/admin/components/ResourceTabs/AuditLogTab/constants/enum.ts
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
index 8e5d88cca..4027f971a 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
@@ -13,18 +13,13 @@ import AuditLogSiteTabSelection from "./components/AuditLogSiteTabSelection";
import SiteAuditLogEntityStatus from "./components/SiteAuditLogEntityStatus";
import SiteAuditLogEntityStatusSide from "./components/SiteAuditLogEntityStatusSide";
import SiteAuditLogProjectStatus from "./components/SiteAuditLogProjectStatus";
+import { AuditLogButtonStates } from "./constants/enum";
interface IProps extends Omit {
label?: string;
entity?: Entity["entityName"];
}
-export const ButtonStates = {
- PROJECTS: 0,
- SITE: 1,
- POLYGON: 2
-};
-
export interface EntityList {
poly_name?: string | undefined;
name?: string | undefined;
@@ -35,7 +30,7 @@ export interface EntityList {
}
const AuditLogTab: FC = ({ label, entity, ...rest }) => {
- const [buttonToogle, setButtonToogle] = useState(ButtonStates.PROJECTS);
+ const [buttonToogle, setButtonToogle] = useState(AuditLogButtonStates.PROJECT);
const { record, isLoading } = useShowContext();
const basename = useBasename();
@@ -69,7 +64,7 @@ const AuditLogTab: FC = ({ label, entity, ...rest }) => {
-
+
Project Status
Update the site status, view updates, or add comments
@@ -82,16 +77,15 @@ const AuditLogTab: FC = ({ label, entity, ...rest }) => {
label="OPEN PROJECT AUDIT LOG"
/>
-
+
-
+
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
index a67b150be..1fcd2b359 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
@@ -11,6 +11,7 @@ import { Entity } from "@/types/common";
import SiteAuditLogEntityStatus from "../components/SiteAuditLogEntityStatus";
import SiteAuditLogEntityStatusSide from "../components/SiteAuditLogEntityStatusSide";
+import { AuditLogButtonStates } from "../constants/enum";
import AuditLogSiteTabSelection from "./AuditLogSiteTabSelection";
interface IProps extends Omit {
@@ -18,16 +19,10 @@ interface IProps extends Omit {
entity?: Entity["entityName"];
}
-export const ButtonStates = {
- PROJECTS: 0,
- SITE: 1,
- POLYGON: 2
-};
-
const AuditLogSiteTab: FC = ({ label, entity, ...rest }) => {
const { record, isLoading } = useShowContext();
const basename = useBasename();
- const [buttonToogle, setButtonToogle] = useState(ButtonStates.PROJECTS);
+ const [buttonToogle, setButtonToogle] = useState(AuditLogButtonStates.PROJECT);
const {
mutateEntity,
@@ -59,7 +54,7 @@ const AuditLogSiteTab: FC = ({ label, entity, ...rest }) => {
-
+
Project Status
Update the site status, view updates, or add comments
@@ -72,13 +67,12 @@ const AuditLogSiteTab: FC = ({ label, entity, ...rest }) => {
label="OPEN PROJECT AUDIT LOG"
/>
-
+
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
index 7e6831049..7ea4498d3 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
@@ -2,7 +2,7 @@ import { FC } from "react";
import Button from "@/components/elements/Button/Button";
-import { ButtonStates } from "../AuditLogTab";
+import { AuditLogButtonStates } from "../constants/enum";
interface AuditLogSiteTabSelectionProps {
buttonToogle: number;
@@ -13,20 +13,20 @@ const AuditLogSiteTabSelection: FC = ({ buttonToo
return (
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
index 32e8a5f78..12b554411 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
@@ -7,6 +7,7 @@ import Text from "@/components/elements/Text/Text";
import { AuditStatusResponse } from "@/generated/apiSchemas";
import CommentarySection from "../../PolygonReviewTab/components/CommentarySection/CommentarySection";
+import { AuditLogButtonStates } from "../constants/enum";
import AuditLogTable from "./AuditLogTable";
export interface SiteAuditLogEntityStatusProps {
@@ -16,7 +17,6 @@ export interface SiteAuditLogEntityStatusProps {
entityType?: number;
entityName?: string;
buttonToogle?: number;
- buttonStates?: { PROJECTS: number; SITE: number; POLYGON: number };
viewPD?: boolean;
}
@@ -34,11 +34,10 @@ const SiteAuditLogEntityStatus: FC
= ({
auditLogData,
refresh,
buttonToogle,
- buttonStates,
viewPD = true
}) => {
- const entityType = buttonToogle === buttonStates?.POLYGON;
- const isSite = buttonToogle === buttonStates?.SITE;
+ const entityType = buttonToogle === AuditLogButtonStates.POLYGON;
+ const isSite = buttonToogle === AuditLogButtonStates.SITE;
const basename = useBasename();
const title = () => {
if (!record?.title) {
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/constants/enum.ts b/src/admin/components/ResourceTabs/AuditLogTab/constants/enum.ts
new file mode 100644
index 000000000..3c5d72bf8
--- /dev/null
+++ b/src/admin/components/ResourceTabs/AuditLogTab/constants/enum.ts
@@ -0,0 +1,6 @@
+/* eslint-disable no-unused-vars */
+export enum AuditLogButtonStates {
+ PROJECT = 0,
+ SITE = 1,
+ POLYGON = 2
+}
diff --git a/src/hooks/AuditStatus/useAuditLogActions.ts b/src/hooks/AuditStatus/useAuditLogActions.ts
index 2111c1e7a..0a3bbfd5e 100644
--- a/src/hooks/AuditStatus/useAuditLogActions.ts
+++ b/src/hooks/AuditStatus/useAuditLogActions.ts
@@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
+import { AuditLogButtonStates } from "@/admin/components/ResourceTabs/AuditLogTab/constants/enum";
import { POLYGON, PROJECT, SITE } from "@/constants/entities";
import {
fetchGetV2SitesSiteCheckApprove,
@@ -21,18 +22,6 @@ import useLoadEntityList from "./useLoadEntityList";
const ESTIMATED_AREA_CRITERIA_ID = 12;
-export const ButtonStates = {
- PROJECTS: 0,
- SITE: 1,
- POLYGON: 2
-};
-
-// const ReverseButtonStates: { [key: number]: string } = {
-// 0: PROJECT,
-// 1: SITE,
-// 2: SITE_POLYGON
-// };
-
const ReverseButtonStates2: { [key: number]: string } = {
0: "project",
1: "site",
@@ -40,19 +29,19 @@ const ReverseButtonStates2: { [key: number]: string } = {
};
const statusActionsMap = {
- [ButtonStates.PROJECTS]: {
+ [AuditLogButtonStates.PROJECT as number]: {
mutateEntity: fetchPutV2ENTITYUUIDStatus,
valuesForStatus: getValueForStatusProject,
statusLabels: projectStatusLabels,
entityType: PROJECT
},
- [ButtonStates.SITE]: {
+ [AuditLogButtonStates.SITE as number]: {
mutateEntity: fetchPutV2ENTITYUUIDStatus,
valuesForStatus: getValueForStatusSite,
statusLabels: siteProgressBarStatusLabels,
entityType: SITE
},
- [ButtonStates.POLYGON]: {
+ [AuditLogButtonStates.POLYGON as number]: {
mutateEntity: fetchPutV2ENTITYUUIDStatus,
valuesForStatus: getValueForStatusPolygon,
statusLabels: polygonProgressBarStatusLabels,
@@ -70,9 +59,9 @@ const useAuditLogActions = ({
entityLevel: string;
}) => {
const { mutateEntity, valuesForStatus, statusLabels, entityType } = statusActionsMap[buttonToogle];
- const isProject = buttonToogle === ButtonStates.PROJECTS;
- const isSite = buttonToogle === ButtonStates.SITE;
- const isPolygon = buttonToogle === ButtonStates.POLYGON;
+ const isProject = buttonToogle === AuditLogButtonStates.PROJECT;
+ const isSite = buttonToogle === AuditLogButtonStates.SITE;
+ const isPolygon = buttonToogle === AuditLogButtonStates.POLYGON;
const isSiteProject = entityLevel === PROJECT;
const [checkPolygons, setCheckPolygons] = useState(undefined);
const [criteriaValidation, setCriteriaValidation] = useState();
From 4a557c71d5ce86da95dfa95cd9b4535d61706394 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 10:17:42 -0400
Subject: [PATCH 10/29] removed unused interface
---
.../components/ResourceTabs/AuditLogTab/AuditLogTab.tsx | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
index 4027f971a..e0289ee42 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
@@ -20,15 +20,6 @@ interface IProps extends Omit {
entity?: Entity["entityName"];
}
-export interface EntityList {
- poly_name?: string | undefined;
- name?: string | undefined;
- uuid?: string | undefined;
- value?: string | undefined;
- meta?: string | undefined;
- status?: string | undefined;
-}
-
const AuditLogTab: FC = ({ label, entity, ...rest }) => {
const [buttonToogle, setButtonToogle] = useState(AuditLogButtonStates.PROJECT);
const { record, isLoading } = useShowContext();
From cd50daa24b27440721aa697c397dfff8c233c37e Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 10:42:27 -0400
Subject: [PATCH 11/29] better type usage
---
.../ResourceTabs/AuditLogTab/AuditLogTab.tsx | 2 +-
.../SiteAuditLogEntityStatusSide.tsx | 4 ++--
.../AuditLogTab/constants/types.ts | 1 +
.../PolygonStatus/StatusDisplay.tsx | 4 +++-
src/hooks/AuditStatus/useAuditLogActions.ts | 22 ++++++++++++++++---
src/hooks/AuditStatus/useLoadEntityList.ts | 3 ++-
6 files changed, 28 insertions(+), 8 deletions(-)
create mode 100644 src/admin/components/ResourceTabs/AuditLogTab/constants/types.ts
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
index e0289ee42..e9e4c4fb0 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
@@ -87,7 +87,7 @@ const AuditLogTab: FC = ({ label, entity, ...rest }) => {
getValueForStatus={valuesForStatus}
progressBarLabels={statusLabels}
mutate={mutateEntity}
- recordType={entityType as "Project" | "Site" | "Polygon"}
+ recordType={entityType}
refresh={() => {
loadEntityList();
refetch();
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
index 17a7326d3..f3eb6329b 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
@@ -11,6 +11,7 @@ import { SelectedItem } from "@/hooks/AuditStatus/useLoadEntityList";
import { recentRequestData } from "@/utils/statusUtils";
import StatusDisplay from "../../PolygonReviewTab/components/PolygonStatus/StatusDisplay";
+import { AuditLogEntity } from "../constants/types";
const SiteAuditLogEntityStatusSide = ({
refresh,
@@ -27,7 +28,7 @@ const SiteAuditLogEntityStatusSide = ({
checkPolygonsSite,
viewPD = false
}: {
- recordType?: "Polygon" | "Site" | "Project";
+ recordType?: AuditLogEntity;
refresh?: () => void;
record?: any;
polygonList?: any[];
@@ -86,7 +87,6 @@ const SiteAuditLogEntityStatusSide = ({
placeholder={`Select ${recordType}`}
options={polygonList!}
onChange={e => {
- console.log("onChange", e);
setSelectedPolygon && setSelectedPolygon(polygonList?.find(item => item?.uuid === e[0]));
}}
/>
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/constants/types.ts b/src/admin/components/ResourceTabs/AuditLogTab/constants/types.ts
new file mode 100644
index 000000000..cbf490f1b
--- /dev/null
+++ b/src/admin/components/ResourceTabs/AuditLogTab/constants/types.ts
@@ -0,0 +1 @@
+export type AuditLogEntity = "Project" | "Site" | "Polygon";
diff --git a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
index 9161918cd..e24ab6d3e 100644
--- a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
+++ b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
@@ -7,6 +7,8 @@ import Text from "@/components/elements/Text/Text";
import ModalConfirm from "@/components/extensive/Modal/ModalConfirm";
import { useModalContext } from "@/context/modal.provider";
+import { AuditLogEntity } from "../../../AuditLogTab/constants/types";
+
const menuPolygonOptions = [
{
title: "Draft",
@@ -93,7 +95,7 @@ const menuProjectOptions = [
];
export interface StatusProps {
- titleStatus: "Site" | "Project" | "Polygon";
+ titleStatus: AuditLogEntity;
mutate?: any;
record?: any;
refresh?: () => void;
diff --git a/src/hooks/AuditStatus/useAuditLogActions.ts b/src/hooks/AuditStatus/useAuditLogActions.ts
index 0a3bbfd5e..b859290bd 100644
--- a/src/hooks/AuditStatus/useAuditLogActions.ts
+++ b/src/hooks/AuditStatus/useAuditLogActions.ts
@@ -1,6 +1,7 @@
import { useEffect, useState } from "react";
import { AuditLogButtonStates } from "@/admin/components/ResourceTabs/AuditLogTab/constants/enum";
+import { AuditLogEntity } from "@/admin/components/ResourceTabs/AuditLogTab/constants/types";
import { POLYGON, PROJECT, SITE } from "@/constants/entities";
import {
fetchGetV2SitesSiteCheckApprove,
@@ -49,6 +50,21 @@ const statusActionsMap = {
}
};
+interface AuditLogActionsResponse {
+ mutateEntity: any;
+ valuesForStatus: any;
+ statusLabels: any;
+ entityType: AuditLogEntity;
+ loadEntityList: () => void;
+ entityListItem: any;
+ selected: any;
+ setSelected: any;
+ checkPolygonsSite: boolean | undefined;
+ auditLogData: { data: GetV2AuditStatusENTITYUUIDResponse } | undefined;
+ refetch: () => void;
+ isLoading: boolean;
+}
+
const useAuditLogActions = ({
record,
buttonToogle,
@@ -57,7 +73,7 @@ const useAuditLogActions = ({
record: any;
buttonToogle: number;
entityLevel: string;
-}) => {
+}): AuditLogActionsResponse => {
const { mutateEntity, valuesForStatus, statusLabels, entityType } = statusActionsMap[buttonToogle];
const isProject = buttonToogle === AuditLogButtonStates.PROJECT;
const isSite = buttonToogle === AuditLogButtonStates.SITE;
@@ -67,7 +83,7 @@ const useAuditLogActions = ({
const [criteriaValidation, setCriteriaValidation] = useState();
const { entityListItem, selected, setSelected, loadEntityList } = useLoadEntityList({
entityUuid: record?.uuid,
- entityType: entityType as "Project" | "Site" | "Polygon",
+ entityType: entityType as AuditLogEntity,
buttonToogle,
entityLevel
});
@@ -145,7 +161,7 @@ const useAuditLogActions = ({
mutateEntity,
valuesForStatus,
statusLabels,
- entityType: entityType,
+ entityType: entityType as AuditLogEntity,
loadEntityList: entityHandlers.loadToEntity,
entityListItem: entityHandlers.ListItemToEntity,
selected: entityHandlers.selectedEntityItem,
diff --git a/src/hooks/AuditStatus/useLoadEntityList.ts b/src/hooks/AuditStatus/useLoadEntityList.ts
index 62f91c18b..d0126dabf 100644
--- a/src/hooks/AuditStatus/useLoadEntityList.ts
+++ b/src/hooks/AuditStatus/useLoadEntityList.ts
@@ -1,5 +1,6 @@
import { useEffect, useRef, useState } from "react";
+import { AuditLogEntity } from "@/admin/components/ResourceTabs/AuditLogTab/constants/types";
import { POLYGON, PROJECT, SITE } from "@/constants/entities";
import {
fetchGetV2ProjectsUUIDSitePolygonsAll,
@@ -18,7 +19,7 @@ export interface SelectedItem {
interface UseLoadEntityListParams {
entityUuid: string;
- entityType: "Site" | "Polygon" | "Project";
+ entityType: AuditLogEntity;
buttonToogle?: number;
entityLevel?: string;
}
From 8cf08944df41dbeb5b523df85bfe79fa27b80597 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 10:53:15 -0400
Subject: [PATCH 12/29] update type in component
---
src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx | 2 +-
.../ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
index e9e4c4fb0..f3be10de3 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
@@ -89,8 +89,8 @@ const AuditLogTab: FC = ({ label, entity, ...rest }) => {
mutate={mutateEntity}
recordType={entityType}
refresh={() => {
- loadEntityList();
refetch();
+ loadEntityList();
}}
record={selected}
polygonList={entityListItem}
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
index 1fcd2b359..65f0b526d 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
@@ -20,9 +20,9 @@ interface IProps extends Omit {
}
const AuditLogSiteTab: FC = ({ label, entity, ...rest }) => {
+ const [buttonToogle, setButtonToogle] = useState(AuditLogButtonStates.PROJECT);
const { record, isLoading } = useShowContext();
const basename = useBasename();
- const [buttonToogle, setButtonToogle] = useState(AuditLogButtonStates.PROJECT);
const {
mutateEntity,
@@ -83,7 +83,7 @@ const AuditLogSiteTab: FC = ({ label, entity, ...rest }) => {
getValueForStatus={valuesForStatus}
progressBarLabels={statusLabels}
mutate={mutateEntity}
- recordType={entityType as "Project" | "Site" | "Polygon"}
+ recordType={entityType}
refresh={() => {
refetch();
loadEntityList();
From ead04cf07bb76137fb2e1b096600a42aad1a7b8e Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 11:11:15 -0400
Subject: [PATCH 13/29] remove duplicated component
---
.../components/AuditLogSiteTab.tsx | 105 ------------------
1 file changed, 105 deletions(-)
delete mode 100644 src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
deleted file mode 100644
index 65f0b526d..000000000
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTab.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-import { Grid, Stack } from "@mui/material";
-import { FC, useEffect, useState } from "react";
-import { Button, Link, TabbedShowLayout, TabProps, useBasename, useShowContext } from "react-admin";
-import { When } from "react-if";
-
-import modules from "@/admin/modules";
-import Text from "@/components/elements/Text/Text";
-import { SITE } from "@/constants/entities";
-import useAuditLogActions from "@/hooks/AuditStatus/useAuditLogActions";
-import { Entity } from "@/types/common";
-
-import SiteAuditLogEntityStatus from "../components/SiteAuditLogEntityStatus";
-import SiteAuditLogEntityStatusSide from "../components/SiteAuditLogEntityStatusSide";
-import { AuditLogButtonStates } from "../constants/enum";
-import AuditLogSiteTabSelection from "./AuditLogSiteTabSelection";
-
-interface IProps extends Omit {
- label?: string;
- entity?: Entity["entityName"];
-}
-
-const AuditLogSiteTab: FC = ({ label, entity, ...rest }) => {
- const [buttonToogle, setButtonToogle] = useState(AuditLogButtonStates.PROJECT);
- const { record, isLoading } = useShowContext();
- const basename = useBasename();
-
- const {
- mutateEntity,
- valuesForStatus,
- statusLabels,
- entityType,
- entityListItem,
- loadEntityList,
- selected,
- setSelected,
- auditLogData,
- refetch,
- checkPolygonsSite
- } = useAuditLogActions({
- record,
- buttonToogle,
- entityLevel: SITE
- });
-
- useEffect(() => {
- refetch();
- loadEntityList();
- }, [buttonToogle]);
-
- return (
-
-
-
-
-
-
-
- Project Status
-
- Update the site status, view updates, or add comments
-
-
-
-
-
-
-
-
-
- {
- refetch();
- loadEntityList();
- }}
- record={selected}
- polygonList={entityListItem}
- selectedPolygon={selected}
- setSelectedPolygon={setSelected}
- auditLogData={auditLogData?.data}
- checkPolygonsSite={checkPolygonsSite}
- />
-
-
-
-
- );
-};
-
-export default AuditLogSiteTab;
From 17b07c43afb9a192414506a29157a175af24bc9e Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 11:20:37 -0400
Subject: [PATCH 14/29] change audit log table titles to be dynamic
---
.../AuditLogTab/components/AuditLogTable.tsx | 26 +++++++------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx
index 7b7a46d31..c6b3b108a 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx
@@ -20,25 +20,17 @@ const getTextForActionTable = (item: { type: string; status: string; request_rem
}
};
+const columnTitles = ["Date", "User", "Action", "Comments", "Attachments"];
+
const AuditLogTable: FC<{ auditLogData: { data: AuditStatusResponse[] } }> = ({ auditLogData }) => {
return (
-
+ <>
-
- Date
-
-
- User
-
-
- Action
-
-
- Comments
-
-
- Attachments
-
+ {columnTitles.map(title => (
+
+ {title}
+
+ ))}
{auditLogData?.data?.map((item: AuditStatusResponse, index: number) => (
@@ -73,7 +65,7 @@ const AuditLogTable: FC<{ auditLogData: { data: AuditStatusResponse[] } }> = ({
))}
-
+ >
);
};
From 7dac0c1e83aa8876e7f26455c209e0c09959d589 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 11:44:05 -0400
Subject: [PATCH 15/29] remove unused param
---
.../ResourceTabs/AuditLogTab/AuditLogTab.tsx | 1 -
.../components/SiteAuditLogEntityStatus.tsx | 29 ++++-------
.../SiteAuditLogEntityStatusSide.tsx | 5 +-
.../PolygonStatus/StatusDisplay.tsx | 49 ++++++-------------
src/generated/apiComponents.ts | 24 ++++++---
src/hooks/AuditStatus/useAuditLogActions.ts | 2 +-
src/hooks/AuditStatus/useLoadEntityList.ts | 1 +
7 files changed, 45 insertions(+), 66 deletions(-)
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
index f3be10de3..065adabcf 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
@@ -77,7 +77,6 @@ const AuditLogTab: FC = ({ label, entity, ...rest }) => {
auditLogData={auditLogData}
refresh={refetch}
buttonToogle={buttonToogle}
- viewPD={false}
/>
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
index 12b554411..90a6e27f8 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
@@ -1,4 +1,3 @@
-import Link from "next/link";
import { FC } from "react";
import { Link as RaLink, useBasename } from "react-admin";
@@ -17,7 +16,6 @@ export interface SiteAuditLogEntityStatusProps {
entityType?: number;
entityName?: string;
buttonToogle?: number;
- viewPD?: boolean;
}
interface SelectedItem {
@@ -33,22 +31,19 @@ const SiteAuditLogEntityStatus: FC = ({
record,
auditLogData,
refresh,
- buttonToogle,
- viewPD = true
+ buttonToogle
}) => {
const entityType = buttonToogle === AuditLogButtonStates.POLYGON;
const isSite = buttonToogle === AuditLogButtonStates.SITE;
const basename = useBasename();
- const title = () => {
+ const getTitle = () => {
if (!record?.title) {
return record?.name;
} else {
return record?.title;
}
};
- const redirectTo = viewPD
- ? `/site/${record?.uuid}?tab=audit-log`
- : `${basename}/${modules.site.ResourceName}/${record?.uuid}/show/6`;
+
return (
@@ -66,19 +61,15 @@ const SiteAuditLogEntityStatus: FC = ({
/>
- {!isSite && History and Discussion for {title()}}
+ {!isSite && History and Discussion for {getTitle()}}
{isSite && (
- History and Discussion for{" "}
- {viewPD ? (
-
- {title()}
-
- ) : (
-
- {title()}
-
- )}
+
+ {getTitle()}
+
)}
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
index f3eb6329b..59ba0e853 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
@@ -25,8 +25,7 @@ const SiteAuditLogEntityStatusSide = ({
getValueForStatus,
progressBarLabels,
tab,
- checkPolygonsSite,
- viewPD = false
+ checkPolygonsSite
}: {
recordType?: AuditLogEntity;
refresh?: () => void;
@@ -40,7 +39,6 @@ const SiteAuditLogEntityStatusSide = ({
progressBarLabels?: Array<{ id: string; label: string }>;
tab?: string;
checkPolygonsSite?: boolean | undefined;
- viewPD?: boolean;
}) => {
const [open, setOpen] = useState(false);
const recentRequest = auditLogData?.find(
@@ -121,7 +119,6 @@ const SiteAuditLogEntityStatusSide = ({
record={record}
tab={tab}
checkPolygonsSite={checkPolygonsSite}
- viewPD={viewPD}
/>
diff --git a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
index e24ab6d3e..64faa1446 100644
--- a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
+++ b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
@@ -13,84 +13,71 @@ const menuPolygonOptions = [
{
title: "Draft",
status: "draft",
- value: 1,
- viewPd: false
+ value: 1
},
{
title: "Submitted",
status: "submitted",
- value: 2,
- viewPd: true
+ value: 2
},
{
title: "Needs More Information",
status: "needs-more-information",
- value: 3,
- viewPd: false
+ value: 3
},
{
title: "Approved",
status: "approved",
- value: 4,
- viewPd: false
+ value: 4
}
];
const menuSiteOptions = [
{
title: "Draft",
status: "draft",
- value: 1,
- viewPd: true
+ value: 1
},
{
title: "Awaiting Approval",
status: "awaiting-approval",
- value: 2,
- viewPd: true
+ value: 2
},
{
title: "Needs More Information",
status: "needs-more-information",
- value: 3,
- viewPd: false
+ value: 3
},
{
title: "Planting in Progress",
status: "planting-in-progress",
- value: 4,
- viewPd: false
+ value: 4
},
{
title: "Approved",
status: "approved",
- value: 5,
- viewPd: false
+ value: 5
}
];
const menuProjectOptions = [
{
title: "Draft",
status: "draft",
- value: 1,
- viewPd: true
+ value: 1
},
{
title: "Awaiting Approval",
status: "awaiting-approval",
- value: 2,
- viewPd: true
+ value: 2
},
{
title: "Needs More Information",
status: "needs-more-information",
- value: 3,
- viewPd: false
+ value: 3
},
{
title: "Approved",
status: "approved",
- value: 4,
- viewPd: false
+ value: 4
}
];
@@ -103,7 +90,6 @@ export interface StatusProps {
refetchPolygon?: () => void;
tab?: string;
checkPolygonsSite?: boolean | undefined;
- viewPD?: boolean;
}
const menuOptionsMap = {
@@ -131,8 +117,7 @@ const StatusDisplay = ({
name,
record,
checkPolygonsSite,
- tab,
- viewPD
+ tab
}: StatusProps) => {
const { refetch: reloadEntity } = useShowContext();
const [notificationStatus, setNotificationStatus] = useState<{
@@ -158,16 +143,14 @@ const StatusDisplay = ({
{DescriptionRequestMap[titleStatus]} {name}?
);
- const filterViewPd = viewPD
- ? menuOptionsMap[titleStatus].filter(option => option.viewPd === true)
- : menuOptionsMap[titleStatus];
+
const openFormModalHandlerStatus = () => {
openModal(
;
export type GetV2ProjectsUUIDSitePolygonsAllResponse = {
@@ -33985,18 +33989,22 @@ export type GetV2ProjectsUUIDSitePolygonsAllResponse = {
created_by?: string;
}[];
-export type GetV2ProjectsUUIDSitePolygonsAllVariables = ApiContext["fetcherOptions"];
+export type GetV2ProjectsUUIDSitePolygonsAllVariables = {
+ pathParams: GetV2ProjectsUUIDSitePolygonsAllPathParams;
+} & ApiContext["fetcherOptions"];
export const fetchGetV2ProjectsUUIDSitePolygonsAll = (
variables: GetV2ProjectsUUIDSitePolygonsAllVariables,
signal?: AbortSignal
) =>
- apiFetch({
- url: "/v2/projects/{uuid}/site-polygons/all",
- method: "get",
- ...variables,
- signal
- });
+ apiFetch<
+ GetV2ProjectsUUIDSitePolygonsAllResponse,
+ GetV2ProjectsUUIDSitePolygonsAllError,
+ undefined,
+ {},
+ {},
+ GetV2ProjectsUUIDSitePolygonsAllPathParams
+ >({ url: "/v2/projects/{uuid}/site-polygons/all", method: "get", ...variables, signal });
export const useGetV2ProjectsUUIDSitePolygonsAll = (
variables: GetV2ProjectsUUIDSitePolygonsAllVariables,
@@ -34021,7 +34029,7 @@ export const useGetV2ProjectsUUIDSitePolygonsAll = ;
diff --git a/src/hooks/AuditStatus/useAuditLogActions.ts b/src/hooks/AuditStatus/useAuditLogActions.ts
index b859290bd..fc8aee96f 100644
--- a/src/hooks/AuditStatus/useAuditLogActions.ts
+++ b/src/hooks/AuditStatus/useAuditLogActions.ts
@@ -92,7 +92,7 @@ const useAuditLogActions = ({
const fetchCheckPolygons = async () => {
if (entityType === "Site" && record?.uuid && isSite) {
const result = await fetchGetV2SitesSiteCheckApprove({
- pathParams: { uuid: isSiteProject ? selected?.uuid : record.uuid }
+ pathParams: { site: isSiteProject ? selected?.uuid : record.uuid }
});
setCheckPolygons(result.data?.can_approve);
}
diff --git a/src/hooks/AuditStatus/useLoadEntityList.ts b/src/hooks/AuditStatus/useLoadEntityList.ts
index d0126dabf..0d5ab44e3 100644
--- a/src/hooks/AuditStatus/useLoadEntityList.ts
+++ b/src/hooks/AuditStatus/useLoadEntityList.ts
@@ -80,6 +80,7 @@ const useLoadEntityList = ({ entityUuid, entityType, buttonToogle, entityLevel }
const _entityList = (res as { data: EntityListItem[] })?.data ?? (res as EntityListItem[]);
const nameProperty = getNameProperty(entityType);
const transformEntityListItem = (item: EntityListItem) => {
+ console.log("item", item);
return {
title: item?.[nameProperty],
uuid: item?.uuid,
From 839e8a9b2b0abe94cd35fb2d2acbd52a55b7b80a Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 12:23:47 -0400
Subject: [PATCH 16/29] Improve the usage of types for texts
---
.../ResourceTabs/AuditLogTab/AuditLogTab.tsx | 5 ++-
.../components/SiteAuditLogEntityStatus.tsx | 23 +++++-------
.../CommentarySection/CommentarySection.tsx | 8 +++--
.../PolygonDrawer/PolygonDrawer.tsx | 2 +-
.../components/NurseryReportShow.tsx | 2 +-
.../components/ProjectReportShow.tsx | 2 +-
.../siteReports/components/SiteReportShow.tsx | 2 +-
.../elements/CommentaryBox/CommentaryBox.tsx | 36 +++++++++++--------
8 files changed, 41 insertions(+), 39 deletions(-)
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
index 065adabcf..0769a5651 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
@@ -7,7 +7,6 @@ import modules from "@/admin/modules";
import Text from "@/components/elements/Text/Text";
import { PROJECT, SITE } from "@/constants/entities";
import useAuditLogActions from "@/hooks/AuditStatus/useAuditLogActions";
-import { Entity } from "@/types/common";
import AuditLogSiteTabSelection from "./components/AuditLogSiteTabSelection";
import SiteAuditLogEntityStatus from "./components/SiteAuditLogEntityStatus";
@@ -17,10 +16,9 @@ import { AuditLogButtonStates } from "./constants/enum";
interface IProps extends Omit {
label?: string;
- entity?: Entity["entityName"];
}
-const AuditLogTab: FC = ({ label, entity, ...rest }) => {
+const AuditLogTab: FC = ({ label, ...rest }) => {
const [buttonToogle, setButtonToogle] = useState(AuditLogButtonStates.PROJECT);
const { record, isLoading } = useShowContext();
const basename = useBasename();
@@ -73,6 +71,7 @@ const AuditLogTab: FC = ({ label, entity, ...rest }) => {
void;
- entityType?: number;
- entityName?: string;
- buttonToogle?: number;
+ refresh: () => void;
+ buttonToogle: number;
}
interface SelectedItem {
@@ -28,12 +28,12 @@ interface SelectedItem {
}
const SiteAuditLogEntityStatus: FC = ({
+ entityType,
record,
auditLogData,
refresh,
buttonToogle
}) => {
- const entityType = buttonToogle === AuditLogButtonStates.POLYGON;
const isSite = buttonToogle === AuditLogButtonStates.SITE;
const basename = useBasename();
const getTitle = () => {
@@ -48,17 +48,12 @@ const SiteAuditLogEntityStatus: FC = ({
- {entityType ? "Polygon" : "Site"} Status and Comments
+ {entityType} Status and Comments
- Update the {entityType ? "polygon" : "site"} status, view updates, or add comments
+ Update the {entityType?.toLowerCase()} status, view updates, or add comments
-
+
{!isSite && History and Discussion for {getTitle()}}
diff --git a/src/admin/components/ResourceTabs/PolygonReviewTab/components/CommentarySection/CommentarySection.tsx b/src/admin/components/ResourceTabs/PolygonReviewTab/components/CommentarySection/CommentarySection.tsx
index 44fbbb71c..15ec3b9e2 100644
--- a/src/admin/components/ResourceTabs/PolygonReviewTab/components/CommentarySection/CommentarySection.tsx
+++ b/src/admin/components/ResourceTabs/PolygonReviewTab/components/CommentarySection/CommentarySection.tsx
@@ -5,16 +5,18 @@ import Text from "@/components/elements/Text/Text";
import Loader from "@/components/generic/Loading/Loader";
import { useGetAuthMe } from "@/generated/apiComponents";
+import { AuditLogEntity } from "../../../AuditLogTab/constants/types";
+
const CommentarySection = ({
- refresh,
record,
entity,
+ refresh,
viewCommentsList = true,
loading = false
}: {
+ record: any;
+ entity: AuditLogEntity;
refresh?: () => void;
- record?: any;
- entity?: "Project" | "SitePolygon" | "Site";
viewCommentsList?: boolean;
loading?: boolean;
}) => {
diff --git a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonDrawer/PolygonDrawer.tsx b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonDrawer/PolygonDrawer.tsx
index f185d5f06..a3ec9fa30 100644
--- a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonDrawer/PolygonDrawer.tsx
+++ b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonDrawer/PolygonDrawer.tsx
@@ -195,7 +195,7 @@ const PolygonDrawer = ({
tab="polygonReview"
checkPolygonsSite={isValidCriteriaData(criteriaValidation)}
/>
-
+
diff --git a/src/admin/modules/nurseryReports/components/NurseryReportShow.tsx b/src/admin/modules/nurseryReports/components/NurseryReportShow.tsx
index 0efd62cde..945586e52 100644
--- a/src/admin/modules/nurseryReports/components/NurseryReportShow.tsx
+++ b/src/admin/modules/nurseryReports/components/NurseryReportShow.tsx
@@ -20,7 +20,7 @@ const NurseryReportShow: FC = () => {
-
+
);
diff --git a/src/admin/modules/projectReports/components/ProjectReportShow.tsx b/src/admin/modules/projectReports/components/ProjectReportShow.tsx
index ae3069cde..6dc74f3e9 100644
--- a/src/admin/modules/projectReports/components/ProjectReportShow.tsx
+++ b/src/admin/modules/projectReports/components/ProjectReportShow.tsx
@@ -20,7 +20,7 @@ const ProjectReportShow: FC = () => {
-
+
);
diff --git a/src/admin/modules/siteReports/components/SiteReportShow.tsx b/src/admin/modules/siteReports/components/SiteReportShow.tsx
index 5eeff841f..1619e161c 100644
--- a/src/admin/modules/siteReports/components/SiteReportShow.tsx
+++ b/src/admin/modules/siteReports/components/SiteReportShow.tsx
@@ -20,7 +20,7 @@ const SiteReportShow: FC = () => {
-
+
);
diff --git a/src/components/elements/CommentaryBox/CommentaryBox.tsx b/src/components/elements/CommentaryBox/CommentaryBox.tsx
index e4626e5f3..d5ff3d90e 100644
--- a/src/components/elements/CommentaryBox/CommentaryBox.tsx
+++ b/src/components/elements/CommentaryBox/CommentaryBox.tsx
@@ -2,11 +2,16 @@ import { useT } from "@transifex/react";
import { useState } from "react";
import { When } from "react-if";
+import { AuditLogEntity } from "@/admin/components/ResourceTabs/AuditLogTab/constants/types";
import Button from "@/components/elements/Button/Button";
import TextArea from "@/components/elements/Inputs/textArea/TextArea";
import Text from "@/components/elements/Text/Text";
import Icon, { IconNames } from "@/components/extensive/Icon/Icon";
-import { fetchPostV2FileUploadMODELCOLLECTIONUUID, usePostV2AuditStatusENTITYUUID } from "@/generated/apiComponents";
+import {
+ fetchPostV2FileUploadMODELCOLLECTIONUUID,
+ PostV2AuditStatusENTITYUUIDRequestBody,
+ usePostV2AuditStatusENTITYUUID
+} from "@/generated/apiComponents";
import { AuditStatusResponse } from "@/generated/apiSchemas";
import Notification from "../Notification/Notification";
@@ -18,9 +23,16 @@ export interface CommentaryBoxProps {
mutate?: any;
refresh?: () => void;
record?: any;
- entity?: string;
+ entity?: AuditLogEntity;
}
+const getRequestPathParam = (entityType: AuditLogEntity) => {
+ if (entityType === "Polygon") {
+ return "site-polygon";
+ }
+ return entityType.toLocaleLowerCase();
+};
+
const CommentaryBox = (props: CommentaryBoxProps) => {
const { name, lastName, buttonSendOnBox } = props;
const t = useT();
@@ -91,22 +103,16 @@ const CommentaryBox = (props: CommentaryBoxProps) => {
}
};
const submitComment = () => {
- const body = new FormData();
- body.append("auditable_type", props.entity as string);
- body.append("auditable_uuid", props.record?.uuid);
- body.append("status", props.record?.status);
- body.append("comment", comment);
- body.append("type", "comment");
- files.forEach((element: File, index: number) => {
- body.append(`file[${index}]`, element);
- });
+ const body: PostV2AuditStatusENTITYUUIDRequestBody = {
+ status: props.record?.status,
+ comment: comment,
+ type: "comment"
+ };
+
setLoading(true);
sendCommentary?.({
pathParams: {
- entity:
- props.entity?.toLocaleLowerCase() == "sitepolygon"
- ? "site-polygon"
- : (props.entity?.toLocaleLowerCase() as string),
+ entity: getRequestPathParam(props.entity!),
uuid: props.record?.uuid as string
},
//@ts-ignore swagger issue
From f98f025137d32263c31b1f99143fa1afca606d84 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 12:25:47 -0400
Subject: [PATCH 17/29] use when instead of conditional
---
.../AuditLogTab/components/SiteAuditLogEntityStatus.tsx | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
index d5810d01d..e465ea13b 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
@@ -1,5 +1,6 @@
import { FC } from "react";
import { Link as RaLink, useBasename } from "react-admin";
+import { When } from "react-if";
import modules from "@/admin/modules";
import Text from "@/components/elements/Text/Text";
@@ -68,7 +69,9 @@ const SiteAuditLogEntityStatus: FC = ({
)}
- {auditLogData && }
+
+
+
);
};
From 780757636b2c1c125760169311f708a9fb0b8933 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 13:22:06 -0400
Subject: [PATCH 18/29] rename variables and delete comments
---
.../ResourceTabs/AuditLogTab/AuditLogTab.tsx | 2 +-
.../SiteAuditLogEntityStatusSide.tsx | 35 +++++++++----------
.../ResourceTabs/AuditLogTab/utils/util.ts | 8 +++++
.../PolygonStatus/StatusDisplay.tsx | 17 +++++----
.../elements/CommentaryBox/CommentaryBox.tsx | 8 +----
5 files changed, 37 insertions(+), 33 deletions(-)
create mode 100644 src/admin/components/ResourceTabs/AuditLogTab/utils/util.ts
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
index 0769a5651..a7e5573fa 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
@@ -85,7 +85,7 @@ const AuditLogTab: FC = ({ label, ...rest }) => {
getValueForStatus={valuesForStatus}
progressBarLabels={statusLabels}
mutate={mutateEntity}
- recordType={entityType}
+ entityType={entityType}
refresh={() => {
refetch();
loadEntityList();
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
index 59ba0e853..581c73971 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
@@ -1,5 +1,6 @@
import classNames from "classnames";
import { Dispatch, SetStateAction, useState } from "react";
+import { When } from "react-if";
import Dropdown from "@/components/elements/Inputs/Dropdown/Dropdown";
import Notification from "@/components/elements/Notification/Notification";
@@ -12,6 +13,7 @@ import { recentRequestData } from "@/utils/statusUtils";
import StatusDisplay from "../../PolygonReviewTab/components/PolygonStatus/StatusDisplay";
import { AuditLogEntity } from "../constants/types";
+import { getRequestPathParam } from "../utils/util";
const SiteAuditLogEntityStatusSide = ({
refresh,
@@ -20,14 +22,14 @@ const SiteAuditLogEntityStatusSide = ({
selectedPolygon,
setSelectedPolygon,
auditLogData,
- recordType = "Polygon",
+ entityType = "Polygon", //useAditLogEntity
mutate,
getValueForStatus,
progressBarLabels,
tab,
checkPolygonsSite
}: {
- recordType?: AuditLogEntity;
+ entityType: AuditLogEntity;
refresh?: () => void;
record?: any;
polygonList?: any[];
@@ -44,7 +46,7 @@ const SiteAuditLogEntityStatusSide = ({
const recentRequest = auditLogData?.find(
(item: AuditStatusResponse) => item.type == "change-request" && item.is_active
);
- const mutateUpload = recordType === "Project" ? usePostV2AuditStatusENTITYUUID : usePostV2AuditStatusENTITYUUID;
+ const mutateUpload = entityType === "Project" ? usePostV2AuditStatusENTITYUUID : usePostV2AuditStatusENTITYUUID;
const { mutate: upload } = mutateUpload({
onSuccess: () => {
setOpen(true);
@@ -59,15 +61,12 @@ const SiteAuditLogEntityStatusSide = ({
upload?.({
pathParams: {
uuid: record?.uuid,
- entity: recordType === "Polygon" ? "site-polygon" : recordType
+ entity: getRequestPathParam(entityType)
},
body: {
- // entity_uuid: record?.uuid,
status: record?.status,
- // entity: recordType === "Polygon" ? "SitePolygon" : recordType,
comment: "",
type: "change-request",
- // is_active: false,
request_removed: true
}
});
@@ -75,29 +74,29 @@ const SiteAuditLogEntityStatusSide = ({
return (
- {polygonList && polygonList?.length > 0 && (
+
{
setSelectedPolygon && setSelectedPolygon(polygonList?.find(item => item?.uuid === e[0]));
}}
/>
- )}
- {`${recordType} Status`}
+
+
{`${entityType} Status`}
- {recentRequest && (
+
@@ -106,14 +105,14 @@ const SiteAuditLogEntityStatusSide = ({
Remove
-
{recentRequestData(recentRequest)}
+
{recentRequestData(recentRequest!)}
{recentRequest?.comment}
- )}
+
{
+ if (entityType === "Polygon") {
+ return "site-polygon";
+ }
+ return entityType.toLocaleLowerCase();
+};
diff --git a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
index 64faa1446..1b4569e6c 100644
--- a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
+++ b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
@@ -8,6 +8,7 @@ import ModalConfirm from "@/components/extensive/Modal/ModalConfirm";
import { useModalContext } from "@/context/modal.provider";
import { AuditLogEntity } from "../../../AuditLogTab/constants/types";
+import { getRequestPathParam } from "../../../AuditLogTab/utils/util";
const menuPolygonOptions = [
{
@@ -144,6 +145,12 @@ const StatusDisplay = ({
);
+ const onFinallyRequest = () => {
+ refresh && refresh();
+ reloadEntity && reloadEntity();
+ closeModal();
+ };
+
const openFormModalHandlerStatus = () => {
openModal(
@@ -259,9 +264,7 @@ const StatusDisplay = ({
}, 3000);
console.error(e);
} finally {
- refresh && refresh();
- reloadEntity && reloadEntity();
- closeModal;
+ onFinallyRequest();
}
}}
/>
diff --git a/src/components/elements/CommentaryBox/CommentaryBox.tsx b/src/components/elements/CommentaryBox/CommentaryBox.tsx
index d5ff3d90e..52cd0bead 100644
--- a/src/components/elements/CommentaryBox/CommentaryBox.tsx
+++ b/src/components/elements/CommentaryBox/CommentaryBox.tsx
@@ -3,6 +3,7 @@ import { useState } from "react";
import { When } from "react-if";
import { AuditLogEntity } from "@/admin/components/ResourceTabs/AuditLogTab/constants/types";
+import { getRequestPathParam } from "@/admin/components/ResourceTabs/AuditLogTab/utils/util";
import Button from "@/components/elements/Button/Button";
import TextArea from "@/components/elements/Inputs/textArea/TextArea";
import Text from "@/components/elements/Text/Text";
@@ -26,13 +27,6 @@ export interface CommentaryBoxProps {
entity?: AuditLogEntity;
}
-const getRequestPathParam = (entityType: AuditLogEntity) => {
- if (entityType === "Polygon") {
- return "site-polygon";
- }
- return entityType.toLocaleLowerCase();
-};
-
const CommentaryBox = (props: CommentaryBoxProps) => {
const { name, lastName, buttonSendOnBox } = props;
const t = useT();
From 7a38c32d6aca860c8bfbdb58af0c71a647dd2de3 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 13:31:44 -0400
Subject: [PATCH 19/29] change tabs to be dynamic
---
.../components/AuditLogSiteTabSelection.tsx | 31 +++++++------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
index 7ea4498d3..0b353d276 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
@@ -2,34 +2,25 @@ import { FC } from "react";
import Button from "@/components/elements/Button/Button";
-import { AuditLogButtonStates } from "../constants/enum";
-
interface AuditLogSiteTabSelectionProps {
buttonToogle: number;
setButtonToogle: (buttonToogle: number) => void;
}
+const tabNames = ["Project Status", "Site Status", "Polygon Status"];
+
const AuditLogSiteTabSelection: FC = ({ buttonToogle, setButtonToogle }) => {
return (
-
-
-
+ {tabNames.map((tabName, index) => (
+
+ ))}
);
};
From 5418730bab6748eb9ee391da1bb426b5e808a3e1 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 13:35:14 -0400
Subject: [PATCH 20/29] remove extra conditional
---
src/components/elements/Inputs/Dropdown/Dropdown.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/elements/Inputs/Dropdown/Dropdown.tsx b/src/components/elements/Inputs/Dropdown/Dropdown.tsx
index 28e247b88..77ecbd9b6 100644
--- a/src/components/elements/Inputs/Dropdown/Dropdown.tsx
+++ b/src/components/elements/Inputs/Dropdown/Dropdown.tsx
@@ -183,7 +183,7 @@ const Dropdown = (props: PropsWithChildren) => {
)}
>
-
0 && options[0].meta}>
+
(value)) ?? ""
From 01f162724bd54ab45e2774ab59281ee9e74e5e86 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Wed, 12 Jun 2024 15:02:46 -0400
Subject: [PATCH 21/29] fix some undefined errors
---
.../components/SiteAuditLogEntityStatusSide.tsx | 14 ++++++++------
.../components/PolygonStatus/StatusDisplay.tsx | 7 +++----
src/utils/statusUtils.ts | 3 ++-
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
index 581c73971..cb3b50123 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
@@ -1,5 +1,5 @@
import classNames from "classnames";
-import { Dispatch, SetStateAction, useState } from "react";
+import { Dispatch, SetStateAction, useMemo, useState } from "react";
import { When } from "react-if";
import Dropdown from "@/components/elements/Inputs/Dropdown/Dropdown";
@@ -22,7 +22,7 @@ const SiteAuditLogEntityStatusSide = ({
selectedPolygon,
setSelectedPolygon,
auditLogData,
- entityType = "Polygon", //useAditLogEntity
+ entityType = "Polygon",
mutate,
getValueForStatus,
progressBarLabels,
@@ -43,9 +43,11 @@ const SiteAuditLogEntityStatusSide = ({
checkPolygonsSite?: boolean | undefined;
}) => {
const [open, setOpen] = useState(false);
- const recentRequest = auditLogData?.find(
- (item: AuditStatusResponse) => item.type == "change-request" && item.is_active
- );
+
+ const recentRequest = useMemo(() => {
+ return auditLogData?.find((item: AuditStatusResponse) => item.type == "change-request" && item.is_active);
+ }, [auditLogData]);
+
const mutateUpload = entityType === "Project" ? usePostV2AuditStatusENTITYUUID : usePostV2AuditStatusENTITYUUID;
const { mutate: upload } = mutateUpload({
onSuccess: () => {
@@ -64,7 +66,7 @@ const SiteAuditLogEntityStatusSide = ({
entity: getRequestPathParam(entityType)
},
body: {
- status: record?.status,
+ status: "",
comment: "",
type: "change-request",
request_removed: true
diff --git a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
index 1b4569e6c..492d6e78e 100644
--- a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
+++ b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
@@ -220,13 +220,12 @@ const StatusDisplay = ({
content={contentRequest}
commentArea
onClose={closeModal}
- onConfirm={async (text: any, opt) => {
- const option = menuOptionsMap[titleStatus].find(option => option.value === opt[0]);
+ onConfirm={async (text: any) => {
try {
await mutate({
- pathParams: { uuid: record?.uuid },
+ pathParams: { uuid: record?.uuid, entity: getRequestPathParam(titleStatus) },
body: {
- status: option?.status,
+ status: "",
comment: text,
type: "change-request",
is_active: true,
diff --git a/src/utils/statusUtils.ts b/src/utils/statusUtils.ts
index 87336bff9..2cea4868a 100644
--- a/src/utils/statusUtils.ts
+++ b/src/utils/statusUtils.ts
@@ -70,7 +70,8 @@ export const projectStatusLabels = [
{ id: "4", label: "Approved" }
];
-export const recentRequestData = (recentRequest: AuditStatusResponse) => {
+export const recentRequestData = (recentRequest: AuditStatusResponse | undefined) => {
+ if (!recentRequest) return "";
return `From ${recentRequest.first_name ?? ""} ${recentRequest.last_name ?? ""} on
${convertDateFormat(recentRequest.date_created) ?? ""}`;
};
From 11310af259be500fa74c2979b4bf7b4e1edf1f57 Mon Sep 17 00:00:00 2001
From: Limber Mamani Vallejos
Date: Wed, 12 Jun 2024 17:22:22 -0400
Subject: [PATCH 22/29] fix some errors
---
.../components/AuditLogSiteTabSelection.tsx | 28 +++---
.../AuditLogTab/components/AuditLogTable.tsx | 88 +++++++++----------
.../components/SiteAuditLogEntityStatus.tsx | 9 +-
.../SiteAuditLogEntityStatusSide.tsx | 2 +-
.../elements/Inputs/Dropdown/Dropdown.tsx | 4 +-
src/components/extensive/Modal/Modal.tsx | 24 +++--
.../extensive/Modal/ModalConfirm.tsx | 4 +-
src/hooks/AuditStatus/useLoadEntityList.ts | 1 -
8 files changed, 74 insertions(+), 86 deletions(-)
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
index 0b353d276..b994c99d5 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogSiteTabSelection.tsx
@@ -9,20 +9,18 @@ interface AuditLogSiteTabSelectionProps {
const tabNames = ["Project Status", "Site Status", "Polygon Status"];
-const AuditLogSiteTabSelection: FC = ({ buttonToogle, setButtonToogle }) => {
- return (
-
- {tabNames.map((tabName, index) => (
-
- ))}
-
- );
-};
+const AuditLogSiteTabSelection: FC = ({ buttonToogle, setButtonToogle }) => (
+
+ {tabNames.map((tabName, index) => (
+
+ ))}
+
+);
export default AuditLogSiteTabSelection;
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx
index c6b3b108a..929238a6b 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx
@@ -22,51 +22,49 @@ const getTextForActionTable = (item: { type: string; status: string; request_rem
const columnTitles = ["Date", "User", "Action", "Comments", "Attachments"];
-const AuditLogTable: FC<{ auditLogData: { data: AuditStatusResponse[] } }> = ({ auditLogData }) => {
- return (
- <>
-
- {columnTitles.map(title => (
-
- {title}
+const AuditLogTable: FC<{ auditLogData: { data: AuditStatusResponse[] } }> = ({ auditLogData }) => (
+ <>
+
+ {columnTitles.map(title => (
+
+ {title}
+
+ ))}
+
+
+ {auditLogData?.data?.map((item: AuditStatusResponse, index: number) => (
+
+
+ {convertDateFormat(item?.date_created)}
- ))}
-
-
- {auditLogData?.data?.map((item: AuditStatusResponse, index: number) => (
-
-
- {convertDateFormat(item?.date_created)}
-
-
- {`${item.first_name} ${item.last_name}`}
-
-
- {getTextForActionTable(item as { type: string; status: string; request_removed: boolean })}
-
-
- {item.comment || "-"}
-
-
- {item?.attachments?.map((attachmentItem: V2FileRead) => (
- {
- attachmentItem.url && window.open(attachmentItem.url, "_blank");
- }}
- >
- {attachmentItem.file_name}
-
- ))}
-
-
- ))}
-
- >
- );
-};
+
+ {`${item.first_name} ${item.last_name}`}
+
+
+ {getTextForActionTable(item as { type: string; status: string; request_removed: boolean })}
+
+
+ {item.comment ?? "-"}
+
+
+ {item?.attachments?.map((attachmentItem: V2FileRead) => (
+ {
+ attachmentItem.url && window.open(attachmentItem.url, "_blank");
+ }}
+ >
+ {attachmentItem.file_name}
+
+ ))}
+
+
+ ))}
+
+ >
+);
export default AuditLogTable;
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
index e465ea13b..1311e1463 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx
@@ -37,13 +37,8 @@ const SiteAuditLogEntityStatus: FC = ({
}) => {
const isSite = buttonToogle === AuditLogButtonStates.SITE;
const basename = useBasename();
- const getTitle = () => {
- if (!record?.title) {
- return record?.name;
- } else {
- return record?.title;
- }
- };
+
+ const getTitle = () => record?.title ?? record?.name;
return (
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
index cb3b50123..107b28ce9 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx
@@ -55,7 +55,7 @@ const SiteAuditLogEntityStatusSide = ({
setTimeout(() => {
setOpen(false);
}, 3000);
- refresh && refresh();
+ refresh?.();
}
});
diff --git a/src/components/elements/Inputs/Dropdown/Dropdown.tsx b/src/components/elements/Inputs/Dropdown/Dropdown.tsx
index 77ecbd9b6..4230207a7 100644
--- a/src/components/elements/Inputs/Dropdown/Dropdown.tsx
+++ b/src/components/elements/Inputs/Dropdown/Dropdown.tsx
@@ -146,7 +146,7 @@ const Dropdown = (props: PropsWithChildren
) => {
"awaiting-approval": "bg-tertiary-600"
};
- return colorMap[option] || "";
+ return colorMap[option] ?? "";
};
const verifyDisableOption = (title: string) => {
@@ -183,7 +183,7 @@ const Dropdown = (props: PropsWithChildren) => {
)}
>
-
+
(value)) ?? ""
diff --git a/src/components/extensive/Modal/Modal.tsx b/src/components/extensive/Modal/Modal.tsx
index 95a65d67a..ac759367e 100644
--- a/src/components/extensive/Modal/Modal.tsx
+++ b/src/components/extensive/Modal/Modal.tsx
@@ -17,19 +17,17 @@ export interface ModalProps extends ModalBaseProps {
secondaryButtonProps?: IButtonProps;
}
-export const ModalBase: FC
= ({ children, className, ...rest }) => {
- return (
-
- {children}
-
- );
-};
+export const ModalBase: FC = ({ children, className, ...rest }) => (
+
+ {children}
+
+);
const Modal: FC = ({
iconProps,
diff --git a/src/components/extensive/Modal/ModalConfirm.tsx b/src/components/extensive/Modal/ModalConfirm.tsx
index 4e37e846e..5d0ed7271 100644
--- a/src/components/extensive/Modal/ModalConfirm.tsx
+++ b/src/components/extensive/Modal/ModalConfirm.tsx
@@ -83,7 +83,7 @@ const ModalConfirm: FC = ({
/>
- Please select an option
+ {t("Please select an option")}
@@ -120,7 +120,7 @@ const ModalConfirm: FC = ({
setTimeout(() => setShowError(false), 3000);
return;
}
- onConfirm(data, selectedOption || [0]);
+ onConfirm(data, selectedOption ?? [0]);
onClose();
}}
>
diff --git a/src/hooks/AuditStatus/useLoadEntityList.ts b/src/hooks/AuditStatus/useLoadEntityList.ts
index 0d5ab44e3..d0126dabf 100644
--- a/src/hooks/AuditStatus/useLoadEntityList.ts
+++ b/src/hooks/AuditStatus/useLoadEntityList.ts
@@ -80,7 +80,6 @@ const useLoadEntityList = ({ entityUuid, entityType, buttonToogle, entityLevel }
const _entityList = (res as { data: EntityListItem[] })?.data ?? (res as EntityListItem[]);
const nameProperty = getNameProperty(entityType);
const transformEntityListItem = (item: EntityListItem) => {
- console.log("item", item);
return {
title: item?.[nameProperty],
uuid: item?.uuid,
From 48c606c908225dfa323b89a02f477d9ee913ccf1 Mon Sep 17 00:00:00 2001
From: Limber Mamani Vallejos
Date: Wed, 12 Jun 2024 17:30:13 -0400
Subject: [PATCH 23/29] fix props.refresh
---
src/components/elements/CommentaryBox/CommentaryBox.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/elements/CommentaryBox/CommentaryBox.tsx b/src/components/elements/CommentaryBox/CommentaryBox.tsx
index 52cd0bead..80c66b42c 100644
--- a/src/components/elements/CommentaryBox/CommentaryBox.tsx
+++ b/src/components/elements/CommentaryBox/CommentaryBox.tsx
@@ -52,7 +52,7 @@ const CommentaryBox = (props: CommentaryBoxProps) => {
setComment("");
setError("");
setFiles([]);
- props.refresh && props.refresh();
+ props.refresh?.();
setLoading(false);
}
});
From 40beace720d9a9a1e802aba9593408a3fb68b855 Mon Sep 17 00:00:00 2001
From: Dotty
Date: Wed, 12 Jun 2024 17:50:53 -0400
Subject: [PATCH 24/29] fix storybook
---
.../elements/CommentaryBox/CommentaryBox.stories.tsx | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/components/elements/CommentaryBox/CommentaryBox.stories.tsx b/src/components/elements/CommentaryBox/CommentaryBox.stories.tsx
index b84671616..602763c3c 100644
--- a/src/components/elements/CommentaryBox/CommentaryBox.stories.tsx
+++ b/src/components/elements/CommentaryBox/CommentaryBox.stories.tsx
@@ -1,5 +1,4 @@
import { Meta, StoryObj } from "@storybook/react";
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { CommentaryBoxProps as Props } from "./CommentaryBox";
import Component from "./CommentaryBox";
@@ -12,14 +11,10 @@ const meta: Meta = {
export default meta;
type Story = StoryObj;
-const client = new QueryClient();
-
export const Default: Story = {
render: (args: Props) => (
-
-
-
+
),
args: {
From ef7b55665893a6be6a19c314bc5e83b1752d2d8b Mon Sep 17 00:00:00 2001
From: Dotty
Date: Wed, 12 Jun 2024 18:02:35 -0400
Subject: [PATCH 25/29] edit commentaryBox stories
---
.../elements/CommentaryBox/CommentaryBox.stories.tsx | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/components/elements/CommentaryBox/CommentaryBox.stories.tsx b/src/components/elements/CommentaryBox/CommentaryBox.stories.tsx
index 602763c3c..55829e34a 100644
--- a/src/components/elements/CommentaryBox/CommentaryBox.stories.tsx
+++ b/src/components/elements/CommentaryBox/CommentaryBox.stories.tsx
@@ -1,20 +1,23 @@
import { Meta, StoryObj } from "@storybook/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { CommentaryBoxProps as Props } from "./CommentaryBox";
import Component from "./CommentaryBox";
-
const meta: Meta = {
title: "Components/Elements/CommentaryBox",
component: Component
};
-
export default meta;
type Story = StoryObj;
+const client = new QueryClient();
+
export const Default: Story = {
render: (args: Props) => (
-
+
+
+
),
args: {
From d59ec3643b9da022ac0a235270d6cd6e69c3c300 Mon Sep 17 00:00:00 2001
From: Limber Mamani Vallejos
Date: Wed, 12 Jun 2024 18:07:44 -0400
Subject: [PATCH 26/29] fix spread error
---
src/components/elements/CommentaryBox/CommentaryBox.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/elements/CommentaryBox/CommentaryBox.tsx b/src/components/elements/CommentaryBox/CommentaryBox.tsx
index 80c66b42c..71c9f7eb3 100644
--- a/src/components/elements/CommentaryBox/CommentaryBox.tsx
+++ b/src/components/elements/CommentaryBox/CommentaryBox.tsx
@@ -161,7 +161,7 @@ const CommentaryBox = (props: CommentaryBoxProps) => {
0}>
- {...files.map((file: any) => (
+ {files.map((file: any) => (
Date: Thu, 13 Jun 2024 00:16:10 -0400
Subject: [PATCH 27/29] improve code
---
.../ResourceTabs/AuditLogTab/AuditLogTab.tsx | 2 +-
.../SiteAuditLogEntityStatusSide.tsx | 2 +-
.../components/SiteAuditLogProjectStatus.tsx | 75 ++++---------------
.../PolygonStatus/StatusDisplay.tsx | 4 +-
.../elements/CommentaryBox/CommentaryBox.tsx | 6 +-
5 files changed, 20 insertions(+), 69 deletions(-)
diff --git a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
index a7e5573fa..967ddd7e3 100644
--- a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
+++ b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
@@ -67,7 +67,7 @@ const AuditLogTab: FC
= ({ label, ...rest }) => {
/>
-
+
{`${entityType} Status`}
void;
auditLogData?: { data: AuditStatusResponse[] };
}
-export const gridData = [
- {
- id: "1",
- date: "28/11/2023 09.39",
- user: "Jessica Chaimers",
- site: null,
- status: "Need More Information",
- comentary: null
- },
- {
- id: "2",
- date: "28/11/2023 09.39",
- user: "Teresa Muthoni",
- site: null,
- status: "Need More Information",
- comentary:
- "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
- },
- {
- id: "3",
- date: "28/11/2023 09.39",
- user: "Jessica Chaimers",
- site: null,
- status: "Awaiting Approval",
- comentary: null
- },
- {
- id: "4",
- date: "28/11/2023 09.39",
- user: "Jessica Chaimers",
- site: null,
- status: "Awaiting Approval",
- comentary: null
- },
- {
- id: "5",
- date: "28/11/2023 09.39",
- user: "Jessica Chaimers",
- site: null,
- status: "Awaiting Approval",
- comentary: null
- }
-];
-
-const SiteAuditLogProjectStatus: FC = ({ record, auditLogData, refresh }) => {
- return (
-
-
-
- Project Status and Comments
-
-
- Update the project status, view updates, or add comments
-
-
-
-
History and Discussion for {record && record?.name}
- {auditLogData &&
}
+const SiteAuditLogProjectStatus: FC
= ({ record, auditLogData }) => (
+
+
+
+ Project Status and Comments
+
+
+ Update the project status, view updates, or add comments
+
- );
-};
+
History and Discussion for {record && record?.name}
+ {auditLogData &&
}
+
+);
export default SiteAuditLogProjectStatus;
diff --git a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
index a0aa03e63..aa6fac8a9 100644
--- a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
+++ b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx
@@ -156,8 +156,8 @@ const StatusDisplay = ({
);
const onFinallyRequest = () => {
- refresh && refresh();
- reloadEntity && reloadEntity();
+ refresh?.();
+ reloadEntity();
closeModal();
};
diff --git a/src/components/elements/CommentaryBox/CommentaryBox.tsx b/src/components/elements/CommentaryBox/CommentaryBox.tsx
index 71c9f7eb3..477d01afa 100644
--- a/src/components/elements/CommentaryBox/CommentaryBox.tsx
+++ b/src/components/elements/CommentaryBox/CommentaryBox.tsx
@@ -128,8 +128,8 @@ const CommentaryBox = (props: CommentaryBoxProps) => {
- {(name && name[0]) ?? ""}
- {(lastName && lastName[0]) ?? ""}
+ {name?.[0] ?? ""}
+ {lastName?.[0] ?? ""}
From 27f74ec62955f7691c05017e1d586699bf00b0d5 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Thu, 13 Jun 2024 00:28:19 -0400
Subject: [PATCH 28/29] update tests
---
.../__snapshots__/CommentaryBox.stories.storyshot | 3 ++-
.../Modal/__snapshots__/ModalWithLogo.stories.storyshot | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/components/elements/CommentaryBox/__snapshots__/CommentaryBox.stories.storyshot b/src/components/elements/CommentaryBox/__snapshots__/CommentaryBox.stories.storyshot
index ae626cd83..ac1cc1756 100644
--- a/src/components/elements/CommentaryBox/__snapshots__/CommentaryBox.stories.storyshot
+++ b/src/components/elements/CommentaryBox/__snapshots__/CommentaryBox.stories.storyshot
@@ -82,7 +82,8 @@ exports[`Storyshots Components/Elements/CommentaryBox Default 1`] = `
className="text-nowrap text-right text-xs text-grey-500"
>
0
- /255 characters
+ /255
+ characters
diff --git a/src/components/extensive/Modal/__snapshots__/ModalWithLogo.stories.storyshot b/src/components/extensive/Modal/__snapshots__/ModalWithLogo.stories.storyshot
index 635cb005a..a68541443 100644
--- a/src/components/extensive/Modal/__snapshots__/ModalWithLogo.stories.storyshot
+++ b/src/components/extensive/Modal/__snapshots__/ModalWithLogo.stories.storyshot
@@ -225,7 +225,8 @@ exports[`Storyshots Components/Extensive/Modal/ModalWithLogo Default 1`] = `
className="text-nowrap text-right text-xs text-grey-500"
>
0
- /255 characters
+ /255
+ characters
From 3e069bebf1175e500a421da3d5d552757d302a03 Mon Sep 17 00:00:00 2001
From: Jose Carlos Laura Ramirez
Date: Thu, 13 Jun 2024 00:51:50 -0400
Subject: [PATCH 29/29] readd translations
---
src/components/extensive/Modal/ModalConfirm.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/extensive/Modal/ModalConfirm.tsx b/src/components/extensive/Modal/ModalConfirm.tsx
index 5d0ed7271..102a9d17a 100644
--- a/src/components/extensive/Modal/ModalConfirm.tsx
+++ b/src/components/extensive/Modal/ModalConfirm.tsx
@@ -109,7 +109,7 @@ const ModalConfirm: FC = ({