From 047e580da0663a23ca71b465c904c5c41a2100b6 Mon Sep 17 00:00:00 2001 From: Dominik Klarkowski Date: Thu, 18 Jun 2026 11:02:31 +0200 Subject: [PATCH] init --- .idea/dataSources.xml | 17 ++++ .idea/db-forest-config.xml | 2 +- app/ai/actions.ts | 7 +- app/api/auth/[...nextauth]/route.ts | 3 + app/layout.tsx | 7 +- app/login/page.tsx | 36 ++++++++ app/page.tsx | 9 +- app/running/[id]/page.tsx | 82 ++++++++++++------ app/running/actions.ts | 43 ++++++---- app/running/page.tsx | 4 +- app/settings/actions.ts | 28 +++++++ app/settings/garmin-credentials-form.tsx | 58 +++++++++++++ app/settings/page.tsx | 59 +++++++++---- app/strength/[id]/page.tsx | 14 ++-- app/strength/import/actions.ts | 4 +- app/strength/page.tsx | 4 +- auth.ts | 34 ++++++++ components/elevation-chart.tsx | 102 +++++++++++++++++++---- components/nav.tsx | 17 +++- components/run-metric-chart.tsx | 17 +++- components/sign-out-button.tsx | 18 ++++ lib/ai/claude.ts | 39 ++++++--- lib/garmin/client.ts | 57 ++++++------- lib/models/analysis.ts | 27 +++--- lib/models/garmin-auth.ts | 48 ++++++++--- lib/models/running.ts | 45 ++++++---- lib/models/strength.ts | 19 +++-- lib/session.ts | 8 ++ middleware.ts | 23 +++++ package.json | 1 + pnpm-lock.yaml | 76 +++++++++++++++++ types/next-auth.d.ts | 16 ++++ 32 files changed, 735 insertions(+), 189 deletions(-) create mode 100644 .idea/dataSources.xml create mode 100644 app/api/auth/[...nextauth]/route.ts create mode 100644 app/login/page.tsx create mode 100644 app/settings/actions.ts create mode 100644 app/settings/garmin-credentials-form.tsx create mode 100644 auth.ts create mode 100644 components/sign-out-button.tsx create mode 100644 lib/session.ts create mode 100644 middleware.ts create mode 100644 types/next-auth.d.ts 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 ( -