import { useEventQueryFilters } from '@/hooks/use-event-query-filters'; import { cn } from '@/utils/cn'; import { useTRPC } from '@/integrations/trpc/react'; import { pushModal } from '@/modals'; import { NOT_SET_VALUE } from '@openpanel/constants'; import { useQuery } from '@tanstack/react-query'; import { SerieIcon } from '../report-chart/common/serie-icon'; import { Widget, WidgetBody } from '../widget'; import { OVERVIEW_COLUMNS_NAME } from './overview-constants'; import OverviewDetailsButton from './overview-details-button'; import { WidgetButtons, WidgetFooter, WidgetHead } from './overview-widget'; import { OverviewWidgetTableGeneric, OverviewWidgetTableLoading, } from './overview-widget-table'; import { useOverviewOptions } from './useOverviewOptions'; import { useOverviewWidgetV2 } from './useOverviewWidget'; interface OverviewTopSourcesProps { projectId: string; } export default function OverviewTopSources({ projectId, }: OverviewTopSourcesProps) { const { range, startDate, endDate } = useOverviewOptions(); const [filters, setFilter] = useEventQueryFilters(); const [widget, setWidget, widgets] = useOverviewWidgetV2('sources', { referrer_name: { title: 'Top sources', btn: 'All', }, referrer: { title: 'Top urls', btn: 'URLs', }, referrer_type: { title: 'Top types', btn: 'Types', }, utm_source: { title: 'UTM Source', btn: 'Source', }, utm_medium: { title: 'UTM Medium', btn: 'Medium', }, utm_campaign: { title: 'UTM Campaign', btn: 'Campaign', }, utm_term: { title: 'UTM Term', btn: 'Term', }, utm_content: { title: 'UTM Content', btn: 'Content', }, }); const trpc = useTRPC(); const query = useQuery( trpc.overview.topGeneric.queryOptions({ projectId, range, filters, column: widget.key, startDate, endDate, }), ); return ( <>
{widget.title}
{widgets.map((w) => ( ))}
{query.isLoading ? ( ) : ( ); }, }} /> )} pushModal('OverviewTopGenericModal', { projectId, column: widget.key, }) } /> {/* */}
); }