|
@@ -7,18 +7,27 @@ import List from "../components/list";
|
|
|
import LoadForm from "../components/loadForm";
|
|
|
import EditModal from "../components/modal";
|
|
|
|
|
|
+import { auth, googleAuthProvider } from "../firebaseConfig";
|
|
|
+
|
|
|
class App extends Component {
|
|
|
state = {
|
|
|
openAddForm: false,
|
|
|
- toggleModal: false
|
|
|
+ toggleModal: false,
|
|
|
+ user: null
|
|
|
};
|
|
|
|
|
|
componentDidMount() {
|
|
|
const { getLoads } = this.props;
|
|
|
|
|
|
getLoads();
|
|
|
+
|
|
|
+ auth.onAuthStateChanged(user => this.setState({ user }));
|
|
|
}
|
|
|
|
|
|
+ authRequest = () => {
|
|
|
+ auth.signInWithPopup(googleAuthProvider).then(res => this.setState({ user: res.user }));
|
|
|
+ };
|
|
|
+
|
|
|
openEditModal = id => {
|
|
|
const { getInitVal } = this.props;
|
|
|
getInitVal(id);
|
|
@@ -30,9 +39,13 @@ class App extends Component {
|
|
|
|
|
|
render() {
|
|
|
const { list, inputData, editLoadsRequest, initialValues, postLoads } = this.props;
|
|
|
- const { openAddForm, toggleModal } = this.state;
|
|
|
+ const { openAddForm, toggleModal, user } = this.state;
|
|
|
return (
|
|
|
<Fragment>
|
|
|
+ <button onClick={this.authRequest}>Auth</button>
|
|
|
+
|
|
|
+ <h1>{user && user.displayName}</h1>
|
|
|
+
|
|
|
<h1 className="h1-tag">
|
|
|
Доставка грузов "to-do list" -{" "}
|
|
|
<span onClick={this.openFormHandler} className="h1-tag h1-tag--add">
|