style: clean up code formatting and remove trailing whitespace

refactor: reorganize imports and fix type imports
This commit is contained in:
Evandro Fonseca Junior committed 2025-11-11 03:08:36 -03:00
1 parent d3704602fd
commit 47c04de6fe
232 files changed
+7140 -4798

No files matched your search

+14 -12
View File
@@ -61,7 +61,7 @@ export interface UpdateTransactionStatusData {
* Cria uma nova transação
*/
export async function createTransaction(
data: CreateTransactionData
data: CreateTransactionData,
): Promise<Transaction> {
// Calcular escrow_fee se não fornecido (2% do valor)
const escrowFee = data.escrow_fee ?? Number((data.amount * 0.02).toFixed(2));
@@ -85,7 +85,7 @@ export async function createTransaction(
data.amount,
data.payment_method,
escrowFee,
]
],
);
return result.rows[0];
@@ -95,13 +95,13 @@ export async function createTransaction(
* Busca transação por ID
*/
export async function getTransactionById(
transactionId: number
transactionId: number,
): Promise<Transaction | null> {
const result = await query<Transaction>(
`
SELECT * FROM transactions WHERE transaction_id = $1
`,
[transactionId]
[transactionId],
);
return result.rows[0] || null;
@@ -112,7 +112,7 @@ export async function getTransactionById(
*/
export async function updateTransactionStatus(
transactionId: number,
data: UpdateTransactionStatusData
data: UpdateTransactionStatusData,
): Promise<Transaction | null> {
const updates: string[] = [];
const params: any[] = [];
@@ -172,7 +172,7 @@ export async function updateTransactionStatus(
WHERE transaction_id = $${paramIndex}
RETURNING *
`,
params
params,
);
return result.rows[0] || null;
@@ -188,7 +188,7 @@ export async function getTransactionsByUser(
status?: Transaction["transaction_status"];
page?: number;
pageSize?: number;
} = {}
} = {},
): Promise<{ transactions: Transaction[]; total: number }> {
const { role = "both", status, page = 1, pageSize = 20 } = filters;
@@ -201,7 +201,9 @@ export async function getTransactionsByUser(
} else if (role === "seller") {
conditions.push(`seller_id = $${paramIndex}`);
} else {
conditions.push(`(buyer_id = $${paramIndex} OR seller_id = $${paramIndex})`);
conditions.push(
`(buyer_id = $${paramIndex} OR seller_id = $${paramIndex})`,
);
}
params.push(userId);
paramIndex++;
@@ -212,12 +214,13 @@ export async function getTransactionsByUser(
paramIndex++;
}
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
const whereClause =
conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
// Contar total
const countResult = await query<{ count: string }>(
`SELECT COUNT(*) as count FROM transactions ${whereClause}`,
params
params,
);
const total = parseInt(countResult.rows[0].count, 10);
@@ -230,7 +233,7 @@ export async function getTransactionsByUser(
ORDER BY created_at DESC
LIMIT $${paramIndex} OFFSET $${paramIndex + 1}
`,
[...params, pageSize, offset]
[...params, pageSize, offset],
);
return {
@@ -238,4 +241,3 @@ export async function getTransactionsByUser(
total,
};
}