give
/
src
/
DonorDashboards
/
resources
/
js
/
app
/
components
/
donation-receipt
Last commit date
index.js
3 years ago
style.scss
3 years ago
index.js
51 lines
| 1 | import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; |
| 2 | import {Fragment} from 'react'; |
| 3 | import {Interweave} from 'interweave'; |
| 4 | |
| 5 | import './style.scss'; |
| 6 | |
| 7 | const DonationReceipt = ({donation}) => { |
| 8 | if (donation === undefined) { |
| 9 | return null; |
| 10 | } |
| 11 | |
| 12 | const {receipt} = donation; |
| 13 | |
| 14 | return receipt.map((section, sectionIndex) => { |
| 15 | const lineItems = section.lineItems.map((item, itemIndex) => { |
| 16 | const value = |
| 17 | typeof item.value === 'object' && item.value.color ? ( |
| 18 | <Fragment> |
| 19 | <div |
| 20 | className="give-donor-dashboard-donation-receipt__status-indicator" |
| 21 | style={{background: item.value.color}} |
| 22 | /> |
| 23 | {item.value.label} |
| 24 | </Fragment> |
| 25 | ) : ( |
| 26 | <Interweave content={item.value} allowAttributes={['download']} /> |
| 27 | ); |
| 28 | |
| 29 | return ( |
| 30 | <div |
| 31 | className={`give-donor-dashboard-donation-receipt__row${ |
| 32 | item.class.includes('total') ? ' give-donor-dashboard-donation-receipt__row--footer' : '' |
| 33 | }`} |
| 34 | key={itemIndex} |
| 35 | > |
| 36 | <div className="give-donor-dashboard-donation-receipt__detail"> |
| 37 | {item.icon && <FontAwesomeIcon icon={item.icon} fixedWidth={true} />} {item.label} |
| 38 | </div> |
| 39 | <div className="give-donor-dashboard-donation-receipt__value">{value}</div> |
| 40 | </div> |
| 41 | ); |
| 42 | }); |
| 43 | return ( |
| 44 | <div className="give-donor-dashboard-donation-receipt__table" key={sectionIndex}> |
| 45 | {lineItems} |
| 46 | </div> |
| 47 | ); |
| 48 | }); |
| 49 | }; |
| 50 | export default DonationReceipt; |
| 51 |