Skip to content

Commit 2df7fc7

Browse files
committed
refactor: improve message display logic in AppMessagesBalance component
- Refactored the message display logic in the `AppMessagesBalance` component to conditionally render the message count and loading state more clearly. - Enhanced the layout by ensuring the `Text` component is only rendered when not loading, improving readability and user experience. These changes streamline the component's rendering process and provide clearer visual feedback regarding message availability.
1 parent 4729b72 commit 2df7fc7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/pages/app-messages/dashboard/AppMessagesBalance.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ const AppMessagesBalance: FC<BoxProps> = props => {
1414
Available messages
1515
</Text>
1616
<Flex direction="column" gap="2">
17-
<Text flex="1" mb="0" color={amount === 0 ? 'accent.red' : 'text.primary'} fontWeight={amount === 0 ? 'bold' : 'normal'}>
18-
{isLoading ? <Skeleton w="80px" h="6" /> : formatWithSuffix(amount || 0)}{' '}
19-
messages
20-
</Text>
17+
{isLoading ? (
18+
<Skeleton w="80px" h="6" />
19+
) : (
20+
<Text
21+
flex="1"
22+
mb="0"
23+
color={amount === 0 ? 'accent.red' : 'text.primary'}
24+
fontWeight={amount === 0 ? 'bold' : 'normal'}
25+
>
26+
{formatWithSuffix(amount || 0)} messages
27+
</Text>
28+
)}
2129
<Button w="100%" onClick={onOpen} size="lg" variant="primary">
2230
Refill
2331
</Button>

0 commit comments

Comments
 (0)