added frontend for friendships, and fixed logic around conflicts

This commit is contained in:
2025-12-18 13:36:03 +01:00
parent 2572db7a24
commit 2e2e9a76f9
5 changed files with 233 additions and 0 deletions

24
src/api/friends.ts Normal file
View 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 }),
})
}