import { A } from "@solidjs/router" import { Show } from "solid-js" import { getProfilePicture } from "applesauce-core/helpers/profile" import { invoiceStatus, type Invoice } from "@/lib/api" import CopyNpub from "@/components/CopyNpub" import { useProfileMetadata } from "@/lib/hooks" import { formatPeriod, formatUsd } from "@/lib/format" const invoiceStatusStyles: Record = { open: "bg-yellow-50 text-yellow-700 border-yellow-200", paid: "bg-green-50 text-green-700 border-green-200", void: "bg-gray-100 text-gray-500 border-gray-200", } type AdminInvoiceListItemProps = { invoice: Invoice href: string showTenant?: boolean } export default function AdminInvoiceListItem(props: AdminInvoiceListItemProps) { // Resolve the owning tenant's profile from the event store. The list that // passes `showTenant` is responsible for priming these profiles in one batch, // so this subscription does not prime on its own. const metadata = useProfileMetadata(() => (props.showTenant ? props.invoice.tenant_pubkey : undefined), { prime: false }) const status = () => invoiceStatus(props.invoice) return (
  • {formatUsd(props.invoice.amount)}

    {formatPeriod(props.invoice.period_start, props.invoice.period_end)}

    {((metadata()?.name || metadata()?.display_name) || props.invoice.tenant_pubkey).slice(0, 1).toUpperCase()}
    } >
    } > {metadata()?.name || metadata()?.display_name}
    {status()}
  • ) }