reducers.tpl 1.43 KB
Newer Older
1
2
3
4
5
6
// WARNING
// THIS FILE HAS BEEN AUTOMATICALLY GENERATED
// WITH /frontend/generate/generate_frontend_files.js
// MODIFY THE FILE ABOVE IF YOUR NOT SATISFIED 
// THIS WARNING DOESN'T APPLY TO .tpl FILES...

7
import {
8
9
10
11
12
13
{% for obj in data %}
    {{obj.NAME}}_HAS_ERROR,
    {{obj.NAME}}_IS_LOADING,
    {{obj.NAME}}_FETCH_DATA_SUCCESS,
    {{obj.NAME}}_INVALIDATED,
{% endfor %}
14
15
} from "./action-types";

16
17
{% for obj in data %}
export function {{obj.name}}HasError(state = false, action) {
18
    switch (action.type) {
19
        case {{obj.NAME}}_HAS_ERROR:
20
21
22
23
24
25
26
            return action.hasError;

        default:
            return state;
    }
}

27
export function {{obj.name}}IsLoading(state = false, action) {
28
    switch (action.type) {
29
        case {{obj.NAME}}_IS_LOADING:
30
31
32
33
34
35
36
            return action.isLoading;

        default:
            return state;
    }
}

37
export function {{obj.name}}Invalidated(state = false, action) {
38
    switch (action.type) {
39
        case {{obj.NAME}}_INVALIDATED:
40
41
42
43
44
45
46
            return action.invalidated;

        default:
            return state;
    }
}

47
export function {{obj.name}}Fetched(state = { {{obj.name}}: [], {{obj.name}}FetchedAt: null }, action) {
48
    switch (action.type) {
49
        case {{obj.NAME}}_FETCH_DATA_SUCCESS:
50
            return {
51
52
                {{obj.name}}: action.{{obj.name}},
                fetchedAt: action.{{obj.name}}FetchedAt
53
54
55
56
57
            }

        default:
            return state;
    }
58
59
60
}

{% endfor %}