Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
💥 - moved components into this.state.habitExist
Browse files Browse the repository at this point in the history
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
  • Loading branch information
paulywill committed Apr 29, 2019
1 parent f641a93 commit a6d2b24
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions client/src/components/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class Dashboard extends Component {
componentDidUpdate(prevProps) {
if (this.props.email !== undefined && this.props.email !== prevProps.email) {
// Do what you want with email
const user = this.props.email
console.log("Dashboard - email is: " + user)

const user = this.props.email
axios.get('/api/habits/first-habit/' + user)
.then(res =>
this.setState({ habitData: res.data.data }, () => {
Expand Down Expand Up @@ -76,26 +74,27 @@ class Dashboard extends Component {
render() {
return (
<div>
<NewHabit email={this.props.email}
handleNewHabitSubmit={this.handleNewHabitSubmit}
newEntry={this.state.newEntry} />

<CheckIn checkIn={this.state.checkIn}
habitId={this.state.habitData._id}
handleCheckIn={this.handleCheckIn}
handleCheckInSubmit={this.handleCheckInSubmit} />;


<main>
<h1>Hello, {this.props.displayName}!</h1>
<p>Have a habit? : {this.state.habitExist.toString()}</p>

{this.state.habitExist &&
<button className='habitButton' onClick={this.handleCheckIn}>Check In</button>
<div>
<button className='habitButton' onClick={this.handleCheckIn}>Check In</button>
<CheckIn checkIn={this.state.checkIn}
habitId={this.state.habitData._id}
handleCheckIn={this.handleCheckIn}
handleCheckInSubmit={this.handleCheckInSubmit} />
</div>
}

{!this.state.habitExist &&
<button className='habitButton' onClick={this.handleNewHabit} >Create New Habit</button>
<div>
<button className='habitButton' onClick={this.handleNewHabit} >Create New Habit</button>
<NewHabit email={this.props.email}
handleNewHabitSubmit={this.handleNewHabitSubmit}
newEntry={this.state.newEntry} />
</div>
}

<h2>Daily Dashboard</h2>
Expand Down

0 comments on commit a6d2b24

Please sign in to comment.