@@ -5,7 +5,7 @@ import { useAtom } from "jotai";
55import { useParams , usePathname } from "next/navigation" ;
66import { useRef } from "react" ;
77import { toast } from "sonner" ;
8- import NotFound from "@/app/not-found " ;
8+ import { WebsiteErrorState } from "@/components/website-error-state " ;
99import { useTrackingSetup } from "@/hooks/use-tracking-setup" ;
1010import { useWebsite } from "@/hooks/use-websites" ;
1111import { 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 ? (
0 commit comments