+ client: login page
This commit is contained in:
20
client/src/actions/login.js
Normal file
20
client/src/actions/login.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
|
||||
import { addErrorToast } from './index';
|
||||
import apiClient from '../api/Api';
|
||||
|
||||
export const processLoginRequest = createAction('PROCESS_LOGIN_REQUEST');
|
||||
export const processLoginFailure = createAction('PROCESS_LOGIN_FAILURE');
|
||||
export const processLoginSuccess = createAction('PROCESS_LOGIN_SUCCESS');
|
||||
|
||||
export const processLogin = values => async (dispatch) => {
|
||||
dispatch(processLoginRequest());
|
||||
try {
|
||||
await apiClient.login(values);
|
||||
window.location.replace(window.location.origin);
|
||||
dispatch(processLoginSuccess());
|
||||
} catch (error) {
|
||||
dispatch(addErrorToast({ error }));
|
||||
dispatch(processLoginFailure());
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user