2023-03-18 12:55:07 +03:00
|
|
|
import type { FC } from 'react';
|
2023-07-16 09:47:10 +03:00
|
|
|
import type { PartialVisitsSummary } from '../../shlink-web-component/visits/reducers/visitsOverview';
|
2023-03-18 12:55:07 +03:00
|
|
|
import { prettify } from '../../utils/helpers/numbers';
|
|
|
|
import type { HighlightCardProps } from './HighlightCard';
|
|
|
|
import { HighlightCard } from './HighlightCard';
|
|
|
|
|
2023-03-18 13:10:03 +03:00
|
|
|
export type VisitsHighlightCardProps = Omit<HighlightCardProps, 'tooltip' | 'children'> & {
|
2023-03-18 12:55:07 +03:00
|
|
|
loading: boolean;
|
|
|
|
excludeBots: boolean;
|
|
|
|
visitsSummary: PartialVisitsSummary;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const VisitsHighlightCard: FC<VisitsHighlightCardProps> = ({ loading, excludeBots, visitsSummary, ...rest }) => (
|
|
|
|
<HighlightCard
|
|
|
|
tooltip={
|
|
|
|
visitsSummary.bots !== undefined
|
|
|
|
? <>{excludeBots ? 'Plus' : 'Including'} <b>{prettify(visitsSummary.bots)}</b> potential bot visits</>
|
|
|
|
: undefined
|
|
|
|
}
|
|
|
|
{...rest}
|
|
|
|
>
|
|
|
|
{loading ? 'Loading...' : prettify(
|
|
|
|
excludeBots && visitsSummary.nonBots ? visitsSummary.nonBots : visitsSummary.total,
|
|
|
|
)}
|
|
|
|
</HighlightCard>
|
|
|
|
);
|