From 122bded4561c55ff1cb79dcb59a7ad4c9bb39b29 Mon Sep 17 00:00:00 2001 From: sina_sajjadi Date: Thu, 16 Apr 2026 12:54:46 +0330 Subject: [PATCH] Refactor video pages to use a shared VideoStepScreen component; streamline UI components and improve code organization --- .../[section]/detail-section-client.tsx | 319 +++++++--------- src/app/details/[section]/page.tsx | 2 +- src/app/details/complete/page.tsx | 61 +-- src/app/details/page.tsx | 240 ++++++------ src/app/globals.css | 355 ++++++++++++++++++ src/app/intro/page.tsx | 24 +- src/app/page.tsx | 88 +++-- src/app/questions/page.tsx | 304 +++++++-------- src/app/rules/page.tsx | 210 ++++++----- src/app/video-2/page.tsx | 238 +----------- src/app/video/page.tsx | 236 +----------- src/components/screens/video-step-screen.tsx | 202 ++++++++++ src/components/ui/fabric-mobile.tsx | 214 +++++++++++ 13 files changed, 1404 insertions(+), 1089 deletions(-) create mode 100644 src/components/screens/video-step-screen.tsx create mode 100644 src/components/ui/fabric-mobile.tsx diff --git a/src/app/details/[section]/detail-section-client.tsx b/src/app/details/[section]/detail-section-client.tsx index e49b0c1..24b9a05 100644 --- a/src/app/details/[section]/detail-section-client.tsx +++ b/src/app/details/[section]/detail-section-client.tsx @@ -1,38 +1,27 @@ "use client"; import Link from "next/link"; -import { useRouter } from "next/navigation"; import { useEffect, useMemo, useState } from "react"; +import { + BackIcon, + FabricCard, + FabricIconLink, + FabricPill, + FabricProgress, + FabricScreen, + FabricStatusBar, + fabricInputClass, + fabricMutedPanelClass, + fabricSecondaryButtonClass, + fabricTextareaClass, +} from "@/components/ui/fabric-mobile"; import { countCompletedDetailedAnswers, - detailedSections, type DetailedSection, - getDetailedQuestionCount, getDetailedSectionProgress, getDetailedSectionStorageKey, } from "@/lib/detailed-questions"; -function BackIcon() { - return ( - - ); -} - export default function DetailSectionClient({ section, }: { @@ -40,7 +29,6 @@ export default function DetailSectionClient({ }) { const [answers, setAnswers] = useState>({}); const [isHydrated, setIsHydrated] = useState(false); - const router = useRouter(); useEffect(() => { const savedAnswers = window.localStorage.getItem( @@ -62,26 +50,7 @@ export default function DetailSectionClient({ getDetailedSectionStorageKey(section.id), JSON.stringify(answers), ); - - const completedTotal = detailedSections.reduce((total, currentSection) => { - const sectionAnswers = - currentSection.id === section.id - ? answers - : ((JSON.parse( - window.localStorage.getItem( - getDetailedSectionStorageKey(currentSection.id), - ) ?? "{}", - ) as Record) ?? {}); - - return ( - total + countCompletedDetailedAnswers(currentSection, sectionAnswers) - ); - }, 0); - - if (completedTotal === getDetailedQuestionCount()) { - router.replace("/details/complete"); - } - }, [answers, isHydrated, router, section, section.id]); + }, [answers, isHydrated, section.id]); const completedCount = useMemo( () => countCompletedDetailedAnswers(section, answers), @@ -100,145 +69,129 @@ export default function DetailSectionClient({ }; return ( -
-
-
- -
-
- 9:41 -
- - -
-
- -
- - - - -

- {section.title} -

- - - {progress}% - -
- -
-

- Section Progress -

-

- {section.title} -

-

- {section.description} -

- -
-
-
- -

- {completedCount} of {section.questions.length} questions answered -

-
- -
- {section.questions.map((question) => { - const value = answers[question.id] ?? ""; - - return ( -
-

+ + + +
+ + + + +
+

Section details

+

+ {section.title} +

+
+ + + {progress}% + +
+ + +

Section progress

+

+ {section.title} +

+

+ {section.description} +

+ + + +

+ {completedCount} of {section.questions.length} questions answered +

+
+ +
+

+ Answers are saved automatically while you type, so you can return to + the section list at any time. +

+
+ +
+ {section.questions.map((question, index) => { + const value = answers[question.id] ?? ""; + + return ( + +
+
+

Prompt {index + 1}

+

{question.label}

-

- {question.description} -

- -
- {question.type === "textarea" ? ( -