Skip to content

Commit

Permalink
fix(console): should not toast invitation sent message when creating …
Browse files Browse the repository at this point in the history
…tenant w/o invitee (#6270)

fix(console): should not toast invitation sent message when creating tenant without invitee
  • Loading branch information
charIeszhao authored Jul 19, 2024
1 parent 64b022b commit 4ac4f8c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions packages/console/src/onboarding/pages/CreateTenant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,21 @@ function CreateTenant() {
tenantId: newTenant.id,
});

// Should not block the onboarding flow if the invitation fails.
try {
await Promise.all(
collaboratorEmails.map(async (email) =>
tenantCloudApi.post('/api/tenants/:tenantId/invitations', {
params: { tenantId: newTenant.id },
body: { invitee: email.value, roleName: TenantRole.Collaborator },
})
)
);
toast.success(t('tenant_members.messages.invitation_sent'));
} catch {
toast.error(t('tenants.create_modal.invitation_failed', { duration: 5 }));
if (collaboratorEmails.length > 0) {
// Should not block the onboarding flow if the invitation fails.
try {
await Promise.all(
collaboratorEmails.map(async (email) =>
tenantCloudApi.post('/api/tenants/:tenantId/invitations', {
params: { tenantId: newTenant.id },
body: { invitee: email.value, roleName: TenantRole.Collaborator },
})
)
);
toast.success(t('tenant_members.messages.invitation_sent'));
} catch {
toast.error(t('tenants.create_modal.invitation_failed', { duration: 5 }));
}
}
navigate(joinPath(OnboardingRoute.Onboarding, newTenant.id, OnboardingPage.SignInExperience));
})
Expand Down

0 comments on commit 4ac4f8c

Please sign in to comment.