refactor: standardize code formatting and improve consistency across various components and API routes for enhanced readability and maintainability
This commit is contained in:
@@ -68,7 +68,7 @@ function FolderDropZone({
|
||||
<div
|
||||
ref={setNodeRef}
|
||||
className={cn(
|
||||
isOver && "ring-2 ring-primary ring-offset-2 rounded-lg p-2"
|
||||
isOver && "ring-2 ring-primary ring-offset-2 rounded-lg p-2",
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
@@ -91,7 +91,7 @@ export default function AccountsPage() {
|
||||
const [editingAccount, setEditingAccount] = useState<Account | null>(null);
|
||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||
const [selectedAccounts, setSelectedAccounts] = useState<Set<string>>(
|
||||
new Set()
|
||||
new Set(),
|
||||
);
|
||||
const [formData, setFormData] = useState({
|
||||
name: "",
|
||||
@@ -117,7 +117,7 @@ export default function AccountsPage() {
|
||||
activationConstraint: {
|
||||
distance: 8,
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
if (
|
||||
@@ -131,7 +131,7 @@ export default function AccountsPage() {
|
||||
|
||||
// Convert accountsWithStats to regular accounts for compatibility
|
||||
const accounts = accountsWithStats.map(
|
||||
({ transactionCount: _transactionCount, ...account }) => account
|
||||
({ transactionCount: _transactionCount, ...account }) => account,
|
||||
);
|
||||
|
||||
const formatCurrency = (amount: number) => {
|
||||
@@ -191,7 +191,7 @@ export default function AccountsPage() {
|
||||
const count = selectedAccounts.size;
|
||||
if (
|
||||
!confirm(
|
||||
`Supprimer ${count} compte${count > 1 ? "s" : ""} et toutes leurs transactions ?`
|
||||
`Supprimer ${count} compte${count > 1 ? "s" : ""} et toutes leurs transactions ?`,
|
||||
)
|
||||
)
|
||||
return;
|
||||
@@ -202,7 +202,7 @@ export default function AccountsPage() {
|
||||
`/api/banking/accounts?ids=${ids.join(",")}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
}
|
||||
},
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete accounts");
|
||||
@@ -275,7 +275,7 @@ export default function AccountsPage() {
|
||||
const handleDeleteFolder = async (folderId: string) => {
|
||||
if (
|
||||
!confirm(
|
||||
"Supprimer ce dossier ? Les comptes seront déplacés à la racine."
|
||||
"Supprimer ce dossier ? Les comptes seront déplacés à la racine.",
|
||||
)
|
||||
)
|
||||
return;
|
||||
@@ -315,7 +315,7 @@ export default function AccountsPage() {
|
||||
// Déplacer vers le dossier du compte cible
|
||||
const targetAccountId = overId.replace("account-", "");
|
||||
const targetAccount = accountsWithStats.find(
|
||||
(a) => a.id === targetAccountId
|
||||
(a) => a.id === targetAccountId,
|
||||
);
|
||||
if (targetAccount) {
|
||||
targetFolderId = targetAccount.folderId;
|
||||
@@ -337,7 +337,7 @@ export default function AccountsPage() {
|
||||
(old: Array<Account & { transactionCount: number }> | undefined) => {
|
||||
if (!old) return old;
|
||||
return old.map((a) => (a.id === accountId ? updatedAccount : a));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Faire la requête en arrière-plan
|
||||
@@ -362,7 +362,7 @@ export default function AccountsPage() {
|
||||
|
||||
const totalBalance = accounts.reduce(
|
||||
(sum, a) => sum + getAccountBalance(a),
|
||||
0
|
||||
0,
|
||||
);
|
||||
|
||||
// Grouper les comptes par folder
|
||||
@@ -375,7 +375,7 @@ export default function AccountsPage() {
|
||||
acc[folderId].push(account);
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, Account[]>
|
||||
{} as Record<string, Account[]>,
|
||||
);
|
||||
|
||||
// Obtenir les folders racine (sans parent) et les trier par nom
|
||||
@@ -429,7 +429,7 @@ export default function AccountsPage() {
|
||||
className={cn(
|
||||
isMobile ? "text-xl" : "text-2xl",
|
||||
"font-bold",
|
||||
totalBalance >= 0 ? "text-emerald-600" : "text-red-600"
|
||||
totalBalance >= 0 ? "text-emerald-600" : "text-red-600",
|
||||
)}
|
||||
>
|
||||
{isMobile && (
|
||||
@@ -486,17 +486,17 @@ export default function AccountsPage() {
|
||||
"text-xs sm:text-sm font-semibold tabular-nums shrink-0",
|
||||
accountsByFolder["no-folder"].reduce(
|
||||
(sum, a) => sum + getAccountBalance(a),
|
||||
0
|
||||
0,
|
||||
) >= 0
|
||||
? "text-emerald-600"
|
||||
: "text-red-600"
|
||||
: "text-red-600",
|
||||
)}
|
||||
>
|
||||
{formatCurrency(
|
||||
accountsByFolder["no-folder"].reduce(
|
||||
(sum, a) => sum + getAccountBalance(a),
|
||||
0
|
||||
)
|
||||
0,
|
||||
),
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
@@ -505,7 +505,7 @@ export default function AccountsPage() {
|
||||
<div className="grid gap-2 sm:gap-3 md:gap-4 grid-cols-2 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{accountsByFolder["no-folder"].map((account) => {
|
||||
const folder = metadata.folders.find(
|
||||
(f: FolderType) => f.id === account.folderId
|
||||
(f: FolderType) => f.id === account.folderId,
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -533,7 +533,7 @@ export default function AccountsPage() {
|
||||
const folderAccounts = accountsByFolder[folder.id] || [];
|
||||
const folderBalance = folderAccounts.reduce(
|
||||
(sum, a) => sum + getAccountBalance(a),
|
||||
0
|
||||
0,
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -562,7 +562,7 @@ export default function AccountsPage() {
|
||||
"text-xs sm:text-sm font-semibold tabular-nums shrink-0",
|
||||
folderBalance >= 0
|
||||
? "text-emerald-600"
|
||||
: "text-red-600"
|
||||
: "text-red-600",
|
||||
)}
|
||||
>
|
||||
{formatCurrency(folderBalance)}
|
||||
@@ -622,7 +622,7 @@ export default function AccountsPage() {
|
||||
<div className="grid gap-2 sm:gap-3 md:gap-4 grid-cols-2 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{folderAccounts.map((account) => {
|
||||
const accountFolder = metadata.folders.find(
|
||||
(f: FolderType) => f.id === account.folderId
|
||||
(f: FolderType) => f.id === account.folderId,
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -666,7 +666,7 @@ export default function AccountsPage() {
|
||||
<Card>
|
||||
<CardContent className="p-4">
|
||||
{accounts.find(
|
||||
(a) => a.id === activeId.replace("account-", "")
|
||||
(a) => a.id === activeId.replace("account-", ""),
|
||||
)?.name || ""}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user