From 7ae457669beb9847fb2b37cacc530f8bcb3a0e72 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 5 Aug 2022 13:07:20 -0700 Subject: [PATCH] Fix event table. --- components/metrics/EventsTable.js | 64 ++++++----------------- components/metrics/EventsTable.module.css | 6 --- components/pages/WebsiteDetails.js | 40 +++++++++----- scripts/check-db.js | 5 ++ 4 files changed, 47 insertions(+), 68 deletions(-) delete mode 100644 components/metrics/EventsTable.module.css diff --git a/components/metrics/EventsTable.js b/components/metrics/EventsTable.js index b3427775..ace39010 100644 --- a/components/metrics/EventsTable.js +++ b/components/metrics/EventsTable.js @@ -1,62 +1,28 @@ -import React, { useState } from 'react'; -import { FormattedMessage } from 'react-intl'; +import { defineMessages, useIntl } from 'react-intl'; import MetricsTable from './MetricsTable'; -import Tag from 'components/common/Tag'; -import DropDown from 'components/common/DropDown'; import { eventTypeFilter } from 'lib/filters'; -import usePageQuery from 'hooks/usePageQuery'; -import styles from './EventsTable.module.css'; -const EVENT_FILTER_DEFAULT = { - value: 'all', - label: , -}; +const messages = defineMessages({ + events: { id: 'metrics.events', defaultMessage: 'Events' }, + actions: { id: 'metrics.actions', defaultMessage: 'Actions' }, +}); export default function EventsTable({ websiteId, ...props }) { - const [eventType, setEventType] = useState(EVENT_FILTER_DEFAULT.value); - const [eventTypes, setEventTypes] = useState([]); - const { resolve, router } = usePageQuery(); - - const dropDownOptions = [EVENT_FILTER_DEFAULT, ...eventTypes.map(t => ({ value: t, label: t }))]; + const { formatMessage } = useIntl(); function handleDataLoad(data) { - setEventTypes([...new Set(data.map(({ x }) => x.split('\t')[0]))]); props.onDataLoad?.(data); } - function handleChange(value) { - router.replace(resolve({ eventType: value === 'all' ? undefined : value })); - setEventType(value); - } - return ( - <> - {eventTypes?.length > 1 && ( -
- -
- )} - } - type="event" - metric={} - websiteId={websiteId} - dataFilter={eventTypeFilter} - filterOptions={eventType === EVENT_FILTER_DEFAULT.value ? [] : [eventType]} - renderLabel={({ x }) =>