diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..324637b --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,17 @@ + + + + + mongo.4 + true + com.dbschema.MongoJdbcDriver + mongodb://localhost:27017/?authSource=admin + + + + + + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/db-forest-config.xml b/.idea/db-forest-config.xml index 612e11a..f5db96b 100644 --- a/.idea/db-forest-config.xml +++ b/.idea/db-forest-config.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/app/ai/actions.ts b/app/ai/actions.ts index 9d0b617..324df8a 100644 --- a/app/ai/actions.ts +++ b/app/ai/actions.ts @@ -2,6 +2,7 @@ import { revalidatePath } from "next/cache"; import { generateAnalysis, generateDashboardAnalysis } from "@/lib/ai/claude"; +import { getCurrentUserId } from "@/lib/session"; import type { AiAnalysisTargetType } from "@/lib/models/analysis"; export type GenerateAnalysisState = { error: string } | { success: true } | null; @@ -10,8 +11,9 @@ export async function generateAnalysisAction( targetType: AiAnalysisTargetType, targetId: string ): Promise { + const userId = await getCurrentUserId(); try { - await generateAnalysis(targetType, targetId); + await generateAnalysis(userId, targetType, targetId); } catch (error) { return { error: error instanceof Error ? error.message : "Nie udało się wygenerować analizy." }; } @@ -22,8 +24,9 @@ export async function generateAnalysisAction( } export async function generateDashboardAnalysisAction(): Promise { + const userId = await getCurrentUserId(); try { - await generateDashboardAnalysis(); + await generateDashboardAnalysis(userId); } catch (error) { return { error: error instanceof Error ? error.message : "Nie udało się wygenerować analizy." }; } diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts new file mode 100644 index 0000000..86c9f3d --- /dev/null +++ b/app/api/auth/[...nextauth]/route.ts @@ -0,0 +1,3 @@ +import { handlers } from "@/auth"; + +export const { GET, POST } = handlers; diff --git a/app/layout.tsx b/app/layout.tsx index b3c0654..7b1677f 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,6 +1,7 @@ import type { Metadata } from "next"; import { Geist, Geist_Mono } from "next/font/google"; import { Nav } from "@/components/nav"; +import { auth } from "@/auth"; import "./globals.css"; const geistSans = Geist({ @@ -18,18 +19,20 @@ export const metadata: Metadata = { description: "Analiza treningów biegowych i siłowych", }; -export default function RootLayout({ +export default async function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { + const session = await auth(); + return ( -