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