From 591d7e8362f412578dac9c02a42ef9ad6d3f23d9 Mon Sep 17 00:00:00 2001 From: Paul Gamble Date: Sun, 28 Apr 2019 21:01:33 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20=20-=20working=20with=20one=20he?= =?UTF-8?q?ader;=20some=20redundency=20del?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The state is working nicely with one header. In addition I've started to remove redundent components no longer needed. #94 --- client/src/components/Dashboard.js | 3 -- client/src/components/header.js | 47 +++++++++++---------- client/src/containers/HeaderLoggedIn.js | 42 ------------------ client/src/containers/Layout.js | 30 ------------- client/src/containers/withAuthentication.js | 40 ------------------ 5 files changed, 24 insertions(+), 138 deletions(-) delete mode 100644 client/src/containers/HeaderLoggedIn.js delete mode 100644 client/src/containers/Layout.js delete mode 100644 client/src/containers/withAuthentication.js diff --git a/client/src/components/Dashboard.js b/client/src/components/Dashboard.js index d5dd13e..66b9d8d 100644 --- a/client/src/components/Dashboard.js +++ b/client/src/components/Dashboard.js @@ -1,10 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -//import Layout from '../containers/Layout'; import SocialProfileList from './SocialProfileList'; -//import { auth } from '../firebase'; import axios from 'axios'; -import HeaderLoggedIn from '../containers/HeaderLoggedIn'; import NewHabit from './NewHabit'; import CheckIn from './check-in'; import CurrentHabit from './CurrentHabit'; diff --git a/client/src/components/header.js b/client/src/components/header.js index 32e1180..6bc46d7 100644 --- a/client/src/components/header.js +++ b/client/src/components/header.js @@ -2,30 +2,31 @@ import React from 'react'; const Header = (props) => ( +
+ {/* Logged in*/} + {props.providerData && +
+ +

Habit Tracker

+ {props.providerData[0].providerName} -
- - {props.providerData && } +
+ } + {/* Not Logged in*/} + {!props.providerData && +
+

Habit Tracker

+
+ } -

Habit Tracker

- - - {props.providerData && - - {props.providerData[0].providerName} - - } - -
- -); +
+); export default Header; \ No newline at end of file diff --git a/client/src/containers/HeaderLoggedIn.js b/client/src/containers/HeaderLoggedIn.js deleted file mode 100644 index 22107bc..0000000 --- a/client/src/containers/HeaderLoggedIn.js +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { Link } from 'react-router-dom'; - - -const propTypes = { - children: PropTypes.node.isRequired, -}; - -const HeaderLoggedIn = ({ children, hamburgerToggle, hamburgerOpen }) => { - return ( -
-
- - - - -

Habit Tracker

- - {children} -
-
- ); -}; - -HeaderLoggedIn.propTypes = propTypes; - -export default HeaderLoggedIn; \ No newline at end of file diff --git a/client/src/containers/Layout.js b/client/src/containers/Layout.js deleted file mode 100644 index 7476651..0000000 --- a/client/src/containers/Layout.js +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import Footer from '../components/footer' -import HeaderLoggedIn from './HeaderLoggedIn'; - -const propTypes = { - children: PropTypes.node.isRequired, - contentCenter: PropTypes.bool -}; - -const Layout = ({ children}) => { - return ( -
- {/*
or Need to swap headers based of if user logged in */} - -
-
- {children} -
-
- -
-
- ); -}; - -Layout.propTypes = propTypes; - -export default Layout; \ No newline at end of file diff --git a/client/src/containers/withAuthentication.js b/client/src/containers/withAuthentication.js deleted file mode 100644 index bef32fe..0000000 --- a/client/src/containers/withAuthentication.js +++ /dev/null @@ -1,40 +0,0 @@ -import React, { Component } from 'react'; -import Delay from 'react-delay'; - -import { auth } from '../firebase'; - -export default WrappedComponent => { - class WithAuthentication extends Component { - state = { - providerData: [] - }; - - componentDidMount() { - auth.getAuth().onAuthStateChanged(user => { - if (user) { - //User is signed in. - console.info('User is signed in.'); - this.setState({ providerData: user.providerData }); - } else { - console.info('Must be authenticated'); - this.props.history.push('/'); - } - }); - } - - render() { - return this.state.providerData.length > 0 ? ( - - ) : ( - -

Loading...

-
- ); - } - } - - return WithAuthentication; -};