From ee808c6dda828c6a3dee03ac77dace5a637f4105 Mon Sep 17 00:00:00 2001 From: User Date: Sat, 23 Mar 2019 14:15:01 -0600 Subject: [PATCH 1/7] Added containers for the Counter components. --- package-lock.json | 56 ++++++++++++++++++------ src/App.js | 8 ++-- src/actions/index.js | 6 +++ src/components/SpecialTextBox.js | 16 +------ src/containers/CounterBottonContainer.js | 12 +++++ src/containers/CounterContainer.js | 13 ++++++ src/containers/SpecialTextContainer.js | 2 + src/index.js | 5 ++- src/reducers/index.js | 23 +++++++--- 9 files changed, 102 insertions(+), 39 deletions(-) create mode 100644 src/containers/CounterBottonContainer.js create mode 100644 src/containers/CounterContainer.js diff --git a/package-lock.json b/package-lock.json index ee9a1d2..d7bb883 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3187,12 +3187,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" @@ -3207,17 +3209,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", @@ -3334,7 +3339,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3346,6 +3352,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3360,6 +3367,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3367,12 +3375,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" @@ -3391,6 +3401,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3471,7 +3482,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3483,6 +3495,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3604,6 +3617,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", @@ -7113,12 +7127,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" @@ -7133,17 +7149,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", @@ -7260,7 +7279,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -7272,6 +7292,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7286,6 +7307,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -7293,12 +7315,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -7317,6 +7341,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -7397,7 +7422,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7409,6 +7435,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -7530,6 +7557,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/App.js b/src/App.js index 392ed1f..e746154 100644 --- a/src/App.js +++ b/src/App.js @@ -1,8 +1,8 @@ import React from 'react'; -import CounterButton from "./components/CounterButton"; -import SpecialTextBox from "./components/SpecialTextBox"; -import Counter from "./components/Counter"; -import SpecialText from "./components/SpecialText"; +import CounterButton from "./containers/CounterBottonContainer"; +import SpecialTextBox from "./containers/SpecialTextBoxContainer"; +import Counter from "./containers/CounterContainer"; +import SpecialText from "./containers/SpecialTextContainer"; import UserButtons from "./components/UserButtons"; import Thermostat from "./components/Thermostat"; import Users from "./components/Users"; diff --git a/src/actions/index.js b/src/actions/index.js index 78955f4..4a10480 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -4,6 +4,12 @@ export function increaseCounter(){ } } +export function decreaseCounter(){ + return { + type:"DECREASE_COUNTER" + } +} + export function setSpecialText(txt){ return { type:"SET_SPECIAL_TEXT", diff --git a/src/components/SpecialTextBox.js b/src/components/SpecialTextBox.js index 53c3938..83141ef 100644 --- a/src/components/SpecialTextBox.js +++ b/src/components/SpecialTextBox.js @@ -1,8 +1,6 @@ import React from 'react'; -import {connect} from "react-redux"; -import {setSpecialText} from "../actions"; -function SpecialTextBox(props) { +export default function SpecialTextBox(props) { return (
Enter Special Text: @@ -13,14 +11,4 @@ function SpecialTextBox(props) { }} />
); -} - -function mapDispatchToProps(dispatch){ - return { - set:function(txt){ - let action = setSpecialText(txt) - dispatch(action); - } - } -} -export default (SpecialTextBox); \ No newline at end of file +} \ No newline at end of file diff --git a/src/containers/CounterBottonContainer.js b/src/containers/CounterBottonContainer.js new file mode 100644 index 0000000..60e7150 --- /dev/null +++ b/src/containers/CounterBottonContainer.js @@ -0,0 +1,12 @@ +import { connect } from 'react-redux'; +import {increaseCounter, decreaseCounter} from "../actions"; +import CounterButton from "../components/CounterButton"; + + +const mapDispatchToProps = { + increase:increaseCounter, + decrease:decreaseCounter + } + + +export default connect(null,mapDispatchToProps)(CounterButton); diff --git a/src/containers/CounterContainer.js b/src/containers/CounterContainer.js new file mode 100644 index 0000000..2e2a094 --- /dev/null +++ b/src/containers/CounterContainer.js @@ -0,0 +1,13 @@ +import { connect } from 'react-redux'; +import Counter from "../components/Counter"; + +//map a prop called text to the state specialText +function mapStateToProps(state){ + console.log("Counter: " + state.currentCount); + + return { + count: state.currentCount + } +} + +export default connect(mapStateToProps)(Counter); diff --git a/src/containers/SpecialTextContainer.js b/src/containers/SpecialTextContainer.js index 794bd45..850edc5 100644 --- a/src/containers/SpecialTextContainer.js +++ b/src/containers/SpecialTextContainer.js @@ -4,6 +4,8 @@ import SpecialText from "../components/SpecialText"; //map a prop called text to the state specialText function mapStateToProps(state){ + console.log("About to pass: " + state.specialText); + return { text: state.specialText } diff --git a/src/index.js b/src/index.js index 25f54ba..e3b82ab 100644 --- a/src/index.js +++ b/src/index.js @@ -2,9 +2,10 @@ import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import './index.css'; - +import {Provider} from "react-redux"; +import store from "./store"; ReactDOM.render( - , + , document.getElementById('root') ); diff --git a/src/reducers/index.js b/src/reducers/index.js index dce7c2c..8df7cc8 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -1,10 +1,12 @@ +import {combineReducers} from "redux"; + function currentCount(state=0, action){ - if(action.type === "INCREASE_COUNTER"){ - + if (action.type === "INCREASE_COUNTER"){ + state += 1; } - if(action.type === "DECREASE_COUNTER"){ - + else if( action.type === "DECREASE_COUNTER"){ + state -= 1; } return state; } @@ -12,9 +14,14 @@ function currentCount(state=0, action){ function users(state =[], action){ if(action.type === "ADD_USER"){ + //let tmp = state.map(p=>p); + //tmp.push(action.value); + //return tmp; + + return [...state, action.value]; } if(action.type === "REMOVE_USER"){ - + return state.splice(); } return state; } @@ -27,3 +34,9 @@ function specialText(state = "", action){ return state; } +let reducers = combineReducers({ + currentCount, + users, + specialText +}) +export default reducers; From 27fd60b56327e8fd4571ed6350a49d4c464bad26 Mon Sep 17 00:00:00 2001 From: User Date: Sat, 23 Mar 2019 14:27:39 -0600 Subject: [PATCH 2/7] Added containers for changing the Current City Component. --- src/App.js | 4 ++-- src/actions/index.js | 7 +++++++ src/components/CityDropDown.js | 1 + src/containers/CityDropDownContainer.js | 11 +++++++++++ src/containers/CurrentCityContainer.js | 14 ++++++++++++++ src/reducers/index.js | 11 ++++++++++- 6 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 src/containers/CityDropDownContainer.js create mode 100644 src/containers/CurrentCityContainer.js diff --git a/src/App.js b/src/App.js index e746154..cd9f207 100644 --- a/src/App.js +++ b/src/App.js @@ -9,8 +9,8 @@ import Users from "./components/Users"; import ChangeTemperature from "./components/ChangeTemperature"; import VideoPlayer from "./components/VideoPlayer"; import VideoTextBox from "./components/VideoTextBox"; -import CurrentCity from "./components/CurrentCity"; -import CityDropDown from "./components/CityDropDown"; +import CurrentCity from "./containers/CurrentCityContainer"; +import CityDropDown from "./containers/CityDropDownContainer"; import SearchTextBox from "./components/SearchTextBox"; import SortUsers from "./components/SortUsers"; import ScaleVideo from "./components/ScaleVideo"; diff --git a/src/actions/index.js b/src/actions/index.js index 4a10480..c0186b8 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -27,4 +27,11 @@ export function removeUser(){ return { type:"REMOVE_USER" } +} + +export function setCurrentCity(city) { + return { + type: "SET_CURRENT_CITY", + value: city + } } \ No newline at end of file diff --git a/src/components/CityDropDown.js b/src/components/CityDropDown.js index 843b9a3..3b5ecff 100644 --- a/src/components/CityDropDown.js +++ b/src/components/CityDropDown.js @@ -11,6 +11,7 @@ function CityDropDown(props) { } } }> + diff --git a/src/containers/CityDropDownContainer.js b/src/containers/CityDropDownContainer.js new file mode 100644 index 0000000..e356c7c --- /dev/null +++ b/src/containers/CityDropDownContainer.js @@ -0,0 +1,11 @@ +import { connect } from 'react-redux'; +import {setCurrentCity} from "../actions"; +import CityDropDown from "../components/CityDropDown"; + + +const mapDispatchToProps = { + set:setCurrentCity + } + + +export default connect(null,mapDispatchToProps)(CityDropDown); diff --git a/src/containers/CurrentCityContainer.js b/src/containers/CurrentCityContainer.js new file mode 100644 index 0000000..7819b81 --- /dev/null +++ b/src/containers/CurrentCityContainer.js @@ -0,0 +1,14 @@ +import { connect } from 'react-redux'; +import {setCurrentCity} from "../actions"; +import CurrentCity from "../components/CurrentCity"; + +//map a prop called text to the state currentCity +function mapStateToProps(state){ + console.log("The new City: " + state.currentCity); + + return { + text: state.currentCity + } +} + +export default connect(mapStateToProps)(CurrentCity); diff --git a/src/reducers/index.js b/src/reducers/index.js index 8df7cc8..0088e70 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -34,9 +34,18 @@ function specialText(state = "", action){ return state; } + +function currentCity(state = "", action) { + if (action.type === "SET_CURRENT_CITY") { + return action.value; + } + return state; +} + let reducers = combineReducers({ currentCount, users, - specialText + specialText, + currentCity }) export default reducers; From e7d99f58916054157f343810317c3cb39aeaa49a Mon Sep 17 00:00:00 2001 From: User Date: Sat, 23 Mar 2019 14:37:52 -0600 Subject: [PATCH 3/7] Added containers for the Thermostat. --- src/App.js | 4 ++-- src/actions/index.js | 7 +++++++ src/containers/ChangeTemperatureContainer.js | 11 +++++++++++ src/containers/ThermostatContainer.js | 13 +++++++++++++ src/reducers/index.js | 12 +++++++++++- 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/containers/ChangeTemperatureContainer.js create mode 100644 src/containers/ThermostatContainer.js diff --git a/src/App.js b/src/App.js index cd9f207..324fc86 100644 --- a/src/App.js +++ b/src/App.js @@ -4,9 +4,9 @@ import SpecialTextBox from "./containers/SpecialTextBoxContainer"; import Counter from "./containers/CounterContainer"; import SpecialText from "./containers/SpecialTextContainer"; import UserButtons from "./components/UserButtons"; -import Thermostat from "./components/Thermostat"; +import Thermostat from "./containers/ThermostatContainer"; import Users from "./components/Users"; -import ChangeTemperature from "./components/ChangeTemperature"; +import ChangeTemperature from "./containers/ChangeTemperatureContainer"; import VideoPlayer from "./components/VideoPlayer"; import VideoTextBox from "./components/VideoTextBox"; import CurrentCity from "./containers/CurrentCityContainer"; diff --git a/src/actions/index.js b/src/actions/index.js index c0186b8..39a32b0 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -34,4 +34,11 @@ export function setCurrentCity(city) { type: "SET_CURRENT_CITY", value: city } +} + +export function setCurrentTemperature(temperature) { + return { + type: "SET_CURRENT_TEMPERATURE", + value: temperature + } } \ No newline at end of file diff --git a/src/containers/ChangeTemperatureContainer.js b/src/containers/ChangeTemperatureContainer.js new file mode 100644 index 0000000..a2fda14 --- /dev/null +++ b/src/containers/ChangeTemperatureContainer.js @@ -0,0 +1,11 @@ +import { connect } from 'react-redux'; +import {setCurrentTemperature} from "../actions"; +import ChangeTemperature from "../components/ChangeTemperature"; + + +const mapDispatchToProps = { + set:setCurrentTemperature + } + + +export default connect(null,mapDispatchToProps)(ChangeTemperature); diff --git a/src/containers/ThermostatContainer.js b/src/containers/ThermostatContainer.js new file mode 100644 index 0000000..ca87110 --- /dev/null +++ b/src/containers/ThermostatContainer.js @@ -0,0 +1,13 @@ +import { connect } from 'react-redux'; +import Thermostat from "../components/Thermostat"; + +//map a prop called text to the state specialText +function mapStateToProps(state){ + console.log("Temperature: " + state.currentTemp); + + return { + temp: state.currentTemp + } +} + +export default connect(mapStateToProps)(Thermostat); diff --git a/src/reducers/index.js b/src/reducers/index.js index 0088e70..4f7d683 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -42,10 +42,20 @@ function currentCity(state = "", action) { return state; } + +function currentTemp(state=0, action) { + if (action.type === "SET_CURRENT_TEMPERATURE") { + return action.value + } + return state; +} + + let reducers = combineReducers({ currentCount, users, specialText, - currentCity + currentCity, + currentTemp }) export default reducers; From 1c00c631cfb2821ed8ed4a8f40c5b57d5be7da6d Mon Sep 17 00:00:00 2001 From: User Date: Sat, 23 Mar 2019 14:39:44 -0600 Subject: [PATCH 4/7] Modified the object of a user to use name instead of first name and last name. --- src/components/UserButtons.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/UserButtons.js b/src/components/UserButtons.js index 261dd4d..a522e51 100644 --- a/src/components/UserButtons.js +++ b/src/components/UserButtons.js @@ -8,8 +8,7 @@ function UserButtons(props) { if(props.add){ props.add({ "id": 1, - "first_name": "george", - "last_name": "bluth", + "name": "George Bluth", "address": "4116 Magnolia Drive, Portland, ME 04103", "phone": 15551234567, "occupation": "father", From e181f4bef0ddd88420c686162af7fe34f8cb0486 Mon Sep 17 00:00:00 2001 From: User Date: Sat, 23 Mar 2019 14:59:42 -0600 Subject: [PATCH 5/7] Added new containers for the Video Player. --- src/App.js | 4 ++-- src/actions/index.js | 7 +++++++ src/containers/SpecialTextContainer.js | 1 - src/containers/VideoPlayerContainer.js | 13 +++++++++++++ src/containers/VideoTextBoxContainer.js | 11 +++++++++++ src/reducers/index.js | 10 +++++++++- 6 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 src/containers/VideoPlayerContainer.js create mode 100644 src/containers/VideoTextBoxContainer.js diff --git a/src/App.js b/src/App.js index 324fc86..0cc5f44 100644 --- a/src/App.js +++ b/src/App.js @@ -7,8 +7,8 @@ import UserButtons from "./components/UserButtons"; import Thermostat from "./containers/ThermostatContainer"; import Users from "./components/Users"; import ChangeTemperature from "./containers/ChangeTemperatureContainer"; -import VideoPlayer from "./components/VideoPlayer"; -import VideoTextBox from "./components/VideoTextBox"; +import VideoPlayer from "./containers/VideoPlayerContainer"; +import VideoTextBox from "./containers/VideoTextBoxContainer"; import CurrentCity from "./containers/CurrentCityContainer"; import CityDropDown from "./containers/CityDropDownContainer"; import SearchTextBox from "./components/SearchTextBox"; diff --git a/src/actions/index.js b/src/actions/index.js index 39a32b0..7c7b6b0 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -41,4 +41,11 @@ export function setCurrentTemperature(temperature) { type: "SET_CURRENT_TEMPERATURE", value: temperature } +} + +export function setVideoUrl(url) { + return { + type: "SET_VIDEO_URL", + value: url + } } \ No newline at end of file diff --git a/src/containers/SpecialTextContainer.js b/src/containers/SpecialTextContainer.js index 850edc5..2ce0b44 100644 --- a/src/containers/SpecialTextContainer.js +++ b/src/containers/SpecialTextContainer.js @@ -1,5 +1,4 @@ import { connect } from 'react-redux'; -import {setCurrentUser} from "../actions"; import SpecialText from "../components/SpecialText"; //map a prop called text to the state specialText diff --git a/src/containers/VideoPlayerContainer.js b/src/containers/VideoPlayerContainer.js new file mode 100644 index 0000000..be5cbf9 --- /dev/null +++ b/src/containers/VideoPlayerContainer.js @@ -0,0 +1,13 @@ +import { connect } from 'react-redux'; +import VideoPlayer from "../components/VideoPlayer"; + +//map a prop called text to the state specialText +function mapStateToProps(state){ + console.log("Video URL: " + state.videoURL); + + return { + URL: state.videoURL + } +} + +export default connect(mapStateToProps)(VideoPlayer); diff --git a/src/containers/VideoTextBoxContainer.js b/src/containers/VideoTextBoxContainer.js new file mode 100644 index 0000000..ac987f1 --- /dev/null +++ b/src/containers/VideoTextBoxContainer.js @@ -0,0 +1,11 @@ +import { connect } from 'react-redux'; +import {setVideoUrl} from "../actions"; +import VideoTextBox from "../components/VideoTextBox"; + + +const mapDispatchToProps = { + set:setVideoUrl + } + + +export default connect(null,mapDispatchToProps)(VideoTextBox); diff --git a/src/reducers/index.js b/src/reducers/index.js index 4f7d683..bb1f432 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -50,12 +50,20 @@ function currentTemp(state=0, action) { return state; } +function videoURL(state="", action) { + if (action.type === "SET_VIDEO_URL") { + return action.value + } + return state; +} + let reducers = combineReducers({ currentCount, users, specialText, currentCity, - currentTemp + currentTemp, + videoURL }) export default reducers; From e72710c45034215b18b5fd8533dd57475132dc68 Mon Sep 17 00:00:00 2001 From: User Date: Mon, 25 Mar 2019 23:15:30 -0600 Subject: [PATCH 6/7] Added container for the Users list. --- src/App.js | 2 +- src/components/Users.js | 4 ++-- src/containers/UsersContainer.js | 12 ++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 src/containers/UsersContainer.js diff --git a/src/App.js b/src/App.js index 0cc5f44..25b75b9 100644 --- a/src/App.js +++ b/src/App.js @@ -5,7 +5,7 @@ import Counter from "./containers/CounterContainer"; import SpecialText from "./containers/SpecialTextContainer"; import UserButtons from "./components/UserButtons"; import Thermostat from "./containers/ThermostatContainer"; -import Users from "./components/Users"; +import Users from "./containers/UsersContainer"; import ChangeTemperature from "./containers/ChangeTemperatureContainer"; import VideoPlayer from "./containers/VideoPlayerContainer"; import VideoTextBox from "./containers/VideoTextBoxContainer"; diff --git a/src/components/Users.js b/src/components/Users.js index 6a04386..bc41891 100644 --- a/src/components/Users.js +++ b/src/components/Users.js @@ -11,8 +11,8 @@ function Users(props) { (props.firstNameFilter && u.name.indexOf(props.firstNameFilter) > -1); }) - usersDivs = usersDivs.map(function(u){ - return
{u.name}
+ usersDivs = usersDivs.map(function(u, i){ + return
{u.name}
}) } return ( diff --git a/src/containers/UsersContainer.js b/src/containers/UsersContainer.js new file mode 100644 index 0000000..34908be --- /dev/null +++ b/src/containers/UsersContainer.js @@ -0,0 +1,12 @@ +import { connect } from 'react-redux'; +import Users from "../components/Users"; + +//map a prop called text to the state specialText +function mapStateToProps(state){ + + return { + users: state.users + } +} + +export default connect(mapStateToProps)(Users); From 8c61c69e895f7131b5bfadc7c0095ed101085a5e Mon Sep 17 00:00:00 2001 From: User Date: Mon, 25 Mar 2019 23:41:22 -0600 Subject: [PATCH 7/7] Added container for the First Name search capability. --- src/App.js | 4 ++-- src/actions/index.js | 8 ++++++++ src/containers/SearchTextBoxContainer.js | 11 +++++++++++ src/containers/UsersContainer.js | 4 +++- src/reducers/index.js | 9 ++++++++- 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 src/containers/SearchTextBoxContainer.js diff --git a/src/App.js b/src/App.js index 25b75b9..7de6e20 100644 --- a/src/App.js +++ b/src/App.js @@ -2,7 +2,7 @@ import React from 'react'; import CounterButton from "./containers/CounterBottonContainer"; import SpecialTextBox from "./containers/SpecialTextBoxContainer"; import Counter from "./containers/CounterContainer"; -import SpecialText from "./containers/SpecialTextContainer"; +import SpecialText from "./containers/SearchTextBoxContainer"; import UserButtons from "./components/UserButtons"; import Thermostat from "./containers/ThermostatContainer"; import Users from "./containers/UsersContainer"; @@ -11,7 +11,7 @@ import VideoPlayer from "./containers/VideoPlayerContainer"; import VideoTextBox from "./containers/VideoTextBoxContainer"; import CurrentCity from "./containers/CurrentCityContainer"; import CityDropDown from "./containers/CityDropDownContainer"; -import SearchTextBox from "./components/SearchTextBox"; +import SearchTextBox from "./containers/SearchTextBoxContainer"; import SortUsers from "./components/SortUsers"; import ScaleVideo from "./components/ScaleVideo"; import Modal from "./components/Modal"; diff --git a/src/actions/index.js b/src/actions/index.js index 7c7b6b0..1a7a752 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -48,4 +48,12 @@ export function setVideoUrl(url) { type: "SET_VIDEO_URL", value: url } +} + + +export function setFirstNameFilter(firstName) { + return { + type: "SET_FIRST_NAME", + value: firstName + } } \ No newline at end of file diff --git a/src/containers/SearchTextBoxContainer.js b/src/containers/SearchTextBoxContainer.js new file mode 100644 index 0000000..f9dc72d --- /dev/null +++ b/src/containers/SearchTextBoxContainer.js @@ -0,0 +1,11 @@ +import { connect } from 'react-redux'; +import {setFirstNameFilter} from "../actions"; +import SearchTextBox from "../components/SearchTextBox"; + + +const mapDispatchToProps = { + set:setFirstNameFilter + } + + +export default connect(null,mapDispatchToProps)(SearchTextBox); diff --git a/src/containers/UsersContainer.js b/src/containers/UsersContainer.js index 34908be..c2185fe 100644 --- a/src/containers/UsersContainer.js +++ b/src/containers/UsersContainer.js @@ -4,8 +4,10 @@ import Users from "../components/Users"; //map a prop called text to the state specialText function mapStateToProps(state){ + console.log("First Name: " + state.searchText); return { - users: state.users + users: state.users, + firstNameFilter: state.searchText } } diff --git a/src/reducers/index.js b/src/reducers/index.js index bb1f432..4471c11 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -57,6 +57,12 @@ function videoURL(state="", action) { return state; } +function searchText(state="", action) { + if (action.type == "SET_FIRST_NAME") { + return action.value; + } + return state; +} let reducers = combineReducers({ currentCount, @@ -64,6 +70,7 @@ let reducers = combineReducers({ specialText, currentCity, currentTemp, - videoURL + videoURL, + searchText }) export default reducers;