From d51d86a38c8da1dc380604a7bd07b121f09ab17f Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Tue, 19 Mar 2019 19:38:48 -0500 Subject: [PATCH 01/12] special text box working --- src/App.js | 84 +++++++++++------------ src/actions/index.js | 26 ++++--- src/components/SpecialTextBox.js | 32 +++------ src/containers/SpecialTextBoxContainer.js | 10 +-- src/index.js | 4 +- src/reducers/index.js | 31 +++++---- 6 files changed, 96 insertions(+), 91 deletions(-) diff --git a/src/App.js b/src/App.js index 392ed1f..767d03b 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 SpecialTextBox from "./containers/SpecialTextBoxContainer"; import Counter from "./components/Counter"; -import SpecialText from "./components/SpecialText"; +import SpecialText from "./containers/SpecialTextContainer"; import UserButtons from "./components/UserButtons"; import Thermostat from "./components/Thermostat"; import Users from "./components/Users"; @@ -19,47 +19,47 @@ import ShowModal from "./components/ShowModal"; function App() { return ( -
-
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
-
- -
- -
- -
- -
- -
- - -
-
- -
- +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+ + +
+
+ +
+ +
); } export default App; \ No newline at end of file diff --git a/src/actions/index.js b/src/actions/index.js index 78955f4..ea69e0b 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -1,24 +1,30 @@ -export function increaseCounter(){ +export function increaseCounter() { return { - type:"INCREASE_COUNTER" + type: "INCREASE_COUNTER" } } -export function setSpecialText(txt){ +// export function decreaseCounter(){ +// return { +// type:"DECREASE_COUNTER" +// } +// } + +export function setSpecialText(txt) { return { - type:"SET_SPECIAL_TEXT", - value:txt + type: "SET_SPECIAL_TEXT", + value: txt } } -export function addUser(user){ +export function addUser(user) { return { - type:"ADD_USER", - value:user + type: "ADD_USER", + value: user } } -export function removeUser(){ +export function removeUser() { return { - type:"REMOVE_USER" + type: "REMOVE_USER" } } \ No newline at end of file diff --git a/src/components/SpecialTextBox.js b/src/components/SpecialTextBox.js index 53c3938..a1fde39 100644 --- a/src/components/SpecialTextBox.js +++ b/src/components/SpecialTextBox.js @@ -1,26 +1,16 @@ import React from 'react'; -import {connect} from "react-redux"; -import {setSpecialText} from "../actions"; +import { connect } from "react-redux"; +import { setSpecialText } from "../actions"; -function SpecialTextBox(props) { +export default function SpecialTextBox(props) { return ( -
- Enter Special Text: - { - if(props.set){ - props.set(e.target.value); - } - }} /> -
+
+ Enter Special Text: + { + if (props.set) { + props.set(e.target.value); + } + }} /> +
); } - -function mapDispatchToProps(dispatch){ - return { - set:function(txt){ - let action = setSpecialText(txt) - dispatch(action); - } - } -} -export default (SpecialTextBox); \ No newline at end of file diff --git a/src/containers/SpecialTextBoxContainer.js b/src/containers/SpecialTextBoxContainer.js index 58e9b4c..7af506d 100644 --- a/src/containers/SpecialTextBoxContainer.js +++ b/src/containers/SpecialTextBoxContainer.js @@ -1,11 +1,11 @@ import { connect } from 'react-redux'; -import {setSpecialText} from "../actions"; +import { setSpecialText } from "../actions"; import SpecialTextBox from "../components/SpecialTextBox"; - +// same thing as store.dispatch({type:whatever}) const mapDispatchToProps = { - set:setSpecialText - } + set: setSpecialText +} -export default connect(null,mapDispatchToProps)(SpecialTextBox); +export default connect(null, mapDispatchToProps)(SpecialTextBox); diff --git a/src/index.js b/src/index.js index 25f54ba..b61c630 100644 --- a/src/index.js +++ b/src/index.js @@ -2,9 +2,11 @@ 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..71c5ae0 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -1,29 +1,36 @@ +import { combineReducers } from "redux"; + +function currentCount(state = 0, action) { + if (action.type === "INCREASE_COUNTER") { -function currentCount(state=0, action){ - if(action.type === "INCREASE_COUNTER"){ - } - if(action.type === "DECREASE_COUNTER"){ - + if (action.type === "DECREASE_COUNTER") { + } 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"){ +function specialText(state = "", action) { + if (action.type === "SET_SPECIAL_TEXT") { return action.value; } return state; } +let reducers = combineReducers({ + currentCount, users, specialText +}) + +export default reducers; + From dfb9c1f0e67ce4e3ccef390881160f251542ad0a Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Tue, 19 Mar 2019 20:02:09 -0500 Subject: [PATCH 02/12] added some stuff to users function --- src/reducers/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/reducers/index.js b/src/reducers/index.js index 71c5ae0..8f6e6d2 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -12,10 +12,20 @@ function currentCount(state = 0, action) { function users(state = [], action) { if (action.type === "ADD_USER") { + // state = [] + // action.value = {} //user object + // state.push(action.value) + // let newArray = state.map(p => p); + // newArray.push(action.value); + // return newArray; + + return [...state,//state.map(p => p); + action.value //newArray.push(action.value); + ] } if (action.type === "REMOVE_USER") { - + //return state.splice } return state; } From 491b51601ece20b08c46af06326627310457f94b Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Wed, 20 Mar 2019 17:28:20 -0500 Subject: [PATCH 03/12] basic reducer functions created --- src/reducers/index.js | 58 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/src/reducers/index.js b/src/reducers/index.js index 8f6e6d2..af00421 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -38,8 +38,64 @@ function specialText(state = "", action) { return state; } +function currentCity(state = "", action) { + if (action.type === "SET_CURRENT_CITY") { + return action.value; + } + return state; +} + +function searchText(state = "", action) { + if (action.type === "SEARCH_TEXT") { + return action.value; + } + return state; +} + +function currentTemp(state = "", action) { + if (action.type === "SET_CURRENT_TEMP") { + return action.value; + } + return state; +} + +function isLoading(state = "", action) { + if (action.type === "IS_LOADING") { + return action.value; + } + if (action.type === "IS_NOT_LOADING") { + return action.value; + } + return state; +} + +function videoURL(state = "", action) { + if (action.type === "SET_VIDEO_URL") { + return action.value; + } + return state; +} + +function currentUserSort(state = "", action) { + if (action.type === "FIRST_NAME") { + return action.value; + } + if (action.type === "LAST_NAME") { + return action.value; + } + return state; +} + +function videoScale(state = "", action) { + if (action.type === "SET_VIDEO_SIZE") { + return action.value; + } + return state; +} + let reducers = combineReducers({ - currentCount, users, specialText + currentCount, users, specialText, currentCity, searchText, currentTemp, + isLoading, videoURL, currentUserSort, videoScale }) export default reducers; From 5be7b5fb832c8beea01579bbea5f5dda0146dda7 Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Wed, 20 Mar 2019 17:38:59 -0500 Subject: [PATCH 04/12] changed some type names in the reducers and added actions --- src/actions/index.js | 57 +++++++++++++++++++++++++++++++++++++++---- src/reducers/index.js | 16 ++++-------- 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index ea69e0b..2184b17 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -4,11 +4,11 @@ export function increaseCounter() { } } -// export function decreaseCounter(){ -// return { -// type:"DECREASE_COUNTER" -// } -// } +export function decreaseCounter() { + return { + type: "DECREASE_COUNTER" + } +} export function setSpecialText(txt) { return { @@ -23,8 +23,55 @@ export function addUser(user) { value: user } } + export function removeUser() { return { type: "REMOVE_USER" } +} + +export function setCurrentCity() { + return { + type: "SET_CURRENT_CITY" + } +} + +export function setSearchText(txt) { + return { + type: "SET_SEARCH_TEXT", + value: txt + } +} + +export function setTemp(num) { + return { + type: "SET_TEMP", + value: num + } +} + +export function setIsLoading() { + return { + type: "SET_IS_LOADING" + } +} + +export function setVideoURL(txt) { + return { + type: "SET_VIDEO_URL", + value: txt + } +} + +export function setCurrentUserSort(txt) { + return { + type: "SET_CURRENT_USER_SORT", + value: txt + } +} + +export function setVideoScale() { + return { + type: "SET_VIDEO_SCALE" + } } \ No newline at end of file diff --git a/src/reducers/index.js b/src/reducers/index.js index af00421..3cc9fab 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -46,24 +46,21 @@ function currentCity(state = "", action) { } function searchText(state = "", action) { - if (action.type === "SEARCH_TEXT") { + if (action.type === "SET_SEARCH_TEXT") { return action.value; } return state; } function currentTemp(state = "", action) { - if (action.type === "SET_CURRENT_TEMP") { + if (action.type === "SET_TEMP") { return action.value; } return state; } function isLoading(state = "", action) { - if (action.type === "IS_LOADING") { - return action.value; - } - if (action.type === "IS_NOT_LOADING") { + if (action.type === "SET_IS_LOADING") { return action.value; } return state; @@ -77,17 +74,14 @@ function videoURL(state = "", action) { } function currentUserSort(state = "", action) { - if (action.type === "FIRST_NAME") { - return action.value; - } - if (action.type === "LAST_NAME") { + if (action.type === "SET_CURRENT_USER_SORT") { return action.value; } return state; } function videoScale(state = "", action) { - if (action.type === "SET_VIDEO_SIZE") { + if (action.type === "SET_VIDEO_SCALE") { return action.value; } return state; From 01cb56906364b1847c745a7d34ff43c8c9146728 Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Thu, 21 Mar 2019 15:19:37 -0500 Subject: [PATCH 05/12] counter and counter button working --- src/App.js | 8 ++++---- src/components/SpecialTextBox.js | 2 -- src/containers/CounterButtonContainer.js | 18 ++++++++++++++++++ src/containers/CounterContainer.js | 10 ++++++++++ src/reducers/index.js | 5 +++-- src/store.js | 4 ++-- 6 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 src/containers/CounterButtonContainer.js create mode 100644 src/containers/CounterContainer.js diff --git a/src/App.js b/src/App.js index 767d03b..9517775 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,7 @@ import React from 'react'; -import CounterButton from "./components/CounterButton"; +import CounterButtonContainer from "./containers/CounterButtonContainer"; import SpecialTextBox from "./containers/SpecialTextBoxContainer"; -import Counter from "./components/Counter"; +import CounterContainer from "./containers/CounterContainer"; import SpecialText from "./containers/SpecialTextContainer"; import UserButtons from "./components/UserButtons"; import Thermostat from "./components/Thermostat"; @@ -21,7 +21,7 @@ function App() { return (
- +

