All files / client/src/services groupServices.ts

100% Statements 15/15
100% Branches 0/0
100% Functions 5/5
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 51 52 53 54 55 56 57 58 59                          356x 14x 14x     356x     13x       12x     356x 1x     1x     356x     2x       2x     356x     32x               32x    
import { api } from "client/utils/api";
import { ApiEndpoint } from "shared/constants/apiEndpoints";
import {
  GetGroupResponse,
  PostJoinGroupRequest,
  PostCloseGroupRequest,
  PostCreateGroupResponse,
  PostJoinGroupResponse,
  PostLeaveGroupResponse,
  PostCloseGroupResponse,
  GetGroupRequest,
} from "shared/types/api/groups";
 
export const postCreateGroup = async (): Promise<PostCreateGroupResponse> => {
  const response = await api.post<PostCreateGroupResponse>(ApiEndpoint.GROUP);
  return response.data;
};
 
export const postJoinGroup = async (
  groupRequest: PostJoinGroupRequest,
): Promise<PostJoinGroupResponse> => {
  const response = await api.post<PostJoinGroupResponse, PostJoinGroupRequest>(
    ApiEndpoint.JOIN_GROUP,
    groupRequest,
  );
  return response.data;
};
 
export const postLeaveGroup = async (): Promise<PostLeaveGroupResponse> => {
  const response = await api.post<PostLeaveGroupResponse>(
    ApiEndpoint.LEAVE_GROUP,
  );
  return response.data;
};
 
export const postCloseGroup = async (
  groupRequest: PostCloseGroupRequest,
): Promise<PostCloseGroupResponse> => {
  const response = await api.post<
    PostCloseGroupResponse,
    PostCloseGroupRequest
  >(ApiEndpoint.CLOSE_GROUP, groupRequest);
  return response.data;
};
 
export const getGroup = async (
  groupCode: string,
): Promise<GetGroupResponse> => {
  const response = await api.get<GetGroupResponse, GetGroupRequest>(
    ApiEndpoint.GROUP,
    {
      params: {
        groupCode,
      },
    },
  );
  return response.data;
};