diff --git a/src/app/[lang]/page.tsx b/src/app/[lang]/page.tsx
index 7465e02..419e558 100644
--- a/src/app/[lang]/page.tsx
+++ b/src/app/[lang]/page.tsx
@@ -39,15 +39,25 @@ export default async function LocaleEntryPage({
);
if (cachedEntryPath) {
+ if (cachedEntryPath === "/intro") {
+ return ;
+ }
redirect(localizePath(cachedEntryPath, lang));
}
// 3. Deep SSR Profile Resolution: resolve profile & redirect directly on server
const profile = await fetchProfileSSR(token);
if (profile) {
- const targetPath = hasCompletedMarriageProfileBasics(profile)
- ? getSubmitPath(profile)
- : "/intro";
+ const isBasicsCompleted = hasCompletedMarriageProfileBasics(profile);
+ if (!isBasicsCompleted) {
+ return ;
+ }
+
+ const targetPath = getSubmitPath(profile);
+ if (targetPath === "/intro") {
+ return ;
+ }
+
redirect(localizePath(targetPath, lang));
}
diff --git a/src/app/intro/intro-client.tsx b/src/app/intro/intro-client.tsx
index 9bc86a2..456b54a 100644
--- a/src/app/intro/intro-client.tsx
+++ b/src/app/intro/intro-client.tsx
@@ -128,7 +128,7 @@ export default function IntroClient() {
const handleSliderComplete = useCallback(
(targetPath: string) => {
const destination = localizePath(targetPath, locale);
- router.prefetch(destination);
+ router.prefetch?.(destination);
setIsStepsOpen(false);
router.replace(destination);
},
diff --git a/src/components/Componentes/slider-page.test.tsx b/src/components/Componentes/slider-page.test.tsx
index b0f678c..3077a8c 100644
--- a/src/components/Componentes/slider-page.test.tsx
+++ b/src/components/Componentes/slider-page.test.tsx
@@ -32,6 +32,7 @@ vi.mock('@/hooks/marriage/query-keys', () => ({
vi.mock('next/navigation', () => ({
useRouter: () => ({
replace: mockReplace,
+ prefetch: vi.fn(),
back: vi.fn(),
}),
}));
diff --git a/src/components/Componentes/slider-page.tsx b/src/components/Componentes/slider-page.tsx
index c0491bc..edf1eb1 100644
--- a/src/components/Componentes/slider-page.tsx
+++ b/src/components/Componentes/slider-page.tsx
@@ -120,7 +120,7 @@ export default function SliderPage({
const targetPath = getSubmitPath(freshProfile);
const localizedTarget = localizePath(targetPath, locale);
- router.prefetch(localizedTarget);
+ router.prefetch?.(localizedTarget);
if (onComplete) {
onComplete(targetPath);
diff --git a/src/hooks/marriage/use-profile-main.test.ts b/src/hooks/marriage/use-profile-main.test.ts
index 0652a93..cd09895 100644
--- a/src/hooks/marriage/use-profile-main.test.ts
+++ b/src/hooks/marriage/use-profile-main.test.ts
@@ -32,7 +32,7 @@ describe("getMarriageProfile", () => {
expect(mocks.setCachedEntryPath).toHaveBeenCalledWith("/questions-list");
});
- it("clears the route for an incomplete onboarding profile", async () => {
+ it("caches the intro route for an incomplete onboarding profile", async () => {
mocks.get.mockResolvedValue({
data: {
status: "pending_onboarding",
@@ -43,7 +43,7 @@ describe("getMarriageProfile", () => {
await getMarriageProfile();
- expect(mocks.setCachedEntryPath).toHaveBeenCalledWith(null);
+ expect(mocks.setCachedEntryPath).toHaveBeenCalledWith("/intro");
});
it("overwrites the old questions route when the backend advances state", async () => {
diff --git a/src/hooks/marriage/use-profile-main.ts b/src/hooks/marriage/use-profile-main.ts
index de7e027..3151832 100644
--- a/src/hooks/marriage/use-profile-main.ts
+++ b/src/hooks/marriage/use-profile-main.ts
@@ -31,7 +31,7 @@ export async function getMarriageProfile() {
});
setCachedMarriageEntryPath(
- hasCompletedMarriageProfileBasics(data) ? getSubmitPath(data) : null,
+ hasCompletedMarriageProfileBasics(data) ? getSubmitPath(data) : "/intro",
);
return data;
diff --git a/src/lib/entry-route-cache.test.ts b/src/lib/entry-route-cache.test.ts
index 707a4e6..143e75a 100644
--- a/src/lib/entry-route-cache.test.ts
+++ b/src/lib/entry-route-cache.test.ts
@@ -21,7 +21,8 @@ describe("entry route cache", () => {
);
expect(normalizeCachedMarriageEntryPath("https://example.com")).toBeNull();
expect(normalizeCachedMarriageEntryPath("//example.com")).toBeNull();
- expect(normalizeCachedMarriageEntryPath("/intro")).toBeNull();
+ expect(normalizeCachedMarriageEntryPath("/intro")).toBe("/intro");
+ expect(normalizeCachedMarriageEntryPath("/invalid-path")).toBeNull();
});
it("requires a real token before trusting the cached route", () => {
diff --git a/src/lib/entry-route-cache.ts b/src/lib/entry-route-cache.ts
index 3e2ceca..9a688ef 100644
--- a/src/lib/entry-route-cache.ts
+++ b/src/lib/entry-route-cache.ts
@@ -7,6 +7,7 @@ import {
export const MARRIAGE_ENTRY_PATH_COOKIE = "HABIB_MARRIAGE_ENTRY_PATH";
const AUTHENTICATED_ENTRY_PATHS = new Set([
+ "/intro",
"/terms",
"/questions-list",
"/finding-match",