import DateFilter from 'components/input/DateFilter'; import WebsiteSelect from 'components/input/WebsiteSelect'; import useMessages from 'hooks/useMessages'; import { parseDateRange } from 'lib/date'; import { useState } from 'react'; import { Button, Form, FormButtons, FormInput, FormRow, SubmitButton, TextField, } from 'react-basics'; import styles from './FunnelForm.module.css'; export function FunnelForm({ onSearch }) { const { formatMessage, labels } = useMessages(); const [dateRange, setDateRange] = useState(''); const [startAt, setStartAt] = useState(); const [endAt, setEndAt] = useState(); const [urls, setUrls] = useState(['']); const [websiteId, setWebsiteId] = useState(''); const [window, setWindow] = useState(60); const handleSubmit = async data => { onSearch(data); }; const handleDateChange = value => { const { startDate, endDate } = parseDateRange(value); setDateRange(value); setStartAt(startDate.getTime()); setEndAt(endDate.getTime()); }; const handleAddUrl = () => setUrls([...urls, '']); const handleRemoveUrl = i => setUrls(urls.splice(i, 1)); const handleWindowChange = value => setWindow(value.target.value); const handleUrlChange = (value, i) => { const nextUrls = [...urls]; nextUrls[i] = value.target.value; setUrls(nextUrls); }; return ( <>
setWebsiteId(value)} /> {urls.map((a, i) => ( handleUrlChange(value, i)} /> ))} Search
); } export default FunnelForm;