import apiService from '../APIRequestService/APIService';

export const  getAllUsers = async () => {
    try {
        const response = await apiService.get('/api/getAllUsr');
        console.log(response.data);
        return response;

    } catch (error) {
        console.error('Error fetching user groups:', error); 
    }
}


export const  createUser = async (data) => {
    try {
        const response = await apiService.post('/api/addOneAppUser', data);
        console.log(response.data);
        return response;
    } catch (error) {
        console.error('Error fetching user groups:', error);
    }
};

export const  updateUser = async (userData) => {
    try {
         // Destructure userId from userData
         const { userId, ...data } = userData;
        const response = await apiService.put(`/api/updateAppUser/${userId}`, data);
        console.log(response.data);
        return response;

    } catch (error) {
        console.error('Error fetching user groups:', error);
    }
};

export const  deleteUser = async (id) => {
    try {
        const response = await apiService.delete(`/api/deleteAppUser/${id}`);
        console.log(response.data);
        return response;

    } catch (error) {
        console.error('Error fetching user groups:', error);
    }
}