forked from composable-com/composable-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcart-promotions.tsx
66 lines (63 loc) · 1.58 KB
/
cart-promotions.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { useIntl } from 'react-intl'
import { CartItem, Redeemable } from '@composable/types'
import {
Box,
Divider,
Flex,
HStack,
Link,
StackDivider,
Tag,
TagCloseButton,
TagLabel,
Wrap,
WrapItem,
Text,
useBreakpointValue,
TagLeftIcon,
} from '@chakra-ui/react'
import { Icon } from '@chakra-ui/icons'
import { MdShoppingCart } from 'react-icons/md'
import { Price } from 'components/price'
import { QuantityPicker } from 'components/quantity-picker'
import { CartItemData, CartSummaryItem } from '.'
interface CartPromotionsProps {
promotions: Redeemable[]
}
export const CartPromotions = ({ promotions }: CartPromotionsProps) => {
const intl = useIntl()
// const isMobile = useBreakpointValue({ base: true, md: false })
if (!promotions.length) {
return null
}
return (
<>
<CartSummaryItem
label={intl.formatMessage({
id: 'cart.summary.promotions',
})}
></CartSummaryItem>
{promotions.map((redeemable) => (
<Flex key={redeemable.id} justify="space-between">
<Tag
size="md"
paddingRight={2}
paddingLeft={2}
borderRadius="sm"
variant="outline"
colorScheme="whiteAlpha"
>
<TagLeftIcon boxSize="12px" as={MdShoppingCart} />
<TagLabel>{redeemable.label}</TagLabel>
</Tag>
<Box>
<Price
rootProps={{ textStyle: 'Body-S', color: 'green' }}
price={`-${redeemable.discount}`}
/>
</Box>
</Flex>
))}
</>
)
}