'use client'; import { FC } from "react"; import { BillingLocation } from "../lib/db-types"; import { formatYearMonth } from "../lib/format"; import { formatCurrency } from "../lib/formatStrings"; import { useTranslations } from "next-intl"; import { ViewBillBadge } from "./ViewBillBadge"; export interface ViewLocationCardProps { location: BillingLocation } export const ViewLocationCard:FC = ({location: { _id, name, yearMonth, bills }}) => { const t = useTranslations("home-page.location-card"); // 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 ?

{ t("payed-total-label") } ${formatCurrency(monthlyExpense)}

: null }
); };