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:
Felipe Coutinho
2026-01-27 14:19:46 +00:00
parent cbfed98882
commit 2eafceb6d3
40 changed files with 241 additions and 352 deletions

View File

@@ -5,7 +5,7 @@ import {
contas,
lancamentos,
pagadores,
pagadorShares,
compartilhamentosPagador,
user as usersTable,
} from "@/db/schema";
import { db } from "@/lib/db";
@@ -23,15 +23,15 @@ export async function fetchPagadorShares(
): Promise<ShareData[]> {
const shareRows = await db
.select({
id: pagadorShares.id,
sharedWithUserId: pagadorShares.sharedWithUserId,
createdAt: pagadorShares.createdAt,
id: compartilhamentosPagador.id,
sharedWithUserId: compartilhamentosPagador.sharedWithUserId,
createdAt: compartilhamentosPagador.createdAt,
userName: usersTable.name,
userEmail: usersTable.email,
})
.from(pagadorShares)
.innerJoin(usersTable, eq(pagadorShares.sharedWithUserId, usersTable.id))
.where(eq(pagadorShares.pagadorId, pagadorId));
.from(compartilhamentosPagador)
.innerJoin(usersTable, eq(compartilhamentosPagador.sharedWithUserId, usersTable.id))
.where(eq(compartilhamentosPagador.pagadorId, pagadorId));
return shareRows.map((share) => ({
id: share.id,
@@ -46,14 +46,14 @@ export async function fetchCurrentUserShare(
pagadorId: string,
userId: string,
): Promise<{ id: string; createdAt: string } | null> {
const shareRow = await db.query.pagadorShares.findFirst({
const shareRow = await db.query.compartilhamentosPagador.findFirst({
columns: {
id: true,
createdAt: true,
},
where: and(
eq(pagadorShares.pagadorId, pagadorId),
eq(pagadorShares.sharedWithUserId, userId),
eq(compartilhamentosPagador.pagadorId, pagadorId),
eq(compartilhamentosPagador.sharedWithUserId, userId),
),
});

View File

@@ -4,7 +4,7 @@ import { randomBytes } from "node:crypto";
import { and, eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { z } from "zod";
import { pagadores, pagadorShares, user } from "@/db/schema";
import { pagadores, compartilhamentosPagador, user } from "@/db/schema";
import { handleActionError, revalidateForEntity } from "@/lib/actions/helpers";
import type { ActionResult } from "@/lib/actions/types";
import { getUser } from "@/lib/auth/server";
@@ -223,10 +223,10 @@ export async function joinPagadorByShareCodeAction(
};
}
const existingShare = await db.query.pagadorShares.findFirst({
const existingShare = await db.query.compartilhamentosPagador.findFirst({
where: and(
eq(pagadorShares.pagadorId, pagadorRow.id),
eq(pagadorShares.sharedWithUserId, user.id),
eq(compartilhamentosPagador.pagadorId, pagadorRow.id),
eq(compartilhamentosPagador.sharedWithUserId, user.id),
),
});
@@ -237,7 +237,7 @@ export async function joinPagadorByShareCodeAction(
};
}
await db.insert(pagadorShares).values({
await db.insert(compartilhamentosPagador).values({
pagadorId: pagadorRow.id,
sharedWithUserId: user.id,
permission: "read",
@@ -259,13 +259,13 @@ export async function deletePagadorShareAction(
const user = await getUser();
const data = shareDeleteSchema.parse(input);
const existing = await db.query.pagadorShares.findFirst({
const existing = await db.query.compartilhamentosPagador.findFirst({
columns: {
id: true,
pagadorId: true,
sharedWithUserId: true,
},
where: eq(pagadorShares.id, data.shareId),
where: eq(compartilhamentosPagador.id, data.shareId),
with: {
pagador: {
columns: {
@@ -287,7 +287,7 @@ export async function deletePagadorShareAction(
};
}
await db.delete(pagadorShares).where(eq(pagadorShares.id, data.shareId));
await db.delete(compartilhamentosPagador).where(eq(compartilhamentosPagador.id, data.shareId));
revalidate();
revalidatePath(`/pagadores/${existing.pagadorId}`);