Donations: show modal when we can't apply the user's badge

This commit is contained in:
yash-signal
2025-08-29 14:29:53 -05:00
committed by GitHub
parent f0488dff25
commit 0e4cdfc566
7 changed files with 25 additions and 20 deletions
+5
View File
@@ -45,6 +45,11 @@ export function DonationErrorModal(props: PropsType): JSX.Element {
body = i18n('icu:Donations__TimedOut__Description');
break;
}
case donationErrorTypeSchema.Enum.BadgeApplicationFailed: {
title = i18n('icu:Donations__BadgeApplicationFailed__Title');
body = i18n('icu:Donations__BadgeApplicationFailed__Description');
break;
}
default:
throw missingCaseError(props.errorType);
+10 -4
View File
@@ -628,6 +628,12 @@ export function PreferencesDonations({
i18n={i18n}
onClose={() => {
setIsSubmitted(false);
if (
workflow?.type === 'DONE' &&
lastError === donationErrorTypeSchema.Enum.BadgeApplicationFailed
) {
clearWorkflow();
}
updateLastError(undefined);
}}
/>
@@ -675,13 +681,13 @@ export function PreferencesDonations({
badge={donationBadge}
applyDonationBadge={applyDonationBadge}
onClose={(error?: Error) => {
clearWorkflow();
if (error) {
log.error('Badge application failed:', error.message);
showToast({
toastType: ToastType.DonationCompletedAndBadgeApplicationFailed,
});
updateLastError(
donationErrorTypeSchema.Enum.BadgeApplicationFailed
);
} else {
clearWorkflow();
showToast({
toastType: ToastType.DonationCompleted,
});
-4
View File
@@ -41,10 +41,6 @@ function getToast(toastType: ToastType): AnyToast {
};
case ToastType.Blocked:
return { toastType: ToastType.Blocked };
case ToastType.DonationCompletedAndBadgeApplicationFailed:
return {
toastType: ToastType.DonationCompletedAndBadgeApplicationFailed,
};
case ToastType.BlockedGroup:
return { toastType: ToastType.BlockedGroup };
case ToastType.CallHistoryCleared:
-10
View File
@@ -118,16 +118,6 @@ export function renderToast({
);
}
if (toastType === ToastType.DonationCompletedAndBadgeApplicationFailed) {
return (
<Toast onClose={hideToast}>
{i18n(
'icu:Donations__Toast__DonationCompletedAndBadgeApplicationFailed'
)}
</Toast>
);
}
if (toastType === ToastType.Blocked) {
return <Toast onClose={hideToast}>{i18n('icu:unblockToSend')}</Toast>;
}