diff --git a/apps/web/src/app/[locale]/plan/page.tsx b/apps/web/src/app/[locale]/plan/page.tsx
index c08dd72..64d7639 100644
--- a/apps/web/src/app/[locale]/plan/page.tsx
+++ b/apps/web/src/app/[locale]/plan/page.tsx
@@ -26,7 +26,11 @@ export default async function PlanPage({ params: { locale } }: { params: { local
const [plan, dailyTarget] = await Promise.all([fetchCurrentPlan(), fetchDailyTarget()]);
- return ;
+ // Calcolato server-side per evitare hydration mismatch nel pannello macros.
+ const dow = new Date().getDay();
+ const todayDayOfWeek = dow === 0 ? 6 : dow - 1;
+
+ return ;
}
const ITALIAN_DATE = new Intl.DateTimeFormat('it-IT', {
@@ -49,9 +53,11 @@ function formatWeek(weekStart: string): string {
function PlanPageContent({
plan,
dailyTarget,
+ todayDayOfWeek,
}: {
plan: Awaited>;
dailyTarget: Awaited>;
+ todayDayOfWeek: number;
}) {
const t = useTranslations('Plan');
@@ -154,7 +160,7 @@ function PlanPageContent({
{plan ? (
) : null}
diff --git a/apps/web/src/app/[locale]/plan/plan-week.tsx b/apps/web/src/app/[locale]/plan/plan-week.tsx
index 41a07c1..62363c2 100644
--- a/apps/web/src/app/[locale]/plan/plan-week.tsx
+++ b/apps/web/src/app/[locale]/plan/plan-week.tsx
@@ -62,18 +62,16 @@ function aggregateMacros(slots: PlanSlot[]): {
const FREE_MEAL_DEFAULT_KCAL = 750;
-// PRD §6 — il pannello macros laterale ancora oggi (lun=0…dom=6).
-function todayDayOfWeek(): number {
- const d = new Date().getDay(); // 0 = Sunday
- return d === 0 ? 6 : d - 1;
-}
-
export function PlanWeek({
plan,
dailyTarget,
+ todayDayOfWeek,
}: {
plan: CurrentPlan;
dailyTarget: DailyTarget | null;
+ /** Indice giorno corrente (lun=0…dom=6) calcolato server-side per evitare
+ * hydration mismatch fra render SSR e client. */
+ todayDayOfWeek: number;
}) {
const t = useTranslations('Plan');
@@ -83,7 +81,7 @@ export function PlanWeek({
byDay.get(slot.dayOfWeek)!.push(slot);
}
- const today = todayDayOfWeek();
+ const today = todayDayOfWeek;
const todaySlots = byDay.get(today) ?? [];
const todayConsumed = aggregateMacros(todaySlots.filter((s) => s.consumed));
const todayPlanned = aggregateMacros(todaySlots);
diff --git a/apps/web/src/app/[locale]/tracking/page.tsx b/apps/web/src/app/[locale]/tracking/page.tsx
index aa26717..2694ff3 100644
--- a/apps/web/src/app/[locale]/tracking/page.tsx
+++ b/apps/web/src/app/[locale]/tracking/page.tsx
@@ -38,11 +38,16 @@ export default async function TrackingPage({ params: { locale } }: { params: { l
fetchTodayCheckIn(),
]);
+ // Calcolato server-side per evitare hydration mismatch su WeightEntryForm.
+ const now = new Date();
+ const todayISO = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
+
return (
);
}
@@ -51,10 +56,12 @@ function TrackingPageContent({
entries,
profile,
todayCheckIn,
+ todayISO,
}: {
entries: Awaited>;
profile: ProfileLike;
todayCheckIn: Awaited>;
+ todayISO: string;
}) {
const t = useTranslations('Tracking');
const latest = entries[0] ?? null;
@@ -135,7 +142,7 @@ function TrackingPageContent({