-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show error box to user when an error occurred creating students (#7187)
- Loading branch information
1 parent
e0c72fd
commit 26c95d1
Showing
1 changed file
with
8 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import { | |
} from '../../Utils/GDevelopServices/User'; | ||
import AuthenticatedUserContext from '../../Profile/AuthenticatedUserContext'; | ||
import { listOtherUserCloudProjects } from '../../Utils/GDevelopServices/Project'; | ||
import { showErrorBox } from '../../UI/Messages/MessageBox'; | ||
|
||
type Props = {| children: React.Node |}; | ||
|
||
|
@@ -122,26 +123,19 @@ const TeamProvider = ({ children }: Props) => { | |
async quantity => { | ||
if (!team || !adminUserId) return; | ||
try { | ||
const createdUsers = await createTeamMembers(getAuthorizationHeader, { | ||
await createTeamMembers(getAuthorizationHeader, { | ||
teamId: team.id, | ||
quantity, | ||
adminUserId, | ||
}); | ||
try { | ||
await activateTeamMembers(getAuthorizationHeader, { | ||
teamId: team.id, | ||
activate: true, | ||
userIds: createdUsers.map(user => user.uid), | ||
adminUserId, | ||
}); | ||
} catch (error) { | ||
console.error( | ||
'An error occurred while activating newly created members', | ||
error | ||
); | ||
} | ||
} catch (error) { | ||
console.error('An error occurred while creating team members:', error); | ||
showErrorBox({ | ||
rawError: error, | ||
message: | ||
'There was an error while creating students in your plan. You can report it at [email protected] or try again later.', | ||
errorId: 'student-creation-error', | ||
}); | ||
} | ||
}, | ||
[team, getAuthorizationHeader, adminUserId] | ||
|