diff --git a/client/src/components/Dashboard.js b/client/src/components/Dashboard.js index 5076e8d..103848a 100644 --- a/client/src/components/Dashboard.js +++ b/client/src/components/Dashboard.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import axios from 'axios'; import NewHabit from './NewHabit'; +import NewHabitForm from './NewHabitForm'; import CheckIn from './CheckIn'; import CurrentHabit from './CurrentHabit'; import Progress from './Progress'; @@ -17,14 +18,6 @@ class Dashboard extends Component { habitExist: false }; - //open check in form - handleCheckIn = () => { - this.setState((prevState) => ({ - checkIn: !prevState.checkIn - })) - } - - //used componentDidUpdate due to async nature of firebase/props componentDidUpdate(prevProps) { if (this.props.email !== undefined && this.props.email !== prevProps.email) { @@ -55,6 +48,8 @@ class Dashboard extends Component { this.setState({ checkIn: false }) } + + //toggle visibility of sidebar with Button hamburgerToggle = () => { this.setState((prevState) => ({ @@ -69,13 +64,26 @@ class Dashboard extends Component { })) } + //open check in form + handleCheckIn = () => { + this.setState((prevState) => ({ + checkIn: !prevState.checkIn + })) + } + render() { return (

Hello, {this.props.displayName}!

Have a habit? : {this.state.habitExist.toString()}

- + {/* TESTING FORM */} + +
+
+
+
+ {/* TESTING FORM */} {this.state.habitExist &&
@@ -99,7 +107,12 @@ class Dashboard extends Component { + + +
+ +
); } diff --git a/client/src/components/NewHabit.js b/client/src/components/NewHabit.js index b317485..d1cac03 100644 --- a/client/src/components/NewHabit.js +++ b/client/src/components/NewHabit.js @@ -26,12 +26,14 @@ class NewHabit extends Component { handleSubmit = (event) => { event.preventDefault(); - if (this.state.habit.length > 0 && this.state.length.length > 0 && this.state.intervals.length > 0 && this.state.intervals !== 'select'){ + console.log((this.state.habit && this.state.length && this.state.intervals && this.state.intervals !== 'select')) + if (this.state.habit && this.state.length && this.state.intervals && this.state.intervals !== 'select'){ this.setState({fieldsValid: true}); - const { name, habit, smart, length, intervals, date } = this.state; - axios.post('/api/habits/newhabit', { name, habit, smart, length, intervals, date }) + const { habit, smart, length, intervals, date } = this.state; + console.log(this.props.email + { habit, smart, length, intervals, date }) + axios.post('/api/habits/newhabit', this.props.email + { habit, smart, length, intervals, date }) .then((result) => { - console.log(result.data); + console.log("result.data: " + result.data); this.setState({habitData: result.data}) }) .catch((error) => { @@ -98,11 +100,11 @@ class NewHabit extends Component { + + @@ -110,11 +112,11 @@ class NewHabit extends Component { + +