Skip to content

Commit d32cb77

Browse files
committed
cleanup cache
1 parent c4d9f2b commit d32cb77

File tree

11 files changed

+460
-41
lines changed

11 files changed

+460
-41
lines changed

apps/dashboard/app/(main)/websites/[id]/layout.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useAtom } from "jotai";
55
import { useParams, usePathname } from "next/navigation";
66
import { useRef } from "react";
77
import { toast } from "sonner";
8-
import NotFound from "@/app/not-found";
8+
import { WebsiteErrorState } from "@/components/website-error-state";
99
import { useTrackingSetup } from "@/hooks/use-tracking-setup";
1010
import { useWebsite } from "@/hooks/use-websites";
1111
import { isAnalyticsRefreshingAtom } from "@/stores/jotai/filterAtoms";
@@ -20,9 +20,11 @@ export default function WebsiteLayout({ children }: WebsiteLayoutProps) {
2020
const { id } = useParams();
2121
const pathname = usePathname();
2222
const queryClient = useQueryClient();
23+
const isDemoRoute = pathname?.startsWith("/demo/");
2324
const {
2425
isLoading: isWebsiteLoading,
2526
isError: isWebsiteError,
27+
error: websiteError,
2628
data: websiteData,
2729
} = useWebsite(id as string);
2830
const { isTrackingSetup, isTrackingSetupLoading } = useTrackingSetup(
@@ -46,17 +48,19 @@ export default function WebsiteLayout({ children }: WebsiteLayoutProps) {
4648
);
4749

4850
if (!id) {
49-
return <NotFound />;
51+
return <WebsiteErrorState error={{ data: { code: "NOT_FOUND" } }} />;
5052
}
5153

5254
if (!isWebsiteLoading && isWebsiteError) {
53-
return <NotFound />;
55+
return (
56+
<WebsiteErrorState error={websiteError} websiteId={id as string} />
57+
);
5458
}
5559

5660
const websiteId = id as string;
5761
const isToolbarLoading =
58-
isWebsiteLoading || isTrackingSetupLoading || isTrackingSetup === null;
59-
const isToolbarDisabled = !isTrackingSetup || isToolbarLoading;
62+
isWebsiteLoading || (!isDemoRoute && (isTrackingSetupLoading || isTrackingSetup === null));
63+
const isToolbarDisabled = !isDemoRoute && (!isTrackingSetup || isToolbarLoading);
6064

6165
const handleRefresh = async () => {
6266
setIsRefreshing(true);
@@ -101,7 +105,8 @@ export default function WebsiteLayout({ children }: WebsiteLayoutProps) {
101105
>
102106
{isAssistantPage ? (
103107
children
104-
) : websiteData &&
108+
) : !isDemoRoute &&
109+
websiteData &&
105110
!isTrackingSetupLoading &&
106111
isTrackingSetup !== null &&
107112
isTrackingSetup === false ? (

apps/dashboard/components/analytics/event-limit-indicator.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
"use client";
22

33
import { WarningIcon } from "@phosphor-icons/react";
4+
import { usePathname } from "next/navigation";
45
import { useQuery } from "@tanstack/react-query";
56
import Link from "next/link";
67
import { buttonVariants } from "@/components/ui/button";
78
import { orpc } from "@/lib/orpc";
89

910
export function EventLimitIndicator() {
11+
const pathname = usePathname();
12+
const isDemoRoute = pathname?.startsWith("/demo/");
13+
1014
const { data } = useQuery({
1115
...orpc.organizations.getUsage.queryOptions(),
16+
enabled: !isDemoRoute,
1217
});
1318

1419
if (!data || data.unlimited) {

apps/dashboard/components/providers/billing-provider.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,16 @@ export function BillingProvider({
7171
const params = useParams();
7272
const pathname = usePathname();
7373

74-
// Determine the websiteId - only pass it for demo routes (unauthenticated viewing)
75-
// For authenticated users on /websites/*, the backend uses their session context
7674
const websiteId = useMemo(() => {
7775
if (propWebsiteId) return propWebsiteId;
7876

79-
// Only use route param for demo routes (public/unauthenticated viewing)
77+
const isDemoRoute = pathname?.startsWith("/demo/");
78+
79+
if (isDemoRoute) {
8080
const routeId = params?.id;
81-
if (typeof routeId === "string" && routeId && pathname?.includes("/demo/")) {
81+
if (typeof routeId === "string" && routeId) {
8282
return routeId;
83+
}
8384
}
8485

8586
return undefined;
@@ -104,7 +105,7 @@ export function BillingProvider({
104105
refetch: refetchBillingContext,
105106
} = useQuery({
106107
...orpc.organizations.getBillingContext.queryOptions({
107-
websiteId,
108+
input: websiteId ? { websiteId } : undefined,
108109
}),
109110
});
110111

0 commit comments

Comments
 (0)