-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📝: Refactor firebase code #94
Comments
WIP: https://github.com/paulywill/v8-geckos-team-07/tree/fix/firebase-ui This change is breaking the working state of our dev build (ie all the links and passing state) however already there's massive improvement IMO. Goal:
App.js: <div className={styles.container}>
{this.state.isSignedIn !== undefined && !this.state.isSignedIn &&
//Not signed-in yet
<div>
<Header />
<div className="circle">
<h2>A simple way to measure whether you did a habit.</h2>
<ol>
<li>Sign in using Google</li>
<li>Create a habit to track</li>
<li>Check in to reflect and log your progress</li>
<li>Review your data to help you along your journey</li>
</ol>
<p>Happy Tracking!</p>
</div>
<StyledFirebaseAuth className={styles.firebaseUi} uiConfig={this.uiConfig}
firebaseAuth={firebaseApp.auth()} />
<Footer />
</div>
}
{this.state.isSignedIn &&
//Signed in
<div className={styles.signedIn} id="content-wrap">
<Header providerData={this.state.providerData} />
<Dashboard />
<button><a className={styles.button} onClick={() => firebaseApp.auth().signOut()}>Sign-out</a></button>
<Footer />
</div>
}
</div> Header.js: import React from 'react';
const Header = (props) => (
<header className="App-header">
{props.providerData && <button
aria-haspopup="true"
aria-expanded={"false"}
id="hamburger-menu" >
<i className="main-button-icon fa fa-bars fa-3x"></i>
</button>}
<h1>Habit Tracker</h1>
{props.providerData &&
<img src={props.providerData[0].photoURL}
alt={props.providerData[0].providerName}
className="container__profile--photo" />
}
</header>
);
export default Header; |
The state is working nicely with one header. In addition I've started to remove redundent components no longer needed. chingu-voyages#94
The firebase folder contained redundent files and components that are no longer being used. chingu-voyages#94
firebase-web-ui react component takes care of what SocialButton|ProfileList use to do. chingu-voyages#94
Errr... was making massive progress and now stuck. Strangely previous code we have running on dev build passes user's data correctly when running Firebase function right in component. However when trying to fetch values from props when passing to Dashboard.js ... no luck. Opened a Stackoverflow question: https://stackoverflow.com/questions/55897496/firebase-providerdata-passed-in-props-trouble-accessing-in-componentdidmount Stumped on state / props / and whether super constructor is still required. |
I was having a hell of time trying to pass the user's email to componentDidMount... after a lengthy post on Stackoverflow https://stackoverflow.com/questions/55904459/passing-props-to-componentdidmount finally got and answer. Will re-add all the code I removed for testing. chingu-voyages#94
There still 2 warnings; 1 for unused var that's breaks everything if I remove it: checkInComplet checkInComp = null; The other warning message is for the sign-out button link. Want's a valid href in the <a> tag. chingu-voyages#94
Starting to see some light at the end of the tunnel again. Still, have to bring back to working order:
|
The modal for New habit is working once again... however the Exit and Submit are not performing as intended. Some of the code that easily read state is no longer working. There is some logic for example that passes around boolean values to determine which buttons to show/hide. Why this was working I'm sure if it was correct or why now there's so much difficulty. Again I think it goes that to 'proper' state/prop passing. Just starting to get the gist of it but there's some sticking points still. I feel as though out dev build was throwing values around like crazy and it worked... now trying to go by best practices I'm stuck figuring our what's happening. It would explain to some degree how the Layout was working previously. I removed it thinking it was a useless wrapper... not I'm thinking it was what was responsible for passing things again. chingu-voyages#94
Moved the components into the this.state.habitExist; this of course breaks some logic. We're setting the habitExist based on clicking the button for the modal not the submission button. chingu-voyages#94
The habitExist was been set just for opening modal. chingu-voyages#94
Following inspiration from https://github.com/hamza-mirza/react-weather-app, making some of our forms statless chingu-voyages#94
Still playing with form refactor chingu-voyages#94
Task Description
Some of the problems and confusing is stemming from a firebase tutorial I used to implement the "google sign-in" button.
firebase has a much simpler solution : firebaseui-web-react
Getting the example they provided did take some time but I finally resolved.
Function
Using the firebaseui-web-react will simplify our components big time!
This allows easy flexibility in the future... ie adding Github, Facebook, etc.
This should also eliminate the need for so many nested components.
My only concern/observation is the elimination or need for 404 routing.
Here's the basic setup:
Feature
#90 - Hamburger / Settings page
The text was updated successfully, but these errors were encountered: