added frontend for friendships, and fixed logic around conflicts
This commit is contained in:
24
src/api/friends.ts
Normal file
24
src/api/friends.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { apiFetch } from './client'
|
||||
import type { Friend, FriendRequest } from '../types/api'
|
||||
|
||||
export function fetchFriends() {
|
||||
return apiFetch<Friend[]>('/friends')
|
||||
}
|
||||
|
||||
export function fetchFriendRequests() {
|
||||
return apiFetch<FriendRequest[]>('/friends/requests')
|
||||
}
|
||||
|
||||
export function sendFriendRequest(receiverUsername: string) {
|
||||
return apiFetch<void>('/friends/request', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ receiver_username: receiverUsername }),
|
||||
});
|
||||
}
|
||||
|
||||
export function acceptFriendRequest(senderUuid: string) {
|
||||
return apiFetch<void>('/friends/accept', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ sender_uuid: senderUuid }),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user