update: revision for index lazy
This commit is contained in:
parent
086c1576b6
commit
91f9bc4745
|
|
@ -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 (
|
||||
<Card shadow="sm" p="lg" radius="md" withBorder>
|
||||
<Stack gap="md">
|
||||
|
|
@ -225,7 +229,7 @@ export default function AssessmentPage() {
|
|||
|
||||
{/* LEFT-SIDE */}
|
||||
{/* Aspek dan Sub-Aspek */}
|
||||
<Flex direction="column" gap="xs" className="mr-4">
|
||||
<Flex direction="column" gap="xs" className="mr-4 w-52">
|
||||
<div className="space-y-4">
|
||||
{aspectsQuery.data?.data.map((aspect) => (
|
||||
<div
|
||||
|
|
@ -251,7 +255,8 @@ export default function AssessmentPage() {
|
|||
{aspect.subAspects.map((subAspect) => (
|
||||
<div
|
||||
key={subAspect.id}
|
||||
className="flex justify-between text-gray-600"
|
||||
className={`flex justify-between text-gray-600 cursor-pointer ${selectedSubAspectId === subAspect.id ? 'font-bold' : ''}`}
|
||||
onClick={() => setSelectedSubAspectId(subAspect.id)}
|
||||
>
|
||||
<div>{subAspect.name}</div>
|
||||
</div>
|
||||
|
|
@ -264,7 +269,12 @@ export default function AssessmentPage() {
|
|||
</Flex>
|
||||
{/* Pertanyaan */}
|
||||
<Stack gap="sm" style={{ flex: 1 }}>
|
||||
{paginatedQuestions.map((question: any, index: number) => {
|
||||
{filteredQuestions.length === 0 ? (
|
||||
<Text color="black" className="text-center p-3">
|
||||
Pertanyaan tidak ada untuk sub-aspek yang dipilih.
|
||||
</Text>
|
||||
) : (
|
||||
filteredQuestions.map((question: any, index: number) => {
|
||||
const questionId = question.questionId;
|
||||
if (!questionId) return null;
|
||||
|
||||
|
|
@ -279,11 +289,7 @@ export default function AssessmentPage() {
|
|||
style={{ position: "relative" }}
|
||||
>
|
||||
<Stack gap="sm">
|
||||
<Flex
|
||||
justify="space-between"
|
||||
align="flex-start"
|
||||
style={{ width: "100%" }}
|
||||
>
|
||||
<Flex justify="space-between" align="flex-start" style={{ width: "100%" }}>
|
||||
<Text
|
||||
className="font-bold"
|
||||
style={{
|
||||
|
|
@ -320,9 +326,7 @@ export default function AssessmentPage() {
|
|||
<label
|
||||
key={option.optionId}
|
||||
className="bg-gray-200 border rounded-lg p-4 cursor-pointer transition-transform transform hover:scale-105 shadow-md hover:shadow-lg flex items-center"
|
||||
onClick={() =>
|
||||
document.getElementById(option.optionId)?.click()
|
||||
}
|
||||
onClick={() => document.getElementById(option.optionId)?.click()}
|
||||
>
|
||||
<Radio
|
||||
id={option.optionId}
|
||||
|
|
@ -338,7 +342,7 @@ export default function AssessmentPage() {
|
|||
assessmentId: assessmentId || "",
|
||||
validationInformation: JSON.stringify({
|
||||
info: "jfjforjfocn",
|
||||
questionId: question.questionId // Tambahkan questionId dalam validationInformation
|
||||
questionId: question.questionId,
|
||||
}),
|
||||
});
|
||||
}}
|
||||
|
|
@ -356,8 +360,9 @@ export default function AssessmentPage() {
|
|||
{/* File Upload */}
|
||||
{question.needFile === true && (
|
||||
<div
|
||||
className={`pt-5 pb-5 pr-5 pl-2 border-2 border-dashed ${dragActive ? "bg-gray-100" : "bg-transparent"
|
||||
} shadow-lg`} // Tambah shadow-lg
|
||||
className={`pt-5 pb-5 pr-5 pl-2 border-2 border-dashed ${
|
||||
dragActive ? "bg-gray-100" : "bg-transparent"
|
||||
} shadow-lg`}
|
||||
onDragOver={handleDragOver}
|
||||
onDragLeave={handleDragLeave}
|
||||
onDrop={handleDrop}
|
||||
|
|
@ -367,8 +372,7 @@ export default function AssessmentPage() {
|
|||
<TbUpload
|
||||
size={24}
|
||||
style={{ marginLeft: "8px", marginRight: "8px" }}
|
||||
/>{" "}
|
||||
{/* Tambah marginLeft */}
|
||||
/>
|
||||
<div className="flex-grow text-right">
|
||||
<Text className="font-bold">
|
||||
Klik untuk unggah atau geser file disini
|
||||
|
|
@ -405,7 +409,8 @@ export default function AssessmentPage() {
|
|||
</Stack>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
})
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
{/* Navigasi dan Pagination */}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user