'client only'; import { Cog8ToothIcon, PlusCircleIcon } from "@heroicons/react/24/outline"; import { FC, ReactNode } 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"; import { useTranslations } from "next-intl"; export interface LocationCardProps { location: BillingLocation } export const LocationCard: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.rich("payed-total", { amount: formatCurrency(monthlyExpense), strong: (chunks:ReactNode) => `${chunks}` })}

: null }
); };