Loading indicator on sign in.
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
|||||||
} from "../../redux/user/user.actions";
|
} from "../../redux/user/user.actions";
|
||||||
import {
|
import {
|
||||||
selectCurrentUser,
|
selectCurrentUser,
|
||||||
|
selectLoginLoading,
|
||||||
selectSignInError,
|
selectSignInError,
|
||||||
} from "../../redux/user/user.selectors";
|
} from "../../redux/user/user.selectors";
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
@@ -21,6 +22,7 @@ import "./sign-in-form.styles.scss";
|
|||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentUser: selectCurrentUser,
|
currentUser: selectCurrentUser,
|
||||||
signInError: selectSignInError,
|
signInError: selectSignInError,
|
||||||
|
loginLoading: selectLoginLoading,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
@@ -34,6 +36,7 @@ export function SignInComponent({
|
|||||||
currentUser,
|
currentUser,
|
||||||
signInError,
|
signInError,
|
||||||
sendPasswordReset,
|
sendPasswordReset,
|
||||||
|
loginLoading,
|
||||||
}) {
|
}) {
|
||||||
const { redirect } = queryString.parse(useLocation().search);
|
const { redirect } = queryString.parse(useLocation().search);
|
||||||
|
|
||||||
@@ -80,7 +83,12 @@ export function SignInComponent({
|
|||||||
{signInError ? (
|
{signInError ? (
|
||||||
<AlertComponent type="error" message={signInError.message} />
|
<AlertComponent type="error" message={signInError.message} />
|
||||||
) : null}
|
) : null}
|
||||||
<Button className="login-btn" type="primary" htmlType="submit">
|
<Button
|
||||||
|
className="login-btn"
|
||||||
|
type="primary"
|
||||||
|
htmlType="submit"
|
||||||
|
loading={loginLoading}
|
||||||
|
>
|
||||||
{t("general.actions.login")}
|
{t("general.actions.login")}
|
||||||
</Button>
|
</Button>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const INITIAL_STATE = {
|
|||||||
//language: "en-US"
|
//language: "en-US"
|
||||||
},
|
},
|
||||||
bodyshop: null,
|
bodyshop: null,
|
||||||
|
loginLoading: false,
|
||||||
fingerprint: null,
|
fingerprint: null,
|
||||||
error: null,
|
error: null,
|
||||||
conflict: false,
|
conflict: false,
|
||||||
@@ -26,6 +27,8 @@ const userReducer = (state = INITIAL_STATE, action) => {
|
|||||||
return { ...state, conflict: false };
|
return { ...state, conflict: false };
|
||||||
case UserActionTypes.SET_INSTANCE_CONFLICT:
|
case UserActionTypes.SET_INSTANCE_CONFLICT:
|
||||||
return { ...state, conflict: true };
|
return { ...state, conflict: true };
|
||||||
|
case UserActionTypes.EMAIL_SIGN_IN_START:
|
||||||
|
return { ...state, loginLoading: true };
|
||||||
case UserActionTypes.VALIDATE_PASSWORD_RESET_START:
|
case UserActionTypes.VALIDATE_PASSWORD_RESET_START:
|
||||||
case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START:
|
case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START:
|
||||||
return {
|
return {
|
||||||
@@ -63,6 +66,7 @@ const userReducer = (state = INITIAL_STATE, action) => {
|
|||||||
case UserActionTypes.SIGN_IN_SUCCESS:
|
case UserActionTypes.SIGN_IN_SUCCESS:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
loginLoading: false,
|
||||||
currentUser: action.payload,
|
currentUser: action.payload,
|
||||||
error: null,
|
error: null,
|
||||||
};
|
};
|
||||||
@@ -99,6 +103,7 @@ const userReducer = (state = INITIAL_STATE, action) => {
|
|||||||
case UserActionTypes.EMAIL_SIGN_UP_FAILURE:
|
case UserActionTypes.EMAIL_SIGN_UP_FAILURE:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
loginLoading: false,
|
||||||
error: action.payload,
|
error: action.payload,
|
||||||
};
|
};
|
||||||
case UserActionTypes.SET_AUTH_LEVEL:
|
case UserActionTypes.SET_AUTH_LEVEL:
|
||||||
|
|||||||
@@ -31,3 +31,8 @@ export const selectAuthLevel = createSelector(
|
|||||||
[selectUser],
|
[selectUser],
|
||||||
(user) => user.authLevel
|
(user) => user.authLevel
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectLoginLoading = createSelector(
|
||||||
|
[selectUser],
|
||||||
|
(user) => user.loginLoading
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user