refactor: atualizar imports para os novos nomes de tabelas
- Atualizar imports em todos os arquivos que usavam os nomes antigos - Corrigir referências para preferenciasUsuario, insightsSalvos, tokensApi, preLancamentos, antecipacoesParcelas, compartilhamentosPagador
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { pagadores, pagadorShares, user as usersTable } from "@/db/schema";
|
||||
import { pagadores, compartilhamentosPagador, user as usersTable } from "@/db/schema";
|
||||
import { db } from "@/lib/db";
|
||||
|
||||
export type PagadorWithAccess = typeof pagadores.$inferSelect & {
|
||||
@@ -18,15 +18,15 @@ export async function fetchPagadoresWithAccess(
|
||||
}),
|
||||
db
|
||||
.select({
|
||||
shareId: pagadorShares.id,
|
||||
shareId: compartilhamentosPagador.id,
|
||||
pagador: pagadores,
|
||||
ownerName: usersTable.name,
|
||||
ownerEmail: usersTable.email,
|
||||
})
|
||||
.from(pagadorShares)
|
||||
.innerJoin(pagadores, eq(pagadorShares.pagadorId, pagadores.id))
|
||||
.from(compartilhamentosPagador)
|
||||
.innerJoin(pagadores, eq(compartilhamentosPagador.pagadorId, pagadores.id))
|
||||
.leftJoin(usersTable, eq(pagadores.userId, usersTable.id))
|
||||
.where(eq(pagadorShares.sharedWithUserId, userId)),
|
||||
.where(eq(compartilhamentosPagador.sharedWithUserId, userId)),
|
||||
]);
|
||||
|
||||
const ownedMapped: PagadorWithAccess[] = owned.map((item) => ({
|
||||
@@ -62,14 +62,14 @@ export async function getPagadorAccess(userId: string, pagadorId: string) {
|
||||
return {
|
||||
pagador,
|
||||
canEdit: true,
|
||||
share: null as typeof pagadorShares.$inferSelect | null,
|
||||
share: null as typeof compartilhamentosPagador.$inferSelect | null,
|
||||
};
|
||||
}
|
||||
|
||||
const share = await db.query.pagadorShares.findFirst({
|
||||
const share = await db.query.compartilhamentosPagador.findFirst({
|
||||
where: and(
|
||||
eq(pagadorShares.pagadorId, pagadorId),
|
||||
eq(pagadorShares.sharedWithUserId, userId),
|
||||
eq(compartilhamentosPagador.pagadorId, pagadorId),
|
||||
eq(compartilhamentosPagador.sharedWithUserId, userId),
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/**
|
||||
* Pagador constants
|
||||
*
|
||||
* Extracted from /lib/pagadores.ts
|
||||
*/
|
||||
|
||||
export const PAGADOR_STATUS_OPTIONS = ["Ativo", "Inativo"] as const;
|
||||
|
||||
export type PagadorStatus = (typeof PAGADOR_STATUS_OPTIONS)[number];
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/**
|
||||
* Pagador defaults - User seeding logic
|
||||
*
|
||||
* Moved from /lib/pagador-defaults.ts to /lib/pagadores/defaults.ts
|
||||
*/
|
||||
|
||||
import { eq } from "drizzle-orm";
|
||||
import { pagadores } from "@/db/schema";
|
||||
import { db } from "@/lib/db";
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import { cartoes, lancamentos } from "@/db/schema";
|
||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
||||
import { db } from "@/lib/db";
|
||||
import {
|
||||
and,
|
||||
eq,
|
||||
@@ -13,6 +10,9 @@ import {
|
||||
sql,
|
||||
sum,
|
||||
} from "drizzle-orm";
|
||||
import { cartoes, lancamentos } from "@/db/schema";
|
||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
||||
import { db } from "@/lib/db";
|
||||
|
||||
const RECEITA = "Receita";
|
||||
const DESPESA = "Despesa";
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
/**
|
||||
* Pagador utility functions
|
||||
*
|
||||
* Extracted from /lib/pagadores.ts
|
||||
*/
|
||||
|
||||
|
||||
import { DEFAULT_PAGADOR_AVATAR } from "./constants";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user