forked from git.gladyson/openmonetis
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:
@@ -3,7 +3,7 @@
|
||||
import { and, eq, inArray } from "drizzle-orm";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { z } from "zod";
|
||||
import { inboxItems } from "@/db/schema";
|
||||
import { preLancamentos } from "@/db/schema";
|
||||
import { handleActionError } from "@/lib/actions/helpers";
|
||||
import type { ActionResult } from "@/lib/actions/types";
|
||||
import { getUser } from "@/lib/auth/server";
|
||||
@@ -40,12 +40,12 @@ export async function markInboxAsProcessedAction(
|
||||
// Verificar se item existe e pertence ao usuário
|
||||
const [item] = await db
|
||||
.select()
|
||||
.from(inboxItems)
|
||||
.from(preLancamentos)
|
||||
.where(
|
||||
and(
|
||||
eq(inboxItems.id, data.inboxItemId),
|
||||
eq(inboxItems.userId, user.id),
|
||||
eq(inboxItems.status, "pending"),
|
||||
eq(preLancamentos.id, data.inboxItemId),
|
||||
eq(preLancamentos.userId, user.id),
|
||||
eq(preLancamentos.status, "pending"),
|
||||
),
|
||||
)
|
||||
.limit(1);
|
||||
@@ -56,13 +56,13 @@ export async function markInboxAsProcessedAction(
|
||||
|
||||
// Marcar item como processado
|
||||
await db
|
||||
.update(inboxItems)
|
||||
.update(preLancamentos)
|
||||
.set({
|
||||
status: "processed",
|
||||
processedAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(inboxItems.id, data.inboxItemId));
|
||||
.where(eq(preLancamentos.id, data.inboxItemId));
|
||||
|
||||
revalidateInbox();
|
||||
|
||||
@@ -82,12 +82,12 @@ export async function discardInboxItemAction(
|
||||
// Verificar se item existe e pertence ao usuário
|
||||
const [item] = await db
|
||||
.select()
|
||||
.from(inboxItems)
|
||||
.from(preLancamentos)
|
||||
.where(
|
||||
and(
|
||||
eq(inboxItems.id, data.inboxItemId),
|
||||
eq(inboxItems.userId, user.id),
|
||||
eq(inboxItems.status, "pending"),
|
||||
eq(preLancamentos.id, data.inboxItemId),
|
||||
eq(preLancamentos.userId, user.id),
|
||||
eq(preLancamentos.status, "pending"),
|
||||
),
|
||||
)
|
||||
.limit(1);
|
||||
@@ -98,13 +98,13 @@ export async function discardInboxItemAction(
|
||||
|
||||
// Marcar item como descartado
|
||||
await db
|
||||
.update(inboxItems)
|
||||
.update(preLancamentos)
|
||||
.set({
|
||||
status: "discarded",
|
||||
discardedAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(inboxItems.id, data.inboxItemId));
|
||||
.where(eq(preLancamentos.id, data.inboxItemId));
|
||||
|
||||
revalidateInbox();
|
||||
|
||||
@@ -123,7 +123,7 @@ export async function bulkDiscardInboxItemsAction(
|
||||
|
||||
// Marcar todos os itens como descartados
|
||||
await db
|
||||
.update(inboxItems)
|
||||
.update(preLancamentos)
|
||||
.set({
|
||||
status: "discarded",
|
||||
discardedAt: new Date(),
|
||||
@@ -131,9 +131,9 @@ export async function bulkDiscardInboxItemsAction(
|
||||
})
|
||||
.where(
|
||||
and(
|
||||
inArray(inboxItems.id, data.inboxItemIds),
|
||||
eq(inboxItems.userId, user.id),
|
||||
eq(inboxItems.status, "pending"),
|
||||
inArray(preLancamentos.id, data.inboxItemIds),
|
||||
eq(preLancamentos.userId, user.id),
|
||||
eq(preLancamentos.status, "pending"),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Data fetching functions for Pré-Lançamentos
|
||||
*/
|
||||
|
||||
|
||||
import { and, desc, eq, gte } from "drizzle-orm";
|
||||
import type {
|
||||
@@ -11,7 +9,7 @@ import {
|
||||
cartoes,
|
||||
categorias,
|
||||
contas,
|
||||
inboxItems,
|
||||
preLancamentos,
|
||||
lancamentos,
|
||||
} from "@/db/schema";
|
||||
import { db } from "@/lib/db";
|
||||
@@ -27,9 +25,9 @@ export async function fetchInboxItems(
|
||||
): Promise<InboxItem[]> {
|
||||
const items = await db
|
||||
.select()
|
||||
.from(inboxItems)
|
||||
.where(and(eq(inboxItems.userId, userId), eq(inboxItems.status, status)))
|
||||
.orderBy(desc(inboxItems.createdAt));
|
||||
.from(preLancamentos)
|
||||
.where(and(eq(preLancamentos.userId, userId), eq(preLancamentos.status, status)))
|
||||
.orderBy(desc(preLancamentos.createdAt));
|
||||
|
||||
return items;
|
||||
}
|
||||
@@ -40,8 +38,8 @@ export async function fetchInboxItemById(
|
||||
): Promise<InboxItem | null> {
|
||||
const [item] = await db
|
||||
.select()
|
||||
.from(inboxItems)
|
||||
.where(and(eq(inboxItems.id, itemId), eq(inboxItems.userId, userId)))
|
||||
.from(preLancamentos)
|
||||
.where(and(eq(preLancamentos.id, itemId), eq(preLancamentos.userId, userId)))
|
||||
.limit(1);
|
||||
|
||||
return item ?? null;
|
||||
@@ -90,10 +88,10 @@ export async function fetchCartoesForSelect(
|
||||
|
||||
export async function fetchPendingInboxCount(userId: string): Promise<number> {
|
||||
const items = await db
|
||||
.select({ id: inboxItems.id })
|
||||
.from(inboxItems)
|
||||
.select({ id: preLancamentos.id })
|
||||
.from(preLancamentos)
|
||||
.where(
|
||||
and(eq(inboxItems.userId, userId), eq(inboxItems.status, "pending")),
|
||||
and(eq(preLancamentos.userId, userId), eq(preLancamentos.status, "pending")),
|
||||
);
|
||||
|
||||
return items.length;
|
||||
|
||||
Reference in New Issue
Block a user