-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relates #8
- Loading branch information
Showing
5 changed files
with
111 additions
and
45 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
55 changes: 55 additions & 0 deletions
55
client/src/components/StepsQuestions/subcomponents/CountryOrCity.js
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,55 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Select } from 'antd'; | ||
import { getCountryNames, getCities } from 'full-countries-cities'; | ||
|
||
const renderOptions = list => { | ||
const { Option } = Select; | ||
|
||
return list.map(item => ( | ||
<Option key={item} value={item}> | ||
{item} | ||
</Option> | ||
)); | ||
}; | ||
|
||
const dropDownFilter = (input, option) => | ||
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0; | ||
|
||
const CountryOrCity = ({ | ||
value, | ||
handleStateChange, | ||
options: { type, countrySelected = '' }, | ||
}) => { | ||
let data; | ||
if (type === 'city') { | ||
data = countrySelected ? getCities(countrySelected) : []; | ||
} | ||
if (type === 'country') { | ||
data = getCountryNames(); | ||
} | ||
return ( | ||
<Select | ||
className="ant-select-country country-w-city" | ||
showSearch | ||
placeholder="Select" | ||
optionFilterProp="children" | ||
value={value} | ||
onChange={newValue => handleStateChange(newValue)} | ||
filterOption={dropDownFilter} | ||
> | ||
{renderOptions(data)} | ||
</Select> | ||
); | ||
}; | ||
|
||
CountryOrCity.propTypes = { | ||
value: PropTypes.string.isRequired, | ||
handleStateChange: PropTypes.func.isRequired, | ||
options: PropTypes.shape({ | ||
type: PropTypes.string.isRequired, | ||
countrySelected: PropTypes.string, | ||
}).isRequired, | ||
}; | ||
|
||
export default CountryOrCity; |
33 changes: 8 additions & 25 deletions
33
client/src/components/StepsQuestions/subcomponents/WelcomeMessage.js
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,26 +1,9 @@ | ||
// import React from 'react'; | ||
// import { Radio } from 'antd'; | ||
import React from 'react'; | ||
|
||
// const BusinessTypes = Object.freeze({ | ||
// stay: 'place to stay', | ||
// eat: 'place to eat or drink', | ||
// shop: 'place to shop', | ||
// }); | ||
// export default (values, handleStateChange) => ( | ||
// <div> | ||
// <Radio.Group value={values.businessType} buttonStyle="solid"> | ||
// {Object.entries(BusinessTypes).map(([key, value]) => ( | ||
// <Radio.Button | ||
// key={key} | ||
// value={key} | ||
// onClick={ | ||
// event => {} | ||
// // handleStateChange({ businessType: event.target.value }) | ||
// } | ||
// > | ||
// {value} | ||
// </Radio.Button> | ||
// ))} | ||
// </Radio.Group> | ||
// </div> | ||
// ); | ||
const Welcome = () => ( | ||
<div> | ||
<h2>Hi, Welcome </h2> | ||
</div> | ||
); | ||
|
||
export default Welcome; |
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,4 +1,6 @@ | ||
import WelcomeMessage from './WelcomeMessage'; | ||
import TypeQuestion from './TypeQuestion'; | ||
import InputQuestion from './InputQuestion'; | ||
import CountryOrCity from './CountryOrCity'; | ||
|
||
export default { TypeQuestion, InputQuestion }; | ||
export default { TypeQuestion, InputQuestion, CountryOrCity, WelcomeMessage }; |
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,5 +1,20 @@ | ||
export default [ | ||
{ stepNo: 0, key: 'name', question: 'name?', type: 'InputQuestion' }, | ||
{ stepNo: 1, key: 'link', question: 'link?', type: 'InputQuestion' }, | ||
{ stepNo: 2, key: 'type', question: 'something?', type: 'TypeQuestion' }, | ||
{ stepNo: 0, key: 'welcome', question: 'welcome', type: 'WelcomeMessage' }, | ||
{ stepNo: 1, key: 'name', question: 'name?', type: 'InputQuestion' }, | ||
{ stepNo: 2, key: 'link', question: 'link?', type: 'InputQuestion' }, | ||
{ | ||
stepNo: 3, | ||
key: 'country', | ||
question: 'something?', | ||
type: 'CountryOrCity', | ||
options: { type: 'country' }, | ||
}, | ||
{ | ||
stepNo: 4, | ||
key: 'city', | ||
question: 'something?', | ||
type: 'CountryOrCity', | ||
options: { type: 'city' }, | ||
}, | ||
{ stepNo: 5, key: 'type', question: 'something?', type: 'TypeQuestion' }, | ||
]; |