import { Flex, Heading, List, ListIcon, ListItem, Text, useColorModeValue, VStack, } from '@chakra-ui/react' import * as React from 'react' import { useEffect, useState } from 'react' import { formatPrice } from 'utils/pricing' import { CheckCircleIcon } from '../../../assets/icons/CheckCircleIcon' import { Card, CardProps } from './Card' export interface PricingCardData { features: React.ReactNode[] name: string price: number | string featureLabel?: string } interface PricingCardProps extends CardProps { data: PricingCardData icon?: JSX.Element button: React.ReactElement } export const PricingCard = ({ data, icon, button, ...rest }: PricingCardProps) => { const { features, price, name } = data const [formattedPrice, setFormattedPrice] = useState(price) const accentColor = useColorModeValue('blue.500', 'white') useEffect(() => { setFormattedPrice(typeof price === 'number' ? formatPrice(price) : price) }, [price]) return ( {icon} {name} {formattedPrice} {typeof price === 'number' && ( / month )} {data.featureLabel && ( {data.featureLabel} )} {features.map((feature, index) => ( {feature} ))} {button} ) }