2022-10-22 06:33:23 +02:00
|
|
|
import List from 'assets/list-ul.svg';
|
2023-01-10 08:59:26 +01:00
|
|
|
import EventDataForm from 'components/metrics/EventDataForm';
|
2022-10-22 06:33:23 +02:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { useState } from 'react';
|
2022-12-27 01:57:59 +01:00
|
|
|
import { Button, Icon, Modal } from 'react-basics';
|
2022-10-22 06:33:23 +02:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
import styles from './EventDataButton.module.css';
|
|
|
|
|
|
|
|
function EventDataButton({ websiteId }) {
|
|
|
|
const [showEventData, setShowEventData] = useState(false);
|
|
|
|
|
|
|
|
function handleClick() {
|
|
|
|
if (!showEventData) {
|
|
|
|
setShowEventData(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleClose() {
|
|
|
|
setShowEventData(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Button
|
|
|
|
tooltip={<FormattedMessage id="label.event-data" defaultMessage="Event" />}
|
|
|
|
tooltipId="button-event"
|
2023-01-06 04:39:29 +01:00
|
|
|
size="sm"
|
2022-10-22 06:33:23 +02:00
|
|
|
onClick={handleClick}
|
|
|
|
className={styles.button}
|
|
|
|
>
|
2022-12-27 01:57:59 +01:00
|
|
|
<Icon>
|
|
|
|
<List />
|
|
|
|
</Icon>
|
2022-10-22 06:33:23 +02:00
|
|
|
Event Data
|
|
|
|
</Button>
|
|
|
|
{showEventData && (
|
2023-01-06 04:39:29 +01:00
|
|
|
<Modal
|
|
|
|
title={<FormattedMessage id="label.event-data" defaultMessage="Query Event Data" />}
|
|
|
|
onClose={handleClose}
|
|
|
|
>
|
|
|
|
{close => <EventDataForm websiteId={websiteId} onClose={close} />}
|
2022-10-22 06:33:23 +02:00
|
|
|
</Modal>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
EventDataButton.propTypes = {
|
|
|
|
websiteId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
|
|
};
|
|
|
|
|
|
|
|
export default EventDataButton;
|