feat: prefix and anti multi-check
This commit is contained in:
@@ -79,10 +79,13 @@ const Timetable = ({
|
||||
|
||||
if (disableNetwork) return;
|
||||
|
||||
// Immediately revert the checkbox state
|
||||
target.checked = !target.checked;
|
||||
|
||||
// post request
|
||||
const json = await post("/api/record", {
|
||||
name: target.name,
|
||||
checked: target.checked,
|
||||
checked: !target.checked,
|
||||
user,
|
||||
});
|
||||
if (json.error !== undefined) {
|
||||
@@ -100,6 +103,7 @@ const Timetable = ({
|
||||
|
||||
const handleInput = (event: React.ChangeEvent<HTMLInputElement>): boolean => {
|
||||
const { target } = event;
|
||||
|
||||
// validate
|
||||
if (target?.children[0]?.tagName !== "TABLE") {
|
||||
console.log("not a table");
|
||||
@@ -202,7 +206,7 @@ const Timetable = ({
|
||||
}
|
||||
const occupied: string[] = json.occupied;
|
||||
const myselect: string[] = json.myselect;
|
||||
console.log(json);
|
||||
// console.log(json);
|
||||
for (const index in indexToElement) {
|
||||
if (occupied.includes(index)) {
|
||||
indexToElement[index].style.display = "none";
|
||||
@@ -226,7 +230,7 @@ const Timetable = ({
|
||||
|
||||
const interval = setInterval(() => {
|
||||
refresh();
|
||||
}, 1000);
|
||||
}, 1500);
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
@@ -264,7 +268,9 @@ const Timetable = ({
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 style={{ textAlign: "center" }}>Login as {user}</h2>
|
||||
<h2 style={{ textAlign: "center" }}>ITSC 学 生 助 理 抢 班 系 统</h2>
|
||||
<h3 style={{ textAlign: "center" }}>Login as {user}</h3>
|
||||
<h3 style={{ textAlign: "center" }}>请勿在短时间内多次操作同一时段的选择,选择后请耐心等待状态更新以确认是否选择成功</h3>
|
||||
<div
|
||||
align="center"
|
||||
ref={ref}
|
||||
@@ -273,7 +279,7 @@ const Timetable = ({
|
||||
overflow: "scroll",
|
||||
}}
|
||||
onInput={handleInput}
|
||||
></div>{" "}
|
||||
></div>
|
||||
{!hideDownloadButton && (
|
||||
<p style={{ display: "flex", justifyContent: "center" }}>
|
||||
<button onClick={DownloadMarks}>Download Selection</button>
|
||||
|
||||
Reference in New Issue
Block a user