diff --git a/package-lock.json b/package-lock.json index 20071db..2224181 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3086,12 +3086,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3106,17 +3108,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3233,7 +3238,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3245,6 +3251,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3259,6 +3266,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3266,12 +3274,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3290,6 +3300,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3370,7 +3381,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3382,6 +3394,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3503,6 +3516,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7487,12 +7501,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7507,17 +7523,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -7634,7 +7653,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -7646,6 +7666,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7660,6 +7681,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -7667,12 +7689,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -7691,6 +7715,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -7771,7 +7796,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7783,6 +7809,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -7904,6 +7931,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/src/components/ChangeTemperature.js b/src/components/ChangeTemperature.js index fa894bc..fdd1a44 100644 --- a/src/components/ChangeTemperature.js +++ b/src/components/ChangeTemperature.js @@ -1,4 +1,5 @@ import React from "react"; +import store from '../store'; function ChangeTemperature(props){ return( @@ -6,7 +7,12 @@ function ChangeTemperature(props){
diff --git a/src/components/CityDropDown.js b/src/components/CityDropDown.js index c47586e..91e462d 100644 --- a/src/components/CityDropDown.js +++ b/src/components/CityDropDown.js @@ -1,4 +1,5 @@ import React from 'react'; +import store from '../store'; function CityDropDown(props) { return ( @@ -6,7 +7,12 @@ function CityDropDown(props) { CurrentCity: { - + let value = e.target.value; + let message = { + type: 'SET_SPECIAL_TEXT', + value: value + } + store.dispatch(message); }} /> ); diff --git a/src/components/Thermostat.js b/src/components/Thermostat.js index 2e43fbe..ce5c3dc 100644 --- a/src/components/Thermostat.js +++ b/src/components/Thermostat.js @@ -1,9 +1,17 @@ import React from "react"; import DonutChart from "./ignore/DonutChart"; +import store from '../store'; class Thermostat extends React.Component { state={temp:""} + componentDidMount() { + store.subscribe(() => { + let temp = store.getState().currentTemp; + this.setState({temp}); + }) + } + render() { const { props, diff --git a/src/reducers/index.js b/src/reducers/index.js index e4e85c8..dc47985 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -1,28 +1,53 @@ import { combineReducers } from 'redux' -function currentCount(state=0, action){ - if(action.type === "INCREASE_COUNTER"){ - +function currentCount(state=0, action) { + if(action.type === "INCREASE_COUNTER") { + return state + 1; } - if(action.type === "DECREASE_COUNTER"){ - + + if(action.type === "DECREASE_COUNTER") { + return state - 1; } + return state; } -function users(state =[], action){ - if(action.type === "ADD_USER"){ +function users(state = [], action) { + if(action.type === "ADD_USER") { } - if(action.type === "REMOVE_USER"){ + + if(action.type === "REMOVE_USER") { } + return state; } function specialText(state = "", action){ - if(action.type === "SET_SPECIAL_TEXT"){ + if(action.type === "SET_SPECIAL_TEXT") { + return action.value; + } + return state; +} + +function currentCity(state = "", action) { + if(action.type === 'SET_CURRENT_CITY') { + return action.value; + } + return state; +} + +function currentTemp(state='', action) { + if(action.type === 'SET_TEMP') { + return action.value; + } + return state; +} + +function isLoading(state=false, action) { + if(action.type === 'SET_IS_LOADING') { return action.value; } return state; @@ -31,5 +56,8 @@ function specialText(state = "", action){ export default combineReducers({ currentCount, users, - specialText + specialText, + currentCity, + currentTemp, + isLoading }) \ No newline at end of file