-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathgroups.js
More file actions
50 lines (33 loc) · 1.69 KB
/
groups.js
File metadata and controls
50 lines (33 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { apiClient } from "./client";
export const getGroups = () => apiClient.get("/groups");
export const getOptimizedSettlements = (groupId) =>
apiClient.post(`/groups/${groupId}/settlements/optimize`, {});
export const createExpense = (groupId, expenseData) =>
apiClient.post(`/groups/${groupId}/expenses`, expenseData);
export const getGroupDetails = (groupId) => {
return Promise.all([getGroupMembers(groupId), getGroupExpenses(groupId)]);
};
export const getGroupMembers = (groupId) =>
apiClient.get(`/groups/${groupId}/members`);
export const getGroupExpenses = (groupId) =>
apiClient.get(`/groups/${groupId}/expenses`);
export const deleteExpense = (groupId, expenseId) =>
apiClient.delete(`/groups/${groupId}/expenses/${expenseId}`);
export const createGroup = (name) => apiClient.post("/groups", { name });
export const joinGroup = (joinCode) =>
apiClient.post("/groups/join", { joinCode });
export const getUserBalanceSummary = () =>
apiClient.get("/users/me/balance-summary");
export const getFriendsBalance = () =>
apiClient.get("/users/me/friends-balance");
// New APIs for Group Settings
export const getGroupById = (groupId) => apiClient.get(`/groups/${groupId}`);
export const updateGroup = (groupId, updates) =>
apiClient.patch(`/groups/${groupId}`, updates);
export const deleteGroup = (groupId) => apiClient.delete(`/groups/${groupId}`);
export const leaveGroup = (groupId) =>
apiClient.post(`/groups/${groupId}/leave`, {});
export const updateMemberRole = (groupId, memberId, role) =>
apiClient.patch(`/groups/${groupId}/members/${memberId}`, { role });
export const removeMember = (groupId, memberId) =>
apiClient.delete(`/groups/${groupId}/members/${memberId}`);