@@ -42,7 +42,7 @@ function App() {
- +

diff --git a/src/components/SpecialTextBox.js b/src/components/SpecialTextBox.js index a1fde39..8c32053 100644 --- a/src/components/SpecialTextBox.js +++ b/src/components/SpecialTextBox.js @@ -1,6 +1,4 @@ import React from 'react'; -import { connect } from "react-redux"; -import { setSpecialText } from "../actions"; export default function SpecialTextBox(props) { return ( diff --git a/src/containers/CounterButtonContainer.js b/src/containers/CounterButtonContainer.js new file mode 100644 index 0000000..a247cc9 --- /dev/null +++ b/src/containers/CounterButtonContainer.js @@ -0,0 +1,18 @@ +import { connect } from 'react-redux'; +import CounterButton from "../components/CounterButton"; +import { increaseCounter, decreaseCounter } from "../actions"; + +function mapDispatchToProps(dispatch) { + return { + increase: function () { + let action = increaseCounter() + dispatch(action) + }, + decrease: function () { + let action = decreaseCounter() + dispatch(action) + } + } +} + +export default connect(null, mapDispatchToProps)(CounterButton) diff --git a/src/containers/CounterContainer.js b/src/containers/CounterContainer.js new file mode 100644 index 0000000..100fea5 --- /dev/null +++ b/src/containers/CounterContainer.js @@ -0,0 +1,10 @@ +import { connect } from 'react-redux'; +import Counter from "../components/Counter"; + +function mapStateToProps(state) { + return { + count: state.currentCount + } +} + +export default connect(mapStateToProps)(Counter) \ No newline at end of file diff --git a/src/reducers/index.js b/src/reducers/index.js index 3cc9fab..680caf6 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -2,10 +2,10 @@ import { combineReducers } from "redux"; function currentCount(state = 0, action) { if (action.type === "INCREASE_COUNTER") { - + return state + 1 } if (action.type === "DECREASE_COUNTER") { - + return state - 1 } return state; } @@ -26,6 +26,7 @@ function users(state = [], action) { } if (action.type === "REMOVE_USER") { //return state.splice + return state.slice(1); } return state; } diff --git a/src/store.js b/src/store.js index 85e79b2..48c9e9c 100644 --- a/src/store.js +++ b/src/store.js @@ -1,7 +1,7 @@ -import {createStore} from 'redux'; +import { createStore } from 'redux'; import state from "./state"; import reducers from "./reducers"; -var store = createStore(reducers,state); +var store = createStore(reducers, state); export default store; \ No newline at end of file From 267ed4949c194a42e05dae60305e807d999312a9 Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Thu, 21 Mar 2019 15:52:19 -0500 Subject: [PATCH 06/12] remove users working --- src/App.js | 4 ++-- src/containers/UserButtonsContainer.js | 18 ++++++++++++++++++ src/containers/UsersContainer.js | 10 ++++++++++ src/reducers/index.js | 9 --------- 4 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 src/containers/UserButtonsContainer.js create mode 100644 src/containers/UsersContainer.js diff --git a/src/App.js b/src/App.js index 9517775..3279b77 100644 --- a/src/App.js +++ b/src/App.js @@ -3,9 +3,9 @@ import CounterButtonContainer from "./containers/CounterButtonContainer"; import SpecialTextBox from "./containers/SpecialTextBoxContainer"; import CounterContainer from "./containers/CounterContainer"; import SpecialText from "./containers/SpecialTextContainer"; -import UserButtons from "./components/UserButtons"; +import UserButtons from "./containers/UserButtonsContainer"; import Thermostat from "./components/Thermostat"; -import Users from "./components/Users"; +import Users from "./containers/UsersContainer"; import ChangeTemperature from "./components/ChangeTemperature"; import VideoPlayer from "./components/VideoPlayer"; import VideoTextBox from "./components/VideoTextBox"; diff --git a/src/containers/UserButtonsContainer.js b/src/containers/UserButtonsContainer.js new file mode 100644 index 0000000..9e9264d --- /dev/null +++ b/src/containers/UserButtonsContainer.js @@ -0,0 +1,18 @@ +import { connect } from 'react-redux'; +import UserButtons from "../components/UserButtons"; +import { addUser, removeUser } from "../actions"; + +function mapDispatchToProps(dispatch) { + return { + add: function (user) { + let action = addUser(user); + dispatch(action) + }, + remove: function () { + let action = removeUser(); + dispatch(action) + } + } +} + +export default connect(null, mapDispatchToProps)(UserButtons) \ No newline at end of file diff --git a/src/containers/UsersContainer.js b/src/containers/UsersContainer.js new file mode 100644 index 0000000..bc9639c --- /dev/null +++ b/src/containers/UsersContainer.js @@ -0,0 +1,10 @@ +import { connect } from 'react-redux'; +import Users from "../components/Users"; + +function mapStateToProps(state) { + return { + users: state.users + } +} + +export default connect(mapStateToProps)(Users) \ No newline at end of file diff --git a/src/reducers/index.js b/src/reducers/index.js index 680caf6..6e5c9fb 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -12,20 +12,11 @@ function currentCount(state = 0, action) { function users(state = [], action) { if (action.type === "ADD_USER") { - // state = [] - // action.value = {} //user object - // state.push(action.value) - - // let newArray = state.map(p => p); - // newArray.push(action.value); - // return newArray; - return [...state,//state.map(p => p); action.value //newArray.push(action.value); ] } if (action.type === "REMOVE_USER") { - //return state.splice return state.slice(1); } return state; From 49ea35d698d8c5db5d9631a733cd049e35f4963e Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Sat, 23 Mar 2019 10:59:25 -0500 Subject: [PATCH 07/12] add user button working --- src/actions/index.js | 2 +- src/components/UserButtons.js | 43 +++++++++++++------------- src/components/Users.js | 22 ++++++------- src/containers/SpecialTextContainer.js | 4 +-- src/containers/UserButtonsContainer.js | 4 +-- src/reducers/index.js | 6 ++-- src/store.js | 2 +- 7 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index 2184b17..ef989c7 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -17,7 +17,7 @@ export function setSpecialText(txt) { } } -export function addUser(user) { +export function add(user) { return { type: "ADD_USER", value: user diff --git a/src/components/UserButtons.js b/src/components/UserButtons.js index 261dd4d..f299d1f 100644 --- a/src/components/UserButtons.js +++ b/src/components/UserButtons.js @@ -2,30 +2,29 @@ import React from 'react'; function UserButtons(props) { return ( -
- - + -
+ } + }>Remove User +
); } export default UserButtons; \ No newline at end of file diff --git a/src/components/Users.js b/src/components/Users.js index 6a04386..ee92cae 100644 --- a/src/components/Users.js +++ b/src/components/Users.js @@ -2,24 +2,24 @@ import React from 'react'; function Users(props) { var usersDivs = null; - if(props.users){ - var sorted = props.users.sort((a,b) => { + if (props.users) { + var sorted = props.users.sort((a, b) => { return a[props.sortOn] > b[props.sortOn]; }); - usersDivs = sorted.filter(function(u){ - return !props.firstNameFilter || - (props.firstNameFilter && - u.name.indexOf(props.firstNameFilter) > -1); + usersDivs = sorted.filter(function (u) { + return !props.firstNameFilter || + (props.firstNameFilter && + u.name.indexOf(props.firstNameFilter) > -1); }) - usersDivs = usersDivs.map(function(u){ + usersDivs = usersDivs.map(function (u) { return
{u.name}
}) } return ( -
-

Users

- {usersDivs} -
+
+

Users

+ {usersDivs} +
); } export default Users; \ No newline at end of file diff --git a/src/containers/SpecialTextContainer.js b/src/containers/SpecialTextContainer.js index 794bd45..5565087 100644 --- a/src/containers/SpecialTextContainer.js +++ b/src/containers/SpecialTextContainer.js @@ -1,9 +1,9 @@ import { connect } from 'react-redux'; -import {setCurrentUser} from "../actions"; +// import { setCurrentUserSort } from "../actions"; import SpecialText from "../components/SpecialText"; //map a prop called text to the state specialText -function mapStateToProps(state){ +function mapStateToProps(state) { return { text: state.specialText } diff --git a/src/containers/UserButtonsContainer.js b/src/containers/UserButtonsContainer.js index 9e9264d..d27ae2b 100644 --- a/src/containers/UserButtonsContainer.js +++ b/src/containers/UserButtonsContainer.js @@ -1,11 +1,11 @@ import { connect } from 'react-redux'; import UserButtons from "../components/UserButtons"; -import { addUser, removeUser } from "../actions"; +import { add, removeUser } from "../actions"; function mapDispatchToProps(dispatch) { return { add: function (user) { - let action = addUser(user); + let action = add(user); dispatch(action) }, remove: function () { diff --git a/src/reducers/index.js b/src/reducers/index.js index 6e5c9fb..76a3ba1 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -12,10 +12,10 @@ function currentCount(state = 0, action) { function users(state = [], action) { if (action.type === "ADD_USER") { - return [...state,//state.map(p => p); - action.value //newArray.push(action.value); - ] + console.log(state) + return [...state, action.value] } + if (action.type === "REMOVE_USER") { return state.slice(1); } diff --git a/src/store.js b/src/store.js index 48c9e9c..9589518 100644 --- a/src/store.js +++ b/src/store.js @@ -2,6 +2,6 @@ import { createStore } from 'redux'; import state from "./state"; import reducers from "./reducers"; -var store = createStore(reducers, state); +let store = createStore(reducers, state); export default store; \ No newline at end of file From e1b5a76abc8a5941e1492f3dfb9dfc253eebb580 Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Tue, 26 Mar 2019 14:14:58 -0500 Subject: [PATCH 08/12] city selection working --- src/App.js | 4 +-- src/actions/index.js | 5 +-- src/components/CityDropDown.js | 32 ++++++++++---------- src/containers/ChangeTemperatureContainer.js | 0 src/containers/CityDropdownContainer.js | 14 +++++++++ src/containers/CurrentCityContainer.js | 10 ++++++ src/containers/ThermostatContainer.js | 0 src/reducers/index.js | 1 - 8 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 src/containers/ChangeTemperatureContainer.js create mode 100644 src/containers/CityDropdownContainer.js create mode 100644 src/containers/CurrentCityContainer.js create mode 100644 src/containers/ThermostatContainer.js diff --git a/src/App.js b/src/App.js index 3279b77..4e3ac92 100644 --- a/src/App.js +++ b/src/App.js @@ -9,8 +9,8 @@ import Users from "./containers/UsersContainer"; 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 ef989c7..db7b576 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -30,9 +30,10 @@ export function removeUser() { } } -export function setCurrentCity() { +export function setCurrentCity(city) { return { - type: "SET_CURRENT_CITY" + type: "SET_CURRENT_CITY", + value: city } } diff --git a/src/components/CityDropDown.js b/src/components/CityDropDown.js index 843b9a3..cc88561 100644 --- a/src/components/CityDropDown.js +++ b/src/components/CityDropDown.js @@ -2,24 +2,24 @@ import React from 'react'; function CityDropDown(props) { return ( -
- CurrentCity: +
+ CurrentCity: -
+ } + }> + + + + + + + + +
); } export default CityDropDown; \ No newline at end of file diff --git a/src/containers/ChangeTemperatureContainer.js b/src/containers/ChangeTemperatureContainer.js new file mode 100644 index 0000000..e69de29 diff --git a/src/containers/CityDropdownContainer.js b/src/containers/CityDropdownContainer.js new file mode 100644 index 0000000..24940f0 --- /dev/null +++ b/src/containers/CityDropdownContainer.js @@ -0,0 +1,14 @@ +import { connect } from 'react-redux'; +import CityDropDown from "../components/CityDropDown"; +import { setCurrentCity } from "../actions"; + +function mapDispatchToProps(dispatch) { + return { + set: function (city) { + let action = setCurrentCity(city) + dispatch(action) + } + } +} + +export default connect(null, mapDispatchToProps)(CityDropDown) \ No newline at end of file diff --git a/src/containers/CurrentCityContainer.js b/src/containers/CurrentCityContainer.js new file mode 100644 index 0000000..b8327da --- /dev/null +++ b/src/containers/CurrentCityContainer.js @@ -0,0 +1,10 @@ +import { connect } from 'react-redux'; +import CurrentCity from "../components/CurrentCity"; + +function mapStateToProps(state) { + return { + text: state.currentCity + } +} + +export default connect(mapStateToProps)(CurrentCity) \ No newline at end of file diff --git a/src/containers/ThermostatContainer.js b/src/containers/ThermostatContainer.js new file mode 100644 index 0000000..e69de29 diff --git a/src/reducers/index.js b/src/reducers/index.js index 76a3ba1..601a146 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -12,7 +12,6 @@ function currentCount(state = 0, action) { function users(state = [], action) { if (action.type === "ADD_USER") { - console.log(state) return [...state, action.value] } From 87dbd4109a514d48b35366087586de2bd2cb77c0 Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Tue, 26 Mar 2019 14:22:03 -0500 Subject: [PATCH 09/12] thermostat working --- src/App.js | 4 ++-- src/actions/index.js | 4 ++-- src/containers/ChangeTemperatureContainer.js | 14 ++++++++++++++ src/containers/ThermostatContainer.js | 10 ++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/App.js b/src/App.js index 4e3ac92..59eb86f 100644 --- a/src/App.js +++ b/src/App.js @@ -4,9 +4,9 @@ import SpecialTextBox from "./containers/SpecialTextBoxContainer"; import CounterContainer from "./containers/CounterContainer"; import SpecialText from "./containers/SpecialTextContainer"; import UserButtons from "./containers/UserButtonsContainer"; -import Thermostat from "./components/Thermostat"; +import Thermostat from "./containers/ThermostatContainer"; import Users from "./containers/UsersContainer"; -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 db7b576..6cf5244 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -44,10 +44,10 @@ export function setSearchText(txt) { } } -export function setTemp(num) { +export function setTemp(temp) { return { type: "SET_TEMP", - value: num + value: temp } } diff --git a/src/containers/ChangeTemperatureContainer.js b/src/containers/ChangeTemperatureContainer.js index e69de29..d8e2c0d 100644 --- a/src/containers/ChangeTemperatureContainer.js +++ b/src/containers/ChangeTemperatureContainer.js @@ -0,0 +1,14 @@ +import { connect } from 'react-redux'; +import ChangeTemperature from "../components/ChangeTemperature"; +import { setTemp } from "../actions"; + +function mapDispatchToProps(dispatch) { + return { + set: function (temp) { + let action = setTemp(temp) + dispatch(action) + } + } +} + +export default connect(null, mapDispatchToProps)(ChangeTemperature) \ No newline at end of file diff --git a/src/containers/ThermostatContainer.js b/src/containers/ThermostatContainer.js index e69de29..2b890a0 100644 --- a/src/containers/ThermostatContainer.js +++ b/src/containers/ThermostatContainer.js @@ -0,0 +1,10 @@ +import { connect } from 'react-redux'; +import Thermostat from "../components/Thermostat"; + +function mapStateToProps(state) { + return { + temp: state.currentTemp + } +} + +export default connect(mapStateToProps)(Thermostat) \ No newline at end of file From 95b3a0f1f848fb31dfe67d65151f9afdc7a3b6d3 Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Tue, 26 Mar 2019 14:34:04 -0500 Subject: [PATCH 10/12] user search working --- src/App.js | 2 +- src/containers/SearchTextBoxContainer.js | 14 ++++++++++++++ src/containers/UsersContainer.js | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/containers/SearchTextBoxContainer.js diff --git a/src/App.js b/src/App.js index 59eb86f..07076c5 100644 --- a/src/App.js +++ b/src/App.js @@ -11,7 +11,7 @@ import VideoPlayer from "./components/VideoPlayer"; import VideoTextBox from "./components/VideoTextBox"; 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/containers/SearchTextBoxContainer.js b/src/containers/SearchTextBoxContainer.js new file mode 100644 index 0000000..295a160 --- /dev/null +++ b/src/containers/SearchTextBoxContainer.js @@ -0,0 +1,14 @@ +import { connect } from 'react-redux'; +import SearchTextBox from "../components/SearchTextBox"; +import { setSearchText } from "../actions"; + +function mapDispatchToProps(dispatch) { + return { + set: function (txt) { + let action = setSearchText(txt) + dispatch(action) + } + } +} + +export default connect(null, mapDispatchToProps)(SearchTextBox) \ No newline at end of file diff --git a/src/containers/UsersContainer.js b/src/containers/UsersContainer.js index bc9639c..484bde4 100644 --- a/src/containers/UsersContainer.js +++ b/src/containers/UsersContainer.js @@ -3,7 +3,9 @@ import Users from "../components/Users"; function mapStateToProps(state) { return { - users: state.users + users: state.users, + firstNameFilter: state.searchText, + sortOn: state.currentUserSort } } From 82c6ccd9e816d408b60cadf843694416dd367df3 Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Tue, 26 Mar 2019 17:47:56 -0500 Subject: [PATCH 11/12] everything working except name sort --- src/App.js | 12 +- src/actions/index.js | 14 ++- src/components/Users.js | 4 +- src/containers/ModalContainer.js | 15 +++ src/containers/ScaleVideoContainer.js | 14 +++ src/containers/ShowModalContainer.js | 9 ++ src/containers/SortUsersContainer.js | 14 +++ src/containers/VideoPlayerContainer.js | 11 ++ src/containers/VideoTextBoxContainer.js | 14 +++ src/reducers/index.js | 2 +- src/state.js | 152 +++++++++++++----------- 11 files changed, 174 insertions(+), 87 deletions(-) create mode 100644 src/containers/ModalContainer.js create mode 100644 src/containers/ScaleVideoContainer.js create mode 100644 src/containers/ShowModalContainer.js create mode 100644 src/containers/SortUsersContainer.js 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 07076c5..b764946 100644 --- a/src/App.js +++ b/src/App.js @@ -7,15 +7,15 @@ import UserButtons from "./containers/UserButtonsContainer"; import Thermostat from "./containers/ThermostatContainer"; import Users from "./containers/UsersContainer"; 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 "./containers/SearchTextBoxContainer"; -import SortUsers from "./components/SortUsers"; -import ScaleVideo from "./components/ScaleVideo"; -import Modal from "./components/Modal"; -import ShowModal from "./components/ShowModal"; +import SortUsers from "./containers/SortUsersContainer"; +import ScaleVideo from "./containers/ScaleVideoContainer"; +import Modal from "./containers/ModalContainer"; +import ShowModal from "./containers/ShowModalContainer"; function App() { return ( diff --git a/src/actions/index.js b/src/actions/index.js index 6cf5244..5d0d71e 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -51,9 +51,10 @@ export function setTemp(temp) { } } -export function setIsLoading() { +export function setIsLoading(isLoading) { return { - type: "SET_IS_LOADING" + type: "SET_IS_LOADING", + value: isLoading } } @@ -64,15 +65,16 @@ export function setVideoURL(txt) { } } -export function setCurrentUserSort(txt) { +export function setCurrentUserSort(sort) { return { type: "SET_CURRENT_USER_SORT", - value: txt + value: sort } } -export function setVideoScale() { +export function setVideoScale(num) { return { - type: "SET_VIDEO_SCALE" + type: "SET_VIDEO_SCALE", + value: num } } \ No newline at end of file diff --git a/src/components/Users.js b/src/components/Users.js index ee92cae..753258a 100644 --- a/src/components/Users.js +++ b/src/components/Users.js @@ -9,10 +9,10 @@ function Users(props) { usersDivs = sorted.filter(function (u) { return !props.firstNameFilter || (props.firstNameFilter && - u.name.indexOf(props.firstNameFilter) > -1); + u.first_name.indexOf(props.firstNameFilter) > -1); }) usersDivs = usersDivs.map(function (u) { - return
{u.name}
+ return
{u.first_name} {u.last_name}
}) } return ( diff --git a/src/containers/ModalContainer.js b/src/containers/ModalContainer.js new file mode 100644 index 0000000..f6f5e11 --- /dev/null +++ b/src/containers/ModalContainer.js @@ -0,0 +1,15 @@ +import { connect } from 'react-redux'; +import Modal from "../components/Modal"; +import { setIsLoading } from "../actions"; + +const mapDispatchToProps = { + setIsLoading: setIsLoading +} + +function mapStateToProps(state) { + return { + isLoading: state.isLoading + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(Modal) \ No newline at end of file diff --git a/src/containers/ScaleVideoContainer.js b/src/containers/ScaleVideoContainer.js new file mode 100644 index 0000000..d531e79 --- /dev/null +++ b/src/containers/ScaleVideoContainer.js @@ -0,0 +1,14 @@ +import { connect } from 'react-redux'; +import ScaleVideo from "../components/ScaleVideo"; +import { setVideoScale } from "../actions"; + +function mapDispatchToProps(dispatch) { + return { + set: function (num) { + let action = setVideoScale(num) + dispatch(action) + } + } +} + +export default connect(null, mapDispatchToProps)(ScaleVideo) \ No newline at end of file diff --git a/src/containers/ShowModalContainer.js b/src/containers/ShowModalContainer.js new file mode 100644 index 0000000..424af24 --- /dev/null +++ b/src/containers/ShowModalContainer.js @@ -0,0 +1,9 @@ +import { connect } from 'react-redux'; +import ShowModal from "../components/ShowModal"; +import { setIsLoading } from "../actions"; + +const mapDispatchToProps = { + setIsLoading: setIsLoading +} + +export default connect(null, mapDispatchToProps)(ShowModal) \ No newline at end of file diff --git a/src/containers/SortUsersContainer.js b/src/containers/SortUsersContainer.js new file mode 100644 index 0000000..5ad1366 --- /dev/null +++ b/src/containers/SortUsersContainer.js @@ -0,0 +1,14 @@ +import { connect } from 'react-redux'; +import SortUsers from "../components/SortUsers"; +import { setCurrentUserSort } from "../actions"; + +function mapDispatchToProps(dispatch) { + return { + set: function (sort) { + let action = setCurrentUserSort(sort) + dispatch(action) + } + } +} + +export default connect(null, mapDispatchToProps)(SortUsers) \ No newline at end of file diff --git a/src/containers/VideoPlayerContainer.js b/src/containers/VideoPlayerContainer.js new file mode 100644 index 0000000..9d8bf05 --- /dev/null +++ b/src/containers/VideoPlayerContainer.js @@ -0,0 +1,11 @@ +import { connect } from 'react-redux'; +import VideoPlayer from "../components/VideoPlayer"; + +function mapStateToProps(state) { + return { + URL: state.videoURL, + scale: state.videoScale + } +} + +export default connect(mapStateToProps)(VideoPlayer) \ No newline at end of file diff --git a/src/containers/VideoTextBoxContainer.js b/src/containers/VideoTextBoxContainer.js new file mode 100644 index 0000000..ac8e794 --- /dev/null +++ b/src/containers/VideoTextBoxContainer.js @@ -0,0 +1,14 @@ +import { connect } from 'react-redux'; +import VideoTextBox from "../components/VideoTextBox"; +import { setVideoURL } from "../actions"; + +function mapDispatchToProps(dispatch) { + return { + set: function (txt) { + let action = setVideoURL(txt) + dispatch(action) + } + } +} + +export default connect(null, mapDispatchToProps)(VideoTextBox) \ No newline at end of file diff --git a/src/reducers/index.js b/src/reducers/index.js index 601a146..8eee586 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -50,7 +50,7 @@ function currentTemp(state = "", action) { return state; } -function isLoading(state = "", action) { +function isLoading(state = false, action) { if (action.type === "SET_IS_LOADING") { return action.value; } diff --git a/src/state.js b/src/state.js index 7c89a59..425b387 100644 --- a/src/state.js +++ b/src/state.js @@ -1,78 +1,86 @@ -export default{ - currentCount:0, - specialText:"", - currentCity:"", - searchText:"", +export default { + currentCount: 0, + specialText: "", + currentCity: "", + searchText: "", currentTemp: 0, isLoading: false, videoURL: "", - currentUserSort:"first_name", - videoScale:1, + currentUserSort: "first_name", + videoScale: 1, users: [ - { - "id": 1, - "name": "george bluth", - "address": "4116 Magnolia Drive, Portland, ME 04103", - "phone": 15551234567, - "occupation": "father", - "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg" - }, - { - "id": 2, - "name": "lucille ball", - "address": "6428 3rd Street East, Zion, IL 60099", - "phone": 15552345678, - "occupation": "mother", - "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/josephstein/128.jpg" - }, - { - "id": 3, - "name": "oscar grouch", - "address": "4797 Sycamore Lane, Dover, NH 03820", - "phone": 15553456789, - "occupation": "uncle", - "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/olegpogodaev/128.jpg" - }, - { - "id": 4, - "name": "Steve Holt", - "address": "3722 Circle Drive, Bristow, VA 20136", - "phone": 15554567890, - "occupation": "friend", - "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/marcoramires/128.jpg" - }, - { - "id": 5, - "name": "gob bluth", - "address": "959 Hilltop Road, Apple Valley, CA 92307", - "phone": 15555678901, - "occupation": "brother", - "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/stephenmoon/128.jpg" - }, - { - "id": 6, - "name": "Tracey Ulman", - "address": "2640 Primrose Lane, Longview, TX 75604", - "phone": 15556789012, - "occupation": "wife", - "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/bigmancho/128.jpg" - }, - { - "id": 7, - "name": "Ted Mosbey", - "address": "959 Hilltop Road, Apple Valley, CA 92307", - "phone": 15555678901, - "occupation": "brother", - "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/stephenmoon/128.jpg" - }, - { - "id": 7, - "name": "Barney Stinson", - "address": "2640 Primrose Lane, Longview, TX 75604", - "phone": 15556789012, - "occupation": "wife", - "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/bigmancho/128.jpg" - } -] + { + "id": 1, + "first_name": "george", + "last_name": "bluth", + "address": "4116 Magnolia Drive, Portland, ME 04103", + "phone": 15551234567, + "occupation": "father", + "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg" + }, + { + "id": 2, + "first_name": "lucille", + "last_name": "ball", + "address": "6428 3rd Street East, Zion, IL 60099", + "phone": 15552345678, + "occupation": "mother", + "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/josephstein/128.jpg" + }, + { + "id": 3, + "first_name": "oscar", + "last_name": "grouch", + "address": "4797 Sycamore Lane, Dover, NH 03820", + "phone": 15553456789, + "occupation": "uncle", + "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/olegpogodaev/128.jpg" + }, + { + "id": 4, + "first_name": "Steve", + "last_name": "Holt", + "address": "3722 Circle Drive, Bristow, VA 20136", + "phone": 15554567890, + "occupation": "friend", + "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/marcoramires/128.jpg" + }, + { + "id": 5, + "first_name": "gob", + "last_name": "bluth", + "address": "959 Hilltop Road, Apple Valley, CA 92307", + "phone": 15555678901, + "occupation": "brother", + "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/stephenmoon/128.jpg" + }, + { + "id": 6, + "first_name": "Tracey", + "last_name": "Ulman", + "address": "2640 Primrose Lane, Longview, TX 75604", + "phone": 15556789012, + "occupation": "wife", + "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/bigmancho/128.jpg" + }, + { + "id": 7, + "first_name": "Ted", + "last_name": "Mosbey", + "address": "959 Hilltop Road, Apple Valley, CA 92307", + "phone": 15555678901, + "occupation": "brother", + "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/stephenmoon/128.jpg" + }, + { + "id": 7, + "first_name": "Barney", + "last_name": "Stinson", + "address": "2640 Primrose Lane, Longview, TX 75604", + "phone": 15556789012, + "occupation": "wife", + "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/bigmancho/128.jpg" + } + ] } \ No newline at end of file From 49957d6c09753f79b75a9c635e28f9e52455f7cd Mon Sep 17 00:00:00 2001 From: Abby Gottlich Date: Tue, 26 Mar 2019 17:54:09 -0500 Subject: [PATCH 12/12] refactored sort users --- src/containers/SortUsersContainer.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/containers/SortUsersContainer.js b/src/containers/SortUsersContainer.js index 5ad1366..8c15931 100644 --- a/src/containers/SortUsersContainer.js +++ b/src/containers/SortUsersContainer.js @@ -2,13 +2,8 @@ import { connect } from 'react-redux'; import SortUsers from "../components/SortUsers"; import { setCurrentUserSort } from "../actions"; -function mapDispatchToProps(dispatch) { - return { - set: function (sort) { - let action = setCurrentUserSort(sort) - dispatch(action) - } - } +const mapDispatchToProps = { + set: setCurrentUserSort } export default connect(null, mapDispatchToProps)(SortUsers) \ No newline at end of file