action.async.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { FETCH_CONFIG } from './helper.js'
  2. export const getWorkspaceList = (user, apiUrl) =>
  3. // @FIXME - Côme - 2018/08/23 - wrong end point, this one only returns workspaces of logged user
  4. fetch(`${apiUrl}/users/${user.user_id}/workspaces`, {
  5. headers: {
  6. 'Authorization': 'Basic ' + user.auth,
  7. ...FETCH_CONFIG.headers
  8. },
  9. method: 'GET'
  10. })
  11. export const getWorkspaceMemberList = (user, apiUrl, idWorkspace) =>
  12. fetch(`${apiUrl}/workspaces/${idWorkspace}/members`, {
  13. headers: {
  14. 'Authorization': 'Basic ' + user.auth,
  15. ...FETCH_CONFIG.headers
  16. },
  17. method: 'GET'
  18. })
  19. export const deleteWorkspace = (user, apiUrl, idWorkspace) =>
  20. fetch(`${apiUrl}/workspaces/${idWorkspace}/delete`, {
  21. headers: {
  22. 'Authorization': 'Basic ' + user.auth,
  23. ...FETCH_CONFIG.headers
  24. },
  25. method: 'PUT'
  26. })
  27. export const getUserList = (user, apiUrl) =>
  28. fetch(`${apiUrl}/users`, {
  29. headers: {
  30. 'Authorization': 'Basic ' + user.auth,
  31. ...FETCH_CONFIG.headers
  32. },
  33. method: 'GET'
  34. })
  35. export const getUserDetail = (user, apiUrl, idUser) =>
  36. fetch(`${apiUrl}/users/${idUser}`, {
  37. headers: {
  38. 'Authorization': 'Basic ' + user.auth,
  39. ...FETCH_CONFIG.headers
  40. },
  41. method: 'GET'
  42. })
  43. export const putUserDisable = (user, apiUrl, idUser) =>
  44. fetch(`${apiUrl}/users/${idUser}/disable`, {
  45. headers: {
  46. 'Authorization': 'Basic ' + user.auth,
  47. ...FETCH_CONFIG.headers
  48. },
  49. method: 'PUT'
  50. })
  51. export const putUserEnable = (user, apiUrl, idUser) =>
  52. fetch(`${apiUrl}/users/${idUser}/enable`, {
  53. headers: {
  54. 'Authorization': 'Basic ' + user.auth,
  55. ...FETCH_CONFIG.headers
  56. },
  57. method: 'PUT'
  58. })
  59. export const putUserProfile = (user, apiUrl, idUser, newProfile) =>
  60. fetch(`${apiUrl}/users/${idUser}/profile`, {
  61. headers: {
  62. 'Authorization': 'Basic ' + user.auth,
  63. ...FETCH_CONFIG.headers
  64. },
  65. body: JSON.stringify({
  66. profile: newProfile
  67. }),
  68. method: 'PUT'
  69. })
  70. export const postAddUser = (user, apiUrl, email, profile) =>
  71. fetch(`${apiUrl}/users`, {
  72. headers: {
  73. 'Authorization': 'Basic ' + user.auth,
  74. ...FETCH_CONFIG.headers
  75. },
  76. body: JSON.stringify({
  77. email,
  78. email_notification: false,
  79. profile
  80. }),
  81. method: 'POST'
  82. })