Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,4 @@ There is no new special thing we have to do. We have all the knowledge we need t
* We should know how to make a fetch call by now. Where does the fetch call go?
* What do you do with the data when the fetch call is complete? Not setState.
* Is there an action message that could represent that the redux store needs to be updated with the list of users you just fetched from the api.
* Does any reducer need to be aware of this message?


* Does any reducer need to be aware of this message?
421 changes: 251 additions & 170 deletions package-lock.json

Large diffs are not rendered by default.

51 changes: 33 additions & 18 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
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 UserButtons from "./components/UserButtons";
import Thermostat from "./components/Thermostat";
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 SearchTextBox from "./components/SearchTextBox";
import SortUsers from "./components/SortUsers";
import ScaleVideo from "./components/ScaleVideo";
import Modal from "./components/Modal";
import ShowModal from "./components/ShowModal";
import CounterButton from "./containers/CounterButtonContainer";
import SpecialTextBox from "./containers/SpecialTextBoxContainer";
import Counter from "./containers/CounterTextContainer";
import SpecialText from "./containers/SpecialTextContainer";
import UserButtons from "./containers/UserButtonsContainer";
import Thermostat from "./containers/ThermostatContainer";
import Users from "./containers/UsersContainer";
import ChangeTemperature from "./containers/ChangeTemperatureContainer";
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 "./containers/SortUsersContainer";
import ScaleVideo from "./containers/ScaleVideoContainer";
import Modal from "./containers/ModalContainer";
import ShowModal from "./containers/ShowModalContainer";

