diff --git a/client/src/components/CurrentHabit.js b/client/src/components/CurrentHabit.js
index 3734aac..df53f6b 100644
--- a/client/src/components/CurrentHabit.js
+++ b/client/src/components/CurrentHabit.js
@@ -16,7 +16,7 @@ const CurrentHabit = ({_id, habit, length, date, smart}) => {
Habit name: {habit}
Start date: {startDate}
Smart habits:
- {smart.map(item => - {item}
)}
+ {smart.map(item => - {item}
)}
Duration (months): {length}
Countdown to finish:
diff --git a/client/src/components/Dashboard.js b/client/src/components/Dashboard.js
index 2a7051a..6dc9b8f 100644
--- a/client/src/components/Dashboard.js
+++ b/client/src/components/Dashboard.js
@@ -1,23 +1,103 @@
import React, { Component } from 'react';
+import axios from 'axios';
+import NewHabit from './NewHabit';
+import CheckIn from './check-in';
+import CurrentHabit from './CurrentHabit';
+import Progress from './Progress';
class Dashboard extends Component {
-
+
+ state = {
+ newEntry: false,
+ newEntryButton: true,
+ habitData: [],
+ hamburgerOpen: false,
+ checkIn: false,
+ habitExist: false,
+ };
+
+ //used componentDidUpdate due to async nature of firebase/props
componentDidUpdate(prevProps) {
if (this.props.email != undefined && this.props.email !== prevProps.email) {
// Do what you want with email
- console.log(this.props.email)
+ const user = this.props.email
+ console.log("email is: " + user)
+
+ axios.get('/api/habits/first-habit/' + user)
+ .then(res =>
+ this.setState({ habitData: res.data.data }, () => {
+ this.state.habitData ? this.setState({
+ newEntry: false, newEntryButton: false,
+ habitExist: true
+ }) : this.setState({ newEntry: true, newEntryButton: true, habitExist: false })
+ })
+ )
+ .catch(error =>
+ console.log(error)
+ )
+
}
}
+ handleNewHabit = () => {
+ this.setState({ newEntry: true })
+ }
+ handleNewHabitSubmit = (data) => {
+ this.setState({ newEntry: false, habitExist: true, newEntryButton: false, habitData: data });
+ }
+
+ handleCheckInSubmit = () => {
+ this.setState({ checkIn: false })
+ }
+
+ //toggle visibility of sidebar with Button
+ hamburgerToggle = () => {
+ this.setState((prevState) => ({
+ hamburgerOpen: !prevState.hamburgerOpen
+ }));
+ }
+
+ //open check in form
+ handleCheckIn = () => {
+ this.setState((prevState) => ({
+ checkIn: !prevState.checkIn
+ }))
+ }
+
render() {
- const email = this.props.email
+ let newHabitButton = null
+ if (this.state.newEntryButton) {
+ newHabitButton =
+ } else {
+ newHabitButton = null
+ }
+
+ let checkInComp = null;
+ let checkInButton = null;
+ if (this.state.habitExist) {
+ checkInComp = ;
+ checkInButton =
+ } else {
+ checkInComp = null;
+ checkInButton = null;
+ }
+
return (
-
Hello, {this.props.displayName}!
-
Your email is: {email}
+
+
+ Daily Dashboard
+ {newHabitButton}
+ {checkInButton}
+
+
+
);
}