Fixed search. Now request relationship is next hurdle
This commit is contained in:
parent
c0c6ad5af4
commit
77481b4ac4
@ -37,9 +37,13 @@ const RequestRelationship:
|
|||||||
setSearchResults([]);
|
setSearchResults([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const user = await getUser() as User;
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const users: User[] = await searchUsers(encodeURIComponent(term)) as User[];
|
console.log(user.id, encodeURIComponent(term));
|
||||||
|
const users: User[] = await searchUsers(user.id, encodeURIComponent(term)) as User[];
|
||||||
|
console.log(users);
|
||||||
setSearchResults(users);
|
setSearchResults(users);
|
||||||
|
setIsLoading(false);
|
||||||
}, 300), []);
|
}, 300), []);
|
||||||
|
|
||||||
const handleSearch = async (text: string) => {
|
const handleSearch = async (text: string) => {
|
||||||
|
@ -114,7 +114,7 @@ export const checkRelationshipStatus = async (userId: number) => {
|
|||||||
const relationshipData = await response.json() as RelationshipData;
|
const relationshipData = await response.json() as RelationshipData;
|
||||||
return relationshipData;
|
return relationshipData;
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
console.log('Error checking relationship status:', error);
|
//console.log('Error checking relationship status:', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -146,10 +146,10 @@ export const updateRelationshipStatus = async (userId: number, status: 'accepted
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const searchUsers = async (searchTerm: string) => {
|
export const searchUsers = async (userId: number, searchTerm: string) => {
|
||||||
try {
|
try {
|
||||||
const apiUrl = `${process.env.EXPO_PUBLIC_API_URL}/api/users/search`;
|
const apiUrl = `${process.env.EXPO_PUBLIC_API_URL}/api/users/search`;
|
||||||
const response = await fetch((apiUrl + `?searchTerm=${searchTerm}`), {
|
const response = await fetch((apiUrl + `?userId=${userId}&searchTerm=${searchTerm}`), {
|
||||||
headers: {
|
headers: {
|
||||||
'x-api-key': process.env.EXPO_PUBLIC_API_KEY ?? '',
|
'x-api-key': process.env.EXPO_PUBLIC_API_KEY ?? '',
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user