|
1 | | -import { redirect } from "next/navigation" |
2 | | -import { SessionProvider } from "next-auth/react" |
3 | | -import { session, projectRepository } from "@/composition" |
4 | | -import ErrorHandler from "@/common/ui/ErrorHandler" |
5 | | -import SessionBarrier from "@/features/auth/view/SessionBarrier" |
6 | | -import ProjectsContextProvider from "@/features/projects/view/ProjectsContextProvider" |
7 | | -import { SidebarTogglableContextProvider, SplitView } from "@/features/sidebar/view" |
| 1 | +import { redirect } from "next/navigation"; |
| 2 | +import { SessionProvider } from "next-auth/react"; |
| 3 | +import { session } from "@/composition"; |
| 4 | +import ErrorHandler from "@/common/ui/ErrorHandler"; |
| 5 | +import SessionBarrier from "@/features/auth/view/SessionBarrier"; |
| 6 | +import ProjectsContextProvider from "@/features/projects/view/ProjectsContextProvider"; |
| 7 | +import { projectDataSource } from "@/composition"; |
| 8 | +import { |
| 9 | + SidebarTogglableContextProvider, |
| 10 | + SplitView, |
| 11 | +} from "@/features/sidebar/view"; |
8 | 12 |
|
9 | | -export default async function Layout({ children }: { children: React.ReactNode }) { |
10 | | - const isAuthenticated = await session.getIsAuthenticated() |
| 13 | +export default async function Layout({ |
| 14 | + children, |
| 15 | +}: { |
| 16 | + children: React.ReactNode; |
| 17 | +}) { |
| 18 | + const isAuthenticated = await session.getIsAuthenticated(); |
11 | 19 | if (!isAuthenticated) { |
12 | | - return redirect("/api/auth/signin") |
| 20 | + return redirect("/api/auth/signin"); |
13 | 21 | } |
14 | | - const projects = await projectRepository.get() |
| 22 | + |
| 23 | + const projects = await projectDataSource.getProjects(); |
| 24 | + console.log("Loaded projects:", projects); |
| 25 | + |
15 | 26 | return ( |
16 | 27 | <ErrorHandler> |
17 | 28 | <SessionProvider> |
18 | 29 | <SessionBarrier> |
19 | 30 | <ProjectsContextProvider initialProjects={projects}> |
20 | 31 | <SidebarTogglableContextProvider> |
21 | | - <SplitView> |
22 | | - {children} |
23 | | - </SplitView> |
| 32 | + <SplitView>{children}</SplitView> |
24 | 33 | </SidebarTogglableContextProvider> |
25 | 34 | </ProjectsContextProvider> |
26 | 35 | </SessionBarrier> |
27 | 36 | </SessionProvider> |
28 | 37 | </ErrorHandler> |
29 | | - ) |
| 38 | + ); |
30 | 39 | } |
0 commit comments