import { useContext, useRef } from 'react'; import { useMessages } from 'hooks'; import { Icon, Form, FormButtons, FormInput, FormRow, PopupTrigger, Popup, SubmitButton, Text, TextField, TooltipPopup, } from 'react-basics'; import Icons from 'components/icons'; import UrlAddForm from './UrlAddForm'; import { ReportContext } from 'components/pages/reports/Report'; import styles from './FunnelParameters.module.css'; import BaseParameters from '../BaseParameters'; export function FunnelParameters() { const { report, runReport, updateReport, isRunning } = useContext(ReportContext); const { formatMessage, labels } = useMessages(); const ref = useRef(null); const { parameters } = report || {}; const { websiteId, dateRange, urls } = parameters || {}; const queryDisabled = !websiteId || !dateRange || urls?.length < 2; const handleSubmit = data => { if (!queryDisabled) { runReport(data); } }; const handleAddUrl = url => { updateReport({ parameters: { urls: parameters.urls.concat(url) } }); }; const handleRemoveUrl = (index, e) => { e.stopPropagation(); const urls = [...parameters.urls]; urls.splice(index, 1); updateReport({ parameters: { urls } }); }; return (
}>
{parameters?.urls?.map((url, index) => { return (
{url}
); })}
{formatMessage(labels.runQuery)} ); } function AddUrlButton({ onAdd }) { const { formatMessage, labels } = useMessages(); return ( {close => { return ; }} ); } export default FunnelParameters;