fix: report intervals
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { useTRPC } from '@/integrations/trpc/react';
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useOverviewOptions } from '@/components/overview/useOverviewOptions';
|
||||
import { AspectContainer } from '../aspect-container';
|
||||
import { ReportChartEmpty } from '../common/empty';
|
||||
import { ReportChartError } from '../common/error';
|
||||
@@ -12,18 +11,12 @@ import { Chart } from './chart';
|
||||
export function ReportAreaChart() {
|
||||
const { isLazyLoading, report, shareId } = useReportChartContext();
|
||||
const trpc = useTRPC();
|
||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||
|
||||
const res = useQuery(
|
||||
trpc.chart.chart.queryOptions(
|
||||
{
|
||||
...report,
|
||||
shareId,
|
||||
reportId: 'id' in report ? report.id : undefined,
|
||||
range: range ?? report.range,
|
||||
startDate: startDate ?? report.startDate,
|
||||
endDate: endDate ?? report.endDate,
|
||||
interval: interval ?? report.interval,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useTRPC } from '@/integrations/trpc/react';
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useOverviewOptions } from '@/components/overview/useOverviewOptions';
|
||||
import { cn } from '@/utils/cn';
|
||||
import { AspectContainer } from '../aspect-container';
|
||||
import { ReportChartEmpty } from '../common/empty';
|
||||
@@ -12,18 +11,12 @@ import { Chart } from './chart';
|
||||
export function ReportBarChart() {
|
||||
const { isLazyLoading, report, shareId } = useReportChartContext();
|
||||
const trpc = useTRPC();
|
||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||
|
||||
const res = useQuery(
|
||||
trpc.chart.aggregate.queryOptions(
|
||||
{
|
||||
...report,
|
||||
shareId,
|
||||
reportId: 'id' in report ? report.id : undefined,
|
||||
range: range ?? report.range,
|
||||
startDate: startDate ?? report.startDate,
|
||||
endDate: endDate ?? report.endDate,
|
||||
interval: interval ?? report.interval,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useTRPC } from '@/integrations/trpc/react';
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useOverviewOptions } from '@/components/overview/useOverviewOptions';
|
||||
import { cn } from '@/utils/cn';
|
||||
import { AspectContainer } from '../aspect-container';
|
||||
import { ReportChartEmpty } from '../common/empty';
|
||||
@@ -14,18 +13,11 @@ import { Summary } from './summary';
|
||||
export function ReportConversionChart() {
|
||||
const { isLazyLoading, report, shareId } = useReportChartContext();
|
||||
const trpc = useTRPC();
|
||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||
console.log(report.limit);
|
||||
const res = useQuery(
|
||||
trpc.chart.conversion.queryOptions(
|
||||
{
|
||||
...report,
|
||||
shareId,
|
||||
reportId: 'id' in report ? report.id : undefined,
|
||||
range: range ?? report.range,
|
||||
startDate: startDate ?? report.startDate,
|
||||
endDate: endDate ?? report.endDate,
|
||||
interval: interval ?? report.interval,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useTRPC } from '@/integrations/trpc/react';
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useOverviewOptions } from '@/components/overview/useOverviewOptions';
|
||||
import { AspectContainer } from '../aspect-container';
|
||||
import { ReportChartEmpty } from '../common/empty';
|
||||
import { ReportChartError } from '../common/error';
|
||||
@@ -12,18 +11,12 @@ import { Chart } from './chart';
|
||||
export function ReportHistogramChart() {
|
||||
const { isLazyLoading, report, shareId } = useReportChartContext();
|
||||
const trpc = useTRPC();
|
||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||
|
||||
const res = useQuery(
|
||||
trpc.chart.chart.queryOptions(
|
||||
{
|
||||
...report,
|
||||
shareId,
|
||||
reportId: 'id' in report ? report.id : undefined,
|
||||
range: range ?? report.range,
|
||||
startDate: startDate ?? report.startDate,
|
||||
endDate: endDate ?? report.endDate,
|
||||
interval: interval ?? report.interval,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { useTRPC } from '@/integrations/trpc/react';
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { cn } from '@/utils/cn';
|
||||
import { useOverviewOptions } from '@/components/overview/useOverviewOptions';
|
||||
import { AspectContainer } from '../aspect-container';
|
||||
import { ReportChartEmpty } from '../common/empty';
|
||||
import { ReportChartError } from '../common/error';
|
||||
@@ -13,18 +11,11 @@ import { Chart } from './chart';
|
||||
export function ReportLineChart() {
|
||||
const { isLazyLoading, report, shareId } = useReportChartContext();
|
||||
const trpc = useTRPC();
|
||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||
|
||||
const res = useQuery(
|
||||
trpc.chart.chart.queryOptions(
|
||||
{
|
||||
...report,
|
||||
shareId,
|
||||
reportId: 'id' in report ? report.id : undefined,
|
||||
range: range ?? report.range,
|
||||
startDate: startDate ?? report.startDate,
|
||||
endDate: endDate ?? report.endDate,
|
||||
interval: interval ?? report.interval,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useTRPC } from '@/integrations/trpc/react';
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useOverviewOptions } from '@/components/overview/useOverviewOptions';
|
||||
import { AspectContainer } from '../aspect-container';
|
||||
import { ReportChartEmpty } from '../common/empty';
|
||||
import { ReportChartError } from '../common/error';
|
||||
@@ -12,18 +11,12 @@ import { Chart } from './chart';
|
||||
export function ReportMapChart() {
|
||||
const { isLazyLoading, report, shareId } = useReportChartContext();
|
||||
const trpc = useTRPC();
|
||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||
|
||||
const res = useQuery(
|
||||
trpc.chart.chart.queryOptions(
|
||||
{
|
||||
...report,
|
||||
shareId,
|
||||
reportId: 'id' in report ? report.id : undefined,
|
||||
range: range ?? report.range,
|
||||
startDate: startDate ?? report.startDate,
|
||||
endDate: endDate ?? report.endDate,
|
||||
interval: interval ?? report.interval,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useTRPC } from '@/integrations/trpc/react';
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useOverviewOptions } from '@/components/overview/useOverviewOptions';
|
||||
import { AspectContainer } from '../aspect-container';
|
||||
import { ReportChartEmpty } from '../common/empty';
|
||||
import { ReportChartError } from '../common/error';
|
||||
@@ -11,18 +10,12 @@ import { Chart } from './chart';
|
||||
export function ReportMetricChart() {
|
||||
const { isLazyLoading, report, shareId } = useReportChartContext();
|
||||
const trpc = useTRPC();
|
||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||
|
||||
const res = useQuery(
|
||||
trpc.chart.chart.queryOptions(
|
||||
{
|
||||
...report,
|
||||
shareId,
|
||||
reportId: 'id' in report ? report.id : undefined,
|
||||
range: range ?? report.range,
|
||||
startDate: startDate ?? report.startDate,
|
||||
endDate: endDate ?? report.endDate,
|
||||
interval: interval ?? report.interval,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useTRPC } from '@/integrations/trpc/react';
|
||||
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useOverviewOptions } from '@/components/overview/useOverviewOptions';
|
||||
import { AspectContainer } from '../aspect-container';
|
||||
import { ReportChartEmpty } from '../common/empty';
|
||||
import { ReportChartError } from '../common/error';
|
||||
@@ -12,18 +11,12 @@ import { Chart } from './chart';
|
||||
export function ReportPieChart() {
|
||||
const { isLazyLoading, report, shareId } = useReportChartContext();
|
||||
const trpc = useTRPC();
|
||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||
|
||||
const res = useQuery(
|
||||
trpc.chart.aggregate.queryOptions(
|
||||
{
|
||||
...report,
|
||||
shareId,
|
||||
reportId: 'id' in report ? report.id : undefined,
|
||||
range: range ?? report.range,
|
||||
startDate: startDate ?? report.startDate,
|
||||
endDate: endDate ?? report.endDate,
|
||||
interval: interval ?? report.interval,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
|
||||
@@ -53,7 +53,7 @@ export function ReportRetentionChart() {
|
||||
criteria,
|
||||
interval: overviewInterval ?? interval,
|
||||
shareId,
|
||||
reportId: id,
|
||||
id,
|
||||
},
|
||||
{
|
||||
placeholderData: keepPreviousData,
|
||||
|
||||
@@ -4,6 +4,7 @@ import FullPageLoadingState from '@/components/full-page-loading-state';
|
||||
import { LoginNavbar } from '@/components/login-navbar';
|
||||
import { OverviewInterval } from '@/components/overview/overview-interval';
|
||||
import { OverviewRange } from '@/components/overview/overview-range';
|
||||
import { useOverviewOptions } from '@/components/overview/useOverviewOptions';
|
||||
import { ReportChart } from '@/components/report-chart';
|
||||
import { useTRPC } from '@/integrations/trpc/react';
|
||||
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
@@ -63,6 +64,7 @@ function RouteComponent() {
|
||||
const { shareId } = Route.useParams();
|
||||
const { header } = useSearch({ from: '/share/report/$shareId' });
|
||||
const trpc = useTRPC();
|
||||
const { range, startDate, endDate, interval } = useOverviewOptions();
|
||||
const shareQuery = useSuspenseQuery(
|
||||
trpc.share.report.queryOptions({
|
||||
shareId,
|
||||
@@ -81,8 +83,6 @@ function RouteComponent() {
|
||||
|
||||
const share = shareQuery.data;
|
||||
|
||||
console.log('share', share);
|
||||
|
||||
// Handle password protection
|
||||
if (share.password && !hasAccess) {
|
||||
return <ShareEnterPassword shareId={share.id} shareType="report" />;
|
||||
@@ -114,7 +114,16 @@ function RouteComponent() {
|
||||
<div className="font-medium text-xl">{share.report.name}</div>
|
||||
</div>
|
||||
<div className="p-4">
|
||||
<ReportChart report={share.report} shareId={shareId} />
|
||||
<ReportChart
|
||||
report={{
|
||||
...share.report,
|
||||
range: range ?? share.report.range,
|
||||
startDate: startDate ?? share.report.startDate,
|
||||
endDate: endDate ?? share.report.endDate,
|
||||
interval: interval ?? share.report.interval,
|
||||
}}
|
||||
shareId={shareId}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user