From f8f6495a61124bab4aaeb2bd07e12148f1af90e9 Mon Sep 17 00:00:00 2001 From: sosokker Date: Fri, 17 Nov 2023 12:01:44 +0700 Subject: [PATCH] Add checkbox handler --- .../EisenhowerMatrix/Eisenhower.jsx | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/EisenhowerMatrix/Eisenhower.jsx b/frontend/src/components/EisenhowerMatrix/Eisenhower.jsx index 8dc159a..7c31328 100644 --- a/frontend/src/components/EisenhowerMatrix/Eisenhower.jsx +++ b/frontend/src/components/EisenhowerMatrix/Eisenhower.jsx @@ -1,22 +1,34 @@ -import React from "react"; +import React, { useState } from "react"; import { FiAlertCircle, FiClock, FiXCircle, FiCheckCircle } from "react-icons/fi"; function EachBlog({ name, colorCode, contentList, icon }) { + const [tasks, setTasks] = useState(contentList); + + const handleCheckboxChange = index => { + const updatedTasks = [...tasks]; + updatedTasks[index].checked = !updatedTasks[index].checked; + setTasks(updatedTasks); + }; + return ( -
-
- {icon} - {name} +
+
+ {icon} + {name}

- {contentList.length === 0 ? ( + {tasks.length === 0 ? (

No tasks

) : ( - contentList.map((item, index) => ( + tasks.map((item, index) => (
- + handleCheckboxChange(index)} + />
))