Add: clear
This commit is contained in:
@@ -34,6 +34,29 @@ export default function Time(props) {
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const updateUsernameByAdmin = (id, username) => {
|
||||
fetch(`${prefix}/api/time/ranges/${id}`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username,
|
||||
token,
|
||||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
if (res.error) {
|
||||
setSnackbarError(true);
|
||||
setSnackbarErrorMessage(res.error);
|
||||
} else {
|
||||
setSnackbarSuccess(true);
|
||||
refreshRanges();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getStats = () => {
|
||||
fetch(`${prefix}/api/stats`, {
|
||||
method: "GET",
|
||||
@@ -330,16 +353,21 @@ export default function Time(props) {
|
||||
{range.username ? range.username : "抢!"}
|
||||
</Button>
|
||||
{isAdmin() && (
|
||||
<Button
|
||||
sx={{
|
||||
userSelect: "none",
|
||||
}}
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
onClick={() => deleteRange(range.id)}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
<>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => updateUsernameByAdmin(range.id, "")}
|
||||
>
|
||||
清空
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
onClick={() => deleteRange(range.id)}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user