ENCOA-109: Made the modal disappear when a user is created

This commit is contained in:
Tiago Ribeiro
2024-08-27 11:14:29 +01:00
parent 7fb0ed884c
commit b7940087b5
5 changed files with 16 additions and 9 deletions

View File

@@ -61,7 +61,7 @@ const USER_TYPE_PERMISSIONS: {
},
};
export default function BatchCreateUser({user}: {user: User}) {
export default function BatchCreateUser({user, onFinish}: {user: User; onFinish: () => void}) {
const [infos, setInfos] = useState<
{
email: string;
@@ -159,6 +159,7 @@ export default function BatchCreateUser({user}: {user: User}) {
try {
for (const newUser of newUsers) await axios.post("/api/make_user", {...newUser, type, expiryDate});
toast.success(`Successfully added ${newUsers.length} user(s)!`);
onFinish();
} catch {
toast.error("Something went wrong, please try again later!");
} finally {