diff --git a/src/components/CustomSelect.tsx b/src/components/CustomSelect.tsx deleted file mode 100644 index 8e08b73..0000000 --- a/src/components/CustomSelect.tsx +++ /dev/null @@ -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(null); - - // Сбрасываем selectedOption при изменении options - useEffect(() => { - setSelectedOption(null); - }, [options]); - - return ( -
- {options.map((option, index) => ( -
setSelectedOption(option)}> - {customOption ? customOption(option) : option} -
- ))} -
- ); -} - -export default CustomSelect; \ No newline at end of file diff --git a/src/components/SearchInput.tsx b/src/components/SearchInput.tsx index 5b93e18..0d96133 100644 --- a/src/components/SearchInput.tsx +++ b/src/components/SearchInput.tsx @@ -7,6 +7,7 @@ import clsx from "clsx"; function SearchInput( props: React.InputHTMLAttributes & { onEnter?: () => void; + setSearch: React.Dispatch>; } ) { const ref = useRef(null); @@ -46,7 +47,16 @@ function SearchInput( // } // }} > -
+
{ + if (ref.current) { + ref.current.value = ""; + ref.current.focus(); + props.setSearch(ref.current.value); + } + }} + >
diff --git a/src/components/SessionComments.tsx b/src/components/SessionComments.tsx index c53106f..bfab89a 100644 --- a/src/components/SessionComments.tsx +++ b/src/components/SessionComments.tsx @@ -76,7 +76,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 = ""; diff --git a/src/pages/SessionsPage.tsx b/src/pages/SessionsPage.tsx index 429f26a..44ef9ec 100644 --- a/src/pages/SessionsPage.tsx +++ b/src/pages/SessionsPage.tsx @@ -87,6 +87,7 @@ function SessionsPage() { value={search || ""} onChange={(e) => setSearch(e.target.value)} onEnter={() => {}} + setSearch={setSearch} />