Loading .......
diff --git a/src/components/ShowModal.js b/src/components/ShowModal.js
index 1e73950..c2e6ae5 100644
--- a/src/components/ShowModal.js
+++ b/src/components/ShowModal.js
@@ -1,11 +1,18 @@
import React from 'react';
+import store from '../store';
+import state from '../state';
function ShowModal(props) {
+
return (
diff --git a/src/components/SpecialText.js b/src/components/SpecialText.js
index 7d3b5e9..2b021fe 100644
--- a/src/components/SpecialText.js
+++ b/src/components/SpecialText.js
@@ -1,7 +1,16 @@
import React from 'react';
+import store from '../store';
class SpecialText extends React.Component {
state={text:""}
+
+ componentDidMount() {
+ store.subscribe(() => {
+ let text = store.getState().specialText;
+ this.setState({text});
+ })
+ }
+
render() {
const {
props,
diff --git a/src/components/SpecialTextBox.js b/src/components/SpecialTextBox.js
index 63cb01f..ceea1cf 100644
--- a/src/components/SpecialTextBox.js
+++ b/src/components/SpecialTextBox.js
@@ -1,12 +1,17 @@
import React from 'react';
-
+import store from '../store';
function SpecialTextBox(props) {
return (
Enter Special Text:
{
-
+ 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