Skip to content

Commit ae864c8

Browse files
committed
refactor: simplify layout and imports in MessagesRefillModal and AppMessagesBalance components
- Removed unnecessary imports and streamlined the layout in the `MessagesRefillModal` component for improved readability. - Adjusted the structure of the `AppMessagesBalance` component to use a `Flex` container instead of a `Box`, enhancing layout consistency. - Consolidated message display logic to improve clarity and maintainability. These changes enhance the overall code quality and user interface consistency across the messaging components.
1 parent b90fc78 commit ae864c8

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

src/features/app-messages/ui/MessagesRefillModal.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import {
1818
UseRadioProps,
1919
VStack
2020
} from '@chakra-ui/react';
21-
import { CURRENCY, FilledWarnIcon16, formatWithSuffix, H4 } from 'src/shared';
21+
import { FilledWarnIcon16, formatWithSuffix, H4 } from 'src/shared';
2222
import { RadioCard } from 'src/shared/ui/checkbox';
2323
import { AppMessagesPackage } from '../model';
24-
import { CurrencyRate, RefillModalContent } from 'src/entities';
24+
import { RefillModalContent } from 'src/entities';
2525
import MessagesPaymentConfirmationModalContent from './MessagesPaymentConfirmationModalContent';
2626
import { usePackagesQuery } from '../model/queries';
2727
import { useBalanceSufficiencyCheck, getPaymentDeficit } from 'src/features/balance';
@@ -89,21 +89,9 @@ const MessagesRefillModal: FC<{
8989
{pkg.price.stringCurrencyAmount}
9090
</Text>
9191
</Flex>
92-
<Flex justify="space-between" w="100%">
93-
<Text textStyle="body2" color="text.secondary">
94-
{formatWithSuffix(pkg.messagesIncluded)} messages
95-
</Text>
96-
<CurrencyRate
97-
textStyle="body2"
98-
color="text.secondary"
99-
leftSign=""
100-
textAlign="end"
101-
currency={CURRENCY.TON}
102-
amount={pkg.price.amount}
103-
reverse
104-
contentUnderSkeleton="&nbsp;TON"
105-
/>
106-
</Flex>
92+
<Text textStyle="body2" color="text.secondary">
93+
{formatWithSuffix(pkg.messagesIncluded)} messages
94+
</Text>
10795
</Box>
10896
</RadioCard>
10997
))}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FC } from 'react';
2-
import { formatWithSuffix, H4 } from 'src/shared';
2+
import { formatWithSuffix } from 'src/shared';
33
import { Box, BoxProps, Button, Flex, Skeleton, Text, useDisclosure } from '@chakra-ui/react';
44
import { MessagesRefillModal } from 'src/features';
55
import { useMessagesBalanceQuery } from 'src/features/app-messages/model/queries';
@@ -13,15 +13,15 @@ const AppMessagesBalance: FC<BoxProps> = props => {
1313
<Text textStyle="label1" mb="5">
1414
Available messages
1515
</Text>
16-
<Box gap="2" display="flex" flexDirection="column">
17-
<Text mb="0" flex="1" color={amount === 0 ? 'accent.red' : 'text.primary'} fontWeight={amount === 0 ? 'bold' : 'normal'}>
16+
<Flex direction="column" gap="2">
17+
<Text flex="1" mb="0" color={amount === 0 ? 'accent.red' : 'text.primary'} fontWeight={amount === 0 ? 'bold' : 'normal'}>
1818
{isLoading ? <Skeleton w="80px" h="6" /> : formatWithSuffix(amount || 0)}{' '}
1919
messages
2020
</Text>
21-
<Button onClick={onOpen} size="lg" variant="primary" w="100%">
21+
<Button w="100%" onClick={onOpen} size="lg" variant="primary">
2222
Refill
2323
</Button>
24-
</Box>
24+
</Flex>
2525
<MessagesRefillModal isOpen={isOpen} onClose={onClose} />
2626
</Box>
2727
);

0 commit comments

Comments
 (0)