mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { useMessages } from 'components/hooks';
|
|
import { useContext } from 'react';
|
|
import { Dropdown, Form, FormButtons, FormInput, FormRow, Item, SubmitButton } from 'react-basics';
|
|
import BaseParameters from '../[reportId]/BaseParameters';
|
|
import { ReportContext } from '../[reportId]/Report';
|
|
|
|
export function RevenueParameters() {
|
|
const { report, runReport, isRunning } = useContext(ReportContext);
|
|
const { formatMessage, labels } = useMessages();
|
|
const { id, parameters } = report || {};
|
|
const { websiteId, dateRange } = parameters || {};
|
|
const queryEnabled = websiteId && dateRange;
|
|
|
|
const handleSubmit = (data: any, e: any) => {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
|
|
runReport(data);
|
|
};
|
|
|
|
return (
|
|
<Form values={parameters} onSubmit={handleSubmit} preventSubmit={true}>
|
|
<BaseParameters showDateSelect={true} allowWebsiteSelect={!id} />
|
|
<FormRow label={formatMessage(labels.currency)}>
|
|
<FormInput name="currency" rules={{ required: formatMessage(labels.required) }}>
|
|
<Dropdown items={['USD', 'EUR', 'MXN']}>
|
|
{item => <Item key={item}>{item}</Item>}
|
|
</Dropdown>
|
|
</FormInput>
|
|
</FormRow>
|
|
<FormButtons>
|
|
<SubmitButton variant="primary" disabled={!queryEnabled} isLoading={isRunning}>
|
|
{formatMessage(labels.runQuery)}
|
|
</SubmitButton>
|
|
</FormButtons>
|
|
</Form>
|
|
);
|
|
}
|
|
|
|
export default RevenueParameters;
|