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..967ddd7e3 100644 --- a/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx +++ b/src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx @@ -1,94 +1,104 @@ -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 { Button, Link, TabbedShowLayout, TabProps, useBasename, useShowContext } from "react-admin"; import { When } from "react-if"; import modules from "@/admin/modules"; -import { V2AdminUserRead } from "@/generated/apiSchemas"; -import { Entity } from "@/types/common"; +import Text from "@/components/elements/Text/Text"; +import { PROJECT, SITE } from "@/constants/entities"; +import useAuditLogActions from "@/hooks/AuditStatus/useAuditLogActions"; + +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"]; } -interface FeedbackProps { - comment: string | undefined; -} +const AuditLogTab: FC = ({ label, ...rest }) => { + const [buttonToogle, setButtonToogle] = useState(AuditLogButtonStates.PROJECT); + const { record, isLoading } = useShowContext(); + const basename = useBasename(); -const Feedback: FC = ({ comment }) => { - if (comment == null) { - return <>-; - } + const { + mutateEntity, + valuesForStatus, + statusLabels, + entityType, + entityListItem, + loadEntityList, + selected, + setSelected, + auditLogData, + refetch, + checkPolygonsSite + } = useAuditLogActions({ + record, + buttonToogle, + entityLevel: record?.project ? SITE : PROJECT + }); - return ( - <> - {comment.split("\n").map(fragment => ( - <> - {fragment} -
- - ))} - - ); -}; - -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("-", " "); + + + + + + Project Status + + Update the site status, view updates, or add comments + + + ))} + +); + +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..929238a6b --- /dev/null +++ b/src/admin/components/ResourceTabs/AuditLogTab/components/AuditLogTable.tsx @@ -0,0 +1,70 @@ +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 columnTitles = ["Date", "User", "Action", "Comments", "Attachments"]; + +const AuditLogTable: FC<{ auditLogData: { data: AuditStatusResponse[] } }> = ({ auditLogData }) => ( + <> +
+ {columnTitles.map(title => ( + + {title} + + ))} +
+
+ {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..1311e1463 --- /dev/null +++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatus.tsx @@ -0,0 +1,74 @@ +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"; +import { AuditStatusResponse } from "@/generated/apiSchemas"; + +import CommentarySection from "../../PolygonReviewTab/components/CommentarySection/CommentarySection"; +import { AuditLogButtonStates } from "../constants/enum"; +import { AuditLogEntity } from "../constants/types"; +import AuditLogTable from "./AuditLogTable"; + +export interface SiteAuditLogEntityStatusProps { + entityType: AuditLogEntity; + record: SelectedItem | null; + auditLogData?: { data: AuditStatusResponse[] }; + refresh: () => void; + buttonToogle: number; +} + +interface SelectedItem { + title?: string | undefined; + name?: string | undefined; + uuid?: string | undefined; + value?: string | undefined; + meta?: string | undefined; + status?: string | undefined; +} + +const SiteAuditLogEntityStatus: FC = ({ + entityType, + record, + auditLogData, + refresh, + buttonToogle +}) => { + const isSite = buttonToogle === AuditLogButtonStates.SITE; + const basename = useBasename(); + + const getTitle = () => record?.title ?? record?.name; + + return ( +
+
+ + {entityType} Status and Comments + + + Update the {entityType?.toLowerCase()} status, view updates, or add comments + + +
+
+ {!isSite && History and Discussion for {getTitle()}} + {isSite && ( + + + {getTitle()} + + + )} +
+ + + +
+ ); +}; + +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..1c760afa6 --- /dev/null +++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogEntityStatusSide.tsx @@ -0,0 +1,129 @@ +import classNames from "classnames"; +import { Dispatch, SetStateAction, useMemo, useState } from "react"; +import { When } from "react-if"; + +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 { usePostV2AuditStatusENTITYUUID } 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"; +import { AuditLogEntity } from "../constants/types"; +import { getRequestPathParam } from "../utils/util"; + +const SiteAuditLogEntityStatusSide = ({ + refresh, + record, + polygonList, + selectedPolygon, + setSelectedPolygon, + auditLogData, + entityType = "Polygon", + mutate, + getValueForStatus, + progressBarLabels, + tab, + checkPolygonsSite +}: { + entityType: AuditLogEntity; + 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; +}) => { + const [open, setOpen] = useState(false); + + 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: () => { + setOpen(true); + setTimeout(() => { + setOpen(false); + }, 3000); + refresh?.(); + } + }); + + const deactivateRecentRequest = async () => { + upload?.({ + pathParams: { + uuid: record?.uuid, + entity: getRequestPathParam(entityType) + }, + body: { + status: "", + comment: "", + type: "change-request", + request_removed: true + } + }); + }; + + return ( +
+ + { + setSelectedPolygon && setSelectedPolygon(polygonList?.find(item => item?.uuid === e[0])); + }} + /> + + {`${entityType} Status`} + + +
+
+
+ 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..1b9195e7c --- /dev/null +++ b/src/admin/components/ResourceTabs/AuditLogTab/components/SiteAuditLogProjectStatus.tsx @@ -0,0 +1,28 @@ +import { FC } from "react"; + +import Text from "@/components/elements/Text/Text"; +import { AuditStatusResponse, ProjectLiteRead } from "@/generated/apiSchemas"; + +import AuditLogTable from "./AuditLogTable"; + +export interface SiteAuditLogProjectStatusProps { + record?: ProjectLiteRead | null; + auditLogData?: { data: AuditStatusResponse[] }; +} + +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/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/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/AuditLogTab/utils/util.ts b/src/admin/components/ResourceTabs/AuditLogTab/utils/util.ts new file mode 100644 index 000000000..eba1a7a61 --- /dev/null +++ b/src/admin/components/ResourceTabs/AuditLogTab/utils/util.ts @@ -0,0 +1,8 @@ +import { AuditLogEntity } from "../constants/types"; + +export const getRequestPathParam = (entityType: AuditLogEntity) => { + if (entityType === "Polygon") { + return "site-polygon"; + } + return entityType.toLocaleLowerCase(); +}; 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/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx index fdbaccb61..aa6fac8a9 100644 --- a/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx +++ b/src/admin/components/ResourceTabs/PolygonReviewTab/components/PolygonStatus/StatusDisplay.tsx @@ -8,30 +8,29 @@ 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"; +import { getRequestPathParam } from "../../../AuditLogTab/utils/util"; + 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 = [ @@ -94,7 +93,7 @@ const menuProjectOptions = [ ]; export interface StatusProps { - titleStatus: "Site" | "Project" | "Polygon"; + titleStatus: AuditLogEntity; mutate?: any; record?: any; refresh?: () => void; @@ -102,7 +101,6 @@ export interface StatusProps { refetchPolygon?: () => void; tab?: string; checkPolygonsSite?: boolean | undefined; - viewPD?: boolean; } const menuOptionsMap = { @@ -130,8 +128,7 @@ const StatusDisplay = ({ name, record, checkPolygonsSite, - tab, - viewPD + tab }: StatusProps) => { const { refetch: reloadEntity } = useShowContext(); const [notificationStatus, setNotificationStatus] = useState<{ @@ -157,16 +154,20 @@ const StatusDisplay = ({ {DescriptionRequestMap[titleStatus]} {name}? ); - const filterViewPd = viewPD - ? menuOptionsMap[titleStatus].filter(option => option.viewPd === true) - : menuOptionsMap[titleStatus]; + + const onFinallyRequest = () => { + refresh?.(); + reloadEntity(); + closeModal(); + }; + const openFormModalHandlerStatus = () => { openModal( option.value === opt[0]); try { await mutate({ - pathParams: { uuid: record?.uuid }, + pathParams: { + uuid: record?.uuid, + entity: getRequestPathParam(titleStatus) + }, body: { status: option?.status, comment: text, @@ -212,9 +216,7 @@ const StatusDisplay = ({ }, 3000); console.error(e); } finally { - refresh?.(); - reloadEntity?.(); - closeModal?.(); + onFinallyRequest(); } }} /> @@ -228,13 +230,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, @@ -272,9 +273,7 @@ const StatusDisplay = ({ }, 3000); console.error(e); } finally { - refresh?.(); - reloadEntity?.(); - closeModal?.(); + onFinallyRequest(); } }} /> 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.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: { diff --git a/src/components/elements/CommentaryBox/CommentaryBox.tsx b/src/components/elements/CommentaryBox/CommentaryBox.tsx index 8a05ee505..477d01afa 100644 --- a/src/components/elements/CommentaryBox/CommentaryBox.tsx +++ b/src/components/elements/CommentaryBox/CommentaryBox.tsx @@ -2,10 +2,18 @@ import { useT } from "@transifex/react"; 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"; import Icon, { IconNames } from "@/components/extensive/Icon/Icon"; +import { + fetchPostV2FileUploadMODELCOLLECTIONUUID, + PostV2AuditStatusENTITYUUIDRequestBody, + usePostV2AuditStatusENTITYUUID +} from "@/generated/apiComponents"; +import { AuditStatusResponse } from "@/generated/apiSchemas"; import Notification from "../Notification/Notification"; @@ -16,19 +24,46 @@ export interface CommentaryBoxProps { mutate?: any; refresh?: () => void; record?: any; - entity?: string; + entity?: AuditLogEntity; } const CommentaryBox = (props: CommentaryBoxProps) => { - const { name, lastName, buttonSendOnBox, record, entity } = props; + const { name, lastName, buttonSendOnBox } = props; + const t = useT(); + + const { mutate: sendCommentary } = usePostV2AuditStatusENTITYUUID({ + onSuccess: (res: AuditStatusResponse) => { + const resAuditlog = res as { data: { uuid: string } }; + const bodyFiles = new FormData(); + files.forEach(element => { + if (element instanceof File) { + bodyFiles.append("upload_file", element); + fetchPostV2FileUploadMODELCOLLECTIONUUID({ + //@ts-ignore swagger issue + body: bodyFiles, + pathParams: { model: "audit-status", collection: "attachments", uuid: resAuditlog.data.uuid as any } + }); + } + }); + setShowNotification(true); + setTimeout(() => { + setShowNotification(false); + }, 3000); + setComment(""); + setError(""); + setFiles([]); + props.refresh?.(); + setLoading(false); + } + }); const [files, setFiles] = useState([]); const [comment, setComment] = useState(""); const [error, setError] = useState(""); const [charCount, setCharCount] = useState(0); - const [showNotification] = useState(false); + const [showNotification, setShowNotification] = useState(false); const [loading, setLoading] = useState(false); const [warning, setWarning] = useState(""); - const t = useT(); + const validFileTypes = [ "application/pdf", "application/vnd.ms-excel", @@ -41,6 +76,7 @@ const CommentaryBox = (props: CommentaryBoxProps) => { ]; const maxFileSize = 10 * 1024 * 1024; const maxFiles = 5; + const handleFileChange = (e: React.ChangeEvent) => { if (e.target.files) { const file = e.target.files[0]; @@ -61,17 +97,23 @@ const CommentaryBox = (props: CommentaryBoxProps) => { } }; const submitComment = () => { - const body = new FormData(); - body.append("entity_uuid", record?.uuid); - body.append("status", record?.status); - body.append("entity", entity as string); - 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: getRequestPathParam(props.entity!), + uuid: props.record?.uuid as string + }, + //@ts-ignore swagger issue + body + }); }; + const handleCommentChange = (e: any) => { setComment(e.target.value); setCharCount(e.target.value.length); @@ -81,14 +123,13 @@ const CommentaryBox = (props: CommentaryBoxProps) => { setWarning(""); } }; - return (
- {name?.[0]} - {lastName?.[0]} + {name?.[0] ?? ""} + {lastName?.[0] ?? ""}