|
|
|
@@ -1,11 +1,11 @@ |
|
|
|
import React, { useState } from 'react'; |
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
import Select from 'react-select' |
|
|
|
import { prices, beds, types, lifeStyles } from '../../constants/filters'; |
|
|
|
import './CreateScrapeRequest.scss' |
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
import { states } from '../../constants/states' |
|
|
|
import Autocomplete from 'react-autocomplete'; |
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
|
|
|
|
export function matchStateToTerm(state, value) { |
|
|
|
return ( |
|
|
|
@@ -14,8 +14,9 @@ export function matchStateToTerm(state, value) { |
|
|
|
} |
|
|
|
const CreateScrapeRequest = ({ handleRequest }) => { |
|
|
|
|
|
|
|
const { t } = useTranslation(); |
|
|
|
const [requestObject, setRequestObject] = useState({ location: '' }) |
|
|
|
const { t } = useTranslation(); |
|
|
|
|
|
|
|
|
|
|
|
const handleChangePriceType = async selectedOption => { |
|
|
|
setRequestObject(s => ({ ...s, price: selectedOption.value })) |
|
|
|
@@ -34,9 +35,6 @@ const CreateScrapeRequest = ({ handleRequest }) => { |
|
|
|
console.log("requestObject", requestObject) |
|
|
|
return ( |
|
|
|
<div className="card card-primary"> |
|
|
|
<div className="card-header"> |
|
|
|
<h3 className="card-title">{t('createScrapeRequest.Title')}</h3> |
|
|
|
</div> |
|
|
|
<form > |
|
|
|
<div className="card-body"> |
|
|
|
<div className="row"> |
|
|
|
@@ -45,19 +43,42 @@ const CreateScrapeRequest = ({ handleRequest }) => { |
|
|
|
<input type="text" className="form-control input-field cursor-pointer" value={requestObject.location} placeholder={t('createScrapeRequest.LocationPlaceholder')} onChange={e => setRequestObject(s => ({ ...s, location: e.target.value }))} /> |
|
|
|
</div> |
|
|
|
</div> */} |
|
|
|
<Autocomplete |
|
|
|
getItemValue={(item) => item.label} |
|
|
|
items={states.map(s => ({ label: s }))} |
|
|
|
renderItem={(item, isHighlighted) => |
|
|
|
<div style={{ background: isHighlighted ? 'lightgray' : 'white' }}> |
|
|
|
{item.label} |
|
|
|
</div> |
|
|
|
} |
|
|
|
shouldItemRender={matchStateToTerm} |
|
|
|
value={requestObject.location} |
|
|
|
onChange={(e, val) => setRequestObject(s => ({ ...s, location: val }))} |
|
|
|
onSelect={(val) => setRequestObject(s => ({ ...s, location: val }))} |
|
|
|
/> |
|
|
|
<div className="col-md-3"> |
|
|
|
<div className="form-group"> |
|
|
|
<Autocomplete |
|
|
|
menuStyle={{ |
|
|
|
padding: ".375rem .75rem", |
|
|
|
fontSize: '1rem', |
|
|
|
fontWeight: '400', |
|
|
|
lineHeight: 1.5, |
|
|
|
color: "#495057", |
|
|
|
backgroundColor: '#fff', |
|
|
|
backgroundClip: "padding-box", |
|
|
|
border: "1px solid #ced4da", |
|
|
|
borderRadius: ".25rem", |
|
|
|
boxShadow: "inset 0 0 0 transparent", |
|
|
|
transition: " border-color .15s ease-in-out,box-shadow .15s ease-in-out", |
|
|
|
background: 'rgba(255, 255, 255, 0.9)', |
|
|
|
position: 'fixed', |
|
|
|
overflow: 'auto', |
|
|
|
maxHeight: '50%', |
|
|
|
zIndex: 2001 |
|
|
|
}} |
|
|
|
renderInput={(props) => <input {...props} type="text" className="form-control input-field cursor-pointer" placeholder={t('createScrapeRequest.LocationPlaceholder')} />} |
|
|
|
getItemValue={(item) => item.label} |
|
|
|
items={states.map(s => ({ label: s }))} |
|
|
|
renderItem={(item, isHighlighted) => |
|
|
|
<div style={{ background: isHighlighted ? 'lightgray' : 'white', }}> |
|
|
|
{item.label} |
|
|
|
</div> |
|
|
|
} |
|
|
|
shouldItemRender={matchStateToTerm} |
|
|
|
value={requestObject.location} |
|
|
|
onChange={(e, val) => setRequestObject(s => ({ ...s, location: val }))} |
|
|
|
onSelect={(val) => setRequestObject(s => ({ ...s, location: val }))} |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="col-md-2"> |
|
|
|
<div className="form-group"> |
|
|
|
<Select options={prices} value={{ name: requestObject.price, label: requestObject.price }} onChange={handleChangePriceType} /> |