2020-08-23 07:01:14 +02:00
|
|
|
import React, { useState } from 'react';
|
2020-08-23 04:05:07 +02:00
|
|
|
import MetricsTable from './MetricsTable';
|
|
|
|
import { urlFilter } from 'lib/filters';
|
2020-08-23 07:01:14 +02:00
|
|
|
import ButtonGroup from '../common/ButtonGroup';
|
2020-08-23 04:05:07 +02:00
|
|
|
|
2020-08-31 23:11:30 +02:00
|
|
|
export default function PagesTable({ websiteId, websiteDomain, limit, onExpand }) {
|
2020-08-23 07:01:14 +02:00
|
|
|
const [filter, setFilter] = useState('Combined');
|
|
|
|
|
2020-08-23 04:05:07 +02:00
|
|
|
return (
|
|
|
|
<MetricsTable
|
|
|
|
title="Pages"
|
|
|
|
type="url"
|
|
|
|
metric="Views"
|
2020-08-23 07:01:14 +02:00
|
|
|
headerComponent={limit ? null : <FilterButtons selected={filter} onClick={setFilter} />}
|
2020-08-23 04:05:07 +02:00
|
|
|
websiteId={websiteId}
|
|
|
|
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)}
|
2020-08-23 04:05:07 +02:00
|
|
|
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}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|