Skip to content

Commit 46fe4dd

Browse files
committed
fix: loading skeleton mess
1 parent f83f430 commit 46fe4dd

File tree

2 files changed

+7
-91
lines changed

2 files changed

+7
-91
lines changed

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

Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { useParams, usePathname } from "next/navigation";
66
import { useRef } from "react";
77
import { toast } from "sonner";
88
import NotFound from "@/app/not-found";
9-
import { Skeleton } from "@/components/ui/skeleton";
109
import { useTrackingSetup } from "@/hooks/use-tracking-setup";
1110
import { useWebsite } from "@/hooks/use-websites";
1211
import { isAnalyticsRefreshingAtom } from "@/stores/jotai/filterAtoms";
@@ -99,66 +98,11 @@ export default function WebsiteLayout({ children }: WebsiteLayoutProps) {
9998
<div
10099
className={`${isAssistantPage ? "min-h-0 flex-1" : "min-h-0 flex-1 overflow-y-auto overscroll-contain"}`}
101100
>
102-
{!isAssistantPage && isTrackingSetupLoading ? (
103-
<div className="space-y-4 p-4">
104-
{/* Two DataTables side by side */}
105-
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
106-
{[1, 2].map((num) => (
107-
<div
108-
className="overflow-hidden rounded border bg-sidebar"
109-
key={`skeleton-table-${num}`}
110-
>
111-
<div className="p-3">
112-
<Skeleton className="h-5 w-32" />
113-
<Skeleton className="mt-1 h-3 w-48" />
114-
</div>
115-
<div className="space-y-2 px-3 pb-3">
116-
{Array.from({ length: 5 }).map((_, idx) => (
117-
<div
118-
className="flex items-center gap-3 rounded bg-muted/20 p-3"
119-
key={`row-${num}-${idx}`}
120-
>
121-
<Skeleton className="size-6 shrink-0 rounded-full" />
122-
<div className="flex-1 space-y-1.5">
123-
<Skeleton className="h-4 w-3/4" />
124-
<Skeleton className="h-3 w-1/2" />
125-
</div>
126-
<Skeleton className="h-4 w-12" />
127-
</div>
128-
))}
129-
</div>
130-
</div>
131-
))}
132-
</div>
133-
{/* Full width DataTable */}
134-
<div className="overflow-hidden rounded border bg-sidebar">
135-
<div className="p-3">
136-
<Skeleton className="h-5 w-40" />
137-
<Skeleton className="mt-1 h-3 w-64" />
138-
<div className="mt-3 flex gap-2">
139-
{[1, 2, 3, 4].map((tab) => (
140-
<Skeleton className="h-8 w-20" key={`tab-${tab}`} />
141-
))}
142-
</div>
143-
</div>
144-
<div className="space-y-2 px-3 pb-3">
145-
{Array.from({ length: 6 }).map((_, idx) => (
146-
<div
147-
className="flex items-center gap-3 rounded bg-muted/20 p-3"
148-
key={`geo-row-${idx}`}
149-
>
150-
<Skeleton className="size-6 shrink-0 rounded" />
151-
<div className="flex-1 space-y-1.5">
152-
<Skeleton className="h-4 w-2/3" />
153-
<Skeleton className="h-3 w-1/3" />
154-
</div>
155-
<Skeleton className="h-4 w-16" />
156-
</div>
157-
))}
158-
</div>
159-
</div>
160-
</div>
161-
) : !(isAssistantPage || isTrackingSetupLoading) &&
101+
{isAssistantPage ? (
102+
children
103+
) : websiteData &&
104+
!isTrackingSetupLoading &&
105+
isTrackingSetup !== null &&
162106
isTrackingSetup === false ? (
163107
<div className="p-4">
164108
<WebsiteTrackingSetupTab websiteId={websiteId} />

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

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,20 @@
33
import type { DynamicQueryFilter } from "@databuddy/shared/types/api";
44
import { WarningIcon } from "@phosphor-icons/react";
55
import { useAtom } from "jotai";
6-
import dynamic from "next/dynamic";
76
import Link from "next/link";
87
import { useParams } from "next/navigation";
98
import { useCallback } from "react";
109
import { Button } from "@/components/ui/button";
1110
import { useDateFilters } from "@/hooks/use-date-filters";
12-
import { useTrackingSetup } from "@/hooks/use-tracking-setup";
1311
import { useWebsite } from "@/hooks/use-websites";
1412
import {
1513
addDynamicFilterAtom,
1614
dynamicQueryFiltersAtom,
1715
isAnalyticsRefreshingAtom,
1816
} from "@/stores/jotai/filterAtoms";
19-
import type {
20-
FullTabProps,
21-
WebsiteDataTabProps,
22-
} from "./_components/utils/types";
23-
import { EmptyState } from "./_components/utils/ui-components";
2417
import { WebsiteOverviewTab } from "./_components/tabs/overview-tab";
25-
import { TabLoadingSkeleton } from "./_components/utils/tab-layout";
26-
27-
const WebsiteTrackingSetupTab = dynamic(
28-
() =>
29-
import("./_components/tabs/tracking-setup-tab").then((mod) => ({
30-
default: mod.WebsiteTrackingSetupTab,
31-
})),
32-
{ loading: () => <TabLoadingSkeleton />, ssr: false }
33-
);
18+
import type { FullTabProps } from "./_components/utils/types";
19+
import { EmptyState } from "./_components/utils/ui-components";
3420

3521
function WebsiteDetailsPage() {
3622
const { id } = useParams();
@@ -59,12 +45,6 @@ function WebsiteDetailsPage() {
5945
addFilter,
6046
};
6147

62-
const settingsProps: WebsiteDataTabProps = {
63-
websiteId: id as string,
64-
dateRange,
65-
websiteData: data,
66-
};
67-
6848
if (isError || !(isLoading || data)) {
6949
return (
7050
<div className="select-none py-8">
@@ -88,14 +68,6 @@ function WebsiteDetailsPage() {
8868
);
8969
}
9070

91-
if (isLoading === null) {
92-
return (
93-
<div className="p-4">
94-
<TabLoadingSkeleton />
95-
</div>
96-
);
97-
}
98-
9971
return (
10072
<div className="p-4">
10173
<WebsiteOverviewTab {...tabProps} />

0 commit comments

Comments
 (0)