From 44077026805ea90297669acdf909abb078633353 Mon Sep 17 00:00:00 2001 From: c00b3r Date: Mon, 9 Jun 2025 17:59:18 +0500 Subject: [PATCH] feat: implement SessionComments component for user feedback and integrate it into SessionModal --- src/components/ModalContainer.tsx | 16 +-- src/components/SessionComments.tsx | 100 +++++++++++++++++++ src/components/icons/SendIcon.tsx | 21 ++++ src/components/modals/CreateSessionModal.tsx | 1 + src/components/modals/SessionModal.tsx | 22 +--- src/pages/DashboardPage.tsx | 5 - 6 files changed, 132 insertions(+), 33 deletions(-) create mode 100644 src/components/SessionComments.tsx create mode 100644 src/components/icons/SendIcon.tsx diff --git a/src/components/ModalContainer.tsx b/src/components/ModalContainer.tsx index f812998..8c112f2 100644 --- a/src/components/ModalContainer.tsx +++ b/src/components/ModalContainer.tsx @@ -45,7 +45,7 @@ function ModalContainer() { initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} - className='h-full' + className="h-full" >
-
-
+
+
setModal(null)} />
{modal} setModal(null)} > - + diff --git a/src/components/SessionComments.tsx b/src/components/SessionComments.tsx new file mode 100644 index 0000000..fff4ad3 --- /dev/null +++ b/src/components/SessionComments.tsx @@ -0,0 +1,100 @@ +import { useRef } from "react"; +import SendIcon from "./icons/SendIcon"; +import NewButton from "./NewButton"; +import { IComment } from "../types/IComments"; +import { useQueryClient } from "@tanstack/react-query"; + +function SessionComments({ + comments, + sessionId, +}: { + comments: IComment[]; + sessionId: string; +}) { + const textareaRef = useRef(null); + const formRef = useRef(null); + const queryClient = useQueryClient(); + + + const handleTextareaInput = () => { + const textarea = textareaRef.current; + const form = formRef.current; + if (!textarea || !form) return; + + textarea.style.height = "auto"; + form.style.height = "auto"; + + const newHeight = Math.min( + textarea.scrollHeight + (32 / 1440) * innerWidth, + (225 / 1440) * innerWidth + ); + const formHeight = Math.min( + form.clientHeight >= 80 ? newHeight + (32 / 1440) * innerWidth : 80, + (225 / 1440) * innerWidth + ); + textarea.style.height = `${newHeight}px`; + form.style.height = `${formHeight}px`; + + textarea.style.overflowY = + textarea.scrollHeight > (225 / 1440) * innerWidth ? "auto" : "hidden"; + }; + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + + console.log("submit"); + }; + + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === "Enter" && !e.shiftKey) { + e.preventDefault(); + handleSubmit(e as unknown as React.FormEvent); + } + }; + + return ( +
+
+ {comments.length > 0 ? ( +
Комменты
+ ) : ( +
+ ghost +
+

Оставьте заметку

+

+ {`В дальнейшем это поможет быстро найти + клиента и не запутаться.`} +

+
+
+ )} +
+
+