From 229facbc7b4978e31f91fc36a347e2d9dec2ed3e Mon Sep 17 00:00:00 2001 From: Regalijan Date: Wed, 8 Nov 2023 13:32:44 -0500 Subject: [PATCH] Actually add user on click --- components/GameModManagementModal.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/GameModManagementModal.tsx b/components/GameModManagementModal.tsx index 79f72e6..846069e 100644 --- a/components/GameModManagementModal.tsx +++ b/components/GameModManagementModal.tsx @@ -22,6 +22,7 @@ import { useEffect, useState } from "react"; export default function (props: { isOpen: boolean; onClose: () => void }) { const [mods, setMods] = useState([]); + const [userToAdd, setUserToAdd] = useState(""); const toast = useToast(); useEffect(() => { @@ -45,6 +46,16 @@ export default function (props: { isOpen: boolean; onClose: () => void }) { }, [props.isOpen]); async function addUser(user: string) { + if (!user || !user.match(/^\d{17,19}$/)) { + toast({ + description: "Please check your input and try again", + status: "error", + title: "Invalid user", + }); + + return; + } + const addResp = await fetch("/api/gme/add", { body: JSON.stringify({ user }), headers: { @@ -133,7 +144,9 @@ export default function (props: { isOpen: boolean; onClose: () => void }) { - +