refactor: standardize code formatting and improve consistency across various components and API routes for enhanced readability and maintainability
This commit is contained in:
@@ -46,7 +46,7 @@ export default function RulesPage() {
|
||||
offset: 0,
|
||||
includeUncategorized: true,
|
||||
},
|
||||
!!metadata
|
||||
!!metadata,
|
||||
);
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
@@ -58,7 +58,7 @@ export default function RulesPage() {
|
||||
const [filterMinCount, setFilterMinCount] = useState(2);
|
||||
const [expandedGroups, setExpandedGroups] = useState<Set<string>>(new Set());
|
||||
const [selectedGroup, setSelectedGroup] = useState<TransactionGroup | null>(
|
||||
null
|
||||
null,
|
||||
);
|
||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||
const [isAutoCategorizing, setIsAutoCategorizing] = useState(false);
|
||||
@@ -89,7 +89,7 @@ export default function RulesPage() {
|
||||
totalAmount: transactions.reduce((sum, t) => sum + t.amount, 0),
|
||||
suggestedKeyword: suggestKeyword(descriptions),
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Filter by search query
|
||||
@@ -100,7 +100,7 @@ export default function RulesPage() {
|
||||
(g) =>
|
||||
g.displayName.toLowerCase().includes(query) ||
|
||||
g.key.includes(query) ||
|
||||
g.suggestedKeyword.toLowerCase().includes(query)
|
||||
g.suggestedKeyword.toLowerCase().includes(query),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ export default function RulesPage() {
|
||||
|
||||
// 1. Add keyword to category
|
||||
const category = metadata.categories.find(
|
||||
(c: { id: string }) => c.id === ruleData.categoryId
|
||||
(c: { id: string }) => c.id === ruleData.categoryId,
|
||||
);
|
||||
if (!category) {
|
||||
throw new Error("Category not found");
|
||||
@@ -177,7 +177,7 @@ export default function RulesPage() {
|
||||
|
||||
// Check if keyword already exists
|
||||
const keywordExists = category.keywords.some(
|
||||
(k: string) => k.toLowerCase() === ruleData.keyword.toLowerCase()
|
||||
(k: string) => k.toLowerCase() === ruleData.keyword.toLowerCase(),
|
||||
);
|
||||
|
||||
if (!keywordExists) {
|
||||
@@ -195,8 +195,8 @@ export default function RulesPage() {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ id, categoryId: ruleData.categoryId }),
|
||||
})
|
||||
)
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ export default function RulesPage() {
|
||||
invalidateAllTransactionQueries(queryClient);
|
||||
invalidateAllCategoryQueries(queryClient);
|
||||
},
|
||||
[metadata, queryClient]
|
||||
[metadata, queryClient],
|
||||
);
|
||||
|
||||
const handleAutoCategorize = useCallback(async () => {
|
||||
@@ -218,7 +218,7 @@ export default function RulesPage() {
|
||||
for (const transaction of uncategorized) {
|
||||
const categoryId = autoCategorize(
|
||||
transaction.description + " " + (transaction.memo || ""),
|
||||
metadata.categories
|
||||
metadata.categories,
|
||||
);
|
||||
if (categoryId) {
|
||||
await fetch("/api/banking/transactions", {
|
||||
@@ -234,7 +234,7 @@ export default function RulesPage() {
|
||||
invalidateAllTransactionQueries(queryClient);
|
||||
invalidateAllCategoryQueries(queryClient);
|
||||
alert(
|
||||
`${categorizedCount} transaction(s) catégorisée(s) automatiquement`
|
||||
`${categorizedCount} transaction(s) catégorisée(s) automatiquement`,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error auto-categorizing:", error);
|
||||
@@ -253,8 +253,8 @@ export default function RulesPage() {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ ...t, categoryId }),
|
||||
})
|
||||
)
|
||||
}),
|
||||
),
|
||||
);
|
||||
// Invalider toutes les queries liées
|
||||
invalidateAllTransactionQueries(queryClient);
|
||||
@@ -264,7 +264,7 @@ export default function RulesPage() {
|
||||
alert("Erreur lors de la catégorisation");
|
||||
}
|
||||
},
|
||||
[queryClient]
|
||||
[queryClient],
|
||||
);
|
||||
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user