"use client";
import type { Entry } from "@/lib/shared/types";
type EntriesListProps = {
activeGroupId: number | null;
loading: boolean;
entries: Entry[];
visibleEntries: Entry[];
activeFilterCount: number;
onOpenDetails: (entry: Entry, index: number) => void;
onClearFilters: () => void;
};
export default function EntriesList({
activeGroupId,
loading,
entries,
visibleEntries,
activeFilterCount,
onOpenDetails,
onClearFilters
}: EntriesListProps) {
return (
{!activeGroupId ? (
Select a group to view entries.
) : loading ? (
{[0, 1, 2].map(row => (
))}
) : entries.length ? (
visibleEntries.length ? (
visibleEntries.map((entry, index) => {
const tags = entry.tags ?? [];
const mobileTagLimit = 2;
const mobileTags = tags.slice(0, mobileTagLimit);
const extraTagCount = Math.max(tags.length - mobileTagLimit, 0);
return (
onOpenDetails(entry, index)}
>
${entry.amountDollars.toFixed(2)}
{new Date(entry.occurredAt).toISOString().slice(0, 10)} - {entry.necessity}
{tags.length ? (
<>
{mobileTags.map(tag => (
#{tag}
))}
{extraTagCount ? (
{extraTagCount} more...
) : null}
{tags.map(tag => (
#{tag}
))}
>
) : (
No tags
)}
);
})
) : (
No matching entries.
{activeFilterCount ? (
) : null}
)
) : (
No entries yet.
)}
);
}