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,8 +1,4 @@
|
||||
/**
|
||||
* API Token utilities for OpenSheets Companion
|
||||
*
|
||||
* Handles JWT generation, validation, and token hashing for device authentication.
|
||||
*/
|
||||
|
||||
|
||||
import crypto from "node:crypto";
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
/**
|
||||
* Better Auth Configuration
|
||||
*
|
||||
* Configuração central de autenticação usando Better Auth.
|
||||
* Suporta email/password e Google OAuth.
|
||||
*/
|
||||
|
||||
|
||||
import { betterAuth } from "better-auth";
|
||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||
|
||||
@@ -1,14 +1,4 @@
|
||||
/**
|
||||
* Server-side authentication utilities
|
||||
*
|
||||
* This module consolidates server-side auth functions from:
|
||||
* - /lib/get-user.tsx
|
||||
* - /lib/get-user-id.tsx
|
||||
* - /lib/get-user-session.tsx
|
||||
*
|
||||
* All functions in this module are server-side only and will redirect
|
||||
* to /login if the user is not authenticated.
|
||||
*/
|
||||
|
||||
|
||||
import { headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
/**
|
||||
* Category defaults and seeding
|
||||
*
|
||||
* Consolidated from:
|
||||
* - /lib/category-defaults.ts
|
||||
*/
|
||||
|
||||
|
||||
import { eq } from "drizzle-orm";
|
||||
import { categorias } from "@/db/schema";
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Common utilities and helpers for dashboard queries
|
||||
*/
|
||||
|
||||
|
||||
import { calculatePercentageChange } from "@/lib/utils/math";
|
||||
import { safeToNumber } from "@/lib/utils/number";
|
||||
|
||||
@@ -18,21 +18,21 @@ export async function updateWidgetPreferences(
|
||||
|
||||
// Check if preferences exist
|
||||
const existing = await db
|
||||
.select({ id: schema.userPreferences.id })
|
||||
.from(schema.userPreferences)
|
||||
.where(eq(schema.userPreferences.userId, user.id))
|
||||
.select({ id: schema.preferenciasUsuario.id })
|
||||
.from(schema.preferenciasUsuario)
|
||||
.where(eq(schema.preferenciasUsuario.userId, user.id))
|
||||
.limit(1);
|
||||
|
||||
if (existing.length > 0) {
|
||||
await db
|
||||
.update(schema.userPreferences)
|
||||
.update(schema.preferenciasUsuario)
|
||||
.set({
|
||||
dashboardWidgets: preferences,
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(schema.userPreferences.userId, user.id));
|
||||
.where(eq(schema.preferenciasUsuario.userId, user.id));
|
||||
} else {
|
||||
await db.insert(schema.userPreferences).values({
|
||||
await db.insert(schema.preferenciasUsuario).values({
|
||||
userId: user.id,
|
||||
dashboardWidgets: preferences,
|
||||
});
|
||||
@@ -54,12 +54,12 @@ export async function resetWidgetPreferences(): Promise<{
|
||||
const user = await getUser();
|
||||
|
||||
await db
|
||||
.update(schema.userPreferences)
|
||||
.update(schema.preferenciasUsuario)
|
||||
.set({
|
||||
dashboardWidgets: null,
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(schema.userPreferences.userId, user.id));
|
||||
.where(eq(schema.preferenciasUsuario.userId, user.id));
|
||||
|
||||
revalidatePath("/dashboard");
|
||||
return { success: true };
|
||||
@@ -74,9 +74,9 @@ export async function getWidgetPreferences(): Promise<WidgetPreferences | null>
|
||||
const user = await getUser();
|
||||
|
||||
const result = await db
|
||||
.select({ dashboardWidgets: schema.userPreferences.dashboardWidgets })
|
||||
.from(schema.userPreferences)
|
||||
.where(eq(schema.userPreferences.userId, user.id))
|
||||
.select({ dashboardWidgets: schema.preferenciasUsuario.dashboardWidgets })
|
||||
.from(schema.preferenciasUsuario)
|
||||
.where(eq(schema.preferenciasUsuario.userId, user.id))
|
||||
.limit(1);
|
||||
|
||||
return result[0]?.dashboardWidgets ?? null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
AntecipacaoParcela,
|
||||
Categoria,
|
||||
InstallmentAnticipation,
|
||||
Lancamento,
|
||||
Pagador,
|
||||
} from "@/db/schema";
|
||||
@@ -25,7 +25,7 @@ export type EligibleInstallment = {
|
||||
/**
|
||||
* Antecipação com dados completos
|
||||
*/
|
||||
export type InstallmentAnticipationWithRelations = InstallmentAnticipation & {
|
||||
export type InstallmentAnticipationWithRelations = AntecipacaoParcela & {
|
||||
lancamento: Lancamento;
|
||||
pagador: Pagador | null;
|
||||
categoria: Categoria | null;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Categoria grouping and sorting helpers for lancamentos
|
||||
*/
|
||||
|
||||
|
||||
import type { SelectOption } from "@/components/lancamentos/types";
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Form state management helpers for lancamentos
|
||||
*/
|
||||
|
||||
|
||||
import type { LancamentoItem } from "@/components/lancamentos/types";
|
||||
import { getTodayDateString } from "@/lib/utils/date";
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
/**
|
||||
* Logo options loader
|
||||
*
|
||||
* Consolidated from:
|
||||
* - /lib/logo-options.ts (async logo loading)
|
||||
*/
|
||||
|
||||
|
||||
import { readdir } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Data fetching function for Category Chart (based on selected filters)
|
||||
*/
|
||||
|
||||
|
||||
import { format } from "date-fns";
|
||||
import { ptBR } from "date-fns/locale";
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Data fetching function for Category Report
|
||||
*/
|
||||
|
||||
|
||||
import { and, eq, inArray, isNull, or, sql } from "drizzle-orm";
|
||||
import { categorias, lancamentos, pagadores } from "@/db/schema";
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Utility functions for Category Report feature
|
||||
*/
|
||||
|
||||
|
||||
import { currencyFormatter } from "@/lib/lancamentos/formatting-helpers";
|
||||
import { calculatePercentageChange } from "@/lib/utils/math";
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Zod schemas for inbox items (OpenSheets Companion)
|
||||
*/
|
||||
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
/**
|
||||
* UI utilities - Functions for UI manipulation and styling
|
||||
*
|
||||
* This module contains UI-related utilities, primarily for className manipulation.
|
||||
*/
|
||||
|
||||
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
Reference in New Issue
Block a user