| import React, { useState } from 'react'; | import React, { useState } from 'react'; | ||||
| import Select from 'react-select' | import Select from 'react-select' | ||||
| import { baths, beds, types, lifeStyles } from '../../constants/filters'; | |||||
| import { baths, beds, types } from '../../constants/filters'; | |||||
| import './CreateScrapeRequest.scss' | import './CreateScrapeRequest.scss' | ||||
| import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||
| import { states } from '../../constants/states' | import { states } from '../../constants/states' | ||||
| setRequestObject(s => ({ ...s, type: selectedOption.value })) | setRequestObject(s => ({ ...s, type: selectedOption.value })) | ||||
| }; | }; | ||||
| const handleChangeLifeStyleType = async selectedOption => { | |||||
| setRequestObject(s => ({ ...s, lifestyle: selectedOption.value })) | |||||
| }; | |||||
| // const handleChangeLifeStyleType = async selectedOption => { | |||||
| // setRequestObject(s => ({ ...s, lifestyle: selectedOption.value })) | |||||
| // }; | |||||
| console.log("requestObject", requestObject) | console.log("requestObject", requestObject) | ||||
| return ( | return ( | ||||
| <div className="col-md-3"> | <div className="col-md-3"> | ||||
| <div className="form-group"> | <div className="form-group"> | ||||
| <Autocomplete | <Autocomplete | ||||
| wrapperProps={{ style: {} }} | |||||
| menuStyle={{ | menuStyle={{ | ||||
| display: 'block', | display: 'block', | ||||
| margin: 0, | margin: 0, | ||||
| <div className="col-md-2"> | <div className="col-md-2"> | ||||
| <Select className="cursor-pointer" options={types} onChange={handleChangeFilterType} placeholder={t('createScrapeRequest.TypePlaceholder')} /> | <Select className="cursor-pointer" options={types} onChange={handleChangeFilterType} placeholder={t('createScrapeRequest.TypePlaceholder')} /> | ||||
| </div> | </div> | ||||
| <div className="col-md-2"> | |||||
| {/* <div className="col-md-2"> | |||||
| <Select className="cursor-pointer" options={lifeStyles} onChange={handleChangeLifeStyleType} placeholder={t('createScrapeRequest.LifestylePlaceholder')} /> | <Select className="cursor-pointer" options={lifeStyles} onChange={handleChangeLifeStyleType} placeholder={t('createScrapeRequest.LifestylePlaceholder')} /> | ||||
| </div> | |||||
| </div> */} | |||||
| <div className="col-md-1"> | <div className="col-md-1"> | ||||
| <button type="button" onClick={() => { handleRequest(requestObject); setRequestObject({ location: '', description: '' }) }} className="btn btn-outline-primary cursor-pointer">Request</button> | <button type="button" onClick={() => { handleRequest(requestObject); setRequestObject({ location: '', description: '' }) }} className="btn btn-outline-primary cursor-pointer">Request</button> | ||||
| </div> | </div> |
| id: scrape._id | id: scrape._id | ||||
| }} | }} | ||||
| target="_blank" rel="noopener noreferrer">{scrape.description || 'No name given'}</Link></h3> | target="_blank" rel="noopener noreferrer">{scrape.description || 'No name given'}</Link></h3> | ||||
| <p> | |||||
| <div className='row'> | |||||
| {scrape.location && <span className="mr-2">Location: <span className='text-info'>{scrape.location}</span></span>} | {scrape.location && <span className="mr-2">Location: <span className='text-info'>{scrape.location}</span></span>} | ||||
| <a className='mr-1' href={scrape.sourceUrl} target="_blank" rel="noopener noreferrer"><i className="fas fa-external-link-square-alt"></i> https://www.apartments.com</a> | <a className='mr-1' href={scrape.sourceUrl} target="_blank" rel="noopener noreferrer"><i className="fas fa-external-link-square-alt"></i> https://www.apartments.com</a> | ||||
| {/* <span className="text-lg">Id: {scrape._id}</span> */} | {/* <span className="text-lg">Id: {scrape._id}</span> */} | ||||
| </p> | |||||
| <p> | |||||
| </div> | |||||
| <div className='row'> | |||||
| <span className="mr-1">Count: <span className='text-info'>{scrape.count}</span></span> | <span className="mr-1">Count: <span className='text-info'>{scrape.count}</span></span> | ||||
| {scrape.createDate && <span className="mr-1">Creation time: <span className='text-info'>{(new Date(scrape.createDate)).toLocaleString()}</span></span>} | {scrape.createDate && <span className="mr-1">Creation time: <span className='text-info'>{(new Date(scrape.createDate)).toLocaleString()}</span></span>} | ||||
| {(scrape.startDate !== undefined && scrape.startDate !== null) ? | {(scrape.startDate !== undefined && scrape.startDate !== null) ? | ||||
| <span className="mr-1">Time: <span className="text-info">{(new Date(scrape.startDate)).toLocaleString()} - {(scrape.endDate != undefined && scrape.endDate !== null) ? (new Date(scrape.endDate)).toLocaleString() : ''}</span> </span> | <span className="mr-1">Time: <span className="text-info">{(new Date(scrape.startDate)).toLocaleString()} - {(scrape.endDate != undefined && scrape.endDate !== null) ? (new Date(scrape.endDate)).toLocaleString() : ''}</span> </span> | ||||
| : <span className="mr-1">{t('scrapeRequest.EstimatedTime')} <span className='text-info'>{(new Date(scrape.estimate)).toLocaleString()}</span></span> | : <span className="mr-1">{t('scrapeRequest.EstimatedTime')} <span className='text-info'>{(new Date(scrape.estimate)).toLocaleString()}</span></span> | ||||
| } | } | ||||
| </p> | |||||
| </div> | |||||
| </td> | </td> | ||||
| <td> | <td> | ||||
| {scrape.filters.map(element => ( | {scrape.filters.map(element => ( |
| import React from 'react' | |||||
| import PropTypes from 'prop-types'; | |||||
| const SearchScrapes = ({ handleSearch }) => { | |||||
| return ( | |||||
| <input className='form-control input-field mb-3' placeholder='Search' onChange={(e) => handleSearch(e.target.value)}></input> | |||||
| ) | |||||
| } | |||||
| SearchScrapes.propTypes = { | |||||
| handleSearch: PropTypes.func | |||||
| }; | |||||
| export default SearchScrapes |
| import ScrapeRequests from '../../components/ScrapeRequests/ScrapeRequests'; | import ScrapeRequests from '../../components/ScrapeRequests/ScrapeRequests'; | ||||
| import { createScrappes, estimateScrappes, executeScrappes, getAllScrappes } from '../../request/scrappe'; | import { createScrappes, estimateScrappes, executeScrappes, getAllScrappes } from '../../request/scrappe'; | ||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||
| import Select from 'react-select' | |||||
| import { scrapeFrom } from '../../constants/filters'; | |||||
| // import Select from 'react-select' | |||||
| // import { scrapeFrom } from '../../constants/filters'; | |||||
| import CustomModal from '../../components/Modals/Modal'; | import CustomModal from '../../components/Modals/Modal'; | ||||
| import SearchScrapes from '../../components/SearchScrapes/SearchScrapes'; | |||||
| const HomePage = () => { | const HomePage = () => { | ||||
| const [scrappes, setScrappes] = useState([]) | const [scrappes, setScrappes] = useState([]) | ||||
| const [showModal, setShowModal] = useState(false) | const [showModal, setShowModal] = useState(false) | ||||
| const [request, setRequest] = useState() | const [request, setRequest] = useState() | ||||
| const [searchQuery, setSearchQuery] = useState('') | |||||
| const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
| useEffect(() => { | useEffect(() => { | ||||
| } | } | ||||
| } | } | ||||
| function handleSearch(query) { | |||||
| setSearchQuery(query) | |||||
| } | |||||
| return ( | return ( | ||||
| <> | <> | ||||
| <CustomModal showModal={showModal} handleClose={() => setShowModal(false)} handleConfirm={handleConfirm} /> | <CustomModal showModal={showModal} handleClose={() => setShowModal(false)} handleConfirm={handleConfirm} /> | ||||
| <h1 className="lead text-center" style={{ fontSize: '80px' }}>{t('scrapeRequests.Columns.Scrape')} </h1> | <h1 className="lead text-center" style={{ fontSize: '80px' }}>{t('scrapeRequests.Columns.Scrape')} </h1> | ||||
| <hr></hr> | <hr></hr> | ||||
| {/* <h2 className="lead text-center text-muted" style={{ fontSize: '40px' }}>https://www.apartments.com/</h2> */} | {/* <h2 className="lead text-center text-muted" style={{ fontSize: '40px' }}>https://www.apartments.com/</h2> */} | ||||
| <Select className="cursor-pointer" defaultValue={scrapeFrom[0]} options={scrapeFrom}></Select> | |||||
| {/* <Select className="cursor-pointer" defaultValue={scrapeFrom[0]} options={scrapeFrom}></Select> */} | |||||
| <div className="form-check" > | |||||
| <input type="checkbox" disabled checked className="form-check-input" /> | |||||
| <label className="form-check-label text-md">www.apartments.com</label> | |||||
| </div> | |||||
| <br></br> | <br></br> | ||||
| <CreateScrapeRequest handleRequest={handleRequest} /> | <CreateScrapeRequest handleRequest={handleRequest} /> | ||||
| <ScrapeRequests scrappes={scrappes} handleExecute={handleExecute} /> | |||||
| <SearchScrapes handleSearch={handleSearch} /> | |||||
| <ScrapeRequests scrappes={scrappes.filter(a => a.description?.toLowerCase()?.includes(searchQuery.toLowerCase()) || !a.description)} handleExecute={handleExecute} /> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </> | </> |