From 4d7297eeea483a7749f38af3dcd0d28cbc9330f8 Mon Sep 17 00:00:00 2001 From: Dotty Date: Fri, 7 Jun 2024 08:48:04 -0400 Subject: [PATCH] fix deploy --- .../elements/CommentaryBox/CommentaryBox.tsx | 143 +----------------- 1 file changed, 5 insertions(+), 138 deletions(-) diff --git a/src/components/elements/CommentaryBox/CommentaryBox.tsx b/src/components/elements/CommentaryBox/CommentaryBox.tsx index 4527a4822..8385e66fe 100644 --- a/src/components/elements/CommentaryBox/CommentaryBox.tsx +++ b/src/components/elements/CommentaryBox/CommentaryBox.tsx @@ -1,115 +1,32 @@ import { useT } from "@transifex/react"; -import { useState } from "react"; import { When } from "react-if"; 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 { usePostV2AuditStatus } from "@/generated/apiComponents"; - -import Notification from "../Notification/Notification"; export interface CommentaryBoxProps { name: string; lastName: string; buttonSendOnBox?: boolean; mutate?: any; - refresh?: () => void; + refresh?: any; record?: any; entity?: string; } const CommentaryBox = (props: CommentaryBoxProps) => { - const { name, lastName, buttonSendOnBox, refresh, record, entity } = props; - const { mutate: sendCommentary } = usePostV2AuditStatus(); - const [files, setFiles] = useState([]); - const [comment, setComment] = useState(""); - const [error, setError] = useState(""); - const [charCount, setCharCount] = useState(0); - const [showNotification, setShowNotification] = useState(false); - const [loading, setLoading] = useState(false); - const [warning, setWarning] = useState(""); + const { name, lastName, buttonSendOnBox } = props; const t = useT(); - const validFileTypes = [ - "application/pdf", - "application/vnd.ms-excel", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - "application/msword", - "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - "image/jpeg", - "image/png", - "image/tiff" - ]; - const maxFileSize = 10 * 1024 * 1024; - const maxFiles = 5; - const handleFileChange = (e: React.ChangeEvent) => { - if (e.target.files) { - const file = e.target.files[0]; - if (files.length >= maxFiles) { - setError("You can upload a maximum of 5 files."); - return; - } - if (!validFileTypes.includes(file?.type)) { - setError("Invalid file type. Only PDF, XLS, DOC, XLSX, DOCX, JPG, PNG, and TIFF are allowed."); - return; - } - if (file.size > maxFileSize) { - setError("File size must be less than 10MB."); - return; - } - setFiles(prevFiles => [...prevFiles, file]); - setError(""); - } - }; - 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); - }); - setLoading(true); - sendCommentary?.( - { - //@ts-ignore swagger issue - body - }, - { - onSuccess: () => { - setShowNotification(true); - setTimeout(() => { - setShowNotification(false); - }, 3000); - setComment(""); - setError(""); - setFiles([]); - refresh && refresh(); - setLoading(false); - } - } - ); - }; - const handleCommentChange = (e: any) => { - setComment(e.target.value); - setCharCount(e.target.value.length); - if (charCount >= 255) { - setWarning("Your comment exceeds 255 characters."); - } else { - setWarning(""); - } - }; return (
- {name?.[0]} - {lastName?.[0]} + {name[0]} + {lastName[0]}