import { useContext, useRef, useState } from 'react'; import { useMessages } from 'hooks'; import { Icon, Form, FormButtons, FormInput, FormRow, Modal, SubmitButton, Text, TextField, Tooltip, } from 'react-basics'; import Icons from 'components/icons'; import AddUrlForm from './AddUrlForm'; import { ReportContext } from 'components/pages/reports/Report'; import styles from './FunnelParameters.module.css'; export function FunnelParameters() { const { report, runReport, updateReport, isRunning } = useContext(ReportContext); const { formatMessage, labels } = useMessages(); const [show, setShow] = useState(false); const ref = useRef(null); const { websiteId, parameters } = report || {}; const queryDisabled = !websiteId || parameters?.urls?.length < 2; const handleSubmit = values => { runReport(values); }; const handleAddUrl = url => { updateReport({ parameters: { ...parameters, urls: parameters.urls.concat(url) } }); }; const handleRemoveUrl = (index, e) => { e.stopPropagation(); const urls = [...parameters.urls]; urls.splice(index, 1); updateReport({ parameters: { ...parameters, urls } }); }; const showAddForm = () => setShow(true); const hideAddForm = () => setShow(false); return ( <>
{show && (