Potentially fix user adding

This commit is contained in:
Regalijan 2023-11-08 13:48:01 -05:00
parent bd7e629436
commit 7087b2ec16
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -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>