- Switch redux -> Context
- Remove excess packages
This commit is contained in:
Daniel Mason 2021-03-31 19:14:22 +13:00
parent ebd88b3bb0
commit 65c092e4ee
Signed by: idanoo
GPG key ID: 387387CDBC02F132
14 changed files with 293 additions and 397 deletions

View file

@ -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);
});
};