umami/components/metrics/PagesTable.js

44 lines
1014 B
JavaScript
Raw Normal View History

2020-08-23 07:01:14 +02:00
import React, { useState } from 'react';
import MetricsTable from './MetricsTable';
import { urlFilter } from 'lib/filters';
2020-08-23 07:01:14 +02:00
import ButtonGroup from '../common/ButtonGroup';
export default function PagesTable({
websiteId,
websiteDomain,
startDate,
endDate,
limit,
onExpand,
}) {
2020-08-23 07:01:14 +02:00
const [filter, setFilter] = useState('Combined');
return (
<MetricsTable
title="Pages"
type="url"
metric="Views"
2020-08-23 07:01:14 +02:00
headerComponent={limit ? null : <FilterButtons selected={filter} onClick={setFilter} />}
websiteId={websiteId}
startDate={startDate}
endDate={endDate}
limit={limit}
dataFilter={urlFilter}
2020-08-23 07:01:14 +02:00
filterOptions={{ domain: websiteDomain, raw: filter === 'Raw' }}
2020-08-25 08:49:14 +02:00
renderLabel={({ x }) => decodeURI(x)}
onExpand={onExpand}
/>
);
}
2020-08-23 07:01:14 +02:00
const FilterButtons = ({ selected, onClick }) => {
return (
<ButtonGroup
size="xsmall"
items={['Combined', 'Raw']}
selectedItem={selected}
onClick={onClick}
/>
);
};