-
-
Notifications
You must be signed in to change notification settings - Fork 367
Expand file tree
/
Copy pathdasboard-layout.tsx
More file actions
48 lines (43 loc) · 1.32 KB
/
dasboard-layout.tsx
File metadata and controls
48 lines (43 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"use client";
import { AppSidebar } from "~/components/AppSideBar";
import {
SidebarInset,
SidebarProvider,
SidebarTrigger,
} from "@usesend/ui/src/sidebar";
import { useIsMobile } from "@usesend/ui/src/hooks/use-mobile";
import { UpgradeModal } from "~/components/payments/UpgradeModal";
import { usePathname } from "next/navigation";
import { useEffect, useRef } from "react";
export function DashboardLayout({ children }: { children: React.ReactNode }) {
const isMobile = useIsMobile();
const pathname = usePathname();
const mainRef = useRef<HTMLElement>(null);
useEffect(() => {
if (mainRef.current) {
mainRef.current.scrollLeft = 0;
}
window.scrollTo({ left: 0 });
document.documentElement.scrollLeft = 0;
document.body.scrollLeft = 0;
}, [pathname]);
return (
<div className="h-full bg-sidebar-background">
<SidebarProvider>
<AppSidebar />
<SidebarInset className="min-w-0">
<main
ref={mainRef}
className="h-full flex-1 overflow-y-auto overflow-x-hidden p-4 xl:px-40"
>
{isMobile ? (
<SidebarTrigger className="h-5 w-5 text-muted-foreground" />
) : null}
{children}
</main>
</SidebarInset>
</SidebarProvider>
<UpgradeModal />
</div>
);
}