mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 21:52:19 +00:00
0.0.7
- Switch redux -> Context - Remove excess packages
This commit is contained in:
parent
ebd88b3bb0
commit
65c092e4ee
14 changed files with 293 additions and 397 deletions
|
@ -1,7 +1,6 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import { toast } from 'react-toastify';
|
||||
import AuthContext from './AuthContext';
|
||||
|
||||
import { PostLogin, PostRegister } from '../Api/index';
|
||||
|
||||
const AuthContextProvider = ({ children }) => {
|
||||
|
@ -22,21 +21,16 @@ const AuthContextProvider = ({ children }) => {
|
|||
PostLogin(formValues).then(user => {
|
||||
if (user) {
|
||||
setUser(user);
|
||||
const { history } = this.props;
|
||||
history.push("/dashboard");
|
||||
localStorage.setItem('user', JSON.stringify(user));
|
||||
}
|
||||
setLoading(false);
|
||||
})
|
||||
}
|
||||
|
||||
const Register = (formValues) => {
|
||||
const { history } = this.props;
|
||||
|
||||
setLoading(true);
|
||||
return PostRegister(formValues).then(response => {
|
||||
if (response) {
|
||||
history.push("/login");
|
||||
}
|
||||
// Do stuff here?
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue