action.async.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { FETCH_CONFIG } from './helper.js'
  2. export const getThreadContent = (apiUrl, idWorkspace, idContent) =>
  3. fetch(`${apiUrl}/workspaces/${idWorkspace}/threads/${idContent}`, {
  4. ...FETCH_CONFIG,
  5. method: 'GET'
  6. })
  7. export const getThreadComment = (apiUrl, idWorkspace, idContent) =>
  8. fetch(`${apiUrl}/workspaces/${idWorkspace}/contents/${idContent}/comments`, {
  9. ...FETCH_CONFIG,
  10. method: 'GET'
  11. })
  12. export const postThreadNewComment = (apiUrl, idWorkspace, idContent, newComment) =>
  13. fetch(`${apiUrl}/workspaces/${idWorkspace}/contents/${idContent}/comments`, {
  14. ...FETCH_CONFIG,
  15. method: 'POST',
  16. body: JSON.stringify({
  17. raw_content: newComment
  18. })
  19. })
  20. export const putThreadStatus = (apiUrl, idWorkspace, idContent, newStatus) =>
  21. fetch(`${apiUrl}/workspaces/${idWorkspace}/threads/${idContent}/status`, {
  22. ...FETCH_CONFIG,
  23. method: 'PUT',
  24. body: JSON.stringify({
  25. status: newStatus
  26. })
  27. })
  28. export const postThreadContent = (apiUrl, idWorkspace, idFolder, contentType, newContentName) =>
  29. fetch(`${apiUrl}/workspaces/${idWorkspace}/contents`, {
  30. ...FETCH_CONFIG,
  31. method: 'POST',
  32. body: JSON.stringify({
  33. parent_id: idFolder,
  34. content_type: contentType,
  35. label: newContentName
  36. })
  37. })