Skip to content

Commit 7abf11b

Browse files
authored
Feature/#154707884 - User sees list of filters on home page listings (#169)
* chore(client): refactor constants into shared * feature(client): add filters * chore(client): export constants on their own as well * chore(e2e): try to harden e2e tests even more
1 parent 81e0a58 commit 7abf11b

File tree

7 files changed

+95
-26
lines changed

7 files changed

+95
-26
lines changed

client/components/CreateProjectForm/CreateProjectForm.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,7 @@ import projectsApiClient from '../../api/projects'
1111
import UploadDropzone from '../UploadDropzone/UploadDropzone'
1212
import styles from './CreateProjectForm.scss'
1313
import { buttonSubmit } from './createProjectFormJss'
14-
15-
const causes = [
16-
'Animal',
17-
'Environment',
18-
'International NGO',
19-
'Health',
20-
'Education',
21-
'Arts & Culture',
22-
'Other'
23-
]
24-
25-
const technologies = [
26-
'JavaScript',
27-
'Ruby',
28-
'Java',
29-
'Python',
30-
'PHP',
31-
'C++',
32-
'Other'
33-
]
14+
import { causes, technologies } from '../shared/constants'
3415

3516
class CreateProjectForm extends Component {
3617
constructor (props, context) {

client/components/Home/Home.js

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,63 @@
1-
import React, { Component } from 'react'
2-
import { connect } from 'react-redux'
1+
import React, { Component, Fragment } from 'react'
32
import PropTypes from 'prop-types'
3+
import { connect } from 'react-redux'
4+
import Checkbox from 'material-ui/Checkbox'
5+
import { FormGroup, FormLabel, FormControlLabel } from 'material-ui/Form'
46

57
import ProjectActionCreator from '../../actions/project'
68
import ListOfProjects from '../ListOfProjects/ListOfProjects'
9+
import styles from './Home.scss'
10+
import { causes, technologies } from '../shared/constants'
711

812
class Home extends Component {
13+
constructor (props) {
14+
super(props)
15+
this.handleCheckbox = this.handleCheckbox.bind(this)
16+
this.renderList = this.renderList.bind(this)
17+
this.state = {
18+
filters: {}
19+
}
20+
}
21+
922
componentDidMount () {
1023
this.props.onLoad()
1124
}
1225

26+
handleCheckbox (event, checked) {
27+
console.log(event.target.name, event.target.value, checked)
28+
}
29+
30+
renderList (items, type) {
31+
return items.map((item, index) => {
32+
return (
33+
<FormControlLabel key={index}
34+
control={ <Checkbox name={type} value={item} onChange={this.handleCheckbox} /> }
35+
label={item}
36+
/>
37+
)
38+
})
39+
}
40+
1341
render () {
1442
return (
15-
<ListOfProjects
16-
title={'Click To Apply'}
17-
projects={this.props.projects} />
43+
<Fragment>
44+
<section className={styles.filterSection}>
45+
<h1>{'Filters'}</h1>
46+
<FormLabel>Causes</FormLabel>
47+
<FormGroup row>
48+
{ this.renderList(causes, 'causes') }
49+
</FormGroup>
50+
51+
<FormLabel>Technologies</FormLabel>
52+
<FormGroup row>
53+
{ this.renderList(technologies, 'technologies') }
54+
</FormGroup>
55+
</section>
56+
57+
<ListOfProjects
58+
title={'Click To Apply'}
59+
projects={this.props.projects} />
60+
</Fragment>
1861
)
1962
}
2063
}

client/components/Home/Home.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.filterSection {
2+
padding: 0 60px;
3+
display: grid;
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const ANIMAL = 'Animal'
2+
export const ENVIRONMENT = 'Environment'
3+
export const INTERNATIONAL_NGO = 'International NGO'
4+
export const HEALTH = 'Health'
5+
export const EDUCATION = 'Education'
6+
export const ARTS_CULTURE = 'Arts & Culture'
7+
8+
export default [
9+
ANIMAL,
10+
ENVIRONMENT,
11+
INTERNATIONAL_NGO,
12+
HEALTH,
13+
EDUCATION,
14+
ARTS_CULTURE,
15+
'Other'
16+
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as causes } from './causes'
2+
export { default as technologies } from './technologies'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const JAVASCRIPT = 'JavaScript'
2+
export const RUBY = 'Ruby'
3+
export const JAVA = 'Java'
4+
export const PYTHON = 'Python'
5+
export const PHP = 'PHP'
6+
export const CPLUSPLUS = 'C++'
7+
8+
export default [
9+
JAVASCRIPT,
10+
RUBY,
11+
JAVA,
12+
PYTHON,
13+
PHP,
14+
CPLUSPLUS,
15+
'Other'
16+
]

e2e/step_definitions/steps.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,25 @@ Then(/^I am on the "(.*)" page$/, async selector => {
2626

2727
When(/^I click the "(.*)" header link$/, async selector => {
2828
const header = client.page.header()
29-
await header.click(`@${selector}Button`)
29+
const button = `@${selector}Button`
30+
await header.waitForElementVisible(button, 2500)
31+
await header.click(button)
3032
})
3133

3234
When(/^I login with the login details (.*?) (.*?)$/, async (email, password) => {
3335
const login = client.page.login()
36+
await login.waitForElementVisible('@loginForm', 2500)
37+
await login.waitForElementVisible('@emailField', 2500)
3438
login.setValue('@emailField', email)
39+
await login.waitForElementVisible('@passwordField', 2500)
3540
login.setValue('@passwordField', password)
3641
await login.submitForm('@loginForm')
3742
})
3843

3944
When(/^I create a project with the project details (.*?)$/, async name => {
4045
const createProject = client.page.createProject()
46+
await createProject.waitForElementVisible('@createProjectForm', 2500)
47+
await createProject.waitForElementVisible('@nameField', 2500)
4148
createProject.setValue('@nameField', name)
4249
await createProject.submitForm('@createProjectForm')
4350
})

0 commit comments

Comments
 (0)