Handle 409/410 when confirming username

This commit is contained in:
Fedor Indutny 2023-02-14 09:39:47 -08:00 committed by GitHub
parent 10885e5d3f
commit 486ada8b6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 106 additions and 15 deletions

View file

@ -120,7 +120,10 @@ export function EditUsernameModalBody({
return i18n('ProfileEditor--username--unavailable');
}
// Displayed through confirmation modal below
if (error === UsernameReservationError.General) {
if (
error === UsernameReservationError.General ||
error === UsernameReservationError.ConflictOrGone
) {
return;
}
throw missingCaseError(error);
@ -264,6 +267,24 @@ export function EditUsernameModalBody({
{i18n('ProfileEditor--username--general-error')}
</ConfirmationDialog>
)}
{error === UsernameReservationError.ConflictOrGone && (
<ConfirmationDialog
dialogName="EditUsernameModalBody.conflictOrGone"
cancelText={i18n('ok')}
cancelButtonVariant={ButtonVariant.Secondary}
i18n={i18n}
onClose={() => {
if (nickname) {
reserveUsername(nickname);
}
}}
>
{i18n('icu:ProfileEditor--username--reservation-gone', {
username: currentUsername,
})}
</ConfirmationDialog>
)}
</>
);
}