chore: clean up code by removing trailing whitespace and ensuring consistent formatting across various files = prettier
This commit is contained in:
@@ -11,7 +11,11 @@ import { useBankingData } from "@/lib/hooks";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Sparkles, RefreshCw } from "lucide-react";
|
||||
import { updateCategory, autoCategorize, updateTransaction } from "@/lib/store-db";
|
||||
import {
|
||||
updateCategory,
|
||||
autoCategorize,
|
||||
updateTransaction,
|
||||
} from "@/lib/store-db";
|
||||
import {
|
||||
normalizeDescription,
|
||||
suggestKeyword,
|
||||
@@ -33,7 +37,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);
|
||||
@@ -64,7 +68,7 @@ export default function RulesPage() {
|
||||
totalAmount: transactions.reduce((sum, t) => sum + t.amount, 0),
|
||||
suggestedKeyword: suggestKeyword(descriptions),
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Filter by search query
|
||||
@@ -75,7 +79,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),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -146,14 +150,16 @@ export default function RulesPage() {
|
||||
if (!data) return;
|
||||
|
||||
// 1. Add keyword to category
|
||||
const category = data.categories.find((c) => c.id === ruleData.categoryId);
|
||||
const category = data.categories.find(
|
||||
(c) => c.id === ruleData.categoryId,
|
||||
);
|
||||
if (!category) {
|
||||
throw new Error("Category not found");
|
||||
}
|
||||
|
||||
// Check if keyword already exists
|
||||
const keywordExists = category.keywords.some(
|
||||
(k) => k.toLowerCase() === ruleData.keyword.toLowerCase()
|
||||
(k) => k.toLowerCase() === ruleData.keyword.toLowerCase(),
|
||||
);
|
||||
|
||||
if (!keywordExists) {
|
||||
@@ -166,19 +172,19 @@ export default function RulesPage() {
|
||||
// 2. Apply to existing transactions if requested
|
||||
if (ruleData.applyToExisting) {
|
||||
const transactions = data.transactions.filter((t) =>
|
||||
ruleData.transactionIds.includes(t.id)
|
||||
ruleData.transactionIds.includes(t.id),
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
transactions.map((t) =>
|
||||
updateTransaction({ ...t, categoryId: ruleData.categoryId })
|
||||
)
|
||||
updateTransaction({ ...t, categoryId: ruleData.categoryId }),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
refresh();
|
||||
},
|
||||
[data, refresh]
|
||||
[data, refresh],
|
||||
);
|
||||
|
||||
const handleAutoCategorize = useCallback(async () => {
|
||||
@@ -192,7 +198,7 @@ export default function RulesPage() {
|
||||
for (const transaction of uncategorized) {
|
||||
const categoryId = autoCategorize(
|
||||
transaction.description + " " + (transaction.memo || ""),
|
||||
data.categories
|
||||
data.categories,
|
||||
);
|
||||
if (categoryId) {
|
||||
await updateTransaction({ ...transaction, categoryId });
|
||||
@@ -201,7 +207,9 @@ export default function RulesPage() {
|
||||
}
|
||||
|
||||
refresh();
|
||||
alert(`${categorizedCount} transaction(s) catégorisée(s) automatiquement`);
|
||||
alert(
|
||||
`${categorizedCount} transaction(s) catégorisée(s) automatiquement`,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error auto-categorizing:", error);
|
||||
alert("Erreur lors de la catégorisation automatique");
|
||||
@@ -217,8 +225,8 @@ export default function RulesPage() {
|
||||
try {
|
||||
await Promise.all(
|
||||
group.transactions.map((t) =>
|
||||
updateTransaction({ ...t, categoryId })
|
||||
)
|
||||
updateTransaction({ ...t, categoryId }),
|
||||
),
|
||||
);
|
||||
refresh();
|
||||
} catch (error) {
|
||||
@@ -226,7 +234,7 @@ export default function RulesPage() {
|
||||
alert("Erreur lors de la catégorisation");
|
||||
}
|
||||
},
|
||||
[data, refresh]
|
||||
[data, refresh],
|
||||
);
|
||||
|
||||
if (isLoading || !data) {
|
||||
@@ -241,7 +249,8 @@ export default function RulesPage() {
|
||||
<span className="flex items-center gap-2 flex-wrap">
|
||||
<span className="text-xs md:text-base">
|
||||
{transactionGroups.length} groupe
|
||||
{transactionGroups.length > 1 ? "s" : ""} de transactions similaires
|
||||
{transactionGroups.length > 1 ? "s" : ""} de transactions
|
||||
similaires
|
||||
</span>
|
||||
<Badge variant="secondary" className="text-[10px] md:text-xs">
|
||||
{uncategorizedCount} non catégorisées
|
||||
@@ -321,4 +330,3 @@ export default function RulesPage() {
|
||||
</PageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user