diff --git a/frontend/src/components/FoundUser.tsx b/frontend/src/components/FoundUser.tsx index 6d2750d3..41c827ab 100644 --- a/frontend/src/components/FoundUser.tsx +++ b/frontend/src/components/FoundUser.tsx @@ -22,7 +22,7 @@ function FoundUser(props: FoundUserProps) { {}, ); - const isRequestSent = friendsRequestsResponse.friends.some( + const isRequestSent = friendsRequestsResponse.friendRequests.some( (friend: User) => String(friend.id) === props.currentId, ); diff --git a/frontend/src/components/Search.tsx b/frontend/src/components/Search.tsx index 18c16ec6..3770d613 100644 --- a/frontend/src/components/Search.tsx +++ b/frontend/src/components/Search.tsx @@ -12,7 +12,7 @@ interface searchProps { const Search = (props: searchProps) => { const navigate = useNavigate(); - //TODO: IF YOU HAVE EMPTY SEARCH, THEN YOU CANT SEARCH ANYTHING + // Logic const [searchQuery, setSearchQuery] = useState(""); const [country, setCountry] = useState(""); @@ -45,18 +45,16 @@ const Search = (props: searchProps) => { const handleSearch = async (e: React.FormEvent) => { e.preventDefault(); - let url: string = `/users/search?q=${searchQuery}`; - if (country !== "" && country !== "-") { - url = url + "&country=" + country; - } - if (userState.status === "anonymous") navigate("/login"); - if (searchQuery.trim() === "") { - return; - } + const countryQuery = (country != "-") ? country : "" + + const urlSearchParams = new URLSearchParams({ + q: searchQuery, + country: countryQuery + }) - props.handler(url); + props.handler(`/users/search?${urlSearchParams}`); }; return ( diff --git a/frontend/src/pages/FriendsPage.tsx b/frontend/src/pages/FriendsPage.tsx index c984038a..fea301db 100644 --- a/frontend/src/pages/FriendsPage.tsx +++ b/frontend/src/pages/FriendsPage.tsx @@ -146,7 +146,7 @@ function FriendsPage() { itemsPerPage={3} refresh={refresh} isSearch={false} - getItems={(response) => response.friends} + getItems={(response) => response.friendSuggestions} renderItem={(resultUser) => ( { const friendsResponse = await dataService.fetchData( - `/users/${user.id}/friends`, + `/users/${user.id}/friends?page=1&maxUsers=100`, "GET", {}, );