helper.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { apiUrl as configApiUrl } from '../configEnv.js'
  2. export const FETCH_CONFIG = {
  3. headers: {
  4. 'Accept': 'application/json',
  5. 'Content-Type': 'application/json'
  6. },
  7. apiUrl: configApiUrl,
  8. mockApiUrl: 'http://localhost:3001' // @todo: better to use one url only and use proxy on mock api to point to real api (if implemented)
  9. }
  10. export const COOKIE = {
  11. USER_LOGIN: 'user_login',
  12. USER_AUTH: 'user_auth'
  13. }
  14. // Côme - 2018/08/02 - shouldn't this come from api ?
  15. export const workspaceConfig = {
  16. slug: 'workspace',
  17. faIcon: 'bank',
  18. hexcolor: '#7d4e24',
  19. creationLabel: 'Create a workspace',
  20. domContainer: 'appFeatureContainer'
  21. }
  22. export const PAGE = {
  23. HOME: '/',
  24. WORKSPACE: {
  25. ROOT: '/workspaces',
  26. DASHBOARD: (idws = ':idws') => `/workspaces/${idws}/dashboard`,
  27. NEW: (idws, type) => `/workspaces/${idws}/contents/${type}/new`,
  28. CALENDAR: (idws = ':idws') => `/workspaces/${idws}/calendar`,
  29. CONTENT_LIST: (idws = ':idws') => `/workspaces/${idws}/contents`,
  30. CONTENT: (idws = ':idws', type = ':type', idcts = ':idcts') => `/workspaces/${idws}/contents/${type}/${idcts}`,
  31. ADMIN: (idws = ':idws') => `/workspaces/${idws}/admin`
  32. },
  33. LOGIN: '/login',
  34. ACCOUNT: '/account',
  35. ADMIN: {
  36. ROOT: '/admin',
  37. WORKSPACE: '/admin/workspace',
  38. USER: '/admin/user'
  39. }
  40. }
  41. export const ROLE = [{
  42. id: 1,
  43. slug: 'reader',
  44. faIcon: 'eye',
  45. hexcolor: '#15d948',
  46. label: 'Reader'
  47. }, {
  48. id: 2,
  49. slug: 'contributor',
  50. faIcon: 'pencil',
  51. hexcolor: '#3145f7',
  52. label: 'Contributor'
  53. }, {
  54. id: 4,
  55. slug: 'content-manager',
  56. faIcon: 'graduation-cap',
  57. hexcolor: '#f2af2d',
  58. label: 'Content manager'
  59. }, {
  60. id: 8,
  61. slug: 'workspace-manager',
  62. faIcon: 'gavel',
  63. hexcolor: '#ed0007',
  64. label: 'Workspace manager'
  65. }]
  66. export const findIdRoleUserWorkspace = (idUser, memberList, roleList) => {
  67. const myself = memberList.find(u => u.id === idUser) || {role: 'reader'}
  68. return (roleList.find(r => myself.role === r.slug) || {id: 1}).id
  69. }
  70. // Côme - 2018/08/21 - useful ?
  71. export const ROLE2 = {
  72. reader: {
  73. id: 1,
  74. sluf: 'reader',
  75. faIcon: 'eye',
  76. hexcolor: '#15D948',
  77. label: 'Reader'
  78. },
  79. contributor: {
  80. id: 2,
  81. slug: 'contributor',
  82. faIcon: 'pencil',
  83. hexcolor: '#3145f7',
  84. label: 'Contributor'
  85. },
  86. contentManager: {
  87. id: 4,
  88. slug: 'content-manager',
  89. faIcon: 'graduation-cap',
  90. hexcolor: '#f2af2d',
  91. label: 'Content manager'
  92. },
  93. workspaceManager: {
  94. id: 8,
  95. slug: 'workspace-manager',
  96. faIcon: 'gavel',
  97. hexcolor: '#ed0007',
  98. label: 'Workspace manager'
  99. }
  100. }
  101. export const PROFILE = {
  102. ADMINISTRATOR: 'administrators',
  103. MANAGER: 'managers',
  104. USER: 'users'
  105. }
  106. export const handleRouteFromApi = route => route.startsWith('/#') ? route.slice(2) : route