|
@@ -70,7 +70,7 @@ const fetchWrapper = async ({url, param, actionName, dispatch, debug = false}) =
|
70
|
70
|
|
71
|
71
|
export const getLangList = () => async dispatch => {
|
72
|
72
|
const fetchGetLangList = await fetchWrapper({
|
73
|
|
- url: `${FETCH_CONFIG.apiUrl}/lang`,
|
|
73
|
+ url: `${FETCH_CONFIG.mockApiUrl}/lang`,
|
74
|
74
|
param: {...FETCH_CONFIG.header, method: 'GET'},
|
75
|
75
|
actionName: LANG,
|
76
|
76
|
dispatch
|
|
@@ -80,7 +80,7 @@ export const getLangList = () => async dispatch => {
|
80
|
80
|
|
81
|
81
|
export const getTimezone = () => async dispatch => {
|
82
|
82
|
const fetchGetTimezone = await fetchWrapper({
|
83
|
|
- url: `${FETCH_CONFIG.apiUrl}/timezone`,
|
|
83
|
+ url: `${FETCH_CONFIG.mockApiUrl}/timezone`,
|
84
|
84
|
param: {...FETCH_CONFIG.header, method: 'GET'},
|
85
|
85
|
actionName: TIMEZONE,
|
86
|
86
|
dispatch
|
|
@@ -88,16 +88,16 @@ export const getTimezone = () => async dispatch => {
|
88
|
88
|
if (fetchGetTimezone.status === 200) dispatch(setTimezone(fetchGetTimezone.json))
|
89
|
89
|
}
|
90
|
90
|
|
91
|
|
-export const userLogin = (login, password, rememberMe) => async dispatch => {
|
|
91
|
+export const postUserLogin = (login, password, rememberMe) => async dispatch => {
|
92
|
92
|
const fetchUserLogin = await fetchWrapper({
|
93
|
|
- url: `${FETCH_CONFIG.apiUrl}/user/login`,
|
|
93
|
+ url: `${FETCH_CONFIG.apiUrl}/sessions/login`,
|
94
|
94
|
param: {
|
95
|
|
- ...FETCH_CONFIG.header,
|
|
95
|
+ headers: {...FETCH_CONFIG.headers},
|
96
|
96
|
method: 'POST',
|
97
|
97
|
body: JSON.stringify({
|
98
|
|
- login,
|
99
|
|
- password,
|
100
|
|
- remember_me: rememberMe
|
|
98
|
+ email: login,
|
|
99
|
+ password: password
|
|
100
|
+ // remember_me: rememberMe
|
101
|
101
|
})
|
102
|
102
|
},
|
103
|
103
|
actionName: USER_LOGIN,
|
|
@@ -106,19 +106,21 @@ export const userLogin = (login, password, rememberMe) => async dispatch => {
|
106
|
106
|
if (fetchUserLogin.status === 200) dispatch(setUserConnected(fetchUserLogin.json))
|
107
|
107
|
}
|
108
|
108
|
|
109
|
|
-export const getIsUserConnected = () => async dispatch => {
|
|
109
|
+export const getUserIsConnected = () => async dispatch => {
|
110
|
110
|
const fetchUserLogged = await fetchWrapper({
|
111
|
|
- url: `${FETCH_CONFIG.apiUrl}/user/is_logged_in`,
|
|
111
|
+ url: `${FETCH_CONFIG.apiUrl}/sessions/whoami`,
|
112
|
112
|
param: {...FETCH_CONFIG.header, method: 'GET'},
|
113
|
113
|
actionName: USER_CONNECTED,
|
114
|
114
|
dispatch
|
115
|
115
|
})
|
116
|
116
|
if (fetchUserLogged.status === 200) dispatch(setUserConnected(fetchUserLogged.json))
|
|
117
|
+ else if (fetchUserLogged.status === 401) dispatch(setUserConnected({logged: false}))
|
|
118
|
+ else dispatch(setUserConnected({logged: undefined}))
|
117
|
119
|
}
|
118
|
120
|
|
119
|
121
|
export const getUserRole = user => async dispatch => {
|
120
|
122
|
const fetchGetUserRole = await fetchWrapper({
|
121
|
|
- url: `${FETCH_CONFIG.apiUrl}/user/${user.id}/roles`,
|
|
123
|
+ url: `${FETCH_CONFIG.mockApiUrl}/user/${user.id}/roles`,
|
122
|
124
|
param: {...FETCH_CONFIG.header, method: 'GET'},
|
123
|
125
|
actionName: USER_ROLE,
|
124
|
126
|
dispatch
|
|
@@ -128,7 +130,7 @@ export const getUserRole = user => async dispatch => {
|
128
|
130
|
|
129
|
131
|
export const updateUserLang = newLang => async dispatch => { // unused
|
130
|
132
|
const fetchUpdateUserLang = await fetchWrapper({
|
131
|
|
- url: `${FETCH_CONFIG.apiUrl}/user`,
|
|
133
|
+ url: `${FETCH_CONFIG.mockApiUrl}/user`,
|
132
|
134
|
param: {...FETCH_CONFIG.header, method: 'PATCH', body: JSON.stringify({lang: newLang})},
|
133
|
135
|
actionName: USER_DATA,
|
134
|
136
|
dispatch
|
|
@@ -148,7 +150,7 @@ export const updateUserLang = newLang => async dispatch => { // unused
|
148
|
150
|
|
149
|
151
|
export const getWorkspaceList = (userId, workspaceIdToOpen) => async dispatch => {
|
150
|
152
|
const fetchGetWorkspaceList = await fetchWrapper({
|
151
|
|
- url: `${FETCH_CONFIG.apiUrl}/user/${userId}/workspace`,
|
|
153
|
+ url: `${FETCH_CONFIG.mockApiUrl}/user/${userId}/workspace`,
|
152
|
154
|
param: {...FETCH_CONFIG.header, method: 'GET'},
|
153
|
155
|
actionName: WORKSPACE_LIST,
|
154
|
156
|
dispatch
|
|
@@ -161,7 +163,7 @@ export const getWorkspaceList = (userId, workspaceIdToOpen) => async dispatch =>
|
161
|
163
|
|
162
|
164
|
export const getWorkspaceContent = (workspaceId, filterStr) => async dispatch => {
|
163
|
165
|
const fetchGetWorkspaceContent = await fetchWrapper({
|
164
|
|
- url: `${FETCH_CONFIG.apiUrl}/workspace/${workspaceId}`,
|
|
166
|
+ url: `${FETCH_CONFIG.mockApiUrl}/workspace/${workspaceId}`,
|
165
|
167
|
param: {...FETCH_CONFIG.header, method: 'GET'},
|
166
|
168
|
actionName: WORKSPACE,
|
167
|
169
|
dispatch
|
|
@@ -171,7 +173,7 @@ export const getWorkspaceContent = (workspaceId, filterStr) => async dispatch =>
|
171
|
173
|
|
172
|
174
|
export const getFolderContent = (workspaceId, folderId) => async dispatch => {
|
173
|
175
|
const fetchGetFolderContent = await fetchWrapper({
|
174
|
|
- url: `${FETCH_CONFIG.apiUrl}/workspace/${workspaceId}/folder/${folderId}`,
|
|
176
|
+ url: `${FETCH_CONFIG.mockApiUrl}/workspace/${workspaceId}/folder/${folderId}`,
|
175
|
177
|
param: {...FETCH_CONFIG.header, method: 'GET'},
|
176
|
178
|
actionName: `${WORKSPACE}/${FOLDER}`,
|
177
|
179
|
dispatch
|
|
@@ -181,7 +183,7 @@ export const getFolderContent = (workspaceId, folderId) => async dispatch => {
|
181
|
183
|
|
182
|
184
|
export const getAppList = () => async dispatch => {
|
183
|
185
|
const fetchGetAppList = await fetchWrapper({
|
184
|
|
- url: `${FETCH_CONFIG.apiUrl}/app/config`,
|
|
186
|
+ url: `${FETCH_CONFIG.mockApiUrl}/app/config`,
|
185
|
187
|
param: {...FETCH_CONFIG.header, method: 'GET'},
|
186
|
188
|
actionName: APP_LIST,
|
187
|
189
|
dispatch
|