mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-06-10 07:16:01 +00:00
refactor: faxina arquitetural — código morto, identificadores em inglês e estrutura padronizada
Refatoração estrutural sem mudanças funcionais. Saldo líquido: −428 linhas. Removido: - 14 funções/constantes mortas verificadas via grep no repo todo: validateCategoriaOwnership, getInstallmentAnticipationsAction, getAnticipationDetailsAction, formatDecimalForDb, currencyFormatterNoCents, optionalDecimalSchema, formatMonthLabel, getGoalProgressStatusColorClass, MONTH_PERIOD_PARAM, calculateRemainingInstallments, e 5 funções fetch* não usadas em inbox/queries.ts. - 1 tipo morto (ImportRow) + 2 órfãos consequentes (InstallmentAnticipationWithRelations, GoalProgressStatus convertido em interno). - ~30 export keywords desnecessários (símbolos usados apenas no próprio arquivo). - Re-exports mortos em barrels: EstablishmentLogoPicker, CategoryReportSkeleton, WidgetSkeleton, toNameKey. - Arquivo features/reports/types.ts (barrel inteiro era órfão). Padronizado (PT-BR→EN em identificadores expostos): - 4 constantes globais (LANCAMENTOS_* → TRANSACTIONS_*). - 12 tipos/interfaces (Lancamento*/Pagador*/Estabelecimento* → equivalentes EN). - 13 funções/components exportados (fetchPagador*, EstabelecimentoInput, PagadorInfoCard, etc.). - 5 props cross-file (preLancamentosCount → inboxPendingCount, pagadorAvatarUrl → payerAvatarUrl, etc.). - Mantidas em PT-BR conforme exceção do CLAUDE.md: variáveis locais (pagador, categoria, lancamento), accessor key pagadorName (persistida em preferências), strings de UI. Reorganizado: - transactions/: 14 helpers soltos na raiz movidos para lib/; barrel actions.ts reduzido de 76 linhas de wrappers para 14 linhas de re-exports puros; anticipation-actions.ts movido para actions/anticipation.ts. - dashboard/: 8 helpers soltos consolidados em dashboard/lib/. - reports/: 5 query files na raiz consolidados em reports/lib/. - payers/: detail-actions.ts (21KB) e detail-queries.ts movidos para payers/lib/. - shared/components/: 9 dos 16 componentes soltos agrupados em brand/, widgets/, feedback/. - shared/lib/fetch-json.ts movido para shared/utils/fetch-json.ts. Validação: pnpm exec tsc --noEmit (0 erros), biome check (0 issues), knip (sem unused). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { RiAtLine, RiCalendarEventLine } from "@remixicon/react";
|
||||
import { format } from "date-fns";
|
||||
import { ptBR } from "date-fns/locale";
|
||||
import { EmptyState } from "@/shared/components/empty-state";
|
||||
import { EmptyState } from "@/shared/components/feedback/empty-state";
|
||||
import { Card } from "@/shared/components/ui/card";
|
||||
import { InboxCard } from "./inbox-card";
|
||||
import type { InboxItem } from "./types";
|
||||
|
||||
@@ -4,10 +4,7 @@ import {
|
||||
RiArrowRightDoubleLine,
|
||||
RiArrowRightSLine,
|
||||
} from "@remixicon/react";
|
||||
import {
|
||||
INBOX_DEFAULT_PAGE_SIZE,
|
||||
INBOX_PAGE_SIZE_OPTIONS,
|
||||
} from "@/features/inbox/page-helpers";
|
||||
import { INBOX_PAGE_SIZE_OPTIONS } from "@/features/inbox/page-helpers";
|
||||
import { Button } from "@/shared/components/ui/button";
|
||||
import {
|
||||
Select,
|
||||
@@ -117,6 +114,3 @@ export function InboxPagination({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Re-export para facilitar uso externo
|
||||
export { INBOX_DEFAULT_PAGE_SIZE };
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TabsList, TabsTrigger } from "@/shared/components/ui/tabs";
|
||||
import type { InboxStatus, InboxStatusCounts } from "./types";
|
||||
import type { InboxStatusCounts } from "./types";
|
||||
|
||||
type InboxTabsProps = {
|
||||
counts: InboxStatusCounts;
|
||||
@@ -36,5 +36,3 @@ export function InboxTabs({ counts, isPending }: InboxTabsProps) {
|
||||
</TabsList>
|
||||
);
|
||||
}
|
||||
|
||||
export type { InboxStatus, InboxStatusCounts };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SelectOption as LancamentoSelectOption } from "@/features/transactions/components/types";
|
||||
import type { SelectOption as TransactionSelectOption } from "@/features/transactions/components/types";
|
||||
|
||||
export type InboxStatus = "pending" | "processed" | "discarded";
|
||||
|
||||
@@ -29,4 +29,4 @@ export type InboxPaginationState = {
|
||||
};
|
||||
|
||||
// Re-export the lancamentos SelectOption for use in inbox components
|
||||
export type SelectOption = LancamentoSelectOption;
|
||||
export type SelectOption = TransactionSelectOption;
|
||||
|
||||
@@ -7,9 +7,9 @@ export type ResolvedInboxSearchParams =
|
||||
export const INBOX_DEFAULT_PAGE_SIZE = 12;
|
||||
export const INBOX_PAGE_SIZE_OPTIONS = [12, 24, 48];
|
||||
|
||||
export const INBOX_STATUSES = ["pending", "processed", "discarded"] as const;
|
||||
const INBOX_STATUSES = ["pending", "processed", "discarded"] as const;
|
||||
|
||||
export const getSingleParam = (
|
||||
const getSingleParam = (
|
||||
params: ResolvedInboxSearchParams,
|
||||
key: string,
|
||||
): string | null => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { and, count, desc, eq } from "drizzle-orm";
|
||||
import { cards, categories, financialAccounts, inboxItems } from "@/db/schema";
|
||||
import { cards, financialAccounts, inboxItems } from "@/db/schema";
|
||||
import type {
|
||||
InboxItem,
|
||||
InboxPaginationState,
|
||||
@@ -10,29 +10,13 @@ import type {
|
||||
import {
|
||||
buildOptionSets,
|
||||
buildSluggedFilters,
|
||||
} from "@/features/transactions/page-helpers";
|
||||
} from "@/features/transactions/lib/page-helpers";
|
||||
import {
|
||||
fetchRecentEstablishments,
|
||||
fetchTransactionFilterSources,
|
||||
} from "@/features/transactions/queries";
|
||||
import { db } from "@/shared/lib/db";
|
||||
|
||||
export async function fetchInboxItems(
|
||||
userId: string,
|
||||
status: InboxStatus = "pending",
|
||||
): Promise<InboxItem[]> {
|
||||
const items = await db
|
||||
.select()
|
||||
.from(inboxItems)
|
||||
.where(and(eq(inboxItems.userId, userId), eq(inboxItems.status, status)))
|
||||
.orderBy(
|
||||
desc(inboxItems.notificationTimestamp),
|
||||
desc(inboxItems.createdAt),
|
||||
);
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
export async function fetchInboxItemsPage(
|
||||
userId: string,
|
||||
status: InboxStatus,
|
||||
@@ -126,65 +110,6 @@ export async function fetchInboxStatusCounts(
|
||||
return counts;
|
||||
}
|
||||
|
||||
export async function fetchInboxItemById(
|
||||
userId: string,
|
||||
itemId: string,
|
||||
): Promise<InboxItem | null> {
|
||||
const [item] = await db
|
||||
.select()
|
||||
.from(inboxItems)
|
||||
.where(and(eq(inboxItems.id, itemId), eq(inboxItems.userId, userId)))
|
||||
.limit(1);
|
||||
|
||||
return item ?? null;
|
||||
}
|
||||
|
||||
export async function fetchCategoriesForSelect(
|
||||
userId: string,
|
||||
type?: string,
|
||||
): Promise<SelectOption[]> {
|
||||
const rows = await db
|
||||
.select({ id: categories.id, name: categories.name })
|
||||
.from(categories)
|
||||
.where(
|
||||
type
|
||||
? and(eq(categories.userId, userId), eq(categories.type, type))
|
||||
: eq(categories.userId, userId),
|
||||
)
|
||||
.orderBy(categories.name);
|
||||
|
||||
return rows.map((row) => ({ value: row.id, label: row.name }));
|
||||
}
|
||||
|
||||
export async function fetchAccountsForSelect(
|
||||
userId: string,
|
||||
): Promise<SelectOption[]> {
|
||||
const rows = await db
|
||||
.select({ id: financialAccounts.id, name: financialAccounts.name })
|
||||
.from(financialAccounts)
|
||||
.where(
|
||||
and(
|
||||
eq(financialAccounts.userId, userId),
|
||||
eq(financialAccounts.status, "ativo"),
|
||||
),
|
||||
)
|
||||
.orderBy(financialAccounts.name);
|
||||
|
||||
return rows.map((row) => ({ value: row.id, label: row.name }));
|
||||
}
|
||||
|
||||
export async function fetchCardsForSelect(
|
||||
userId: string,
|
||||
): Promise<(SelectOption & { lastDigits?: string })[]> {
|
||||
const rows = await db
|
||||
.select({ id: cards.id, name: cards.name })
|
||||
.from(cards)
|
||||
.where(and(eq(cards.userId, userId), eq(cards.status, "ativo")))
|
||||
.orderBy(cards.name);
|
||||
|
||||
return rows.map((row) => ({ value: row.id, label: row.name }));
|
||||
}
|
||||
|
||||
export async function fetchAppLogoMap(
|
||||
userId: string,
|
||||
): Promise<Record<string, string>> {
|
||||
|
||||
Reference in New Issue
Block a user