import { useEventQueryFilters } from '@/hooks/use-event-query-filters'; import { cn } from '@/utils/cn'; import { useState } from 'react'; import type { IChartType } from '@openpanel/validation'; import { useNumber } from '@/hooks/use-numer-formatter'; import { useTRPC } from '@/integrations/trpc/react'; import { pushModal } from '@/modals'; import { countries } from '@/translations/countries'; import { NOT_SET_VALUE } from '@openpanel/constants'; import { useQuery } from '@tanstack/react-query'; import { ChevronRightIcon } from 'lucide-react'; import { ReportChart } from '../report-chart'; 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 OverviewTopGeoProps { projectId: string; } export default function OverviewTopGeo({ projectId }: OverviewTopGeoProps) { const { interval, range, previous, startDate, endDate } = useOverviewOptions(); const [chartType, setChartType] = useState('bar'); const [filters, setFilter] = useEventQueryFilters(); const isPageFilter = filters.find((filter) => filter.name === 'path'); const [widget, setWidget, widgets] = useOverviewWidgetV2('geo', { country: { title: 'Top countries', btn: 'Countries', }, region: { title: 'Top regions', btn: 'Regions', }, city: { title: 'Top cities', btn: 'Cities', }, }); const number = useNumber(); 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, }) } /> {/* */}
Map
); }