From 5e016dccefb3e59c6cfb6d05db9af03100d32878 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Fri, 3 Feb 2023 21:51:54 +0800 Subject: [PATCH] fix refresh conflict --- components/Timetable.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/Timetable.tsx b/components/Timetable.tsx index 57ff86c..e3024c6 100644 --- a/components/Timetable.tsx +++ b/components/Timetable.tsx @@ -29,7 +29,7 @@ const Timetable = ({ user }) => { if (input.checked) { alert("Error: Conflict select"); location.reload(); - return + return; } } for (const input of conflicts[target.name]) { @@ -149,7 +149,15 @@ const Timetable = ({ user }) => { } else { indexToElement[index].style.display = ""; } - indexToElement[index].checked = myselect.includes(index); + const includes = myselect.includes(index); + indexToElement[index].checked = includes; + // after checked, find conflicts input + if (includes) { + for (const input of conflicts[index]) { + console.log("conflict", input); + input.setAttribute("disabled", "true"); + } + } } }; React.useEffect(() => {