import React, { useState } from 'react';
import { FormattedMessage } from 'react-intl';
import MetricsTable from './MetricsTable';
import FilterButtons from 'components/common/FilterButtons';
import { refFilter } from 'lib/filters';
export const FILTER_DOMAIN_ONLY = 0;
export const FILTER_COMBINED = 1;
export const FILTER_RAW = 2;
export default function ReferrersTable({ websiteId, websiteDomain, showFilters, ...props }) {
const [filter, setFilter] = useState(FILTER_COMBINED);
const buttons = [
{
label: ,
value: FILTER_DOMAIN_ONLY,
},
{
label: ,
value: FILTER_COMBINED,
},
{ label: , value: FILTER_RAW },
];
const renderLink = ({ w: href, x: url }) => {
return (href || url).startsWith('http') ? (
{decodeURI(url)}
) : (
decodeURI(url)
);
};
return (
<>
{showFilters && }
}
type="referrer"
metric={}
websiteId={websiteId}
dataFilter={refFilter}
filterOptions={{
domain: websiteDomain,
domainOnly: filter === FILTER_DOMAIN_ONLY,
raw: filter === FILTER_RAW,
}}
renderLabel={renderLink}
/>
>
);
}