Skip to content

Commit b70bd60

Browse files
committed
Implemented api front end to backend calls
1 parent 30890a7 commit b70bd60

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

client/src/lib/api/friends.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { FriendsResponse } from "../../types/friends";
2+
import api from "../api";
3+
4+
export const searchUsers = (query: string) =>
5+
api.get(`/friends/search/?q=${query}`);
6+
7+
/* Send friend request */
8+
export const sendFriendRequest = (id: number) =>
9+
api.post(`/friends/send/${id}/`);
10+
11+
/* Cancel request */
12+
export const cancelFriendRequest = (requestId: number) =>
13+
api.post(`/friends/cancel/${requestId}/`);
14+
15+
/* Accept request */
16+
export const acceptFriendRequest = (requestId: number) =>
17+
api.post(`/friends/accept/${requestId}/`);
18+
19+
/* Decline request */
20+
export const declineFriendRequest = (requestId: number) =>
21+
api.post(`/friends/decline/${requestId}/`);
22+
23+
/* Remove friend */
24+
export const removeFriend = (userId: number) =>
25+
api.post(`/friends/remove/${userId}/`);
26+
27+
/* Get my friends */
28+
export const getFriends = () =>
29+
// api.get(`/friends/list/`);
30+
api.get<FriendsResponse>("/friends/list/");
31+
32+
/* Incoming requests */
33+
export const getIncomingRequests = () => api.get(`/friends/requests/`);
34+
35+
/* Sent requests */
36+
export const getSentRequests = () => api.get(`/friends/requests_sent/`);

0 commit comments

Comments
 (0)