Skip to content

Commit

Permalink
Show error box to user when an error occurred creating students (#7187)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreSi authored Nov 25, 2024
1 parent e0c72fd commit 26c95d1
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions newIDE/app/src/Profile/Team/TeamProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 |};

Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 26c95d1

Please sign in to comment.