diff --git a/components/common/Calendar.js b/components/common/Calendar.js index 0414ff7f..237f065e 100644 --- a/components/common/Calendar.js +++ b/components/common/Calendar.js @@ -18,7 +18,7 @@ import { } from 'date-fns'; import Button from './Button'; import useLocale from 'hooks/useLocale'; -import { dateFormat } from 'lib/lang'; +import { dateFormat } from 'lib/date'; import { chunk } from 'lib/array'; import Chevron from 'assets/chevron-down.svg'; import Cross from 'assets/times.svg'; diff --git a/components/common/DateFilter.js b/components/common/DateFilter.js index 6279d338..45950086 100644 --- a/components/common/DateFilter.js +++ b/components/common/DateFilter.js @@ -6,8 +6,7 @@ import Modal from './Modal'; import DropDown from './DropDown'; import DatePickerForm from 'components/forms/DatePickerForm'; import useLocale from 'hooks/useLocale'; -import { getDateRange } from 'lib/date'; -import { dateFormat } from 'lib/lang'; +import { getDateRange, dateFormat } from 'lib/date'; import Calendar from 'assets/calendar-alt.svg'; import Icon from './Icon'; diff --git a/components/common/NoData.module.css b/components/common/NoData.module.css index 82f9c3ee..518fa488 100644 --- a/components/common/NoData.module.css +++ b/components/common/NoData.module.css @@ -1,8 +1,11 @@ .container { color: var(--gray500); font-size: var(--font-size-normal); - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); + position: relative; + display: flex; + align-items: center; + justify-content: center; + text-align: center; + width: 100%; + height: 100%; } diff --git a/components/layout/GridLayout.module.css b/components/layout/GridLayout.module.css index f17c195e..675fce16 100644 --- a/components/layout/GridLayout.module.css +++ b/components/layout/GridLayout.module.css @@ -35,6 +35,6 @@ .row > .col { border-top: 1px solid var(--gray300); border-left: 0; - padding: 0; + padding: 20px 0; } } diff --git a/components/metrics/BarChart.js b/components/metrics/BarChart.js index c3903829..856e81e8 100644 --- a/components/metrics/BarChart.js +++ b/components/metrics/BarChart.js @@ -3,7 +3,7 @@ import classNames from 'classnames'; import ChartJS from 'chart.js'; import Legend from 'components/metrics/Legend'; import { formatLongNumber } from 'lib/format'; -import { dateFormat, timeFormat } from 'lib/lang'; +import { dateFormat } from 'lib/date'; import useLocale from 'hooks/useLocale'; import useTheme from 'hooks/useTheme'; import { DEFAUL_CHART_HEIGHT, DEFAULT_ANIMATION_DURATION, THEME_COLORS } from 'lib/constants'; @@ -46,7 +46,7 @@ export default function BarChart({ case 'minute': return index % 2 === 0 ? dateFormat(d, 'H:mm', locale) : ''; case 'hour': - return timeFormat(d, locale); + return dateFormat(d, 'p', locale); case 'day': if (records > 31) { if (w <= 500) { @@ -93,9 +93,9 @@ export default function BarChart({ function getTooltipFormat(unit) { switch (unit) { case 'hour': - return 'EEE ha — MMM d yyyy'; + return 'EEE p — PPP'; default: - return 'EEE MMMM d yyyy'; + return 'PPPP'; } } diff --git a/components/metrics/DataTable.module.css b/components/metrics/DataTable.module.css index b8b203c4..b21b92b9 100644 --- a/components/metrics/DataTable.module.css +++ b/components/metrics/DataTable.module.css @@ -1,14 +1,15 @@ .table { position: relative; + height: 100%; font-size: var(--font-size-small); - display: flex; - flex-direction: column; - flex: 1; + display: grid; + grid-template-rows: fit-content(100%) auto; overflow: hidden; } .body { position: relative; + height: 100%; overflow: auto; } diff --git a/components/metrics/EventsTable.js b/components/metrics/EventsTable.js index 5599bc2e..e497a25e 100644 --- a/components/metrics/EventsTable.js +++ b/components/metrics/EventsTable.js @@ -19,7 +19,7 @@ export default function EventsTable({ websiteId, ...props }) { function handleDataLoad(data) { setEventTypes([...new Set(data.map(({ x }) => x.split('\t')[0]))]); - props.onDataLoad(data); + props.onDataLoad?.(data); } return ( diff --git a/components/metrics/MetricsTable.js b/components/metrics/MetricsTable.js index 25bb4a08..95eb00c3 100644 --- a/components/metrics/MetricsTable.js +++ b/components/metrics/MetricsTable.js @@ -17,7 +17,6 @@ import styles from './MetricsTable.module.css'; export default function MetricsTable({ websiteId, - websiteDomain, type, className, dataFilter, @@ -42,7 +41,6 @@ export default function MetricsTable({ type, start_at: +startDate, end_at: +endDate, - domain: websiteDomain, url, }, onDataLoad, diff --git a/components/metrics/MetricsTable.module.css b/components/metrics/MetricsTable.module.css index e93f536e..d3a70866 100644 --- a/components/metrics/MetricsTable.module.css +++ b/components/metrics/MetricsTable.module.css @@ -1,6 +1,7 @@ .container { position: relative; min-height: 430px; + height: 100%; font-size: var(--font-size-small); display: flex; flex-direction: column; diff --git a/components/metrics/RealtimeLog.js b/components/metrics/RealtimeLog.js index 63add268..8324f686 100644 --- a/components/metrics/RealtimeLog.js +++ b/components/metrics/RealtimeLog.js @@ -2,11 +2,11 @@ import React, { useMemo, useState } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; import { FixedSizeList } from 'react-window'; import firstBy from 'thenby'; -import { format } from 'date-fns'; import Icon from 'components/common/Icon'; import Tag from 'components/common/Tag'; import Dot from 'components/common/Dot'; import FilterButtons from 'components/common/FilterButtons'; +import NoData from 'components/common/NoData'; import { devices } from 'components/messages'; import useLocale from 'hooks/useLocale'; import useCountryNames from 'hooks/useCountryNames'; @@ -15,8 +15,8 @@ import Bolt from 'assets/bolt.svg'; import Visitor from 'assets/visitor.svg'; import Eye from 'assets/eye.svg'; import { stringToColor } from 'lib/format'; +import { dateFormat } from 'lib/date'; import styles from './RealtimeLog.module.css'; -import NoData from '../common/NoData'; const TYPE_ALL = 0; const TYPE_PAGEVIEW = 1; @@ -129,7 +129,12 @@ export default function RealtimeLog({ data, websites, websiteId }) { id="message.log.visitor" defaultMessage="Visitor from {country} using {browser} on {os} {device}" values={{ - country: {countryNames[country]}, + country: ( + + {countryNames[country] || + intl.formatMessage({ id: 'label.unknown', defaultMessage: 'Unknown' })} + + ), browser: {BROWSERS[browser]}, os: {os}, device: {intl.formatMessage(devices[device])?.toLowerCase()}, @@ -140,7 +145,7 @@ export default function RealtimeLog({ data, websites, websiteId }) { } function getTime({ created_at }) { - return format(new Date(created_at), 'h:mm:ss'); + return dateFormat(new Date(created_at), 'pp', locale); } function getColor(row) { @@ -176,9 +181,11 @@ export default function RealtimeLog({ data, websites, websiteId }) {