From 830ea9f63525fa17ff41dc188942284f851280fa Mon Sep 17 00:00:00 2001 From: abiyasa05 Date: Fri, 15 Nov 2024 09:29:09 +0700 Subject: [PATCH] update: change position on pagination when device is responsive --- .../assessment/index.lazy.tsx | 180 +++++++----------- 1 file changed, 74 insertions(+), 106 deletions(-) diff --git a/apps/frontend/src/routes/_assessmentLayout/assessment/index.lazy.tsx b/apps/frontend/src/routes/_assessmentLayout/assessment/index.lazy.tsx index ab2ab79..d0498b3 100644 --- a/apps/frontend/src/routes/_assessmentLayout/assessment/index.lazy.tsx +++ b/apps/frontend/src/routes/_assessmentLayout/assessment/index.lazy.tsx @@ -5,14 +5,11 @@ import { Text, Loader, ActionIcon, - CloseButton, - Group, } from "@mantine/core"; import { Card, CardContent, CardDescription, - CardTitle, } from "@/shadcn/components/ui/card"; import { Button } from "@/shadcn/components/ui/button"; import { Textarea } from "@/shadcn/components/ui/textarea"; @@ -34,30 +31,18 @@ import { getQuestionsAllQueryOptions, toggleFlagAnswer, } from "@/modules/assessmentManagement/queries/assessmentQueries"; -import { TbFlagFilled, TbUpload, TbChevronRight, TbChevronDown, TbLayoutSidebarLeftCollapseFilled, TbMenu2 } from "react-icons/tb"; +import { TbFlagFilled, TbChevronRight, TbChevronDown, TbLayoutSidebarLeftCollapseFilled } from "react-icons/tb"; import FinishAssessmentModal from "@/modules/assessmentManagement/modals/ConfirmModal"; import FileUpload from "@/modules/assessmentManagement/fileUpload/fileUpload"; import ValidationModal from "@/modules/assessmentManagement/modals/ValidationModal"; -import FileSizeValidationModal from "@/modules/assessmentManagement/modals/FileSizeValidationModal"; import { Sheet, - SheetClose, SheetContent, - SheetDescription, - SheetFooter, - SheetHeader, SheetTitle, - SheetTrigger, } from "@/shadcn/components/ui/sheet"; import { LeftSheet, - LeftSheetClose, LeftSheetContent, - LeftSheetDescription, - LeftSheetFooter, - LeftSheetHeader, - LeftSheetTitle, - LeftSheetTrigger, } from "@/shadcn/components/ui/leftsheet"; import { useState, useRef, useEffect } from "react"; import AppHeader from "@/components/AppHeader"; @@ -93,12 +78,6 @@ export interface SubmitOptionResponse { }; } -// const [isLeftSidebarOpen, setIsLeftSidebarOpen] = useState(false); - -// export const toggleLeftSidebar = () => setIsLeftSidebarOpen(!isLeftSidebarOpen); - -// import AppHeader from '../../../components/AppHeader'; - export default function AssessmentPage() { const [page, setPage] = useState(1); const limit = 10; @@ -128,15 +107,8 @@ export default function AssessmentPage() { const [openNavbar, setOpenNavbar] = useState(false); const [isLeftSidebarOpen, setIsLeftSidebarOpen] = useState(false); - // Toggle the sidebar open/close on mobile - const toggleSidebar = () => setIsSidebarOpen(!isSidebarOpen); - const toggleLeftSidebar = () => setIsLeftSidebarOpen(!isLeftSidebarOpen); - const toggleSidebarLeftSide = () => { - setIsSidebarOpen((prevState) => !prevState); - }; - // Fungsi toggle untuk membuka/menutup navbar const toggle = () => { setOpenNavbar((prevState) => !prevState); @@ -648,10 +620,6 @@ export default function AssessmentPage() { {/* LEFT-SIDE */} {/* Aspek dan Sub-Aspek */} - {/* */} setIsLeftSidebarOpen(open)}> +
{/* Aspek */} @@ -672,7 +641,7 @@ export default function AssessmentPage() { ) ) .map((aspect) => ( -
+
toggleAspect(aspect.id)} @@ -715,6 +684,7 @@ export default function AssessmentPage() { {/* Sidebar for Desktop (Always Visible) */}
+
{/* Aspek */} @@ -790,10 +760,10 @@ export default function AssessmentPage() {
{/* Question Number */} - {startIndex + index + 1}. + {startIndex + index + 1}. {/* Question Text */} - {question.questionText} + {question.questionText} {/* Action Icon/Flag */} 0 ? ( -
+
handleAnswerChange(question.questionId, value)} @@ -880,6 +850,20 @@ export default function AssessmentPage() { }) )} + {/* Pagination for mobile */} +
+ { + if (selectedSubAspectId) { + handlePageChange(selectedSubAspectId, newPage); + } + }} + > + Halaman {currentPage} dari {totalPages} + +
{/* RIGHT-SIDE */} @@ -887,7 +871,7 @@ export default function AssessmentPage() { {isMobile && ( @@ -896,14 +880,13 @@ export default function AssessmentPage() { {/* Sidebar for mobile (only when toggled) */}
setIsSidebarOpen(open)}> - + Nomor Soal - {/* Nomor Soal */} {/* Navigasi (Number of Questions) */} -
+
{Array.from({ length: totalQuestionsInSubAspect }).map((_, i) => { const questionNumber = startIndex + i + 1; const questionId = filteredQuestions[i]?.questionId; @@ -930,64 +913,50 @@ export default function AssessmentPage() { })}
-
- { - if (selectedSubAspectId) { - handlePageChange(selectedSubAspectId, newPage); - } - }} - > - Halaman {currentPage} dari {totalPages} - -
+ {/* Divider */} +
{/* Skor Aspek dan Sub-Aspek */}
- - - Nilai Sementara - - - - - {filteredAspects.length > 0 ? ( - filteredAspects.map((aspect) => { - const aspectScore = parseFloat(aspect.averageScore).toFixed(2); - const aspectScoreValue = parseFloat(aspectScore); +

Nilai Sementara

+
+
+ {filteredAspects.length > 0 ? ( + filteredAspects.map((aspect) => { + const aspectScore = parseFloat(aspect.averageScore).toFixed(2); + const aspectScoreValue = parseFloat(aspectScore); - return ( -
- {aspect.aspectName} - = 4.5 - ? "text-green-700" - : aspectScoreValue >= 3.5 - ? "text-green-400" - : aspectScoreValue >= 2.5 - ? "text-yellow-400" - : aspectScoreValue >= 1.5 - ? "text-orange-500" - : "text-red-500" - }`} - > - {aspectScore} - -
- ); - }) - ) : ( - Data aspek ini kosong - )} - + return ( +
+ {aspect.aspectName} + = 4.5 + ? "text-green-700" + : aspectScoreValue >= 3.5 + ? "text-green-400" + : aspectScoreValue >= 2.5 + ? "text-yellow-400" + : aspectScoreValue >= 1.5 + ? "text-orange-500" + : "text-red-500" + }`} + > + {aspectScore} + +
+ ); + }) + ) : ( + Data aspek ini kosong + )} +
- {/* Divider */} -
+ {/* Divider */} +
- {/* Skor Sub-Aspek */} + {/* Skor Sub-Aspek */} +
{filteredSubAspects.length > 0 ? ( filteredSubAspects.map((subAspect) => { const subAspectScore = parseFloat(subAspect.averageScore).toFixed(2); @@ -995,7 +964,7 @@ export default function AssessmentPage() { return (
- {subAspect.subAspectName} + {subAspect.subAspectName} = 4.5 @@ -1017,18 +986,17 @@ export default function AssessmentPage() { ) : ( Data sub-aspek ini kosong )} - - - {/* Finish Button */} -
-
- + + {/* Finish Button */} +
+ +
{/* Finish Assessment Modal */} setValidationModalOpen(false)} unansweredQuestions={unansweredQuestions} /> - +