From c05b516bbb12ad4c21cad35c370620560f2fdfc5 Mon Sep 17 00:00:00 2001 From: Marina Avramenko Date: Thu, 29 Aug 2024 16:37:47 +0300 Subject: [PATCH] add task solution --- src/components/PostDetails.tsx | 2 +- src/components/UserSelector.tsx | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/components/PostDetails.tsx b/src/components/PostDetails.tsx index d73360ff6..22e1b81a1 100644 --- a/src/components/PostDetails.tsx +++ b/src/components/PostDetails.tsx @@ -65,7 +65,7 @@ export const PostDetails: React.FC = ({ post }) => { )} - {!comments.length && !isError && isLoading && ( + {!comments.length && !isError && !isLoading && (

No comments yet

diff --git a/src/components/UserSelector.tsx b/src/components/UserSelector.tsx index 3c765196c..58fc31a16 100644 --- a/src/components/UserSelector.tsx +++ b/src/components/UserSelector.tsx @@ -18,18 +18,21 @@ export const UserSelector: React.FC = ({ }) => { const [focused, setFocused] = useState(false); - const onFocused = () => { - if (focused) { - setFocused(false); - } else { - setFocused(true); - } + const toggleDropdown = () => { + setFocused(prev => !prev); + }; + + const handleUserSelect = (user: User) => { + setSelectedUser(user); + setFocused(false); + setSelectedPost(null); }; return (
setFocused(false)} >