Fix this thingy

This commit is contained in:
Ethan O'Brien 2024-05-27 16:35:27 -05:00
parent a6592beed0
commit 2c114e3f59

View file

@ -5,17 +5,24 @@ import Request from '../Request.jsx'
function Admin() { function Admin() {
const [imp, setimp] = useState(); const [imp, setimp] = useState();
const [exp, setexp] = useState(); const [exp, setexp] = useState();
const ids = [setimp, setexp];
const handleSubmit = async (id, event) => { const handleSubmit = async (event) => {
await Request( await Request(
"/api/webui/admin", "/api/webui/admin",
{ {
import: !!imp, import: !imp
export: !!exp
} }
); );
ids[id](event.target.checked); setimp(!imp);
};
const handleSubmit2 = async (event) => {
await Request(
"/api/webui/admin",
{
export: !exp
}
);
setexp(!exp);
}; };
if (imp === undefined) { if (imp === undefined) {
@ -34,9 +41,9 @@ function Admin() {
<div id="home"> <div id="home">
<h1>Admin</h1> <h1>Admin</h1>
<div> <div>
<input type="checkbox" id="import" name="import" checked={!!imp} onClick={(i)=>handleSubmit(0, i)} /> <input type="checkbox" id="import" name="import" checked={!!imp} onClick={(i)=>handleSubmit(i)} />
<label for="import">Allow account imports</label><br/><br/> <label for="import">Allow account imports</label><br/><br/>
<input type="checkbox" id="exp" name="exp" checked={!!exp} onClick={(i)=>handleSubmit(1, i)} /> <input type="checkbox" id="exp" name="exp" checked={!!exp} onClick={(i)=>handleSubmit2(i)} />
<label for="exp">Allow account exports</label> <label for="exp">Allow account exports</label>
</div> </div>
</div> </div>