From 91f9bc4745d3bf009bbd24b9e7c361c3f786226d Mon Sep 17 00:00:00 2001 From: falendikategar Date: Thu, 10 Oct 2024 15:54:21 +0700 Subject: [PATCH] update: revision for index lazy --- .../assessment/index.lazy.tsx | 283 +++++++++--------- 1 file changed, 144 insertions(+), 139 deletions(-) diff --git a/apps/frontend/src/routes/_dashboardLayout/assessment/index.lazy.tsx b/apps/frontend/src/routes/_dashboardLayout/assessment/index.lazy.tsx index 9757a23..c6efe1b 100644 --- a/apps/frontend/src/routes/_dashboardLayout/assessment/index.lazy.tsx +++ b/apps/frontend/src/routes/_dashboardLayout/assessment/index.lazy.tsx @@ -213,6 +213,10 @@ export default function AssessmentPage() { const endIndex = startIndex + limit; const paginatedQuestions = data?.data.slice(startIndex, endIndex) || []; + const filteredQuestions = paginatedQuestions.filter((question) => { + return question.subAspectId === selectedSubAspectId; // Misalnya, jika `question` memiliki `subAspectId` + }); + return ( @@ -225,7 +229,7 @@ export default function AssessmentPage() { {/* LEFT-SIDE */} {/* Aspek dan Sub-Aspek */} - +
{aspectsQuery.data?.data.map((aspect) => (
(
setSelectedSubAspectId(subAspect.id)} >
{subAspect.name}
@@ -264,148 +269,148 @@ export default function AssessmentPage() { {/* Pertanyaan */} - {paginatedQuestions.map((question: any, index: number) => { - const questionId = question.questionId; - if (!questionId) return null; + {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)} - style={{ position: "relative" }} - > - - - - {startIndex + index + 1}. {question.questionText} - + return ( + (questionRefs.current[questionId] = el)} + style={{ position: "relative" }} + > + + + + {startIndex + index + 1}. {question.questionText} + - { - setFlaggedQuestions((prevFlags) => ({ - ...prevFlags, - [questionId]: !prevFlags[questionId], - })); - toggleFlagMutation.mutate(questionId); - }} - title="Tandai" - color={flaggedQuestions[questionId] ? "red" : "gray"} - > - - - - - {question.options?.length > 0 ? ( - -
- {question.options.map((option: any) => ( - - ))} -
-
- ) : ( - Tidak ada opsi untuk pertanyaan ini. - )} - -