Skip to content

Commit

Permalink
fixup! fix(suite): display other-error in FirmwareRevisionCheckBanner
Browse files Browse the repository at this point in the history
  • Loading branch information
komret committed Sep 30, 2024
1 parent feac8db commit b81ec4f
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TranslationKey } from '@suite-common/intl-types';
import { isDeviceAcquired } from '@suite-common/suite-utils';
import { selectDevice } from '@suite-common/wallet-core';
import { Banner } from '@trezor/components';
Expand All @@ -7,15 +8,11 @@ import { HELP_CENTER_FIRMWARE_REVISION_CHECK } from '@trezor/urls';
import { Translation, TrezorLink } from 'src/components/suite';
import { useSelector } from 'src/hooks/suite';

const getMessage = (error: FirmwareRevisionCheckError) => {
switch (error) {
case 'cannot-perform-check-offline':
return 'TR_DEVICE_FIRMWARE_REVISION_CHECK_UNABLE_TO_PERFORM';
case 'other-error':
return 'TR_FIRMWARE_REVISION_CHECK_OTHER_ERROR';
default:
return 'TR_FIRMWARE_REVISION_CHECK_FAILED';
}
const messages: Record<FirmwareRevisionCheckError, TranslationKey> = {
'cannot-perform-check-offline': 'TR_DEVICE_FIRMWARE_REVISION_CHECK_UNABLE_TO_PERFORM',
'other-error': 'TR_FIRMWARE_REVISION_CHECK_OTHER_ERROR',
'revision-mismatch': 'TR_FIRMWARE_REVISION_CHECK_FAILED',
'firmware-version-unknown': 'TR_FIRMWARE_REVISION_CHECK_FAILED',
};

export const FirmwareRevisionCheckBanner = () => {
Expand All @@ -28,7 +25,6 @@ export const FirmwareRevisionCheckBanner = () => {
return null;
}

const message = getMessage(device.authenticityChecks.firmwareRevision.error);
const wasOffline =
device.authenticityChecks.firmwareRevision.error === 'cannot-perform-check-offline';

Expand All @@ -46,7 +42,7 @@ export const FirmwareRevisionCheckBanner = () => {
)
}
>
<Translation id={message} />
<Translation id={messages[device.authenticityChecks.firmwareRevision.error]} />
</Banner>
);
};

0 comments on commit b81ec4f

Please sign in to comment.