diff --git a/frontend/src/app/ideology-test/page.tsx b/frontend/src/app/ideology-test/page.tsx
index 084e6aa..29eec06 100644
--- a/frontend/src/app/ideology-test/page.tsx
+++ b/frontend/src/app/ideology-test/page.tsx
@@ -32,6 +32,17 @@ export default function IdeologyTest() {
const totalQuestions = questions.length;
const progress = ((currentQuestion + 1) / totalQuestions) * 100;
+ // Auto-clear error message after 3 seconds
+ useEffect(() => {
+ if (error) {
+ const timer = setTimeout(() => {
+ setError(null);
+ }, 3000);
+
+ return () => clearTimeout(timer);
+ }
+ }, [error]);
+
useEffect(() => {
const loadProgress = async (loadedQuestions: Question[]) => {
try {
@@ -79,6 +90,18 @@ export default function IdeologyTest() {
const handleEndTest = async () => {
if (isSubmitting) return; // Prevent multiple submissions
+
+ // Check if all questions have been answered
+ const unansweredQuestions = Object.keys(userAnswers).length;
+ if (unansweredQuestions < questions.length) {
+ setError(
+ `Please answer all questions before submitting. You have ${
+ questions.length - unansweredQuestions
+ } questions remaining.`,
+ );
+ return;
+ }
+ setError(null);
setIsSubmitting(true);
try {
@@ -261,8 +284,6 @@ export default function IdeologyTest() {
};
if (loading) return ;
- if (error)
- return
Error: {error}
;
if (
!questions ||
questions.length === 0 ||
@@ -301,6 +322,12 @@ export default function IdeologyTest() {
{/* Answer Buttons Section - Fixed at bottom */}
+ {error && (
+
+ )}
+
{answerOptions.map((answer) => {
const isSelected =
userAnswers[questions[currentQuestion].id] ===
diff --git a/frontend/src/app/insights/page.tsx b/frontend/src/app/insights/page.tsx
index b4b48e5..e4a5f11 100644
--- a/frontend/src/app/insights/page.tsx
+++ b/frontend/src/app/insights/page.tsx
@@ -38,6 +38,14 @@ export default function InsightsPage() {
const [publicFigure, setPublicFigure] = useState("");
const canvasRef = useRef
(null);
+ // Emit modal state changes
+ useEffect(() => {
+ const event = new CustomEvent("shareModalState", {
+ detail: { isOpen: isShareModalOpen },
+ });
+ window.dispatchEvent(event);
+ }, [isShareModalOpen]);
+
const testId = searchParams.get("testId");
useEffect(() => {
diff --git a/frontend/src/components/LayoutContent.tsx b/frontend/src/components/LayoutContent.tsx
index 4cefd6d..3f20591 100644
--- a/frontend/src/components/LayoutContent.tsx
+++ b/frontend/src/components/LayoutContent.tsx
@@ -8,7 +8,7 @@ import { useAuth } from "@/hooks/useAuth";
import { useVerification } from "@/hooks/useVerification";
import { usePathname } from "next/navigation";
import type * as React from "react";
-import { useEffect, useMemo } from "react";
+import { useEffect, useMemo, useState } from "react";
type BackgroundVariant = "signin" | "home" | "settings" | "results" | "default";
@@ -28,6 +28,8 @@ export function LayoutContent({ children }: LayoutContentProps) {
useVerification();
const pathname = usePathname();
+ const [isShareModalOpen, setIsShareModalOpen] = useState(false);
+
// Page checks
const pageStates = useMemo(
() => ({
@@ -65,6 +67,19 @@ export function LayoutContent({ children }: LayoutContentProps) {
pageStates,
]);
+ // Listen for share modal state changes from child components
+ useEffect(() => {
+ const handleShareModalState = (e: Event) => {
+ const event = e as CustomEvent<{ isOpen: boolean }>;
+ setIsShareModalOpen(event.detail.isOpen);
+ };
+
+ window.addEventListener('shareModalState', handleShareModalState);
+ return () => {
+ window.removeEventListener('shareModalState', handleShareModalState);
+ };
+ }, []);
+
const getBackgroundVariant = (): BackgroundVariant => {
const { isSignInPage, isHomePage, isSettingsPage, isResultsPage } =
pageStates;
@@ -113,7 +128,8 @@ export function LayoutContent({ children }: LayoutContentProps) {
isRegistered &&
!isSignInPage &&
!isRegisterPage &&
- !isWelcomePage;
+ !isWelcomePage &&
+ !isShareModalOpen;
return (
@@ -122,7 +138,7 @@ export function LayoutContent({ children }: LayoutContentProps) {
{children}
- {showNav &&
}
+ {showNav &&
}
);
}