Skip to content

Commit d0c0a11

Browse files
committed
handle error message
1 parent 15a2a17 commit d0c0a11

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed
Loading

packages/k2-alpine/src/components/Header/BalanceHeader.tsx

+20-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ import React from 'react'
22
import { LayoutChangeEvent } from 'react-native'
33
import { Text, View } from '../Primitives'
44
import { PriceChangeIndicator } from '../PriceChangeIndicator/PriceChangeIndicator'
5+
import { Icons } from '../../theme/tokens/Icons'
56

67
export const BalanceHeader = ({
78
accountName,
89
formattedBalance,
910
currency,
11+
errorMessage,
1012
onLayout
1113
}: {
1214
accountName: string
1315
formattedBalance: string
1416
currency: string
17+
errorMessage?: string
1518
onLayout?: (event: LayoutChangeEvent) => void
1619
}): JSX.Element => {
1720
return (
@@ -32,12 +35,23 @@ export const BalanceHeader = ({
3235
</Text>
3336
</View>
3437
</View>
35-
<PriceChangeIndicator
36-
formattedPrice="$12.7"
37-
status="up"
38-
formattedPercent="3.7%"
39-
textVariant="buttonMedium"
40-
/>
38+
{errorMessage ? (
39+
<View sx={{ gap: 4, alignItems: 'center', flexDirection: 'row' }}>
40+
<Icons.Alert.Error width={16} height={16} color={ERROR_COLOR} />
41+
<Text variant="buttonMedium" sx={{ color: ERROR_COLOR }}>
42+
{errorMessage}
43+
</Text>
44+
</View>
45+
) : (
46+
<PriceChangeIndicator
47+
formattedPrice="$12.7"
48+
status="up"
49+
formattedPercent="3.7%"
50+
textVariant="buttonMedium"
51+
/>
52+
)}
4153
</View>
4254
)
4355
}
56+
57+
const ERROR_COLOR = '#F5643B'

packages/k2-alpine/src/components/Header/Header.stories.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ export const All = (): JSX.Element => {
2020
formattedBalance="$7,377.37"
2121
currency="USD"
2222
/>
23+
<BalanceHeader
24+
accountName="Account 1"
25+
formattedBalance="$7,377.37"
26+
errorMessage="Unable to load all balances"
27+
currency="USD"
28+
/>
2329
<NavigationTitleHeader title="Account 1" subtitle="$51.72 USD" />
2430
</View>
2531
</ScrollView>

packages/k2-alpine/src/theme/tokens/Icons.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import IconTrendingArrowUp from '../../assets/icons/trending_arrow_up.svg'
3232
import IconTrendingArrowDown from '../../assets/icons/trending_arrow_down.svg'
3333
import IconQRCode2 from '../../assets/icons/qr_code_2.svg'
3434
import IconNotifications from '../../assets/icons/notifications.svg'
35+
import IconAlertError from '../../assets/icons/alert_error.svg'
3536

3637
export const Icons = {
3738
Action: {
@@ -40,7 +41,8 @@ export const Icons = {
4041
Clear: IconClear
4142
},
4243
Alert: {
43-
IconErrorOutline: IconErrorOutline
44+
IconErrorOutline: IconErrorOutline,
45+
Error: IconAlertError
4446
},
4547
Device: {
4648
IconGPPMaybe: IconGPPMaybe

0 commit comments

Comments
 (0)