import { callAPI } from '../utils/api' import { formatPrice, timePassedSinceTimestamp } from './humanize' import { capitalize, getAvatarOfFallback } from '../utils/misc' import React from 'react' const deletePurchase = id => callAPI(null, { url: `/api/purchases/${id}`, method: 'delete', }).then(() => location.reload()).catch(() => alert('There was a problem deleting the purchase')) const Purchase = ({ purchase, me }) =>
avatar-icon
{formatPrice(purchase.price)} {timePassedSinceTimestamp(purchase.when)}
{capitalize(purchase.payer.name)} {purchase.debtors.map(debtor => debtor.name).map(capitalize).join(' ยท ')}
{/* language=CSS */}
export default Purchase