From 5148c60ad8cfb78c20bec36bcf4f2b4cbf35f3e1 Mon Sep 17 00:00:00 2001
From: mortezaei
Date: Sun, 30 Aug 2026 05:22:39 +0330
Subject: [PATCH] feat: implement initial server-side injection of marriage
data into window global and improve cookie parsing robustness
---
src/app/layout.tsx | 26 ++++++++++++++++++++++++++
src/lib/auth-bridge.ts | 23 +++++++++++++++++++----
src/lib/cookies.ts | 8 +++++++-
3 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 45a2dfa..bbeb056 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -85,6 +85,24 @@ export default async function RootLayout({
? cookieLocale
: defaultLocale;
+ const rawMarriageCookie =
+ cookieStore.get("HABIB_MARRIAGE_DATA")?.value ??
+ cookieStore.get("habib_marriage_data")?.value;
+
+ let initialMarriageJson: string | null = null;
+ if (rawMarriageCookie) {
+ try {
+ const decoded = decodeURIComponent(rawMarriageCookie);
+ JSON.parse(decoded);
+ initialMarriageJson = decoded;
+ } catch {
+ try {
+ JSON.parse(rawMarriageCookie);
+ initialMarriageJson = rawMarriageCookie;
+ } catch {}
+ }
+ }
+
return (
+ {initialMarriageJson && (
+
+ )}