Skip to content

Commit

Permalink
Merge branch 'master' into DJ_add-acronym-in-import_WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
DJensen94 authored Feb 14, 2024
2 parents bc701f4 + c91c03b commit faac3a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions backend/src/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ export const invite = wrapHandler(async (event) => {

body.email = body.email.toLowerCase();

if (body.state) {
body.regionId = REGION_STATE_MAP[body.state];
}

// Check if user already exists
let user = await User.findOne({
email: body.email
Expand All @@ -357,14 +361,17 @@ export const invite = wrapHandler(async (event) => {
...body
});
await User.save(user);
await sendInviteEmail(user.email, organization);
if (process.env.IS_LOCAL!) {
console.log('Cannot send invite email while running on local.');
} else {
await sendInviteEmail(user.email, organization);
}
} else if (!user.firstName && !user.lastName) {
// Only set the user first name and last name the first time the user is invited.
user.firstName = body.firstName;
user.lastName = body.lastName;
await User.save(user);
}

// Always update the userType, if specified in the request.
if (body.userType) {
user.userType = body.userType;
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/Users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ export const Users: React.FC = () => {
'lastName',
'email',
'roles',
'userType'
'userType',
'state'
]}
onImport={async (results) => {
// TODO: use a batch call here instead.
Expand All @@ -329,7 +330,7 @@ export const Users: React.FC = () => {
}
try {
createdUsers.push(
await apiPost('/users/', {
await apiPost('/users', {
body
})
);
Expand Down

0 comments on commit faac3a4

Please sign in to comment.