import api from './client';

export const apiGetGroup = async ({ user, active, search }: { user: string, active: string, search: string }) => {
   const response = await api.get(`mobile/group?user=${user}&active=${active}&search=${search}`);
   return response.data;
};

export const apiCreateGroup = async (data: { user: string, name: string }) => {
   const response = await api.post('mobile/group', data);
   return response.data;
};

export const apiEditGroup = async (data: { user: string, name: string }, id: string) => {
   const response = await api.put(`mobile/group/${id}`, data);
   return response.data;
};

export const apiDeleteGroup = async (data: { user: string, isActive: boolean }, id: string) => {
   const response = await api.delete(`mobile/group/${id}`, { data });
   return response.data;
};

export const apiGetDivisionGroup = async ({ user }: { user: string }) => {
   const response = await api.get(`mobile/group/get-division?user=${user}`);
   return response.data;
};

export const apiGetPosition = async ({ user, active, search, group }: { user: string, active: string, search: string, group?: string }) => {
   const response = await api.get(`mobile/position?user=${user}&active=${active}&group=${group}&search=${search}`);
   return response.data;
};

export const apiCreatePosition = async (data: { user: string, name: string, idGroup: string }) => {
   const response = await api.post('mobile/position', data);
   return response.data;
};

export const apiDeletePosition = async (data: { user: string, isActive: boolean }, id: string) => {
   const response = await api.delete(`mobile/position/${id}`, { data });
   return response.data;
};

export const apiEditPosition = async (data: { user: string, name: string, idGroup: string }, id: string) => {
   const response = await api.put(`mobile/position/${id}`, data)
   return response.data
};
