add ability to add intire countries as edge cases

This commit is contained in:
Sara Vieira
2018-11-25 15:42:26 +01:00
parent da271907d3
commit c9ca5170b5
2 changed files with 37 additions and 33 deletions

View File

@@ -71,7 +71,7 @@ class City extends Component {
/>
</Wrapper>,
<Title>YES 🚗</Title>,
<Message>{edgeCases(cities[0].name)}</Message>,
<Message>{edgeCases(cities[0])}</Message>,
]
) : (
<Title>NO 😕</Title>

View File

@@ -2,45 +2,49 @@ const cases = [
{
type: 'price',
message: 'The price for getting an Uber is the same as getting a taxi',
name: 'berlin',
},
{
type: 'safety',
message:
'Be careful getting an Uber in porto because of taxi drivers. Mainly in airports and train stations',
name: 'porto',
},
{
type: 'payment',
message:
'Uber drivers only take payment by cash. If they think you\'ll pay by card then they\'ll cancel the ride',
name: 'buenos aires',
},
{
type: 'price',
message: 'A ride from Charles de Gaule Airport to Paris is legally set at 50-55€, and 30-35€ from Orly Airport. Beware of frauds.',
name: 'paris',
},
{
type: 'safety',
message:
'Be aware! Some taxi drivers may attack your uber driver.',
name: 'istanbul',
city: ['berlin'],
},
{
type: 'price',
message:
'Uber drivers only take payment by cash. If they think you\'ll pay by card then they\'ll cancel the ride',
name: 'san salvador',
'A ride from Charles de Gaule Airport to Paris is legally set at 50-55€, and 30-35€ from Orly Airport. Beware of frauds.',
city: ['paris'],
},
{
type: 'safety',
message: 'Be aware! Some taxi drivers may attack your uber driver.',
city: ['porto', 'istanbul'],
},
{
type: 'price',
message:
"Uber drivers only take payment by cash. If they think you'll pay by card then they'll cancel the ride",
city: ['san salvador', 'buenos aires'],
},
{
type: 'service',
message: 'Only Uber Black is available in Seoul.',
name: 'seoul',
}
city: ['seoul'],
},
{
type: 'service',
message: 'It is preferred to take Yandex Taxi',
country: ['russia'],
},
]
export default city =>
city &&
(cases.filter(c => c.name.toLowerCase() === city.toLowerCase())[0] || {})
.message
export default ({
name,
info: {
country: { long_name },
},
}) => {
const match = cases.find(
c =>
(c.city && c.city.includes(name.toLowerCase())) ||
(c.country && c.country.includes(long_name.toLowerCase()))
)
if (match) {
return match.message
}
}