-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ignacio Peluaga
committed
Mar 7, 2021
1 parent
6400edf
commit d7f7fc5
Showing
7 changed files
with
99 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Action } from 'redux' | ||
|
||
export enum FilterFormActions { | ||
CHANGE_UNI = "CHANGE_UNI", | ||
CHANGE_AREA = "CHANGE_AREA", | ||
CHANGE_TIPO = "CHANGE_TIPO", | ||
CHANGE_RESULTS = "CHANGE_RESULTS", | ||
} | ||
|
||
export interface IUniChangeAction extends Action { | ||
payload: string | ||
} | ||
export interface IAreaChangeAction extends Action { | ||
payload: string | ||
} | ||
export interface ITipoChangeAction extends Action { | ||
payload: string | ||
} | ||
export interface IResultsChangeAction extends Action { | ||
payload: [string, string][] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,33 @@ | ||
import { Dispatch } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
|
||
import FilterForm from '../components/FilterForm'; | ||
import IGlobalState from '../states/globalState'; | ||
import { FilterFormActions } from '../actions/FilterFormActions' | ||
|
||
const mapStateToProps = (state:IGlobalState) => { | ||
return({university: state.uni}) //las propiedades del componente FilterForm | ||
//crea esa propiedad a partir de la información del estado global | ||
const mapStateToProps = (state: IGlobalState) => ({ | ||
uni: state.uni, | ||
area: state.area, | ||
tipo: state.tipo, | ||
results: state.results | ||
}) | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch) => { | ||
return { | ||
setUni: (uni: string) => { | ||
dispatch({ type: FilterFormActions.CHANGE_UNI, payload: uni }); | ||
}, | ||
setTipo: (tipo: string) => { | ||
dispatch({ type: FilterFormActions.CHANGE_TIPO, payload: tipo }); | ||
}, | ||
setArea: (area: string) => { | ||
dispatch({ type: FilterFormActions.CHANGE_AREA, payload: area }); | ||
}, | ||
setResults: (results: [string, string][]) => { | ||
dispatch({ type: FilterFormActions.CHANGE_RESULTS, payload: results }); | ||
} | ||
} | ||
} | ||
|
||
//Con esto, ese FilterForm recibe el store de forma automatica | ||
export default connect(mapStateToProps)(FilterForm); | ||
export default connect(mapStateToProps, mapDispatchToProps)(FilterForm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters