import React, { useState } from 'react'; import styles from './itemCard.module.scss'; import { ReactComponent as ChevronBack } from 'ionicons/dist/svg/chevron-back.svg'; import { IonButton } from '@ionic/react'; type OwnProps = { leftImage?: string, heading: { name: string, value: string }, value: string, description?: string, rightText?: { name: string, type: 'success' | 'danger' | 'warning' | undefined }, details?: Array<{ name: string, value: string }>, form?: JSX.Element, } // Card - Image on the left, heading-value-description in the middle and status or any text on the right. // Eg: Pending invoice cards. Follow input form patter from the commented card in the end of this file export const ItemCard: React.FC = (props) => { const [showDetails, setShowDetails] = useState(false); let statusClass = ''; if (props.rightText && props.rightText.type) { switch(props.rightText.type) { case 'success' : statusClass = styles.success; break; case 'danger' : statusClass = styles.danger; break; case 'warning' : statusClass = styles.warning; break; default: statusClass = ''; } } return
setShowDetails(true)}>
{ props.heading.name }: {props.heading.value}

{props.value}

{props.description}

{ props.rightText &&
{ props.rightText.name }
}
{ showDetails && props.details &&
{ if (e.target.className.toString().includes('backdrop')) { setShowDetails(false); } }}>
setShowDetails(false)} fill={'clear'} size={'small'}>

Pending Invoice

    { props.details.map((detail, key) => { return
  • { detail.value }

  • }) }
{ props.form }
}
} {/*
Cancel Invoice setShowDetails(false)}> Paid
*/}