action.async.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { FETCH_CONFIG } from './helper.js'
  2. export const getThreadContent = (user, apiUrl, idWorkspace, idContent) =>
  3. fetch(`${apiUrl}/workspaces/${idWorkspace}/threads/${idContent}`, {
  4. headers: {
  5. ...FETCH_CONFIG.headers,
  6. 'Authorization': 'Basic ' + user.auth
  7. },
  8. method: 'GET'
  9. })
  10. export const getThreadComment = (user, apiUrl, idWorkspace, idContent) =>
  11. fetch(`${apiUrl}/workspaces/${idWorkspace}/contents/${idContent}/comments`, {
  12. headers: {
  13. ...FETCH_CONFIG.headers,
  14. 'Authorization': 'Basic ' + user.auth
  15. },
  16. method: 'GET'
  17. })
  18. export const postThreadNewComment = (user, apiUrl, idWorkspace, idContent, newComment) =>
  19. fetch(`${apiUrl}/workspaces/${idWorkspace}/contents/${idContent}/comments`, {
  20. headers: {
  21. ...FETCH_CONFIG.headers,
  22. 'Authorization': 'Basic ' + user.auth
  23. },
  24. method: 'POST',
  25. body: JSON.stringify({
  26. raw_content: newComment
  27. })
  28. })
  29. export const putThreadStatus = (user, apiUrl, idWorkspace, idContent, newStatus) =>
  30. fetch(`${apiUrl}/workspaces/${idWorkspace}/threads/${idContent}/status`, {
  31. headers: {
  32. ...FETCH_CONFIG.headers,
  33. 'Authorization': 'Basic ' + user.auth
  34. },
  35. method: 'PUT',
  36. body: JSON.stringify({
  37. status: newStatus
  38. })
  39. })
  40. export const postThreadContent = (user, apiUrl, idWorkspace, idFolder, contentType, newContentName) =>
  41. fetch(`${apiUrl}/workspaces/${idWorkspace}/contents`, {
  42. headers: {
  43. ...FETCH_CONFIG.headers,
  44. 'Authorization': 'Basic ' + user.auth
  45. },
  46. method: 'POST',
  47. body: JSON.stringify({
  48. parent_id: idFolder,
  49. content_type: contentType,
  50. label: newContentName
  51. })
  52. })
  53. export const putThreadContent = (user, apiUrl, idWorkspace, idContent, label) =>
  54. fetch(`${apiUrl}/workspaces/${idWorkspace}/threads/${idContent}`, {
  55. headers: {
  56. ...FETCH_CONFIG.headers,
  57. 'Authorization': 'Basic ' + user.auth
  58. },
  59. method: 'PUT',
  60. body: JSON.stringify({
  61. label: label,
  62. raw_content: '' // threads have no content
  63. })
  64. })