diff --git a/apps/frontend/src/routes/_assessmentLayout.tsx b/apps/frontend/src/routes/_assessmentLayout.tsx new file mode 100644 index 0000000..852d95b --- /dev/null +++ b/apps/frontend/src/routes/_assessmentLayout.tsx @@ -0,0 +1,65 @@ +import { Navigate, Outlet, createFileRoute } from "@tanstack/react-router"; +import AppHeader from "../components/AppHeader"; +import AppNavbar from "../components/AppNavbar"; +import useAuth from "@/hooks/useAuth"; +import { useQuery } from "@tanstack/react-query"; +import fetchRPC from "@/utils/fetchRPC"; +import client from "@/honoClient"; +import { useState } from "react"; + +export const Route = createFileRoute("/_assessmentLayout")({ + component: AssessmentLayout, + + // beforeLoad: ({ location }) => { + // if (true) { + // throw redirect({ + // to: "/login", + // }); + // } + // }, +}); + +function AssessmentLayout() { + const { isAuthenticated, saveAuthData } = useAuth(); + + useQuery({ + queryKey: ["my-profile"], + queryFn: async () => { + const response = await fetchRPC(client.auth["my-profile"].$get()); + + saveAuthData({ + id: response.id, + name: response.name, + permissions: response.permissions, + }); + + return response; + }, + enabled: isAuthenticated, + }); + + const [openNavbar, setNavbarOpen] = useState(true); + const toggle = () => { + setNavbarOpen(!openNavbar); + }; + + return isAuthenticated ? ( +
+ {/* Header */} + + + {/* Main Content Area */} +
+ {/* Sidebar */} + + + {/* Main Content */} +
+ +
+
+
+ ) : ( + + ); +} diff --git a/apps/frontend/src/routes/_dashboardLayout/assessment/index.lazy.tsx b/apps/frontend/src/routes/_assessmentLayout/assessment/index.lazy.tsx similarity index 70% rename from apps/frontend/src/routes/_dashboardLayout/assessment/index.lazy.tsx rename to apps/frontend/src/routes/_assessmentLayout/assessment/index.lazy.tsx index 220ecf8..5930adb 100644 --- a/apps/frontend/src/routes/_dashboardLayout/assessment/index.lazy.tsx +++ b/apps/frontend/src/routes/_assessmentLayout/assessment/index.lazy.tsx @@ -25,13 +25,14 @@ import { import { TbFlagFilled, TbUpload, TbChevronRight, TbChevronUp } from "react-icons/tb"; import FinishAssessmentModal from "@/modules/assessmentManagement/modals/ConfirmModal"; import { useState, useRef, useEffect } from "react"; +import AppHeader from "@/components/AppHeader"; const getQueryParam = (param: string) => { const urlParams = new URLSearchParams(window.location.search); return urlParams.get(param); }; -export const Route = createLazyFileRoute("/_dashboardLayout/assessment/")({ +export const Route = createLazyFileRoute("/_assessmentLayout/assessment/")({ component: AssessmentPage, }); @@ -446,8 +447,9 @@ export default function AssessmentPage() { {/* LEFT-SIDE */} {/* Aspek dan Sub-Aspek */} - -
+ +
+ {/* Aspek */} {aspectsQuery.data?.data .filter((aspect) => aspect.subAspects.some((subAspect) => @@ -457,13 +459,13 @@ export default function AssessmentPage() { .map((aspect) => (
toggleAspect(aspect.id)} > -
{aspect.name}
+
{aspect.name}
{openAspects[aspect.id] ? ( @@ -473,6 +475,7 @@ export default function AssessmentPage() {
+ {/* Sub-Aspek */} {openAspects[aspect.id] && (
{aspect.subAspects @@ -482,7 +485,7 @@ export default function AssessmentPage() { .map((subAspect) => (
setSelectedSubAspectId(subAspect.id)} >
{subAspect.name}
@@ -494,179 +497,182 @@ export default function AssessmentPage() { ))}
+ {/* Pertanyaan */} - - - Harap menjawab semua pertanyaan yang tersedia - - Semua jawaban Anda akan ditinjau - {filteredQuestions.length === 0 ? ( - - Pertanyaan tidak ada untuk sub-aspek yang dipilih. + + + Harap menjawab semua pertanyaan yang tersedia - ) : ( - filteredQuestions.map((question: any, index: number) => { - const questionId = question.questionId; - if (!questionId) return null; + Semua jawaban Anda akan ditinjau + {filteredQuestions.length === 0 ? ( + + Pertanyaan tidak ada untuk sub-aspek yang dipilih. + + ) : ( + filteredQuestions.map((question: any, index: number) => { + const questionId = question.questionId; + if (!questionId) return null; - return ( -
(questionRefs.current[questionId] = el)} - className="space-y-4" - > - - - {startIndex + index + 1}. -
- - {question.questionText} - -
- - {/* Action Icon */} - { - setFlaggedQuestions((prevFlags) => ({ - ...prevFlags, - [questionId]: !prevFlags[questionId], - })); - toggleFlagMutation.mutate(questionId); - }} - title={ - !answers[question.questionId] - ? "Pilih jawaban terlebih dahulu" - : "Tandai" - } - color={flaggedQuestions[questionId] ? "red" : "white"} - style={{ - border: "1px gray solid", - borderRadius: "4px", - backgroundColor: flaggedQuestions[questionId] ? "red" : "white", - }} - disabled={!answers[question.questionId]} - > - - -
- - {/* Opsi Radio Button */} - {question.options?.length > 0 ? ( -
- -
- {question.options.map((option: any) => ( - - ))} -
-
-
- ) : ( - Tidak ada opsi untuk pertanyaan ini. - )} - - {/* Textarea */} -
-