feat: add categorization feature for transaction groups with UI enhancements for category selection
This commit is contained in:
@@ -210,6 +210,25 @@ export default function RulesPage() {
|
||||
}
|
||||
}, [data, refresh]);
|
||||
|
||||
const handleCategorizeGroup = useCallback(
|
||||
async (group: TransactionGroup, categoryId: string | null) => {
|
||||
if (!data) return;
|
||||
|
||||
try {
|
||||
await Promise.all(
|
||||
group.transactions.map((t) =>
|
||||
updateTransaction({ ...t, categoryId })
|
||||
)
|
||||
);
|
||||
refresh();
|
||||
} catch (error) {
|
||||
console.error("Error categorizing group:", error);
|
||||
alert("Erreur lors de la catégorisation");
|
||||
}
|
||||
},
|
||||
[data, refresh]
|
||||
);
|
||||
|
||||
if (isLoading || !data) {
|
||||
return <LoadingState />;
|
||||
}
|
||||
@@ -277,6 +296,9 @@ export default function RulesPage() {
|
||||
isExpanded={expandedGroups.has(group.key)}
|
||||
onToggleExpand={() => toggleExpand(group.key)}
|
||||
onCreateRule={() => handleCreateRule(group)}
|
||||
onCategorize={(categoryId) =>
|
||||
handleCategorizeGroup(group, categoryId)
|
||||
}
|
||||
categories={data.categories}
|
||||
formatCurrency={formatCurrency}
|
||||
formatDate={formatDate}
|
||||
|
||||
Reference in New Issue
Block a user