From a23b6fe36f74dcfa6ebc05d97094f4893bd67d84 Mon Sep 17 00:00:00 2001 From: MaximeFARRE Date: Mon, 25 May 2026 14:08:55 +0200 Subject: [PATCH 1/3] feat: add full Polar history import --- web/app/(app)/connections/actions.ts | 21 +++++++++++++++ .../(app)/connections/connections-client.tsx | 26 +++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/web/app/(app)/connections/actions.ts b/web/app/(app)/connections/actions.ts index 1ae4bac..6799704 100644 --- a/web/app/(app)/connections/actions.ts +++ b/web/app/(app)/connections/actions.ts @@ -6,6 +6,8 @@ import { syncGarminMetrics } from "@/lib/server/garmin/sync" import { importAllStravaHistory, importStravaHistory, syncRecentStrava } from "@/lib/server/strava/sync" import { createClient } from "@/lib/supabase/server" +const POLAR_FULL_HISTORY_DAYS = 3650 + export async function syncStrava(): Promise<{ synced?: number; error?: string }> { const supabase = await createClient() const { @@ -158,3 +160,22 @@ export async function syncPolarHistory(days = 30): Promise<{ synced?: number; er return { error: e instanceof Error ? e.message : "Synchronisation Polar échouée" } } } + +export async function syncAllPolarHistory(): Promise<{ synced?: number; error?: string }> { + const supabase = await createClient() + const { + data: { user }, + } = await supabase.auth.getUser() + + if (!user) return { error: "Non authentifié" } + + try { + const { syncPolarMetrics } = await import("@/lib/server/polar/sync") + const synced = await syncPolarMetrics(user.id, POLAR_FULL_HISTORY_DAYS) + revalidatePath("/connections") + revalidatePath("/dashboard") + return { synced } + } catch (e) { + return { error: e instanceof Error ? e.message : "Import complet Polar échoué" } + } +} diff --git a/web/app/(app)/connections/connections-client.tsx b/web/app/(app)/connections/connections-client.tsx index 51b6145..d78e30d 100644 --- a/web/app/(app)/connections/connections-client.tsx +++ b/web/app/(app)/connections/connections-client.tsx @@ -13,6 +13,7 @@ import { disconnectTerra, disconnectPolar, syncGarminHistory, + syncAllPolarHistory, syncPolarHistory, syncAllStravaHistory, syncStrava, @@ -389,6 +390,7 @@ export function StravaCard({ export function PolarCard({ connected, providerUserId, lastSyncAt }: TerraCardProps) { const router = useRouter() const [syncing, setSyncing] = useState(false) + const [importingAll, setImportingAll] = useState(false) const [disconnecting, setDisconnecting] = useState(false) const lastSyncLabel = lastSyncAt @@ -410,6 +412,18 @@ export function PolarCard({ connected, providerUserId, lastSyncAt }: TerraCardPr } } + async function handleImportAllHistory() { + setImportingAll(true) + const result = await syncAllPolarHistory() + setImportingAll(false) + if (result.error) { + toast.error(result.error) + } else { + toast.success(`Import complet Polar terminé — ${result.synced ?? 0} journée(s)`) + router.refresh() + } + } + return ( @@ -461,15 +475,23 @@ export function PolarCard({ connected, providerUserId, lastSyncAt }: TerraCardPr router.refresh() } }} - disabled={syncing || disconnecting} + disabled={syncing || importingAll || disconnecting} > {syncing ? "Synchronisation…" : "Importer 30 jours"} + From 4fb0f0dd01e4664a09dc722d0a99b7f749f1962c Mon Sep 17 00:00:00 2001 From: MaximeFARRE Date: Mon, 25 May 2026 14:17:18 +0200 Subject: [PATCH 2/3] fix: remove overflow-hidden on health dashboard cards to prevent tooltip clipping --- .gitignore | 1 + web/app/(app)/health/page.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index cbff7e3..cf5775a 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ next-env.d.ts # Python __pycache__/ *.pyc +.vercel diff --git a/web/app/(app)/health/page.tsx b/web/app/(app)/health/page.tsx index daee537..69fe09d 100644 --- a/web/app/(app)/health/page.tsx +++ b/web/app/(app)/health/page.tsx @@ -209,7 +209,7 @@ export default async function HealthPage() { {/* Main recovery metrics grid */}
{/* Sommeil */} - +
@@ -231,7 +231,7 @@ export default async function HealthPage() { {/* HRV */} - +
@@ -259,7 +259,7 @@ export default async function HealthPage() { {/* FC de repos */} - +
@@ -281,7 +281,7 @@ export default async function HealthPage() { {/* Body Battery & Stress */} - +
From d4f171a002dc7faa63d7f3ed79be89f4a5256d69 Mon Sep 17 00:00:00 2001 From: MaximeFARRE Date: Mon, 25 May 2026 14:19:15 +0200 Subject: [PATCH 3/3] fix: show y-axis in health chart by adjusting left margin and width --- web/app/(app)/health/health-chart.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/app/(app)/health/health-chart.tsx b/web/app/(app)/health/health-chart.tsx index 91c3f1b..c670921 100644 --- a/web/app/(app)/health/health-chart.tsx +++ b/web/app/(app)/health/health-chart.tsx @@ -111,7 +111,7 @@ export function HealthChart({ data }: HealthChartProps) {
) : ( - + } />