refactor: remove CustomSelect component and update SearchInput and SessionComments for improved functionality
This commit is contained in:
@@ -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;
|
||||
@@ -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>
|
||||
|
||||
@@ -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 = "";
|
||||
|
||||
@@ -18,7 +18,7 @@ function EditTable({ table }: { table: Server }) {
|
||||
return api.put(`servers/${table.id}`, {
|
||||
json: {
|
||||
name: tableName,
|
||||
location: tableDescription,
|
||||
description: tableDescription,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
@@ -80,6 +80,7 @@ function SessionsPage() {
|
||||
value={search || ""}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
onEnter={() => {}}
|
||||
setSearch={setSearch}
|
||||
/>
|
||||
<div className="flex gap-[0.556vw]">
|
||||
<MultySelect
|
||||
|
||||
Reference in New Issue
Block a user