function App() {
const loadUser = (url,callback) =>{
fetch(url)
.then(function(response) {
return response.json();
})
.then(function(myJson) {
myJson.forEach(user => {
callback(user)
})
});

}


function App(props) {
loadUser(props.url,props.loadData)
return (
<div className="App">
<div className="container">
Expand Down
53 changes: 53 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ export function increaseCounter(){
}
}

export function decreaseCounter(){
return {
type:"DECREASE_COUNTER"
}
}

export function setSpecialText(txt){
return {
type:"SET_SPECIAL_TEXT",
Expand All @@ -21,4 +27,51 @@ export function removeUser(){
return {
type:"REMOVE_USER"
}
}

export const currentCity = (city)=>{
return {
type:"SET_CURRENT_CITY",
value:city
}
}

export const setTemp = (temp) =>{
return {
type:"SET_TEMP",
value:temp
}
}

export const setSearchText = (text) =>{
return {
type:"SET_SEARCH_TEXT",
value:text
}
}

export const setIsLoading =(isLoading)=>{
return{
type : "SET_IS_LOADING",
value : isLoading
}
}

export const setVideoURL= (URL)=>{
return {
type : "SET_VIDEO_URL",
value : URL
}
}
export const setCurrentUserSort=(sort)=>{
return{
type : "SET_CURRENT_USER_SORT",
value : sort
}
}
export const setVideoScale = (scale)=>{
return{
type : "SET_VIDEO_SCALE",
value : scale
}
}
5 changes: 4 additions & 1 deletion src/components/CityDropDown.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';



function CityDropDown(props) {
props.set("Austin")
return (
<div>
CurrentCity:
<select onChange={
<select id={"CityView"} onChange={
(e)=>{
if(props.set){
props.set(e.target.value);
Expand Down
11 changes: 1 addition & 10 deletions src/components/SpecialTextBox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import {connect} from "react-redux";
import {setSpecialText} from "../actions";


function SpecialTextBox(props) {
return (
Expand All @@ -15,12 +14,4 @@ function SpecialTextBox(props) {
);
}

function mapDispatchToProps(dispatch){
return {
set:function(txt){
let action = setSpecialText(txt)
dispatch(action);
}
}
}
export default (SpecialTextBox);
3 changes: 1 addition & 2 deletions src/components/UserButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function Users(props) {
(props.firstNameFilter &&
u.name.indexOf(props.firstNameFilter) > -1);
})
usersDivs = usersDivs.map(function(u){
return <div>{u.name}</div>
usersDivs = usersDivs.map(function(u,index){
return <div key={index}>{u.name}</div>
})
}
return (
Expand Down
18 changes: 18 additions & 0 deletions src/containers/AppContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import App from "../App.js"
import { connect } from 'react-redux';
import {addUser} from "../actions"


const mapDispatchToProps = {
loadData:addUser,
}

function mapStateToProps(state){
return {
url:"https://jsonplaceholder.typicode.com/users"
}
}


export default connect(mapStateToProps,mapDispatchToProps)(App);

9 changes: 9 additions & 0 deletions src/containers/ChangeTemperatureContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { connect } from 'react-redux';
import ChangeTemperature from "../components/ChangeTemperature";
import {setTemp} from "../actions/index"

const mapDispatchToProps = {
set:setTemp
}

export default connect(null,mapDispatchToProps)(ChangeTemperature);
10 changes: 10 additions & 0 deletions src/containers/CityDropDownContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { connect } from 'react-redux';
import CityDropDown from "../components/CityDropDown";
import {currentCity} from "../actions/index"

//map a prop called text to the state specialText
const mapDispatchToProps = {
set: currentCity
}

export default connect(null,mapDispatchToProps)(CityDropDown);
11 changes: 11 additions & 0 deletions src/containers/CounterButtonContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { connect } from 'react-redux';
import CounterButtons from "../components/CounterButton";
import {increaseCounter,decreaseCounter} from "../actions/index"

//map a prop called text to the state specialText
const mapDispatchToProps = {
increase: increaseCounter,
decrease: decreaseCounter
}

export default connect(null,mapDispatchToProps)(CounterButtons);
11 changes: 11 additions & 0 deletions src/containers/CounterTextContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { connect } from 'react-redux';
import Counter from "../components/Counter";

//map a prop called text to the state specialText
function mapStateToProps(state){
return {
count: state.currentCount
}
}

export default connect(mapStateToProps)(Counter);
11 changes: 11 additions & 0 deletions src/containers/CurrentCityContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { connect } from 'react-redux';
import CurrentCity from "../components/CurrentCity";

//map a prop called text to the state specialText
function mapStateToProps(state){
return {
text: state.currentCity
}
}

export default connect(mapStateToProps)(CurrentCity);
16 changes: 16 additions & 0 deletions src/containers/ModalContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { connect } from 'react-redux';
import {setIsLoading} from "../actions";
import Modal from "../components/Modal";


const mapDispatchToProps = {
setIsLoading:setIsLoading,
}

function mapStateToProps(state){
return {
isLoading: state.isLoading,
}
}

export default connect(mapStateToProps,mapDispatchToProps)(Modal);
11 changes: 11 additions & 0 deletions src/containers/ScaleVideoContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { connect } from 'react-redux';
import {setVideoScale} from "../actions";
import ScaleVideo from "../components/ScaleVideo";


const mapDispatchToProps = {
set:setVideoScale,
}


export default connect(null,mapDispatchToProps)(ScaleVideo);
11 changes: 11 additions & 0 deletions src/containers/SearchTextBoxContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { connect } from 'react-redux';
import {setSearchText} from "../actions";
import SearchTextBox from "../components/SearchTextBox";


const mapDispatchToProps = {
set:setSearchText,
}


export default connect(null,mapDispatchToProps)(SearchTextBox);
11 changes: 11 additions & 0 deletions src/containers/ShowModalContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { connect } from 'react-redux';
import {setIsLoading} from "../actions";
import ShowModal from "../components/ShowModal";


const mapDispatchToProps = {
setIsLoading:setIsLoading,
}


export default connect(null,mapDispatchToProps)(ShowModal);
9 changes: 9 additions & 0 deletions src/containers/SortUsersContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { connect } from 'react-redux';
import SortUsers from "../components/SortUsers";
import {setCurrentUserSort} from "../actions/index"

const mapDispatchToProps = {
set:setCurrentUserSort
}

export default connect(null,mapDispatchToProps)(SortUsers);
2 changes: 1 addition & 1 deletion src/containers/SpecialTextBoxContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SpecialTextBox from "../components/SpecialTextBox";


const mapDispatchToProps = {
set:setSpecialText
set:setSpecialText,
}


Expand Down
1 change: 0 additions & 1 deletion src/containers/SpecialTextContainer.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/containers/ThermostatContainer.js
Original file line number Diff line number Diff line change
@@ -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){
return {
temp: state.currentTemp
}
}

export default connect(mapStateToProps)(Thermostat);
10 changes: 10 additions & 0 deletions src/containers/UserButtonsContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { connect } from 'react-redux';
import UserButton from "../components/UserButtons";
import {addUser,removeUser} from "../actions"

//map a prop called text to the state specialText
const mapDispatchToProps={
add:addUser,remove:removeUser
}

export default connect(null,mapDispatchToProps)(UserButton);
13 changes: 13 additions & 0 deletions src/containers/UsersContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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,
firstNameFilter:state.searchText,
sortOn:state.currentUserSort
}
}

export default connect(mapStateToProps)(Users);
Loading