2019-08-31 04:07:25 +05:00
|
|
|
import http from './http';
|
|
|
|
import socket from './socket';
|
|
|
|
|
|
|
|
/* Actions */
|
|
|
|
|
|
|
|
const getUsers = (headers) => socket.get('/users', undefined, headers);
|
|
|
|
|
|
|
|
const createUser = (data, headers) => socket.post('/users', data, headers);
|
|
|
|
|
|
|
|
const getCurrentUser = (headers) => socket.get('/users/me', undefined, headers);
|
|
|
|
|
|
|
|
const updateUser = (id, data, headers) => socket.patch(`/users/${id}`, data, headers);
|
|
|
|
|
2019-10-18 08:06:34 +05:00
|
|
|
const updateUserEmail = (id, data, headers) => socket.patch(`/users/${id}/email`, data, headers);
|
|
|
|
|
|
|
|
const updateUserPassword = (id, data, headers) => socket.patch(`/users/${id}/password`, data, headers);
|
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
const uploadUserAvatar = (id, file, headers) => http.post(
|
|
|
|
`/users/${id}/upload-avatar`,
|
|
|
|
{
|
|
|
|
file,
|
|
|
|
},
|
|
|
|
headers,
|
|
|
|
);
|
|
|
|
|
|
|
|
const deleteUser = (id, headers) => socket.delete(`/users/${id}`, undefined, headers);
|
|
|
|
|
|
|
|
export default {
|
|
|
|
getUsers,
|
|
|
|
createUser,
|
|
|
|
getCurrentUser,
|
|
|
|
updateUser,
|
2019-10-18 08:06:34 +05:00
|
|
|
updateUserEmail,
|
|
|
|
updateUserPassword,
|
2019-08-31 04:07:25 +05:00
|
|
|
uploadUserAvatar,
|
|
|
|
deleteUser,
|
|
|
|
};
|