Potentially fix user adding
This commit is contained in:
parent
bd7e629436
commit
7087b2ec16
@ -45,8 +45,8 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
|
|||||||
})();
|
})();
|
||||||
}, [props.isOpen]);
|
}, [props.isOpen]);
|
||||||
|
|
||||||
async function addUser(user: string) {
|
async function addUser() {
|
||||||
if (!user || !user.match(/^\d{17,19}$/)) {
|
if (!userToAdd || !userToAdd.match(/^\d{17,19}$/)) {
|
||||||
toast({
|
toast({
|
||||||
description: "Please check your input and try again",
|
description: "Please check your input and try again",
|
||||||
status: "error",
|
status: "error",
|
||||||
@ -57,7 +57,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const addResp = await fetch("/api/gme/add", {
|
const addResp = await fetch("/api/gme/add", {
|
||||||
body: JSON.stringify({ user }),
|
body: JSON.stringify({ user: userToAdd }),
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
},
|
},
|
||||||
@ -75,7 +75,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
description: `User ${user} added`,
|
description: `User ${userToAdd} added`,
|
||||||
status: "success",
|
status: "success",
|
||||||
title: "Success",
|
title: "Success",
|
||||||
});
|
});
|
||||||
@ -148,7 +148,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
|
|||||||
onChange={(e) => setUserToAdd(e.target.value)}
|
onChange={(e) => setUserToAdd(e.target.value)}
|
||||||
placeholder="1234567890987654321"
|
placeholder="1234567890987654321"
|
||||||
/>
|
/>
|
||||||
<Button onClick={async () => await addUser(userToAdd)}>Add</Button>
|
<Button onClick={async () => await addUser()}>Add</Button>
|
||||||
</HStack>
|
</HStack>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user