-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
relates #14
- Loading branch information
Showing
15 changed files
with
12,338 additions
and
3,266 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,9 +1,24 @@ | ||
import { FETCH_CATEGORY, SELECT_LOCATION } from './types'; | ||
|
||
import { FETCH_CATEGORY, CHOSEN_SYMPTOMS, FETCH_SYMPTOMS,SELECT_LOCATION } from "./types"; | ||
|
||
|
||
export const chooseCategory = category => { | ||
return { type: FETCH_CATEGORY, payload: category }; | ||
}; | ||
|
||
|
||
export const chooseLocation = location => { | ||
return { type: SELECT_LOCATION, payload: location }; | ||
|
||
export const chooseSymptoms = symptoms => { | ||
const chosenSymptoms = Object.keys(symptoms); | ||
const symptomsSelected = chosenSymptoms.filter(item => { | ||
return symptoms[item] === true; | ||
}) | ||
return { type: CHOSEN_SYMPTOMS, payload: symptomsSelected }; | ||
}; | ||
|
||
export const renderSymptoms = category => { | ||
return { type: FETCH_SYMPTOMS, payload: category } | ||
|
||
}; |
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,2 +1,4 @@ | ||
export const FETCH_CATEGORY = 'FETCH_CATEGORY'; | ||
export const SELECT_LOCATION = 'SELECT_LOCATION'; | ||
export const FETCH_CATEGORY = 'FETCH_CATEGORY'; | ||
export const CHOSEN_SYMPTOMS = 'CHOSEN_SYMPTOMS'; | ||
export const FETCH_SYMPTOMS = 'FETCH_SYMPTOMS'; |
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { Link } from 'react-router-dom'; | ||
import * as actions from '../actions'; | ||
|
||
class SymptomsForm extends Component { | ||
|
||
constructor(props) { | ||
super(props) | ||
|
||
this.state = { | ||
symptoms: {} | ||
} | ||
|
||
this.selectSymptoms = this.selectSymptoms.bind(this); | ||
this.sendSymptoms = this.sendSymptoms.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
const symptoms = this.props.symptoms.reduce((res, item) => { | ||
res[item] = false; | ||
return res; | ||
}, {}); | ||
|
||
this.setState({ symptoms }); | ||
} | ||
|
||
renderSymptoms(category) { | ||
return this.props.symptoms.map(symptom => { | ||
return ( | ||
<div key={symptom} className="pv1-ns pv2"> | ||
<input type="checkbox" | ||
className="ml6-ns pl2-ns" | ||
name="symptom" | ||
value={symptom} | ||
onChange={this.selectSymptoms} /> | ||
|
||
<span className="custom-font white f4 ml3-ns pl2 tj">{symptom}</span> | ||
|
||
</div> | ||
); | ||
}); | ||
} | ||
|
||
selectSymptoms(event) { | ||
const symptom = event.target.value; | ||
this.setState({ symptoms: {...this.state.symptoms, [symptom]: event.target.checked }}) | ||
} | ||
|
||
sendSymptoms() { | ||
this.props.chooseSymptoms(this.state.symptoms); | ||
} | ||
|
||
render() { | ||
|
||
return ( | ||
<div className="mw6 mw7-ns center ph3 ph3-ns"> | ||
<form className="pv3 pv4-ns ml4 pl4-ns"> | ||
{this.renderSymptoms(this.props.category)} | ||
</form> | ||
<div className="ph3"> | ||
<Link | ||
className="f6 fw6 ttu tracked link dim br3 ph3 pv2 mb2 dib orange bg-white fl" | ||
to="/categories" | ||
> | ||
Back | ||
</Link> | ||
<Link | ||
className="f6 fw6 ttu tracked link dim br3 ph3 pv2 mb2 dib orange bg-white fr" | ||
onClick={this.sendSymptoms} | ||
to="/location" | ||
> | ||
Next | ||
</Link> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToProps = ({ symptoms, category }) => ({ symptoms, category }); | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
chooseSymptoms: symptoms => dispatch(actions.chooseSymptoms(symptoms)) | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(SymptomsForm); |
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,39 +1,39 @@ | ||
import airPollution from "../icons/1.png"; | ||
import waterPollution from "../icons/2.png"; | ||
import wasteDisposal from "../icons/3.png"; | ||
import badInfra from "../icons/4.png"; | ||
import airPollution from '../icons/1.png'; | ||
import waterPollution from '../icons/2.png'; | ||
import wasteDisposal from '../icons/3.png'; | ||
import badInfra from '../icons/4.png'; | ||
|
||
export default function() { | ||
return [ | ||
{ | ||
name: "Waste Disposal", | ||
name: 'Waste Disposal', | ||
icon: wasteDisposal, | ||
alt: "Waste Burning icon" | ||
alt: 'Waste Burning icon' | ||
}, | ||
{ | ||
name: "Air Pollution", | ||
name: 'Air Pollution', | ||
icon: airPollution, | ||
alt: "Air Pollution icon" | ||
alt: 'Air Pollution icon' | ||
}, | ||
{ | ||
name: "Water Pollution", | ||
name: 'Water Pollution', | ||
icon: waterPollution, | ||
alt: "Water Pollution icon" | ||
alt: 'Water Pollution icon' | ||
}, | ||
{ | ||
name: "Bad Infrastructures", | ||
name: 'Bad Infrastructures', | ||
icon: badInfra, | ||
alt: "Bad Infrastructures icon" | ||
alt: 'Bad Infrastructures icon' | ||
}, | ||
{ | ||
name: "Waste Burning", | ||
icon: "", | ||
alt: "Waste Burning icon" | ||
name: 'Waste Burning', | ||
icon: '', | ||
alt: 'Waste Burning icon' | ||
}, | ||
{ | ||
name: "Noise", | ||
icon: "", | ||
alt: "Noise icon" | ||
name: 'Noise', | ||
icon: '', | ||
alt: 'Noise icon' | ||
} | ||
]; | ||
} |
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,10 @@ | ||
import { CHOSEN_SYMPTOMS } from '../actions/types'; | ||
|
||
export default function(state = {}, action) { | ||
switch (action.type) { | ||
case CHOSEN_SYMPTOMS: | ||
return action.payload; | ||
default: | ||
return state; | ||
} | ||
} |
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,34 @@ | ||
import { FETCH_SYMPTOMS } from '../actions/types'; | ||
|
||
export default (state = [], action) => { | ||
switch (action.type) { | ||
case FETCH_SYMPTOMS: | ||
const symptoms = { | ||
'Waste Burning': ['Bad smell in the streets', 'Risk of fire'], | ||
'Water Pollution': [ | ||
'Sewage is overflooding', | ||
'Bad smells coming from sewage' | ||
], | ||
Noise: [ | ||
'Loud construction noise even late at night', | ||
"Kids can't sleep because of noise" | ||
], | ||
'Waste Disposal': [ | ||
'No room to park because of the garbage', | ||
'Not enough garbage collection' | ||
], | ||
'Air Pollution': [ | ||
'Can not breathe because of the dust', | ||
'Need to wear masks' | ||
], | ||
'Bad Infrastructures': [ | ||
'Roads are dangerous because of holes', | ||
'I got injured' | ||
] | ||
}; | ||
|
||
return Object.values(symptoms[action.payload]); | ||
default: | ||
return state; | ||
} | ||
}; |
Oops, something went wrong.