Skip to content

Commit 1e42c84

Browse files
committed
Merge branch 'frontend-sdcard-warning'
2 parents aa0347d + 6764cdc commit 1e42c84

File tree

13 files changed

+64
-25
lines changed

13 files changed

+64
-25
lines changed

frontends/web/src/components/banners/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,24 @@
1414
* limitations under the License.
1515
*/
1616

17+
import type { AccountCode } from '@/api/account';
18+
import type { TDevices } from '@/api/devices';
1719
import { Testing } from './testing';
1820
import { Update } from './update';
1921
import { Banner } from './banner';
2022
import { MobileDataWarning } from './mobiledatawarning';
2123
import { Offline } from './offline';
24+
import { SDCardWarning } from './sdcard';
2225

23-
export const GlobalBanners = () => {
26+
type Props = {
27+
code?: AccountCode;
28+
devices: TDevices;
29+
}
30+
31+
export const GlobalBanners = ({
32+
code,
33+
devices,
34+
}: Props) => {
2435
return (
2536
<>
2637
<Testing />
@@ -30,6 +41,7 @@ export const GlobalBanners = () => {
3041
<Banner msgKey="bitbox02nova" />
3142
<MobileDataWarning />
3243
<Offline />
44+
<SDCardWarning code={code} devices={devices} />
3345
</>
3446
);
3547
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright 2025 Shift Crypto AG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { useTranslation } from 'react-i18next';
18+
import type { AccountCode } from '@/api/account';
19+
import type { TDevices } from '@/api/devices';
20+
import { useSDCard } from '@/hooks/sdcard';
21+
import { Status } from '@/components/status/status';
22+
23+
type Props = {
24+
code?: AccountCode;
25+
devices: TDevices;
26+
}
27+
28+
export const SDCardWarning = ({
29+
code,
30+
devices,
31+
}: Props) => {
32+
const { t } = useTranslation();
33+
const hasCard = useSDCard(devices, code ? [code] : undefined);
34+
35+
return (
36+
<Status hidden={!hasCard} type="warning">
37+
{t('warning.sdcard')}
38+
</Status>
39+
);
40+
};

frontends/web/src/routes/account/account.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { statusChanged, syncAddressesCount, syncdone } from '@/api/accountsync';
2323
import { bitsuranceLookup } from '@/api/bitsurance';
2424
import { TDevices } from '@/api/devices';
2525
import { getMarketVendors, MarketVendors } from '@/api/market';
26-
import { useSDCard } from '@/hooks/sdcard';
2726
import { alertUser } from '@/components/alert/Alert';
2827
import { Balance } from '@/components/balance/balance';
2928
import { HeadersSync } from '@/components/headerssync/headerssync';
@@ -178,8 +177,6 @@ const RemountAccount = ({
178177
getConfig().then(({ backend }) => setUsesProxy(backend.proxy.useProxy));
179178
}, [maybeCheckBitsuranceStatus]);
180179

181-
const hasCard = useSDCard(devices, [code]);
182-
183180
const onAccountChanged = useCallback((status: accountApi.IStatus | undefined) => {
184181
if (status === undefined || status.fatalError) {
185182
return;
@@ -275,10 +272,7 @@ const RemountAccount = ({
275272
<GuidedContent>
276273
<Main>
277274
<ContentWrapper>
278-
<GlobalBanners />
279-
<Status hidden={!hasCard} type="warning">
280-
{t('warning.sdcard')}
281-
</Status>
275+
<GlobalBanners code={code} devices={devices} />
282276
<Status className={style.status} hidden={status === undefined || !status.offlineError} type="error">
283277
{offlineErrorTextLines.join('\n')}
284278
</Status>

frontends/web/src/routes/account/summary/accountssummary.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import { statusChanged, syncdone } from '@/api/accountsync';
2323
import { unsubscribe } from '@/utils/subscriptions';
2424
import { TUnsubscribe } from '@/utils/transport-common';
2525
import { useMountedRef } from '@/hooks/mount';
26-
import { useSDCard } from '@/hooks/sdcard';
27-
import { Status } from '@/components/status/status';
2826
import { GuideWrapper, GuidedContent, Header, Main } from '@/components/layout';
2927
import { View } from '@/components/view/view';
3028
import { Chart } from './chart';
@@ -66,8 +64,6 @@ export const AccountsSummary = ({
6664
const [accountsBalanceSummary, setAccountsBalanceSummary] = useState<accountApi.TAccountsBalanceSummary>();
6765
const [balances, setBalances] = useState<Balances>();
6866

69-
const hasCard = useSDCard(devices);
70-
7167
const getChartData = useCallback(async () => {
7268
// replace previous timer if present
7369
if (summaryReqTimerID.current) {
@@ -180,10 +176,7 @@ export const AccountsSummary = ({
180176
<GuidedContent>
181177
<Main>
182178
<ContentWrapper>
183-
<GlobalBanners />
184-
<Status hidden={!hasCard} type="warning">
185-
{t('warning.sdcard')}
186-
</Status>
179+
<GlobalBanners devices={devices} />
187180
{accountsByKeystore.map(({ keystore }) => (
188181
<BackupReminder
189182
key={keystore.rootFingerprint}

frontends/web/src/routes/device/no-device-connected.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const NoDeviceConnected = ({
3737
<GuideWrapper>
3838
<GuidedContent>
3939
<ContentWrapper>
40-
<GlobalBanners />
40+
<GlobalBanners devices={devices} />
4141
</ContentWrapper>
4242
<Header
4343
hideSidebarToggler

frontends/web/src/routes/device/waiting.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const Waiting = () => {
6464
<GuidedContent>
6565
<Main>
6666
<ContentWrapper>
67-
<GlobalBanners />
67+
<GlobalBanners devices={devices} />
6868
</ContentWrapper>
6969
<Header title={<h2>{t('welcome.title')}</h2>}>
7070
<OutlinedSettingsButton />

frontends/web/src/routes/settings/about.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const About = ({ devices, hasAccounts }: TPagePropsWithSettingsTabs) => {
3333
<GuidedContent>
3434
<Main>
3535
<ContentWrapper>
36-
<GlobalBanners />
36+
<GlobalBanners devices={devices} />
3737
</ContentWrapper>
3838
<Header
3939
hideSidebarToggler

frontends/web/src/routes/settings/advanced-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const AdvancedSettings = ({ devices, hasAccounts }: TPagePropsWithSetting
8080
<GuidedContent>
8181
<Main>
8282
<ContentWrapper>
83-
<GlobalBanners />
83+
<GlobalBanners devices={devices} />
8484
</ContentWrapper>
8585
<Header
8686
hideSidebarToggler

frontends/web/src/routes/settings/bb02-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const BB02Settings = ({ deviceID, devices, hasAccounts }: TWrapperProps) => {
6666
<GuideWrapper>
6767
<GuidedContent>
6868
<ContentWrapper>
69-
<GlobalBanners />
69+
<GlobalBanners devices={devices} />
7070
</ContentWrapper>
7171
<Header
7272
hideSidebarToggler

frontends/web/src/routes/settings/general.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const General = ({ devices, hasAccounts }: TPagePropsWithSettingsTabs) =>
3939
<GuidedContent>
4040
<Main>
4141
<ContentWrapper>
42-
<GlobalBanners />
42+
<GlobalBanners devices={devices} />
4343
</ContentWrapper>
4444
<Header
4545
hideSidebarToggler

0 commit comments

Comments
 (0)