summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/api/crud.types.js
blob: ac9b3f39b68d8b50c0b8b4c82ea71d8c9b357089 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
export const as_type = (a, b) => [a, b].join('_').toUpperCase()

export const with_type = (type, actions) =>
  actions.reduce((a, b) => (a[b] = as_type(type, b)) && a, {})

export const crud_type = (type, actions=[]) =>
  with_type(type, actions.concat([
    'index_loading',
    'index',
    'index_error',
    'index_sort',
    'show_loading',
    'show',
    'show_error',
    'create_loading',
    'create',
    'create_error',
    'update_loading',
    'update',
    'update_error',
    'destroy_loading',
    'destroy',
    'destroy_error',
    'upload_loading',
    'upload_progress',
    'upload_waiting',
    'upload_complete',
    'upload_error',
    'sort',
    'update_option',
    'update_options',
    'loading',
    'loaded',
    'error',
  ]))