All files / src/api user-group.api.ts

0% Statements 0/24
0% Branches 0/1
0% Functions 0/1
0% Lines 0/24

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                                                                                                                   
import api from './axios'
import type { UserGroup, UserGroupWithMembers, UserGroupCreate, UserGroupUpdate } from '@/types'
 
// ----------------------------------------------------------------
// USER GROUP API
// ----------------------------------------------------------------
export const userGroupApi = {
  /**
   * Get all user groups
   */
  list: (skip = 0, limit = 100) => {
    return api.get<UserGroup[]>('/user-groups/', { params: { skip, limit } })
  },
 
  /**
   * Get user group by ID with members
   */
  getById: (userGroupId: string) => {
    return api.get<UserGroupWithMembers>(`/user-groups/${userGroupId}`)
  },
 
  /**
   * Create user group (TEACHER/ADMIN only)
   */
  create: (data: UserGroupCreate) => {
    return api.post<UserGroup>('/user-groups/', data)
  },
 
  /**
   * Delete user group (TEACHER/ADMIN only)
   */
  delete: (userGroupId: string) => {
    return api.delete(`/user-groups/${userGroupId}`)
  },
 
  /**
   * Add member to group (TEACHER/ADMIN only)
   */
  addMember: (userGroupId: string, userId: string) => {
    return api.post(`/user-groups/${userGroupId}/users/${userId}`)
  },
 
  /**
   * Remove member from group (TEACHER/ADMIN only)
   */
  removeMember: (userGroupId: string, userId: string) => {
    return api.delete(`/user-groups/${userGroupId}/users/${userId}`)
  },
 
  /**
   * Update user group (TEACHER/ADMIN only)
   */
  update(userGroupId: string, data: UserGroupUpdate) {
  return api.put<UserGroupWithMembers>(`/user-groups/${userGroupId}`, data)
}
 
}