mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { useContext } from 'react';
|
|
import { useMessages } from '@/components/hooks';
|
|
import { Form, FormButtons, FormSubmitButton } from '@umami/react-zen';
|
|
import { ReportContext } from '../[reportId]/Report';
|
|
import { BaseParameters } from '../[reportId]/BaseParameters';
|
|
|
|
export function UTMParameters() {
|
|
const { report, runReport, isRunning } = useContext(ReportContext);
|
|
const { formatMessage, labels } = useMessages();
|
|
|
|
const { id, parameters } = report || {};
|
|
const { websiteId, dateRange } = parameters || {};
|
|
const queryDisabled = !websiteId || !dateRange;
|
|
|
|
const handleSubmit = (data: any, e: any) => {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
|
|
if (!queryDisabled) {
|
|
runReport(data);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Form values={parameters} onSubmit={handleSubmit} preventSubmit={true}>
|
|
<BaseParameters showDateSelect={true} allowWebsiteSelect={!id} />
|
|
<FormButtons>
|
|
<FormSubmitButton variant="primary" isDisabled={queryDisabled} isLoading={isRunning}>
|
|
{formatMessage(labels.runQuery)}
|
|
</FormSubmitButton>
|
|
</FormButtons>
|
|
</Form>
|
|
);
|
|
}
|