Skip to content

Instantly share code, notes, and snippets.

@codrin-iftimie
Last active June 15, 2020 14:36
Show Gist options
  • Save codrin-iftimie/1052f09244f40084488e471ff69cdc9d to your computer and use it in GitHub Desktop.
Save codrin-iftimie/1052f09244f40084488e471ff69cdc9d to your computer and use it in GitHub Desktop.
// Disclaimer: not actual code
// actions/login.js
import authService from "services/authService"
import {getLoginInfo} from "selectors/login"
export function login() {
return function thunk(dispatch, getState) {
const data = getLoginInfo(getState());
if (!data.username) {
notifications.show({message: "Please enter an email"})
}
dispatch({type: "LOGIN_LOADING", isLoading: true});
await authService.login(data);
dispatch({type: "LOGIN_LOADING", isLoading: false});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment