feat: add uncategorized transaction count and percentage to transactions page; adjust table height for better layout

This commit is contained in:
Julien Froidefond
2025-12-20 11:04:11 +01:00
parent dff2a9061f
commit d61d9181c7
3 changed files with 23 additions and 3 deletions

View File

@@ -112,6 +112,11 @@ export default function TransactionsPage() {
const filteredTransactions = transactionsData?.transactions || []; const filteredTransactions = transactionsData?.transactions || [];
const totalTransactions = transactionsData?.total || 0; const totalTransactions = transactionsData?.total || 0;
const hasMore = transactionsData?.hasMore || false; const hasMore = transactionsData?.hasMore || false;
const uncategorizedCount = transactionsData?.uncategorizedCount || 0;
const uncategorizedPercent =
totalTransactions > 0
? Math.round((uncategorizedCount / totalTransactions) * 100)
: 0;
// For filter comboboxes, we'll use empty arrays for now // For filter comboboxes, we'll use empty arrays for now
// They can be enhanced later with separate queries if needed // They can be enhanced later with separate queries if needed
@@ -133,7 +138,11 @@ export default function TransactionsPage() {
<PageLayout> <PageLayout>
<PageHeader <PageHeader
title="Transactions" title="Transactions"
description={`${totalTransactions} transaction${totalTransactions > 1 ? "s" : ""}`} description={
totalTransactions > 0
? `${totalTransactions} transaction${totalTransactions > 1 ? "s" : ""}${uncategorizedPercent}% non catégorisées`
: `${totalTransactions} transaction${totalTransactions > 1 ? "s" : ""}`
}
actions={ actions={
<OFXImportDialog onImportComplete={invalidateAll}> <OFXImportDialog onImportComplete={invalidateAll}>
<Button className="md:h-10 md:px-5"> <Button className="md:h-10 md:px-5">

View File

@@ -238,7 +238,7 @@ export function TransactionTable({
<div <div
ref={parentRef} ref={parentRef}
className="overflow-auto" className="overflow-auto"
style={{ height: "calc(100vh - 300px)", minHeight: "400px" }} style={{ height: "calc(100vh - 200px)", minHeight: "600px" }}
> >
<div <div
style={{ style={{
@@ -468,7 +468,7 @@ export function TransactionTable({
<div <div
ref={parentRef} ref={parentRef}
className="overflow-auto" className="overflow-auto"
style={{ height: "calc(100vh - 400px)", minHeight: "400px" }} style={{ height: "calc(100vh - 200px)", minHeight: "700px" }}
> >
<div <div
style={{ style={{

View File

@@ -26,6 +26,7 @@ export interface TransactionsPaginatedResult {
transactions: Transaction[]; transactions: Transaction[];
total: number; total: number;
hasMore: boolean; hasMore: boolean;
uncategorizedCount: number;
} }
export const bankingService = { export const bankingService = {
@@ -210,6 +211,15 @@ export const bankingService = {
// Get total count // Get total count
const total = await prisma.transaction.count({ where }); const total = await prisma.transaction.count({ where });
// Get uncategorized count with same filters
const uncategorizedWhere = {
...where,
categoryId: null,
};
const uncategorizedCount = await prisma.transaction.count({
where: uncategorizedWhere,
});
// Get paginated transactions // Get paginated transactions
const transactions = await prisma.transaction.findMany({ const transactions = await prisma.transaction.findMany({
where, where,
@@ -252,6 +262,7 @@ export const bankingService = {
transactions: transformedTransactions, transactions: transformedTransactions,
total, total,
hasMore: offset + limit < total, hasMore: offset + limit < total,
uncategorizedCount,
}; };
}, },