Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rosewang01 committed May 17, 2024
1 parent 323c18d commit 2b5e5c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions client/src/components/buttons/InviteUserButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { postData } from '../../util/api';

function InviteUserButton() {
const [open, setOpen] = useState(false);
const [email, setEmail] = useState('');
const [emails, setEmails] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);

Expand All @@ -27,11 +27,11 @@ function InviteUserButton() {

const handleInvite = async () => {
setLoading(true);
postData('admin/invite', { email }).then((res) => {
postData('admin/invite', { emails }).then((res) => {
if (res.error) {
setError(res.error.message);
} else {
setAlert(`${email} successfully invited!`, AlertType.SUCCESS);
setAlert(`${emails} successfully invited!`, AlertType.SUCCESS);
setOpen(false);
}
setLoading(false);
Expand All @@ -40,7 +40,7 @@ function InviteUserButton() {

const updateEmail = (event: React.ChangeEvent<HTMLInputElement>) => {
setError('');
setEmail(event.target.value);
setEmails(event.target.value);
};

return (
Expand All @@ -51,15 +51,14 @@ function InviteUserButton() {
<Dialog open={open} onClose={handleClose}>
<DialogContent>
<DialogContentText>
Please enter one or more email addresses separated by commas and
role of the user you would like to invite. (ex. a@gmail.com,
b@outlook.com)
Please enter one or more email addresses separated by commas. (ex.
a@gmail.com, b@outlook.com)
</DialogContentText>
<TextField
autoFocus
margin="dense"
id="name"
label="Email Address"
label="Email Addresses"
type="email"
fullWidth
variant="standard"
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/admin.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const inviteUser = async (

const emailInviteList = lowercaseEmailList.filter((email) => {
if (existingUserEmails.includes(email)) {
next(ApiError.badRequest(`User with email ${email} already exists`));
throw ApiError.badRequest(`User with email ${email} already exists`);
}
return !existingUserEmails.includes(email);
});
Expand Down

0 comments on commit 2b5e5c4

Please sign in to comment.