'client only'; import { Cog8ToothIcon, PlusCircleIcon } from "@heroicons/react/24/outline"; import { FC } from "react"; import { BillBadge } from "./BillBadge"; import { BillingLocation } from "../lib/db-types"; import { formatYearMonth } from "../lib/format"; import { formatCurrency } from "../lib/formatStrings"; import Link from "next/link"; export interface LocationCardProps { location: BillingLocation } export const LocationCard:FC = ({location: { _id, name, yearMonth, bills }}) => { // sum all the billAmounts const monthlyExpense = bills.reduce((acc, bill) => bill.paid ? acc + (bill.payedAmount ?? 0) : acc, 0); return(

{formatYearMonth(yearMonth)} {name}

{ bills.map(bill => ) }
{ monthlyExpense > 0 ?

Payed total: { formatCurrency(monthlyExpense) }

: null }
); };