refactor: remove CustomSelect component and update SearchInput and SessionComments for improved functionality

This commit is contained in:
2025-06-17 14:48:23 +05:00
parent facb76e904
commit 39dd596e01
5 changed files with 19 additions and 30 deletions
-27
View File
@@ -1,27 +0,0 @@
import { useEffect, useState } from "react";
interface Props {
options: string[];
customOption?: React.ReactNode;
}
function CustomSelect({ options, customOption }: Props) {
const [selectedOption, setSelectedOption] = useState<string | null>(null);
// Сбрасываем selectedOption при изменении options
useEffect(() => {
setSelectedOption(null);
}, [options]);
return (
<div>
{options.map((option, index) => (
<div key={index} onClick={() => setSelectedOption(option)}>
{customOption ? customOption(option) : option}
</div>
))}
</div>
);
}
export default CustomSelect;
+11 -1
View File
@@ -7,6 +7,7 @@ import clsx from "clsx";
function SearchInput(
props: React.InputHTMLAttributes<HTMLInputElement> & {
onEnter?: () => void;
setSearch: React.Dispatch<React.SetStateAction<string | null>>;
}
) {
const ref = useRef<HTMLInputElement>(null);
@@ -47,7 +48,16 @@ function SearchInput(
// }
// }}
>
<div className="text-[#7D7D7D] size-[1.111vw]">
<div
className="text-[#7D7D7D] size-[1.111vw]"
onClick={() => {
if (ref.current) {
ref.current.value = "";
ref.current.focus();
props.setSearch(ref.current.value);
}
}}
>
<CloseIcon />
</div>
</button>
+6 -1
View File
@@ -72,7 +72,12 @@ function SessionComments({ sessionId }: { sessionId: string }) {
e.preventDefault();
const textarea = textareaRef.current;
if (!textarea?.value || textarea.value.length > 200) return;
if (
!textarea?.value ||
textarea.value.length > 200 ||
textarea.value.trim() === ""
)
return;
createComment(textarea.value);
textarea.value = "";
+1 -1
View File
@@ -18,7 +18,7 @@ function EditTable({ table }: { table: Server }) {
return api.put(`servers/${table.id}`, {
json: {
name: tableName,
location: tableDescription,
description: tableDescription,
},
});
},
+1
View File
@@ -80,6 +80,7 @@ function SessionsPage() {
value={search || ""}
onChange={(e) => setSearch(e.target.value)}
onEnter={() => {}}
setSearch={setSearch}
/>
<div className="flex gap-[0.556vw]">
<MultySelect