1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | import {
|
12 | initialEndpointState,
|
13 | handleRequest,
|
14 | handleSuccess,
|
15 | handleFailure,
|
16 | handleTimeout,
|
17 | handleMistake,
|
18 | } from '../../../utility';
|
19 | import { handleActions } from 'redux-actions';
|
20 |
|
21 | import type { ApiEndpointState } from '../../../utility';
|
22 |
|
23 | import {
|
24 | getApiProfileRequest,
|
25 | getApiProfileSuccess,
|
26 | getApiProfileFailure,
|
27 | getApiProfileTimeout,
|
28 | getApiProfileMistake,
|
29 | putApiProfileCustomerRequest,
|
30 | putApiProfileCustomerSuccess,
|
31 | putApiProfileCustomerFailure,
|
32 | putApiProfileCustomerTimeout,
|
33 | putApiProfileCustomerMistake,
|
34 | postApiProfilePhotosProfileRequest,
|
35 | postApiProfilePhotosProfileSuccess,
|
36 | postApiProfilePhotosProfileFailure,
|
37 | postApiProfilePhotosProfileTimeout,
|
38 | postApiProfilePhotosProfileMistake,
|
39 | postApiProfilePhotosBackgroundRequest,
|
40 | postApiProfilePhotosBackgroundSuccess,
|
41 | postApiProfilePhotosBackgroundFailure,
|
42 | postApiProfilePhotosBackgroundTimeout,
|
43 | postApiProfilePhotosBackgroundMistake,
|
44 | } from '../../actions_gen/profile';
|
45 |
|
46 | export type profileState = {|
|
47 | +getApiProfile: ApiEndpointState,
|
48 | +putApiProfileCustomer: ApiEndpointState,
|
49 | +postApiProfilePhotosProfile: ApiEndpointState,
|
50 | +postApiProfilePhotosBackground: ApiEndpointState,
|
51 | |};
|
52 |
|
53 | const initialState: profileState = {
|
54 | getApiProfile: { ...initialEndpointState },
|
55 | putApiProfileCustomer: { ...initialEndpointState },
|
56 | postApiProfilePhotosProfile: { ...initialEndpointState },
|
57 | postApiProfilePhotosBackground: { ...initialEndpointState },
|
58 | };
|
59 |
|
60 | const handlerMap = new Map([
|
61 | [
|
62 | getApiProfileRequest,
|
63 | state => handleRequest('getApiProfile', state),
|
64 | ],
|
65 | [
|
66 | getApiProfileSuccess,
|
67 | (state, action) => handleSuccess('getApiProfile', state, action),
|
68 | ],
|
69 | [
|
70 | getApiProfileFailure,
|
71 | (state, action) => handleFailure('getApiProfile', state, action),
|
72 | ],
|
73 | [
|
74 | getApiProfileTimeout,
|
75 | (state, action) => handleTimeout('getApiProfile', state, action),
|
76 | ],
|
77 | [
|
78 | getApiProfileMistake,
|
79 | (state, action) => handleMistake('getApiProfile', state, action),
|
80 | ],
|
81 |
|
82 | [
|
83 | putApiProfileCustomerRequest,
|
84 | state => handleRequest('putApiProfileCustomer', state),
|
85 | ],
|
86 | [
|
87 | putApiProfileCustomerSuccess,
|
88 | (state, action) => handleSuccess('putApiProfileCustomer', state, action),
|
89 | ],
|
90 | [
|
91 | putApiProfileCustomerFailure,
|
92 | (state, action) => handleFailure('putApiProfileCustomer', state, action),
|
93 | ],
|
94 | [
|
95 | putApiProfileCustomerTimeout,
|
96 | (state, action) => handleTimeout('putApiProfileCustomer', state, action),
|
97 | ],
|
98 | [
|
99 | putApiProfileCustomerMistake,
|
100 | (state, action) => handleMistake('putApiProfileCustomer', state, action),
|
101 | ],
|
102 |
|
103 | [
|
104 | postApiProfilePhotosProfileRequest,
|
105 | state => handleRequest('postApiProfilePhotosProfile', state),
|
106 | ],
|
107 | [
|
108 | postApiProfilePhotosProfileSuccess,
|
109 | (state, action) => handleSuccess('postApiProfilePhotosProfile', state, action),
|
110 | ],
|
111 | [
|
112 | postApiProfilePhotosProfileFailure,
|
113 | (state, action) => handleFailure('postApiProfilePhotosProfile', state, action),
|
114 | ],
|
115 | [
|
116 | postApiProfilePhotosProfileTimeout,
|
117 | (state, action) => handleTimeout('postApiProfilePhotosProfile', state, action),
|
118 | ],
|
119 | [
|
120 | postApiProfilePhotosProfileMistake,
|
121 | (state, action) => handleMistake('postApiProfilePhotosProfile', state, action),
|
122 | ],
|
123 |
|
124 | [
|
125 | postApiProfilePhotosBackgroundRequest,
|
126 | state => handleRequest('postApiProfilePhotosBackground', state),
|
127 | ],
|
128 | [
|
129 | postApiProfilePhotosBackgroundSuccess,
|
130 | (state, action) => handleSuccess('postApiProfilePhotosBackground', state, action),
|
131 | ],
|
132 | [
|
133 | postApiProfilePhotosBackgroundFailure,
|
134 | (state, action) => handleFailure('postApiProfilePhotosBackground', state, action),
|
135 | ],
|
136 | [
|
137 | postApiProfilePhotosBackgroundTimeout,
|
138 | (state, action) => handleTimeout('postApiProfilePhotosBackground', state, action),
|
139 | ],
|
140 | [
|
141 | postApiProfilePhotosBackgroundMistake,
|
142 | (state, action) => handleMistake('postApiProfilePhotosBackground', state, action),
|
143 | ],
|
144 | ]);
|
145 |
|
146 | export default handleActions(handlerMap, initialState);
|