You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PaymentCard.tsx 933B

1234567891011121314151617181920212223242526272829
  1. import React, { useState } from 'react';
  2. import { Typography, Flex} from 'antd';
  3. import type { Transaction } from '@/types/payment';
  4. import formatDate from '@/helper/util/formatDateTime';
  5. const { Text, Title } = Typography;
  6. type PaymentCardProps = Omit<Transaction, 'id'>
  7. const PaymentCard: React.FC<PaymentCardProps> = ({ name, created_at, amount }: PaymentCardProps) => {
  8. const sign = (amount > 0) ? "+" : "-";
  9. return (
  10. <Flex className='border-y !bg-white hover:!bg-gray-100 cursor-pointer !border-gray-100 !py-2 !px-6'>
  11. <Flex vertical flex={1}>
  12. <Text className='!font-bold'>{name}</Text>
  13. <Text>{formatDate(created_at)}</Text>
  14. </Flex>
  15. <Flex align='center'>
  16. <Text className={`!font-bold ${(amount > 0) ? '!text-green-700' : '!text-red-700'} `}>
  17. {`${sign} RM ${Math.abs(amount).toFixed(2)}`}
  18. </Text>
  19. </Flex>
  20. </Flex>
  21. )
  22. }
  23. export default PaymentCard;