chore: clean up code by removing trailing whitespace and ensuring consistent formatting across various files = prettier
This commit is contained in:
@@ -43,12 +43,12 @@ export function AccountFilterCombobox({
|
||||
// Calculate total amount per account based on filtered transactions
|
||||
const accountTotals = useMemo(() => {
|
||||
if (!filteredTransactions) return {};
|
||||
|
||||
|
||||
const totals: Record<string, number> = {};
|
||||
filteredTransactions.forEach((t) => {
|
||||
totals[t.accountId] = (totals[t.accountId] || 0) + t.amount;
|
||||
});
|
||||
|
||||
|
||||
return totals;
|
||||
}, [filteredTransactions]);
|
||||
|
||||
@@ -64,7 +64,7 @@ export function AccountFilterCombobox({
|
||||
// Get root folders (folders without parent) - same as folders/page.tsx
|
||||
const rootFolders = useMemo(
|
||||
() => folders.filter((f) => f.parentId === null),
|
||||
[folders]
|
||||
[folders],
|
||||
);
|
||||
|
||||
// Get child folders for a given parent - same as FolderTreeItem
|
||||
@@ -78,7 +78,7 @@ export function AccountFilterCombobox({
|
||||
// Get accounts without folder
|
||||
const orphanAccounts = useMemo(
|
||||
() => accounts.filter((a) => !a.folderId),
|
||||
[accounts]
|
||||
[accounts],
|
||||
);
|
||||
|
||||
const selectedAccounts = accounts.filter((a) => value.includes(a.id));
|
||||
@@ -89,7 +89,7 @@ export function AccountFilterCombobox({
|
||||
const directAccounts = getFolderAccounts(folderId);
|
||||
const childFoldersList = getChildFolders(folderId);
|
||||
const childAccounts = childFoldersList.flatMap((cf) =>
|
||||
getAllAccountsInFolder(cf.id)
|
||||
getAllAccountsInFolder(cf.id),
|
||||
);
|
||||
return [...directAccounts, ...childAccounts];
|
||||
};
|
||||
@@ -126,7 +126,7 @@ export function AccountFilterCombobox({
|
||||
|
||||
if (allSelected) {
|
||||
const newSelection = value.filter(
|
||||
(v) => !allFolderAccountIds.includes(v)
|
||||
(v) => !allFolderAccountIds.includes(v),
|
||||
);
|
||||
onChange(newSelection.length > 0 ? newSelection : ["all"]);
|
||||
} else {
|
||||
@@ -153,7 +153,7 @@ export function AccountFilterCombobox({
|
||||
const folderAccounts = getAllAccountsInFolder(folderId);
|
||||
if (folderAccounts.length === 0) return false;
|
||||
const selectedCount = folderAccounts.filter((a) =>
|
||||
value.includes(a.id)
|
||||
value.includes(a.id),
|
||||
).length;
|
||||
return selectedCount > 0 && selectedCount < folderAccounts.length;
|
||||
};
|
||||
@@ -162,7 +162,9 @@ export function AccountFilterCombobox({
|
||||
const renderFolder = (folder: Folder, depth: number, parentPath: string) => {
|
||||
const folderAccounts = getFolderAccounts(folder.id);
|
||||
const childFoldersList = getChildFolders(folder.id);
|
||||
const currentPath = parentPath ? `${parentPath} ${folder.name}` : folder.name;
|
||||
const currentPath = parentPath
|
||||
? `${parentPath} ${folder.name}`
|
||||
: folder.name;
|
||||
const paddingLeft = depth * 16 + 8;
|
||||
|
||||
return (
|
||||
@@ -183,7 +185,7 @@ export function AccountFilterCombobox({
|
||||
<Check
|
||||
className={cn(
|
||||
"h-4 w-4",
|
||||
isFolderSelected(folder.id) ? "opacity-100" : "opacity-0"
|
||||
isFolderSelected(folder.id) ? "opacity-100" : "opacity-0",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
@@ -211,7 +213,7 @@ export function AccountFilterCombobox({
|
||||
<Check
|
||||
className={cn(
|
||||
"ml-auto h-4 w-4 shrink-0",
|
||||
value.includes(account.id) ? "opacity-100" : "opacity-0"
|
||||
value.includes(account.id) ? "opacity-100" : "opacity-0",
|
||||
)}
|
||||
/>
|
||||
</CommandItem>
|
||||
@@ -220,7 +222,7 @@ export function AccountFilterCombobox({
|
||||
|
||||
{/* Child folders - recursive */}
|
||||
{childFoldersList.map((childFolder) =>
|
||||
renderFolder(childFolder, depth + 1, currentPath)
|
||||
renderFolder(childFolder, depth + 1, currentPath),
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
@@ -239,10 +241,15 @@ export function AccountFilterCombobox({
|
||||
{selectedAccounts.length === 1 ? (
|
||||
<>
|
||||
{(() => {
|
||||
const AccountIcon = accountTypeIcons[selectedAccounts[0].type];
|
||||
return <AccountIcon className="h-4 w-4 text-muted-foreground shrink-0" />;
|
||||
const AccountIcon =
|
||||
accountTypeIcons[selectedAccounts[0].type];
|
||||
return (
|
||||
<AccountIcon className="h-4 w-4 text-muted-foreground shrink-0" />
|
||||
);
|
||||
})()}
|
||||
<span className="truncate text-left">{selectedAccounts[0].name}</span>
|
||||
<span className="truncate text-left">
|
||||
{selectedAccounts[0].name}
|
||||
</span>
|
||||
</>
|
||||
) : selectedAccounts.length > 1 ? (
|
||||
<>
|
||||
@@ -254,7 +261,9 @@ export function AccountFilterCombobox({
|
||||
) : (
|
||||
<>
|
||||
<Wallet className="h-4 w-4 text-muted-foreground shrink-0" />
|
||||
<span className="text-muted-foreground truncate text-left">Tous les comptes</span>
|
||||
<span className="text-muted-foreground truncate text-left">
|
||||
Tous les comptes
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
@@ -290,15 +299,20 @@ export function AccountFilterCombobox({
|
||||
<span>Tous les comptes</span>
|
||||
{filteredTransactions && (
|
||||
<span className="text-xs text-muted-foreground ml-1">
|
||||
({formatCurrency(
|
||||
filteredTransactions.reduce((sum, t) => sum + t.amount, 0)
|
||||
)})
|
||||
(
|
||||
{formatCurrency(
|
||||
filteredTransactions.reduce(
|
||||
(sum, t) => sum + t.amount,
|
||||
0,
|
||||
),
|
||||
)}
|
||||
)
|
||||
</span>
|
||||
)}
|
||||
<Check
|
||||
className={cn(
|
||||
"ml-auto h-4 w-4",
|
||||
isAll ? "opacity-100" : "opacity-0"
|
||||
isAll ? "opacity-100" : "opacity-0",
|
||||
)}
|
||||
/>
|
||||
</CommandItem>
|
||||
@@ -321,7 +335,9 @@ export function AccountFilterCombobox({
|
||||
className="min-w-0"
|
||||
>
|
||||
<AccountIcon className="h-4 w-4 text-muted-foreground shrink-0" />
|
||||
<span className="truncate min-w-0 flex-1">{account.name}</span>
|
||||
<span className="truncate min-w-0 flex-1">
|
||||
{account.name}
|
||||
</span>
|
||||
{total !== undefined && (
|
||||
<span className="text-xs text-muted-foreground ml-1 shrink-0">
|
||||
({formatCurrency(total)})
|
||||
@@ -330,7 +346,9 @@ export function AccountFilterCombobox({
|
||||
<Check
|
||||
className={cn(
|
||||
"ml-auto h-4 w-4 shrink-0",
|
||||
value.includes(account.id) ? "opacity-100" : "opacity-0"
|
||||
value.includes(account.id)
|
||||
? "opacity-100"
|
||||
: "opacity-0",
|
||||
)}
|
||||
/>
|
||||
</CommandItem>
|
||||
|
||||
Reference in New Issue
Block a user