Skip to content

Commit

Permalink
Fix endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
gf-rog committed Apr 2, 2024
1 parent 33b4850 commit 80b9162
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/FoundUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand Down
18 changes: 8 additions & 10 deletions frontend/src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down Expand Up @@ -45,18 +45,16 @@ const Search = (props: searchProps) => {
const handleSearch = async (e: React.FormEvent<HTMLFormElement>) => {
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 (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/FriendsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function FriendsPage() {
itemsPerPage={3}
refresh={refresh}
isSearch={false}
getItems={(response) => response.friends}
getItems={(response) => response.friendSuggestions}
renderItem={(resultUser) => (
<FoundUser
user={resultUser}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function SearchPage() {

const fetchFriends = async () => {
const friendsResponse = await dataService.fetchData(
`/users/${user.id}/friends`,
`/users/${user.id}/friends?page=1&maxUsers=100`,
"GET",
{},
);
Expand Down

0 comments on commit 80b9162

Please sign in to comment.