From 7d0781b03502aabcedbede35890337f513c82ac0 Mon Sep 17 00:00:00 2001 From: Felipe Coutinho Date: Wed, 6 May 2026 18:42:54 +0000 Subject: [PATCH] =?UTF-8?q?refactor:=20faxina=20arquitetural=20=E2=80=94?= =?UTF-8?q?=20c=C3=B3digo=20morto,=20identificadores=20em=20ingl=C3=AAs=20?= =?UTF-8?q?e=20estrutura=20padronizada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- knip.jsonc | 4 +- next.config.ts | 1 + scripts/mock-data.ts | 2 +- src/app/(auth)/layout.tsx | 2 +- .../accounts/[accountId]/statement/page.tsx | 6 +- src/app/(dashboard)/calendar/page.tsx | 2 +- .../cards/[cardId]/invoice/page.tsx | 2 +- .../categories/[categoryId]/page.tsx | 2 +- src/app/(dashboard)/dashboard/page.tsx | 4 +- src/app/(dashboard)/layout.tsx | 6 +- .../(dashboard)/payers/[payerId]/loading.tsx | 2 +- src/app/(dashboard)/payers/[payerId]/page.tsx | 32 ++--- src/app/(dashboard)/payers/loading.tsx | 2 +- .../(dashboard)/reports/card-usage/page.tsx | 2 +- .../reports/category-trends/page.tsx | 8 +- .../reports/establishments/page.tsx | 2 +- .../(dashboard)/transactions/import/page.tsx | 2 +- src/app/(dashboard)/transactions/loading.tsx | 2 +- src/app/(dashboard)/transactions/page.tsx | 2 +- src/app/(landing-page)/page.tsx | 2 +- .../[transactionId]/attachments/route.ts | 2 +- .../[seriesId]/anticipations/route.ts | 2 +- .../components/account-select-items.tsx | 2 +- .../accounts/components/accounts-page.tsx | 2 +- src/features/accounts/queries.ts | 4 +- src/features/accounts/statement-queries.ts | 4 +- .../components/attachments-page.tsx | 2 +- .../attachments/hooks/use-attachment-url.ts | 4 +- src/features/auth/components/auth-sidebar.tsx | 2 +- .../budgets/components/budgets-page.tsx | 2 +- src/features/budgets/queries.ts | 2 +- src/features/calendar/queries.ts | 2 +- .../cards/components/card-select-items.tsx | 2 +- src/features/cards/components/cards-page.tsx | 2 +- src/features/cards/queries.ts | 6 +- .../components/category-select-items.tsx | 2 +- src/features/categories/queries.ts | 2 +- src/features/dashboard/bills/bills-helpers.ts | 2 +- .../categories/category-details-queries.ts | 4 +- .../categories/category-history-queries.ts | 4 +- .../categories/category-overview-queries.ts | 2 +- .../purchases-by-category-queries.ts | 4 +- .../components/bills/bill-payment-dialog.tsx | 2 +- .../dashboard/components/bills/bills-list.tsx | 2 +- .../category-breakdown-widget-view.tsx | 2 +- .../components/dashboard-grid-editable.tsx | 2 +- .../goals-progress/goals-progress-list.tsx | 2 +- .../installment-expenses-list.tsx | 2 +- .../invoices/invoice-payment-dialog.tsx | 2 +- .../components/invoices/invoices-list.tsx | 2 +- .../dashboard/components/notes/notes-list.tsx | 2 +- .../payment-breakdown-list.tsx | 2 +- .../payment-status-category-section.tsx | 2 +- .../payment-status-widget-view.tsx | 2 +- .../percentage-change-indicator.tsx | 2 +- .../components/widgets/attachments-widget.tsx | 2 +- .../widgets/category-history-widget.tsx | 2 +- .../widgets/category-trends-widget.tsx | 2 +- .../components/widgets/inbox-widget.tsx | 4 +- .../widgets/income-expense-balance-widget.tsx | 2 +- .../components/widgets/my-accounts-widget.tsx | 4 +- .../components/widgets/payers-widget.tsx | 4 +- .../widgets/purchases-by-category-widget.tsx | 2 +- .../widgets/recurring-expenses-widget.tsx | 2 +- .../widgets/spending-overview-widget.tsx | 2 +- .../widgets/top-establishments-widget.tsx | 4 +- .../widgets/top-expenses-widget.tsx | 2 +- .../expenses/installment-analysis-queries.ts | 2 +- .../expenses/installment-expenses-helpers.ts | 14 +-- .../expenses/recurring-expenses-queries.ts | 2 +- .../dashboard/fetch-dashboard-data.ts | 6 +- .../goals-progress/goals-progress-helpers.ts | 4 - .../goals-progress/goals-progress-queries.ts | 2 +- .../dashboard/invoices/invoices-queries.ts | 2 +- .../dashboard/{ => lib}/accounts-queries.ts | 0 .../dashboard/{ => lib}/extract-logo-names.ts | 2 +- .../{ => lib}/inbox-snapshot-queries.ts | 2 +- .../dashboard/{ => lib}/navbar-queries.ts | 12 +- .../dashboard/{ => lib}/payers-queries.ts | 2 +- .../{ => lib}/preferences-queries.ts | 0 .../{ => lib}/top-establishments-queries.ts | 2 +- .../{ => lib}/transaction-filters.ts | 0 src/features/dashboard/notes/notes-mappers.ts | 2 +- src/features/dashboard/notes/notes-queries.ts | 2 +- .../notifications/notifications-queries.ts | 8 +- .../current-period-overview-queries.ts | 4 +- .../overview/period-overview-queries.ts | 12 +- src/features/dashboard/page-data-queries.ts | 6 +- .../payments/payment-conditions-queries.ts | 2 +- .../payments/payment-methods-queries.ts | 2 +- .../payments/payment-status-queries.ts | 2 +- .../inbox/components/inbox-items-list.tsx | 2 +- .../inbox/components/inbox-pagination.tsx | 8 +- src/features/inbox/components/inbox-tabs.tsx | 4 +- src/features/inbox/components/types.ts | 4 +- src/features/inbox/page-helpers.ts | 4 +- src/features/inbox/queries.ts | 79 +------------ src/features/insights/actions.ts | 35 +----- src/features/insights/actions/storage.ts | 61 +--------- .../insights/components/insights-page.tsx | 2 +- .../insights/hooks/use-saved-insights.ts | 2 +- .../components/invoice-summary-card.tsx | 2 +- .../landing/components/mobile-nav.tsx | 2 +- src/features/landing/constants.ts | 2 +- src/features/notes/components/notes-page.tsx | 2 +- src/features/notes/components/types.ts | 2 +- src/features/notes/queries.ts | 10 +- .../details/payer-card-usage-card.tsx | 6 +- .../components/details/payer-header-card.tsx | 2 +- .../components/details/payer-history-card.tsx | 6 +- .../components/details/payer-info-card.tsx | 2 +- .../details/payer-leave-share-card.tsx | 4 +- .../details/payer-monthly-summary-card.tsx | 4 +- .../details/payer-payment-method-cards.tsx | 12 +- .../components/details/payer-sharing-card.tsx | 8 +- .../payers/components/payer-select-items.tsx | 2 +- .../payers/lib/build-readonly-option-sets.ts | 2 +- .../payers/{ => lib}/detail-actions.ts | 18 +-- .../payers/{ => lib}/detail-queries.ts | 4 +- .../cards/card-category-breakdown.tsx | 4 +- .../components/cards/card-invoice-status.tsx | 2 +- .../components/cards/card-top-expenses.tsx | 4 +- .../components/cards/card-usage-chart.tsx | 2 +- .../components/cards/cards-overview.tsx | 2 +- .../reports/components/category-cell.tsx | 2 +- .../components/category-report-cards.tsx | 2 +- .../components/category-report-chart.tsx | 4 +- .../components/category-report-export.tsx | 2 +- .../components/category-report-filters.tsx | 2 +- .../components/category-report-page.tsx | 4 +- .../reports/components/category-table.tsx | 6 +- .../establishments/establishments-list.tsx | 6 +- .../establishments/highlights-cards.tsx | 4 +- .../establishments/summary-cards.tsx | 4 +- .../establishments/top-categories.tsx | 6 +- .../reports/establishments/queries.ts | 8 +- .../reports/{ => lib}/cards-report-queries.ts | 2 +- .../{ => lib}/category-chart-queries.ts | 0 .../{ => lib}/category-report-queries.ts | 4 +- .../{ => lib}/category-trends-queries.ts | 0 src/features/reports/{ => lib}/utils.ts | 0 src/features/reports/types.ts | 7 -- .../settings/components/preferences-form.tsx | 12 +- src/features/settings/lib/parse-changelog.ts | 2 +- src/features/settings/queries.ts | 8 +- src/features/transactions/actions.ts | 86 ++------------ .../anticipation.ts} | 111 +----------------- .../transactions/actions/attachments.ts | 2 +- .../transactions/actions/bulk-actions.ts | 6 +- src/features/transactions/actions/core.ts | 31 ++--- .../transactions/actions/export-actions.ts | 8 +- .../transactions/actions/fetch-by-id.ts | 2 +- .../actions/fetch-dialog-options.ts | 2 +- .../transactions/actions/import-action.ts | 7 +- .../transactions/actions/single-actions.ts | 14 +-- .../attachments/attachment-file-picker.tsx | 2 +- .../attachments/attachment-upload.tsx | 2 +- .../anticipate-installments-dialog.tsx | 2 +- .../components/dialogs/bulk-import-dialog.tsx | 2 +- .../components/dialogs/mass-add-dialog.tsx | 8 +- .../dialogs/refund-transaction-dialog.tsx | 4 +- .../dialogs/transaction-details-dialog.tsx | 2 +- .../basic-fields-section.tsx | 4 +- .../transaction-dialog/category-section.tsx | 2 +- .../transaction-dialog/condition-section.tsx | 2 +- .../payment-method-section.tsx | 2 +- .../transaction-dialog-types.ts | 4 +- .../transaction-dialog/transaction-dialog.tsx | 4 +- .../components/import/global-fields.tsx | 2 +- .../components/page/transactions-page.tsx | 2 +- .../transactions/components/select-items.tsx | 2 +- .../components/shared/anticipation-card.tsx | 2 +- .../components/shared/establishment-input.tsx | 6 +- .../components/table/transactions-columns.tsx | 8 +- .../components/table/transactions-filters.tsx | 2 +- .../components/table/transactions-table.tsx | 8 +- .../components/transactions-export.tsx | 8 +- .../hooks/use-installment-anticipations.ts | 2 +- .../hooks/use-transaction-attachments.ts | 4 +- .../{ => lib}/anticipation-queries.ts | 2 +- .../transactions/{ => lib}/attachment-copy.ts | 0 .../{ => lib}/attachment-queries.ts | 0 .../{ => lib}/attachments-config.ts | 0 .../{ => lib}/category-helpers.ts | 0 .../transactions/{ => lib}/column-order.ts | 8 +- .../transactions/{ => lib}/constants.ts | 0 .../transactions/{ => lib}/export-types.ts | 2 +- .../transactions/{ => lib}/form-helpers.ts | 4 +- .../{ => lib}/formatting-helpers.ts | 0 .../transactions/{ => lib}/page-helpers.ts | 14 +-- src/features/transactions/queries.ts | 2 +- .../components/{ => brand}/logo-icon.tsx | 0 .../components/{ => brand}/logo-text.tsx | 0 src/shared/components/{ => brand}/logo.tsx | 4 +- .../entity-avatar/category-icon-badge.tsx | 4 +- src/shared/components/entity-avatar/index.ts | 5 - .../components/{ => feedback}/empty-state.tsx | 0 .../{ => feedback}/payment-success.tsx | 0 .../components/{ => feedback}/status-dot.tsx | 0 .../month-picker/use-month-period.ts | 2 - .../navigation/navbar/app-navbar.tsx | 12 +- .../navigation/navbar/nav-items.tsx | 2 +- .../navigation/navbar/navbar-shell.tsx | 2 +- .../navigation/navbar/navbar-user.tsx | 8 +- .../navigation/navbar/notification-bell.tsx | 4 +- .../notification-bell-content.tsx | 12 +- .../navbar/notification-bell/types.ts | 2 +- .../use-notification-bell.ts | 14 +-- src/shared/components/skeletons/index.ts | 2 - .../{ => widgets}/expandable-widget-card.tsx | 4 +- .../components/{ => widgets}/widget-card.tsx | 0 .../{ => widgets}/widget-empty-state.tsx | 0 src/shared/lib/accounts/constants.ts | 2 +- src/shared/lib/actions/helpers.ts | 2 +- src/shared/lib/auth/config.ts | 4 +- src/shared/lib/categories/icons.ts | 6 +- .../lib/installments/anticipation-helpers.ts | 12 +- .../lib/installments/anticipation-types.ts | 16 --- .../lib/logo/establishment-logo-queries.ts | 2 - src/shared/lib/payers/access.ts | 2 +- src/shared/lib/payers/defaults.ts | 2 +- src/shared/lib/payers/details.ts | 10 +- src/shared/lib/payers/notifications.ts | 16 +-- src/shared/lib/schemas/common.ts | 19 --- src/shared/lib/schemas/insights.ts | 4 +- src/shared/lib/types/notifications.ts | 6 +- src/shared/utils/currency.ts | 20 ---- src/shared/{lib => utils}/fetch-json.ts | 0 src/shared/utils/period/index.ts | 13 +- 229 files changed, 415 insertions(+), 872 deletions(-) rename src/features/dashboard/{ => lib}/accounts-queries.ts (100%) rename src/features/dashboard/{ => lib}/extract-logo-names.ts (94%) rename src/features/dashboard/{ => lib}/inbox-snapshot-queries.ts (98%) rename src/features/dashboard/{ => lib}/navbar-queries.ts (86%) rename src/features/dashboard/{ => lib}/payers-queries.ts (98%) rename src/features/dashboard/{ => lib}/preferences-queries.ts (100%) rename src/features/dashboard/{ => lib}/top-establishments-queries.ts (83%) rename src/features/dashboard/{ => lib}/transaction-filters.ts (100%) rename src/features/payers/{ => lib}/detail-actions.ts (98%) rename src/features/payers/{ => lib}/detail-queries.ts (96%) rename src/features/reports/{ => lib}/cards-report-queries.ts (99%) rename src/features/reports/{ => lib}/category-chart-queries.ts (100%) rename src/features/reports/{ => lib}/category-report-queries.ts (99%) rename src/features/reports/{ => lib}/category-trends-queries.ts (100%) rename src/features/reports/{ => lib}/utils.ts (100%) delete mode 100644 src/features/reports/types.ts rename src/features/transactions/{anticipation-actions.ts => actions/anticipation.ts} (79%) rename src/features/transactions/{ => lib}/anticipation-queries.ts (98%) rename src/features/transactions/{ => lib}/attachment-copy.ts (100%) rename src/features/transactions/{ => lib}/attachment-queries.ts (100%) rename src/features/transactions/{ => lib}/attachments-config.ts (100%) rename src/features/transactions/{ => lib}/category-helpers.ts (100%) rename src/features/transactions/{ => lib}/column-order.ts (71%) rename src/features/transactions/{ => lib}/constants.ts (100%) rename src/features/transactions/{ => lib}/export-types.ts (94%) rename src/features/transactions/{ => lib}/form-helpers.ts (99%) rename src/features/transactions/{ => lib}/formatting-helpers.ts (100%) rename src/features/transactions/{ => lib}/page-helpers.ts (98%) rename src/shared/components/{ => brand}/logo-icon.tsx (100%) rename src/shared/components/{ => brand}/logo-text.tsx (100%) rename src/shared/components/{ => brand}/logo.tsx (92%) rename src/shared/components/{ => feedback}/empty-state.tsx (100%) rename src/shared/components/{ => feedback}/payment-success.tsx (100%) rename src/shared/components/{ => feedback}/status-dot.tsx (100%) rename src/shared/components/{ => widgets}/expandable-widget-card.tsx (97%) rename src/shared/components/{ => widgets}/widget-card.tsx (100%) rename src/shared/components/{ => widgets}/widget-empty-state.tsx (100%) rename src/shared/{lib => utils}/fetch-json.ts (100%) diff --git a/knip.jsonc b/knip.jsonc index 9161b95..8b803ad 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -12,8 +12,10 @@ ], // PostCSS is inferred from the config file, but the project only depends on // the Tailwind PostCSS plugin directly. + // `server-only` is provided implicitly by Next.js — no install needed. "ignoreDependencies": [ - "postcss" + "postcss", + "server-only" ], "next": true, "postcss": true, diff --git a/next.config.ts b/next.config.ts index a3b3f2d..d052b52 100644 --- a/next.config.ts +++ b/next.config.ts @@ -21,6 +21,7 @@ const nextConfig: NextConfig = { experimental: { prefetchInlining: true, turbopackFileSystemCacheForDev: true, + optimizePackageImports: ["@remixicon/react"], }, // Headers for Safari compatibility diff --git a/scripts/mock-data.ts b/scripts/mock-data.ts index 01529e3..d66881f 100644 --- a/scripts/mock-data.ts +++ b/scripts/mock-data.ts @@ -21,7 +21,7 @@ import type { PAYMENT_METHODS, TRANSACTION_CONDITIONS, TRANSACTION_TYPES, -} from "@/features/transactions/constants"; +} from "@/features/transactions/lib/constants"; import { buildInvoicePaymentNote, INITIAL_BALANCE_CATEGORY_NAME, diff --git a/src/app/(auth)/layout.tsx b/src/app/(auth)/layout.tsx index a1bd359..6346780 100644 --- a/src/app/(auth)/layout.tsx +++ b/src/app/(auth)/layout.tsx @@ -1,4 +1,4 @@ -import { Logo } from "@/shared/components/logo"; +import { Logo } from "@/shared/components/brand/logo"; export default function AuthLayout({ children, diff --git a/src/app/(dashboard)/accounts/[accountId]/statement/page.tsx b/src/app/(dashboard)/accounts/[accountId]/statement/page.tsx index d0fee88..dbab7b2 100644 --- a/src/app/(dashboard)/accounts/[accountId]/statement/page.tsx +++ b/src/app/(dashboard)/accounts/[accountId]/statement/page.tsx @@ -7,8 +7,8 @@ import { AdjustBalanceDialog } from "@/features/accounts/components/adjust-balan import type { Account } from "@/features/accounts/components/types"; import { fetchAccountData, - fetchAccountLancamentosPage, fetchAccountSummary, + fetchAccountTransactionsPage, } from "@/features/accounts/statement-queries"; import { fetchUserPreferences } from "@/features/settings/queries"; import { TransactionsPage as LancamentosSection } from "@/features/transactions/components/page/transactions-page"; @@ -22,7 +22,7 @@ import { mapTransactionsData, type ResolvedSearchParams, resolveTransactionPagination, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import { fetchRecentEstablishments, fetchTransactionFilterSources, @@ -89,7 +89,7 @@ export default async function Page({ params, searchParams }: PageProps) { accountId: account.id, }); - const transactionsPage = await fetchAccountLancamentosPage( + const transactionsPage = await fetchAccountTransactionsPage( filters, pagination, ); diff --git a/src/app/(dashboard)/calendar/page.tsx b/src/app/(dashboard)/calendar/page.tsx index e331188..a9ba0a8 100644 --- a/src/app/(dashboard)/calendar/page.tsx +++ b/src/app/(dashboard)/calendar/page.tsx @@ -4,7 +4,7 @@ import { fetchCalendarData } from "@/features/calendar/queries"; import { getSingleParam, type ResolvedSearchParams, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import MonthNavigation from "@/shared/components/month-picker/month-navigation"; import { getUserId } from "@/shared/lib/auth/server"; import type { CalendarPeriod } from "@/shared/lib/types/calendar"; diff --git a/src/app/(dashboard)/cards/[cardId]/invoice/page.tsx b/src/app/(dashboard)/cards/[cardId]/invoice/page.tsx index e1793e4..663bdf0 100644 --- a/src/app/(dashboard)/cards/[cardId]/invoice/page.tsx +++ b/src/app/(dashboard)/cards/[cardId]/invoice/page.tsx @@ -21,7 +21,7 @@ import { getSingleParam, mapTransactionsData, type ResolvedSearchParams, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import { fetchRecentEstablishments, fetchTransactionFilterSources, diff --git a/src/app/(dashboard)/categories/[categoryId]/page.tsx b/src/app/(dashboard)/categories/[categoryId]/page.tsx index aaf3b62..1961310 100644 --- a/src/app/(dashboard)/categories/[categoryId]/page.tsx +++ b/src/app/(dashboard)/categories/[categoryId]/page.tsx @@ -7,7 +7,7 @@ import { TransactionsPage } from "@/features/transactions/components/page/transa import { buildOptionSets, buildSluggedFilters, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import { fetchRecentEstablishments, fetchTransactionFilterSources, diff --git a/src/app/(dashboard)/dashboard/page.tsx b/src/app/(dashboard)/dashboard/page.tsx index 269df93..a4f1fc8 100644 --- a/src/app/(dashboard)/dashboard/page.tsx +++ b/src/app/(dashboard)/dashboard/page.tsx @@ -2,9 +2,9 @@ import { connection } from "next/server"; import { DashboardGridEditable } from "@/features/dashboard/components/dashboard-grid-editable"; import { DashboardMetricsCards } from "@/features/dashboard/components/dashboard-metrics-cards"; import { DashboardWelcome } from "@/features/dashboard/components/dashboard-welcome"; -import { extractDashboardLogoNames } from "@/features/dashboard/extract-logo-names"; +import { extractDashboardLogoNames } from "@/features/dashboard/lib/extract-logo-names"; import { fetchDashboardPageData } from "@/features/dashboard/page-data-queries"; -import { getSingleParam } from "@/features/transactions/page-helpers"; +import { getSingleParam } from "@/features/transactions/lib/page-helpers"; import { LogoPrefetchProvider } from "@/shared/components/entity-avatar"; import MonthNavigation from "@/shared/components/month-picker/month-navigation"; import { getUser } from "@/shared/lib/auth/server"; diff --git a/src/app/(dashboard)/layout.tsx b/src/app/(dashboard)/layout.tsx index 407ab13..63ea29b 100644 --- a/src/app/(dashboard)/layout.tsx +++ b/src/app/(dashboard)/layout.tsx @@ -1,5 +1,5 @@ import { connection } from "next/server"; -import { fetchDashboardNavbarData } from "@/features/dashboard/navbar-queries"; +import { fetchDashboardNavbarData } from "@/features/dashboard/lib/navbar-queries"; import { AppNavbar } from "@/shared/components/navigation/navbar/app-navbar"; import { LogoDevProvider } from "@/shared/components/providers/logo-dev-provider"; import { PrivacyProvider } from "@/shared/components/providers/privacy-provider"; @@ -21,8 +21,8 @@ export default async function DashboardLayout({
diff --git a/src/app/(dashboard)/payers/[payerId]/loading.tsx b/src/app/(dashboard)/payers/[payerId]/loading.tsx index 1bb7800..17c1471 100644 --- a/src/app/(dashboard)/payers/[payerId]/loading.tsx +++ b/src/app/(dashboard)/payers/[payerId]/loading.tsx @@ -4,7 +4,7 @@ import { Skeleton } from "@/shared/components/ui/skeleton"; * Loading state para a página de detalhes do pagador. * Layout: navegação mensal + tabs com card compartilhado do pagador. */ -export default function PagadorDetailsLoading() { +export default function PayerDetailsLoading() { return (
diff --git a/src/app/(dashboard)/payers/[payerId]/page.tsx b/src/app/(dashboard)/payers/[payerId]/page.tsx index 5ad79e5..4f90362 100644 --- a/src/app/(dashboard)/payers/[payerId]/page.tsx +++ b/src/app/(dashboard)/payers/[payerId]/page.tsx @@ -8,7 +8,7 @@ import { connection } from "next/server"; import { PayerCardUsageCard } from "@/features/payers/components/details/payer-card-usage-card"; import { PayerHeaderCard } from "@/features/payers/components/details/payer-header-card"; import { PayerHistoryCard } from "@/features/payers/components/details/payer-history-card"; -import { PagadorInfoCard } from "@/features/payers/components/details/payer-info-card"; +import { PayerInfoCard } from "@/features/payers/components/details/payer-info-card"; import { PayerLeaveShareCard } from "@/features/payers/components/details/payer-leave-share-card"; import { PayerMonthlySummaryCard } from "@/features/payers/components/details/payer-monthly-summary-card"; import { @@ -16,12 +16,12 @@ import { PayerPaymentStatusCard, } from "@/features/payers/components/details/payer-payment-method-cards"; import { PayerSharingCard } from "@/features/payers/components/details/payer-sharing-card"; +import { buildReadOnlyOptionSets } from "@/features/payers/lib/build-readonly-option-sets"; import { fetchCurrentUserShare, - fetchPagadorLancamentos, fetchPayerShares, -} from "@/features/payers/detail-queries"; -import { buildReadOnlyOptionSets } from "@/features/payers/lib/build-readonly-option-sets"; + fetchPayerTransactions, +} from "@/features/payers/lib/detail-queries"; import { fetchUserPreferences } from "@/features/settings/queries"; import { TransactionsPage as LancamentosSection } from "@/features/transactions/components/page/transactions-page"; import { @@ -36,13 +36,12 @@ import { type SluggedFilters, type SlugMaps, type TransactionSearchFilters, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import { fetchRecentEstablishments, fetchTransactionFilterSources, } from "@/features/transactions/queries"; import { LogoPrefetchProvider } from "@/shared/components/entity-avatar"; -import { ExpandableWidgetCard } from "@/shared/components/expandable-widget-card"; import MonthNavigation from "@/shared/components/month-picker/month-navigation"; import { Tabs, @@ -50,16 +49,17 @@ import { TabsList, TabsTrigger, } from "@/shared/components/ui/tabs"; +import { ExpandableWidgetCard } from "@/shared/components/widgets/expandable-widget-card"; import { getUserId } from "@/shared/lib/auth/server"; import { prefetchLogoMappings } from "@/shared/lib/logo/prefetch-server"; import { getPayerAccess } from "@/shared/lib/payers/access"; import { - fetchPagadorBoletoItems, - fetchPagadorBoletoStats, - fetchPagadorCardUsage, - fetchPagadorPaymentStatus, + fetchPayerBoletoItems, + fetchPayerBoletoStats, + fetchPayerCardUsage, fetchPayerHistory, fetchPayerMonthlyBreakdown, + fetchPayerPaymentStatus, type PayerCardUsageItem, } from "@/shared/lib/payers/details"; import { parsePeriodParam } from "@/shared/utils/period"; @@ -182,7 +182,7 @@ export default async function Page({ params, searchParams }: PageProps) { estabelecimentos, userPreferences, ] = await Promise.all([ - fetchPagadorLancamentos(filters), + fetchPayerTransactions(filters), fetchPayerMonthlyBreakdown({ userId: dataOwnerId, payerId: pagador.id, @@ -193,22 +193,22 @@ export default async function Page({ params, searchParams }: PageProps) { payerId: pagador.id, period: selectedPeriod, }), - fetchPagadorCardUsage({ + fetchPayerCardUsage({ userId: dataOwnerId, payerId: pagador.id, period: selectedPeriod, }), - fetchPagadorBoletoStats({ + fetchPayerBoletoStats({ userId: dataOwnerId, payerId: pagador.id, period: selectedPeriod, }), - fetchPagadorBoletoItems({ + fetchPayerBoletoItems({ userId: dataOwnerId, payerId: pagador.id, period: selectedPeriod, }), - fetchPagadorPaymentStatus({ + fetchPayerPaymentStatus({ userId: dataOwnerId, payerId: pagador.id, period: selectedPeriod, @@ -333,7 +333,7 @@ export default async function Page({ params, searchParams }: PageProps) { /> - + {canEdit && payerData.shareCode ? (
diff --git a/src/app/(dashboard)/reports/card-usage/page.tsx b/src/app/(dashboard)/reports/card-usage/page.tsx index a6904cc..f565302 100644 --- a/src/app/(dashboard)/reports/card-usage/page.tsx +++ b/src/app/(dashboard)/reports/card-usage/page.tsx @@ -1,11 +1,11 @@ import { RiBankCard2Line } from "@remixicon/react"; import { connection } from "next/server"; -import { fetchCartoesReportData } from "@/features/reports/cards-report-queries"; import { CardCategoryBreakdown } from "@/features/reports/components/cards/card-category-breakdown"; import { CardInvoiceStatus } from "@/features/reports/components/cards/card-invoice-status"; import { CardTopExpenses } from "@/features/reports/components/cards/card-top-expenses"; import { CardUsageChart } from "@/features/reports/components/cards/card-usage-chart"; import { CardsOverview } from "@/features/reports/components/cards/cards-overview"; +import { fetchCartoesReportData } from "@/features/reports/lib/cards-report-queries"; import MonthNavigation from "@/shared/components/month-picker/month-navigation"; import { Card } from "@/shared/components/ui/card"; import { getUser } from "@/shared/lib/auth/server"; diff --git a/src/app/(dashboard)/reports/category-trends/page.tsx b/src/app/(dashboard)/reports/category-trends/page.tsx index 5ed6964..ac78840 100644 --- a/src/app/(dashboard)/reports/category-trends/page.tsx +++ b/src/app/(dashboard)/reports/category-trends/page.tsx @@ -1,15 +1,15 @@ import { redirect } from "next/navigation"; import { connection } from "next/server"; import type { Category } from "@/db/schema"; -import { fetchCategoryChartData } from "@/features/reports/category-chart-queries"; -import { fetchCategoryReport } from "@/features/reports/category-report-queries"; -import { fetchUserCategories } from "@/features/reports/category-trends-queries"; import { CategoryReportPage } from "@/features/reports/components/category-report-page"; import type { CategoryOption, FilterState, } from "@/features/reports/components/types"; -import { validateDateRange } from "@/features/reports/utils"; +import { fetchCategoryChartData } from "@/features/reports/lib/category-chart-queries"; +import { fetchCategoryReport } from "@/features/reports/lib/category-report-queries"; +import { fetchUserCategories } from "@/features/reports/lib/category-trends-queries"; +import { validateDateRange } from "@/features/reports/lib/utils"; import { getUserId } from "@/shared/lib/auth/server"; import type { CategoryReportFilters } from "@/shared/lib/types/reports"; import { addMonthsToPeriod, getCurrentPeriod } from "@/shared/utils/period"; diff --git a/src/app/(dashboard)/reports/establishments/page.tsx b/src/app/(dashboard)/reports/establishments/page.tsx index 44c44a5..0a3556d 100644 --- a/src/app/(dashboard)/reports/establishments/page.tsx +++ b/src/app/(dashboard)/reports/establishments/page.tsx @@ -34,7 +34,7 @@ const validatePeriodFilter = (value: string | null): PeriodFilter => { return "6"; }; -export default async function TopEstabelecimentosPage({ +export default async function TopEstablishmentsPage({ searchParams, }: PageProps) { await connection(); diff --git a/src/app/(dashboard)/transactions/import/page.tsx b/src/app/(dashboard)/transactions/import/page.tsx index b41789b..a034160 100644 --- a/src/app/(dashboard)/transactions/import/page.tsx +++ b/src/app/(dashboard)/transactions/import/page.tsx @@ -3,7 +3,7 @@ import { ImportPage } from "@/features/transactions/components/import/import-pag import { buildOptionSets, buildSluggedFilters, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import { fetchTransactionFilterSources } from "@/features/transactions/queries"; import { getUserId } from "@/shared/lib/auth/server"; diff --git a/src/app/(dashboard)/transactions/loading.tsx b/src/app/(dashboard)/transactions/loading.tsx index 4b51712..9362da2 100644 --- a/src/app/(dashboard)/transactions/loading.tsx +++ b/src/app/(dashboard)/transactions/loading.tsx @@ -8,7 +8,7 @@ import { Skeleton } from "@/shared/components/ui/skeleton"; * Loading state para a página de lançamentos * Mantém o mesmo layout da página final */ -export default function LancamentosLoading() { +export default function TransactionsLoading() { return (
{/* Month Picker placeholder */} diff --git a/src/app/(dashboard)/transactions/page.tsx b/src/app/(dashboard)/transactions/page.tsx index 0f143b5..b486dbc 100644 --- a/src/app/(dashboard)/transactions/page.tsx +++ b/src/app/(dashboard)/transactions/page.tsx @@ -11,7 +11,7 @@ import { mapTransactionsData, type ResolvedSearchParams, resolveTransactionPagination, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import { fetchRecentEstablishments, fetchTransactionFilterSources, diff --git a/src/app/(landing-page)/page.tsx b/src/app/(landing-page)/page.tsx index 02ff3b9..5b442d1 100644 --- a/src/app/(landing-page)/page.tsx +++ b/src/app/(landing-page)/page.tsx @@ -24,7 +24,7 @@ import { import { landingImages } from "@/features/landing/images"; import { fetchGitHubStats } from "@/features/landing/queries"; import { AnimatedThemeToggler } from "@/shared/components/animated-theme-toggler"; -import { Logo } from "@/shared/components/logo"; +import { Logo } from "@/shared/components/brand/logo"; import { NavbarShell } from "@/shared/components/navigation/navbar/navbar-shell"; import { Badge } from "@/shared/components/ui/badge"; import { Button } from "@/shared/components/ui/button"; diff --git a/src/app/api/transactions/[transactionId]/attachments/route.ts b/src/app/api/transactions/[transactionId]/attachments/route.ts index 7a2a3c8..4044ed6 100644 --- a/src/app/api/transactions/[transactionId]/attachments/route.ts +++ b/src/app/api/transactions/[transactionId]/attachments/route.ts @@ -1,5 +1,5 @@ import { NextResponse } from "next/server"; -import { fetchTransactionAttachments } from "@/features/transactions/attachment-queries"; +import { fetchTransactionAttachments } from "@/features/transactions/lib/attachment-queries"; import { getOptionalUserSession } from "@/shared/lib/auth/server"; const PRIVATE_RESPONSE_HEADERS = { diff --git a/src/app/api/transactions/installments/[seriesId]/anticipations/route.ts b/src/app/api/transactions/installments/[seriesId]/anticipations/route.ts index 3187c71..52f0de9 100644 --- a/src/app/api/transactions/installments/[seriesId]/anticipations/route.ts +++ b/src/app/api/transactions/installments/[seriesId]/anticipations/route.ts @@ -1,5 +1,5 @@ import { NextResponse } from "next/server"; -import { fetchInstallmentAnticipations } from "@/features/transactions/anticipation-queries"; +import { fetchInstallmentAnticipations } from "@/features/transactions/lib/anticipation-queries"; import { getOptionalUserSession } from "@/shared/lib/auth/server"; const PRIVATE_RESPONSE_HEADERS = { diff --git a/src/features/accounts/components/account-select-items.tsx b/src/features/accounts/components/account-select-items.tsx index 6abd3a9..ff9b902 100644 --- a/src/features/accounts/components/account-select-items.tsx +++ b/src/features/accounts/components/account-select-items.tsx @@ -1,6 +1,6 @@ "use client"; -import StatusDot from "@/shared/components/status-dot"; +import StatusDot from "@/shared/components/feedback/status-dot"; import { getAccountTypeIcon } from "@/shared/utils/icons"; export function AccountTypeSelectContent({ label }: { label: string }) { diff --git a/src/features/accounts/components/accounts-page.tsx b/src/features/accounts/components/accounts-page.tsx index 012f31f..337efd7 100644 --- a/src/features/accounts/components/accounts-page.tsx +++ b/src/features/accounts/components/accounts-page.tsx @@ -8,7 +8,7 @@ import { toast } from "sonner"; import { deleteAccountAction } from "@/features/accounts/actions"; import { AccountCard } from "@/features/accounts/components/account-card"; import { ConfirmActionDialog } from "@/shared/components/confirm-action-dialog"; -import { EmptyState } from "@/shared/components/empty-state"; +import { EmptyState } from "@/shared/components/feedback/empty-state"; import { Button } from "@/shared/components/ui/button"; import { Card } from "@/shared/components/ui/card"; import { diff --git a/src/features/accounts/queries.ts b/src/features/accounts/queries.ts index af88cb2..aaea78d 100644 --- a/src/features/accounts/queries.ts +++ b/src/features/accounts/queries.ts @@ -99,13 +99,13 @@ async function fetchAccountsByStatus( return { accounts, logoOptions }; } -export async function fetchAccountsForUser( +async function fetchAccountsForUser( userId: string, ): Promise<{ accounts: AccountData[]; logoOptions: string[] }> { return fetchAccountsByStatus(userId, false); } -export async function fetchInactiveForUser( +async function fetchInactiveForUser( userId: string, ): Promise<{ accounts: AccountData[]; logoOptions: string[] }> { return fetchAccountsByStatus(userId, true); diff --git a/src/features/accounts/statement-queries.ts b/src/features/accounts/statement-queries.ts index e869356..0edac9e 100644 --- a/src/features/accounts/statement-queries.ts +++ b/src/features/accounts/statement-queries.ts @@ -154,7 +154,7 @@ export async function fetchAccountSummary( }; } -export async function fetchAccountLancamentos( +export async function fetchAccountTransactions( filters: SQL[], settledOnly = true, ) { @@ -167,7 +167,7 @@ export async function fetchAccountLancamentos( }); } -export async function fetchAccountLancamentosPage( +export async function fetchAccountTransactionsPage( filters: SQL[], { page, diff --git a/src/features/attachments/components/attachments-page.tsx b/src/features/attachments/components/attachments-page.tsx index 22f82b3..379a4d6 100644 --- a/src/features/attachments/components/attachments-page.tsx +++ b/src/features/attachments/components/attachments-page.tsx @@ -18,7 +18,7 @@ import { fetchTransactionDialogOptionsAction } from "@/features/transactions/act import { TransactionDetailsDialog } from "@/features/transactions/components/dialogs/transaction-details-dialog"; import { TransactionDialog } from "@/features/transactions/components/dialogs/transaction-dialog/transaction-dialog"; import type { TransactionItem } from "@/features/transactions/components/types"; -import { EmptyState } from "@/shared/components/empty-state"; +import { EmptyState } from "@/shared/components/feedback/empty-state"; import { Card, CardContent } from "@/shared/components/ui/card"; import { cn } from "@/shared/utils/ui"; diff --git a/src/features/attachments/hooks/use-attachment-url.ts b/src/features/attachments/hooks/use-attachment-url.ts index 437fba5..46d287e 100644 --- a/src/features/attachments/hooks/use-attachment-url.ts +++ b/src/features/attachments/hooks/use-attachment-url.ts @@ -2,11 +2,11 @@ import { useQuery } from "@tanstack/react-query"; import { useEffect, useRef, useState } from "react"; -import { fetchJson } from "@/shared/lib/fetch-json"; +import { fetchJson } from "@/shared/utils/fetch-json"; const ATTACHMENT_URL_STALE_TIME = 4 * 60 * 1000; -export const attachmentUrlQueryKey = (attachmentId: string) => +const attachmentUrlQueryKey = (attachmentId: string) => ["attachments", "url", attachmentId] as const; export function useAttachmentUrlQuery(attachmentId: string, enabled: boolean) { diff --git a/src/features/auth/components/auth-sidebar.tsx b/src/features/auth/components/auth-sidebar.tsx index ac2c1bf..9f65f43 100644 --- a/src/features/auth/components/auth-sidebar.tsx +++ b/src/features/auth/components/auth-sidebar.tsx @@ -3,7 +3,7 @@ import { RiBarChart2Line, RiShieldCheckLine, } from "@remixicon/react"; -import { Logo } from "@/shared/components/logo"; +import { Logo } from "@/shared/components/brand/logo"; import { DotPattern } from "@/shared/components/ui/dot-pattern"; import { AuthSidebarInvoicesMock } from "./auth-sidebar-invoices-mock"; diff --git a/src/features/budgets/components/budgets-page.tsx b/src/features/budgets/components/budgets-page.tsx index 5a55fa2..3fff581 100644 --- a/src/features/budgets/components/budgets-page.tsx +++ b/src/features/budgets/components/budgets-page.tsx @@ -8,7 +8,7 @@ import { duplicatePreviousMonthBudgetsAction, } from "@/features/budgets/actions"; import { ConfirmActionDialog } from "@/shared/components/confirm-action-dialog"; -import { EmptyState } from "@/shared/components/empty-state"; +import { EmptyState } from "@/shared/components/feedback/empty-state"; import { Button } from "@/shared/components/ui/button"; import { Card } from "@/shared/components/ui/card"; import { BudgetCard } from "./budget-card"; diff --git a/src/features/budgets/queries.ts b/src/features/budgets/queries.ts index 2d3e902..33233f6 100644 --- a/src/features/budgets/queries.ts +++ b/src/features/budgets/queries.ts @@ -26,7 +26,7 @@ type BudgetData = { } | null; }; -export type CategoryOption = { +type CategoryOption = { id: string; name: string; icon: string | null; diff --git a/src/features/calendar/queries.ts b/src/features/calendar/queries.ts index 09297c8..13b8bb8 100644 --- a/src/features/calendar/queries.ts +++ b/src/features/calendar/queries.ts @@ -4,7 +4,7 @@ import { buildOptionSets, buildSluggedFilters, mapTransactionsData, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import { fetchRecentEstablishments, fetchTransactionFilterSources, diff --git a/src/features/cards/components/card-select-items.tsx b/src/features/cards/components/card-select-items.tsx index 3cb7285..019fdeb 100644 --- a/src/features/cards/components/card-select-items.tsx +++ b/src/features/cards/components/card-select-items.tsx @@ -2,7 +2,7 @@ import { RiBankLine } from "@remixicon/react"; import Image from "next/image"; -import StatusDot from "@/shared/components/status-dot"; +import StatusDot from "@/shared/components/feedback/status-dot"; import { resolveCardBrandLogoSrc } from "@/shared/lib/cards/brand-assets"; import { resolveLogoSrc } from "@/shared/lib/logo"; diff --git a/src/features/cards/components/cards-page.tsx b/src/features/cards/components/cards-page.tsx index b73d1ce..68c38b1 100644 --- a/src/features/cards/components/cards-page.tsx +++ b/src/features/cards/components/cards-page.tsx @@ -6,7 +6,7 @@ import { useMemo, useState } from "react"; import { toast } from "sonner"; import { deleteCardAction } from "@/features/cards/actions"; import { ConfirmActionDialog } from "@/shared/components/confirm-action-dialog"; -import { EmptyState } from "@/shared/components/empty-state"; +import { EmptyState } from "@/shared/components/feedback/empty-state"; import { Button } from "@/shared/components/ui/button"; import { Card as UiCard } from "@/shared/components/ui/card"; import { diff --git a/src/features/cards/queries.ts b/src/features/cards/queries.ts index 06fab5e..0041381 100644 --- a/src/features/cards/queries.ts +++ b/src/features/cards/queries.ts @@ -19,7 +19,7 @@ type CardData = { accountName: string; }; -export type AccountSimple = { +type AccountSimple = { id: string; name: string; logo: string | null; @@ -121,7 +121,7 @@ async function fetchCardsByStatus( return { cards: cardList, accounts, logoOptions }; } -export async function fetchCardsForUser(userId: string): Promise<{ +async function fetchCardsForUser(userId: string): Promise<{ cards: CardData[]; accounts: AccountSimple[]; logoOptions: string[]; @@ -129,7 +129,7 @@ export async function fetchCardsForUser(userId: string): Promise<{ return fetchCardsByStatus(userId, false); } -export async function fetchInactiveForUser(userId: string): Promise<{ +async function fetchInactiveForUser(userId: string): Promise<{ cards: CardData[]; accounts: AccountSimple[]; logoOptions: string[]; diff --git a/src/features/categories/components/category-select-items.tsx b/src/features/categories/components/category-select-items.tsx index bac4bf6..b8e77a0 100644 --- a/src/features/categories/components/category-select-items.tsx +++ b/src/features/categories/components/category-select-items.tsx @@ -1,6 +1,6 @@ "use client"; -import StatusDot from "@/shared/components/status-dot"; +import StatusDot from "@/shared/components/feedback/status-dot"; export function TypeSelectContent({ label }: { label: string }) { const isReceita = label === "Receita"; diff --git a/src/features/categories/queries.ts b/src/features/categories/queries.ts index 82607b1..8a0077f 100644 --- a/src/features/categories/queries.ts +++ b/src/features/categories/queries.ts @@ -3,7 +3,7 @@ import { type Category, categories } from "@/db/schema"; import type { CategoryType } from "@/shared/lib/categories/constants"; import { db } from "@/shared/lib/db"; -export type CategoryData = { +type CategoryData = { id: string; name: string; type: CategoryType; diff --git a/src/features/dashboard/bills/bills-helpers.ts b/src/features/dashboard/bills/bills-helpers.ts index 99c2552..8dbc2a2 100644 --- a/src/features/dashboard/bills/bills-helpers.ts +++ b/src/features/dashboard/bills/bills-helpers.ts @@ -8,7 +8,7 @@ import { } from "@/shared/utils/financial-dates"; export type BillDialogState = PaymentDialogState; -export type BillStatusDateItem = Pick< +type BillStatusDateItem = Pick< DashboardBill, "dueDate" | "boletoPaymentDate" | "isSettled" >; diff --git a/src/features/dashboard/categories/category-details-queries.ts b/src/features/dashboard/categories/category-details-queries.ts index 54a4f15..ef35090 100644 --- a/src/features/dashboard/categories/category-details-queries.ts +++ b/src/features/dashboard/categories/category-details-queries.ts @@ -1,6 +1,6 @@ import { and, desc, eq, isNull, ne, or, sql } from "drizzle-orm"; import { categories, financialAccounts, transactions } from "@/db/schema"; -import { mapTransactionsData } from "@/features/transactions/page-helpers"; +import { mapTransactionsData } from "@/features/transactions/lib/page-helpers"; import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX, INITIAL_BALANCE_NOTE, @@ -17,7 +17,7 @@ import { getPreviousPeriod } from "@/shared/utils/period"; type MappedLancamentos = ReturnType; -export type CategoryDetailData = { +type CategoryDetailData = { category: { id: string; name: string; diff --git a/src/features/dashboard/categories/category-history-queries.ts b/src/features/dashboard/categories/category-history-queries.ts index 4a9eea2..282275a 100644 --- a/src/features/dashboard/categories/category-history-queries.ts +++ b/src/features/dashboard/categories/category-history-queries.ts @@ -11,14 +11,14 @@ import { formatPeriodMonthShort, } from "@/shared/utils/period"; -export type CategoryOption = { +type CategoryOption = { id: string; name: string; icon: string | null; type: "receita" | "despesa"; }; -export type CategoryHistoryItem = { +type CategoryHistoryItem = { id: string; name: string; icon: string | null; diff --git a/src/features/dashboard/categories/category-overview-queries.ts b/src/features/dashboard/categories/category-overview-queries.ts index 2437ef7..4067862 100644 --- a/src/features/dashboard/categories/category-overview-queries.ts +++ b/src/features/dashboard/categories/category-overview-queries.ts @@ -22,7 +22,7 @@ import { excludeInitialBalanceWhenConfigured, excludeRefundEntries, excludeTransactionsFromExcludedAccounts, -} from "@/features/dashboard/transaction-filters"; +} from "@/features/dashboard/lib/transaction-filters"; import { db } from "@/shared/lib/db"; import { getAdminPayerId } from "@/shared/lib/payers/get-admin-id"; import { safeToNumber as toNumber } from "@/shared/utils/number"; diff --git a/src/features/dashboard/categories/purchases-by-category-queries.ts b/src/features/dashboard/categories/purchases-by-category-queries.ts index 986abf0..d66e51d 100644 --- a/src/features/dashboard/categories/purchases-by-category-queries.ts +++ b/src/features/dashboard/categories/purchases-by-category-queries.ts @@ -1,10 +1,10 @@ -export type CategoryOption = { +type CategoryOption = { id: string; name: string; type: string; }; -export type CategoryTransaction = { +type CategoryTransaction = { id: string; name: string; amount: number; diff --git a/src/features/dashboard/components/bills/bill-payment-dialog.tsx b/src/features/dashboard/components/bills/bill-payment-dialog.tsx index 7195e5a..46878bf 100644 --- a/src/features/dashboard/components/bills/bill-payment-dialog.tsx +++ b/src/features/dashboard/components/bills/bill-payment-dialog.tsx @@ -14,8 +14,8 @@ import type { } from "@/features/dashboard/bills/bills-queries"; import { AccountCardSelectContent } from "@/features/transactions/components/select-items"; import { EstablishmentLogo } from "@/shared/components/entity-avatar"; +import { PaymentSuccess } from "@/shared/components/feedback/payment-success"; import MoneyValues from "@/shared/components/money-values"; -import { PaymentSuccess } from "@/shared/components/payment-success"; import { Badge } from "@/shared/components/ui/badge"; import { Button } from "@/shared/components/ui/button"; import { Card } from "@/shared/components/ui/card"; diff --git a/src/features/dashboard/components/bills/bills-list.tsx b/src/features/dashboard/components/bills/bills-list.tsx index 9f085d7..0acdcaa 100644 --- a/src/features/dashboard/components/bills/bills-list.tsx +++ b/src/features/dashboard/components/bills/bills-list.tsx @@ -1,6 +1,6 @@ import { RiBarcodeFill } from "@remixicon/react"; import type { DashboardBill } from "@/features/dashboard/bills/bills-queries"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { BillListItem } from "./bill-list-item"; type BillsListProps = { diff --git a/src/features/dashboard/components/category-breakdown/category-breakdown-widget-view.tsx b/src/features/dashboard/components/category-breakdown/category-breakdown-widget-view.tsx index 87a94a5..df8e029 100644 --- a/src/features/dashboard/components/category-breakdown/category-breakdown-widget-view.tsx +++ b/src/features/dashboard/components/category-breakdown/category-breakdown-widget-view.tsx @@ -13,7 +13,7 @@ import { TabsList, TabsTrigger, } from "@/shared/components/ui/tabs"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { formatPeriodForUrl } from "@/shared/utils/period"; import { CategoryBreakdownChart } from "./category-breakdown-chart"; import { CategoryBreakdownList } from "./category-breakdown-list"; diff --git a/src/features/dashboard/components/dashboard-grid-editable.tsx b/src/features/dashboard/components/dashboard-grid-editable.tsx index 860a722..0be3ced 100644 --- a/src/features/dashboard/components/dashboard-grid-editable.tsx +++ b/src/features/dashboard/components/dashboard-grid-editable.tsx @@ -40,8 +40,8 @@ import { } from "@/features/dashboard/widget-registry/widget-config"; import { NoteDialog } from "@/features/notes/components/note-dialog"; import { TransactionDialog } from "@/features/transactions/components/dialogs/transaction-dialog/transaction-dialog"; -import { ExpandableWidgetCard } from "@/shared/components/expandable-widget-card"; import { Button } from "@/shared/components/ui/button"; +import { ExpandableWidgetCard } from "@/shared/components/widgets/expandable-widget-card"; type DashboardGridEditableProps = { data: DashboardData; diff --git a/src/features/dashboard/components/goals-progress/goals-progress-list.tsx b/src/features/dashboard/components/goals-progress/goals-progress-list.tsx index d97af68..fee590c 100644 --- a/src/features/dashboard/components/goals-progress/goals-progress-list.tsx +++ b/src/features/dashboard/components/goals-progress/goals-progress-list.tsx @@ -1,6 +1,6 @@ import { RiFundsLine } from "@remixicon/react"; import type { GoalProgressItem } from "@/features/dashboard/goals-progress/goals-progress-queries"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { GoalProgressItem as GoalProgressListItem } from "./goals-progress-item"; type GoalsProgressListProps = { diff --git a/src/features/dashboard/components/installment-expenses/installment-expenses-list.tsx b/src/features/dashboard/components/installment-expenses/installment-expenses-list.tsx index 9a62335..5062ed1 100644 --- a/src/features/dashboard/components/installment-expenses/installment-expenses-list.tsx +++ b/src/features/dashboard/components/installment-expenses/installment-expenses-list.tsx @@ -1,6 +1,6 @@ import { RiNumbersLine } from "@remixicon/react"; import type { InstallmentExpense } from "@/features/dashboard/expenses/installment-expenses-queries"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { InstallmentExpenseListItem } from "./installment-expense-list-item"; type InstallmentExpensesListProps = { diff --git a/src/features/dashboard/components/invoices/invoice-payment-dialog.tsx b/src/features/dashboard/components/invoices/invoice-payment-dialog.tsx index 9799471..b7fc2e3 100644 --- a/src/features/dashboard/components/invoices/invoice-payment-dialog.tsx +++ b/src/features/dashboard/components/invoices/invoice-payment-dialog.tsx @@ -14,8 +14,8 @@ import type { InvoicePaymentAccountOption, } from "@/features/dashboard/invoices/invoices-queries"; import { AccountCardSelectContent } from "@/features/transactions/components/select-items"; +import { PaymentSuccess } from "@/shared/components/feedback/payment-success"; import MoneyValues from "@/shared/components/money-values"; -import { PaymentSuccess } from "@/shared/components/payment-success"; import { Badge } from "@/shared/components/ui/badge"; import { Button } from "@/shared/components/ui/button"; import { Card } from "@/shared/components/ui/card"; diff --git a/src/features/dashboard/components/invoices/invoices-list.tsx b/src/features/dashboard/components/invoices/invoices-list.tsx index c9ce3d5..44195b4 100644 --- a/src/features/dashboard/components/invoices/invoices-list.tsx +++ b/src/features/dashboard/components/invoices/invoices-list.tsx @@ -1,6 +1,6 @@ import { RiBillLine } from "@remixicon/react"; import type { DashboardInvoice } from "@/features/dashboard/invoices/invoices-queries"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { InvoiceListItem } from "./invoice-list-item"; type InvoicesListProps = { diff --git a/src/features/dashboard/components/notes/notes-list.tsx b/src/features/dashboard/components/notes/notes-list.tsx index 8beeb15..9edd713 100644 --- a/src/features/dashboard/components/notes/notes-list.tsx +++ b/src/features/dashboard/components/notes/notes-list.tsx @@ -1,6 +1,6 @@ import { RiTodoLine } from "@remixicon/react"; import type { Note } from "@/features/notes/components/types"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { NoteListItem } from "./note-list-item"; type NotesListProps = { diff --git a/src/features/dashboard/components/payment-overview/payment-breakdown-list.tsx b/src/features/dashboard/components/payment-overview/payment-breakdown-list.tsx index 1da7954..d4295da 100644 --- a/src/features/dashboard/components/payment-overview/payment-breakdown-list.tsx +++ b/src/features/dashboard/components/payment-overview/payment-breakdown-list.tsx @@ -1,5 +1,5 @@ import type { ReactNode } from "react"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { PaymentBreakdownListItem, type PaymentBreakdownListItemData, diff --git a/src/features/dashboard/components/payment-status/payment-status-category-section.tsx b/src/features/dashboard/components/payment-status/payment-status-category-section.tsx index 907f9c8..e9a4718 100644 --- a/src/features/dashboard/components/payment-status/payment-status-category-section.tsx +++ b/src/features/dashboard/components/payment-status/payment-status-category-section.tsx @@ -1,5 +1,5 @@ +import StatusDot from "@/shared/components/feedback/status-dot"; import MoneyValues from "@/shared/components/money-values"; -import StatusDot from "@/shared/components/status-dot"; import { Progress } from "@/shared/components/ui/progress"; type PaymentStatusCategorySectionProps = { diff --git a/src/features/dashboard/components/payment-status/payment-status-widget-view.tsx b/src/features/dashboard/components/payment-status/payment-status-widget-view.tsx index 2bcb77b..49605e2 100644 --- a/src/features/dashboard/components/payment-status/payment-status-widget-view.tsx +++ b/src/features/dashboard/components/payment-status/payment-status-widget-view.tsx @@ -1,7 +1,7 @@ import { RiWallet3Line } from "@remixicon/react"; import type { PaymentStatusData } from "@/features/dashboard/payments/payment-status-queries"; import { CardContent } from "@/shared/components/ui/card"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { PaymentStatusCategorySection } from "./payment-status-category-section"; type PaymentStatusWidgetViewProps = { diff --git a/src/features/dashboard/components/percentage-change-indicator.tsx b/src/features/dashboard/components/percentage-change-indicator.tsx index 182dff5..ba64254 100644 --- a/src/features/dashboard/components/percentage-change-indicator.tsx +++ b/src/features/dashboard/components/percentage-change-indicator.tsx @@ -6,7 +6,7 @@ import { import { formatPercentage } from "@/shared/utils/percentage"; import { cn } from "@/shared/utils/ui"; -export type PercentageChangeTrend = "up" | "down" | "flat"; +type PercentageChangeTrend = "up" | "down" | "flat"; type PercentageChangeIndicatorProps = { value?: number | null; diff --git a/src/features/dashboard/components/widgets/attachments-widget.tsx b/src/features/dashboard/components/widgets/attachments-widget.tsx index e78731c..5c03bfd 100644 --- a/src/features/dashboard/components/widgets/attachments-widget.tsx +++ b/src/features/dashboard/components/widgets/attachments-widget.tsx @@ -14,7 +14,7 @@ import { TooltipContent, TooltipTrigger, } from "@/shared/components/ui/tooltip"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { formatDateOnly } from "@/shared/utils/date"; import { formatBytes } from "@/shared/utils/number"; diff --git a/src/features/dashboard/components/widgets/category-history-widget.tsx b/src/features/dashboard/components/widgets/category-history-widget.tsx index a14960d..7a8bd8a 100644 --- a/src/features/dashboard/components/widgets/category-history-widget.tsx +++ b/src/features/dashboard/components/widgets/category-history-widget.tsx @@ -26,7 +26,7 @@ import { PopoverContent, PopoverTrigger, } from "@/shared/components/ui/popover"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { CATEGORY_COLORS } from "@/shared/utils/category-colors"; import { formatCurrency, formatCurrencyCompact } from "@/shared/utils/currency"; import { getIconComponent } from "@/shared/utils/icons"; diff --git a/src/features/dashboard/components/widgets/category-trends-widget.tsx b/src/features/dashboard/components/widgets/category-trends-widget.tsx index 46e91e9..fd2204f 100644 --- a/src/features/dashboard/components/widgets/category-trends-widget.tsx +++ b/src/features/dashboard/components/widgets/category-trends-widget.tsx @@ -5,7 +5,7 @@ import type { DashboardCategoryBreakdownItem } from "@/features/dashboard/catego import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator"; import { CategoryIconBadge } from "@/shared/components/entity-avatar"; import MoneyValues from "@/shared/components/money-values"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { formatPercentage } from "@/shared/utils/percentage"; type CategoryTrendsWidgetProps = { diff --git a/src/features/dashboard/components/widgets/inbox-widget.tsx b/src/features/dashboard/components/widgets/inbox-widget.tsx index 1e02d92..6559993 100644 --- a/src/features/dashboard/components/widgets/inbox-widget.tsx +++ b/src/features/dashboard/components/widgets/inbox-widget.tsx @@ -9,7 +9,7 @@ import Image from "next/image"; import { useRouter } from "next/navigation"; import { useMemo, useState } from "react"; import { toast } from "sonner"; -import type { DashboardInboxSnapshot } from "@/features/dashboard/inbox-snapshot-queries"; +import type { DashboardInboxSnapshot } from "@/features/dashboard/lib/inbox-snapshot-queries"; import type { DashboardWidgetQuickActionOptions } from "@/features/dashboard/widget-registry/widget-config"; import { discardInboxItemAction, @@ -19,7 +19,7 @@ import { TransactionDialog } from "@/features/transactions/components/dialogs/tr import { ConfirmActionDialog } from "@/shared/components/confirm-action-dialog"; import MoneyValues from "@/shared/components/money-values"; import { Button } from "@/shared/components/ui/button"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { resolveLogoSrc } from "@/shared/lib/logo"; const DEFAULT_INBOX_APP_LOGO = "/avatars/default_icon.png"; diff --git a/src/features/dashboard/components/widgets/income-expense-balance-widget.tsx b/src/features/dashboard/components/widgets/income-expense-balance-widget.tsx index c3888aa..807f57b 100644 --- a/src/features/dashboard/components/widgets/income-expense-balance-widget.tsx +++ b/src/features/dashboard/components/widgets/income-expense-balance-widget.tsx @@ -9,7 +9,7 @@ import { ChartContainer, ChartTooltip, } from "@/shared/components/ui/chart"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { formatCurrency } from "@/shared/utils/currency"; type IncomeExpenseBalanceWidgetProps = { diff --git a/src/features/dashboard/components/widgets/my-accounts-widget.tsx b/src/features/dashboard/components/widgets/my-accounts-widget.tsx index 79bc1bf..6ce110e 100644 --- a/src/features/dashboard/components/widgets/my-accounts-widget.tsx +++ b/src/features/dashboard/components/widgets/my-accounts-widget.tsx @@ -10,7 +10,7 @@ import Image from "next/image"; import Link from "next/link"; import { useTransition } from "react"; import { toast } from "sonner"; -import type { DashboardAccount } from "@/features/dashboard/accounts-queries"; +import type { DashboardAccount } from "@/features/dashboard/lib/accounts-queries"; import { updateMyAccountsWidgetPreference } from "@/features/dashboard/widget-registry/widget-actions"; import MoneyValues from "@/shared/components/money-values"; import { Badge } from "@/shared/components/ui/badge"; @@ -21,7 +21,7 @@ import { TooltipContent, TooltipTrigger, } from "@/shared/components/ui/tooltip"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { isAccountInactive } from "@/shared/lib/accounts/constants"; import { resolveLogoSrc } from "@/shared/lib/logo"; import { formatPeriodForUrl } from "@/shared/utils/period"; diff --git a/src/features/dashboard/components/widgets/payers-widget.tsx b/src/features/dashboard/components/widgets/payers-widget.tsx index 0c51600..258b808 100644 --- a/src/features/dashboard/components/widgets/payers-widget.tsx +++ b/src/features/dashboard/components/widgets/payers-widget.tsx @@ -7,14 +7,14 @@ import { } from "@remixicon/react"; import Link from "next/link"; import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator"; -import type { DashboardPagador } from "@/features/dashboard/payers-queries"; +import type { DashboardPagador } from "@/features/dashboard/lib/payers-queries"; import MoneyValues from "@/shared/components/money-values"; import { Avatar, AvatarFallback, AvatarImage, } from "@/shared/components/ui/avatar"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { getAvatarSrc } from "@/shared/lib/payers/utils"; import { buildInitials } from "@/shared/utils/initials"; diff --git a/src/features/dashboard/components/widgets/purchases-by-category-widget.tsx b/src/features/dashboard/components/widgets/purchases-by-category-widget.tsx index 2804081..2f12dcd 100644 --- a/src/features/dashboard/components/widgets/purchases-by-category-widget.tsx +++ b/src/features/dashboard/components/widgets/purchases-by-category-widget.tsx @@ -12,7 +12,7 @@ import { SelectTrigger, SelectValue, } from "@/shared/components/ui/select"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { CATEGORY_TYPE_LABEL } from "@/shared/lib/categories/constants"; import { formatTransactionDate } from "@/shared/utils/date"; diff --git a/src/features/dashboard/components/widgets/recurring-expenses-widget.tsx b/src/features/dashboard/components/widgets/recurring-expenses-widget.tsx index 41b584a..b2a937f 100644 --- a/src/features/dashboard/components/widgets/recurring-expenses-widget.tsx +++ b/src/features/dashboard/components/widgets/recurring-expenses-widget.tsx @@ -2,7 +2,7 @@ import { RiRefreshLine } from "@remixicon/react"; import type { RecurringExpensesData } from "@/features/dashboard/expenses/recurring-expenses-queries"; import { EstablishmentLogo } from "@/shared/components/entity-avatar"; import MoneyValues from "@/shared/components/money-values"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; type RecurringExpensesWidgetProps = { data: RecurringExpensesData; diff --git a/src/features/dashboard/components/widgets/spending-overview-widget.tsx b/src/features/dashboard/components/widgets/spending-overview-widget.tsx index a29b882..7430044 100644 --- a/src/features/dashboard/components/widgets/spending-overview-widget.tsx +++ b/src/features/dashboard/components/widgets/spending-overview-widget.tsx @@ -3,7 +3,7 @@ import { RiArrowUpDoubleLine, RiStore2Line } from "@remixicon/react"; import { useState } from "react"; import type { TopExpensesData } from "@/features/dashboard/expenses/top-expenses-queries"; -import type { TopEstablishmentsData } from "@/features/dashboard/top-establishments-queries"; +import type { TopEstablishmentsData } from "@/features/dashboard/lib/top-establishments-queries"; import { Tabs, TabsContent, diff --git a/src/features/dashboard/components/widgets/top-establishments-widget.tsx b/src/features/dashboard/components/widgets/top-establishments-widget.tsx index e3742a7..29ee1bb 100644 --- a/src/features/dashboard/components/widgets/top-establishments-widget.tsx +++ b/src/features/dashboard/components/widgets/top-establishments-widget.tsx @@ -1,8 +1,8 @@ import { RiStore2Line } from "@remixicon/react"; -import type { TopEstablishmentsData } from "@/features/dashboard/top-establishments-queries"; +import type { TopEstablishmentsData } from "@/features/dashboard/lib/top-establishments-queries"; import { EstablishmentLogo } from "@/shared/components/entity-avatar"; import MoneyValues from "@/shared/components/money-values"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; type TopEstablishmentsWidgetProps = { data: TopEstablishmentsData; diff --git a/src/features/dashboard/components/widgets/top-expenses-widget.tsx b/src/features/dashboard/components/widgets/top-expenses-widget.tsx index fddf358..9d3b06b 100644 --- a/src/features/dashboard/components/widgets/top-expenses-widget.tsx +++ b/src/features/dashboard/components/widgets/top-expenses-widget.tsx @@ -9,7 +9,7 @@ import type { import { EstablishmentLogo } from "@/shared/components/entity-avatar"; import MoneyValues from "@/shared/components/money-values"; import { Switch } from "@/shared/components/ui/switch"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { formatTransactionDate } from "@/shared/utils/date"; type TopExpensesWidgetProps = { diff --git a/src/features/dashboard/expenses/installment-analysis-queries.ts b/src/features/dashboard/expenses/installment-analysis-queries.ts index 427d903..a92bb67 100644 --- a/src/features/dashboard/expenses/installment-analysis-queries.ts +++ b/src/features/dashboard/expenses/installment-analysis-queries.ts @@ -31,7 +31,7 @@ function calculateDueDate(period: string, dueDay: string | null): Date | null { } } -export type InstallmentDetail = { +type InstallmentDetail = { id: string; currentInstallment: number; amount: number; diff --git a/src/features/dashboard/expenses/installment-expenses-helpers.ts b/src/features/dashboard/expenses/installment-expenses-helpers.ts index 6288b59..a827b9b 100644 --- a/src/features/dashboard/expenses/installment-expenses-helpers.ts +++ b/src/features/dashboard/expenses/installment-expenses-helpers.ts @@ -4,7 +4,7 @@ import { formatLastInstallmentDate, } from "@/shared/lib/installments/utils"; -export type InstallmentExpenseDisplay = { +type InstallmentExpenseDisplay = { compactLabel: string | null; isLast: boolean; remainingInstallments: number; @@ -13,7 +13,7 @@ export type InstallmentExpenseDisplay = { progress: number; }; -export const buildInstallmentCompactLabel = ( +const buildInstallmentCompactLabel = ( currentInstallment: number | null, installmentCount: number | null, ) => { @@ -24,7 +24,7 @@ export const buildInstallmentCompactLabel = ( return null; }; -export const isInstallmentLast = ( +const isInstallmentLast = ( currentInstallment: number | null, installmentCount: number | null, ) => { @@ -35,7 +35,7 @@ export const isInstallmentLast = ( return currentInstallment === installmentCount && installmentCount > 1; }; -export const calculateInstallmentRemainingCount = ( +const calculateInstallmentRemainingCount = ( currentInstallment: number | null, installmentCount: number | null, ) => { @@ -46,7 +46,7 @@ export const calculateInstallmentRemainingCount = ( return Math.max(0, installmentCount - currentInstallment); }; -export const calculateInstallmentRemainingAmount = ( +const calculateInstallmentRemainingAmount = ( amount: number, currentInstallment: number | null, installmentCount: number | null, @@ -54,7 +54,7 @@ export const calculateInstallmentRemainingAmount = ( amount * calculateInstallmentRemainingCount(currentInstallment, installmentCount); -export const formatInstallmentEndDate = ( +const formatInstallmentEndDate = ( period: string, currentInstallment: number | null, installmentCount: number | null, @@ -72,7 +72,7 @@ export const formatInstallmentEndDate = ( return formatLastInstallmentDate(lastDate); }; -export const buildInstallmentProgress = ( +const buildInstallmentProgress = ( currentInstallment: number | null, installmentCount: number | null, ) => { diff --git a/src/features/dashboard/expenses/recurring-expenses-queries.ts b/src/features/dashboard/expenses/recurring-expenses-queries.ts index 71c4e9b..8a73cf5 100644 --- a/src/features/dashboard/expenses/recurring-expenses-queries.ts +++ b/src/features/dashboard/expenses/recurring-expenses-queries.ts @@ -1,4 +1,4 @@ -export type RecurringExpense = { +type RecurringExpense = { id: string; name: string; amount: number; diff --git a/src/features/dashboard/fetch-dashboard-data.ts b/src/features/dashboard/fetch-dashboard-data.ts index 081a0d4..aa34cdc 100644 --- a/src/features/dashboard/fetch-dashboard-data.ts +++ b/src/features/dashboard/fetch-dashboard-data.ts @@ -1,13 +1,13 @@ import { cacheLife, cacheTag } from "next/cache"; import { fetchAttachmentsForPeriod } from "@/features/attachments/queries"; -import { fetchDashboardAccounts } from "./accounts-queries"; import { fetchDashboardCategoryOverview } from "./categories/category-overview-queries"; -import { fetchDashboardInboxSnapshot } from "./inbox-snapshot-queries"; import { fetchDashboardInvoices } from "./invoices/invoices-queries"; +import { fetchDashboardAccounts } from "./lib/accounts-queries"; +import { fetchDashboardInboxSnapshot } from "./lib/inbox-snapshot-queries"; +import { fetchDashboardPayers } from "./lib/payers-queries"; import { fetchDashboardNotes } from "./notes/notes-queries"; import { fetchDashboardCurrentPeriodOverview } from "./overview/current-period-overview-queries"; import { fetchDashboardPeriodOverview } from "./overview/period-overview-queries"; -import { fetchDashboardPayers } from "./payers-queries"; async function fetchDashboardDataInternal(userId: string, period: string) { const [ diff --git a/src/features/dashboard/goals-progress/goals-progress-helpers.ts b/src/features/dashboard/goals-progress/goals-progress-helpers.ts index e51ee1a..1c688a3 100644 --- a/src/features/dashboard/goals-progress/goals-progress-helpers.ts +++ b/src/features/dashboard/goals-progress/goals-progress-helpers.ts @@ -5,7 +5,6 @@ import type { import type { GoalProgressCategory, GoalProgressItem, - GoalProgressStatus, } from "@/features/dashboard/goals-progress/goals-progress-queries"; import { formatPercentage } from "@/shared/utils/percentage"; @@ -18,9 +17,6 @@ export const formatGoalProgressPercentage = (value: number, withSign = false) => signDisplay: withSign ? "always" : "auto", }); -export const getGoalProgressStatusColorClass = (status: GoalProgressStatus) => - status === "exceeded" ? "text-destructive" : ""; - export const mapGoalProgressCategoriesToBudgetCategories = ( categories: GoalProgressCategory[], ): BudgetCategory[] => diff --git a/src/features/dashboard/goals-progress/goals-progress-queries.ts b/src/features/dashboard/goals-progress/goals-progress-queries.ts index d440bed..34d3b74 100644 --- a/src/features/dashboard/goals-progress/goals-progress-queries.ts +++ b/src/features/dashboard/goals-progress/goals-progress-queries.ts @@ -1,4 +1,4 @@ -export type GoalProgressStatus = "on-track" | "critical" | "exceeded"; +type GoalProgressStatus = "on-track" | "critical" | "exceeded"; export type GoalProgressItem = { id: string; diff --git a/src/features/dashboard/invoices/invoices-queries.ts b/src/features/dashboard/invoices/invoices-queries.ts index 75db3d1..bab1cd7 100644 --- a/src/features/dashboard/invoices/invoices-queries.ts +++ b/src/features/dashboard/invoices/invoices-queries.ts @@ -55,7 +55,7 @@ type RawInvoiceBreakdownRow = { amount: number | string | null; }; -export type InvoicePagadorBreakdown = { +type InvoicePagadorBreakdown = { payerId: string | null; pagadorName: string; pagadorAvatar: string | null; diff --git a/src/features/dashboard/accounts-queries.ts b/src/features/dashboard/lib/accounts-queries.ts similarity index 100% rename from src/features/dashboard/accounts-queries.ts rename to src/features/dashboard/lib/accounts-queries.ts diff --git a/src/features/dashboard/extract-logo-names.ts b/src/features/dashboard/lib/extract-logo-names.ts similarity index 94% rename from src/features/dashboard/extract-logo-names.ts rename to src/features/dashboard/lib/extract-logo-names.ts index 8b64377..25d2f7c 100644 --- a/src/features/dashboard/extract-logo-names.ts +++ b/src/features/dashboard/lib/extract-logo-names.ts @@ -1,4 +1,4 @@ -import type { DashboardData } from "./fetch-dashboard-data"; +import type { DashboardData } from "../fetch-dashboard-data"; /** * Coleta todos os nomes de estabelecimentos exibidos nos widgets do diff --git a/src/features/dashboard/inbox-snapshot-queries.ts b/src/features/dashboard/lib/inbox-snapshot-queries.ts similarity index 98% rename from src/features/dashboard/inbox-snapshot-queries.ts rename to src/features/dashboard/lib/inbox-snapshot-queries.ts index 6bf7a2f..915f2db 100644 --- a/src/features/dashboard/inbox-snapshot-queries.ts +++ b/src/features/dashboard/lib/inbox-snapshot-queries.ts @@ -3,7 +3,7 @@ import { cacheLife, cacheTag } from "next/cache"; import { cards, financialAccounts, inboxItems } from "@/db/schema"; import { db } from "@/shared/lib/db"; -export type DashboardInboxItem = { +type DashboardInboxItem = { id: string; sourceAppName: string | null; parsedName: string | null; diff --git a/src/features/dashboard/navbar-queries.ts b/src/features/dashboard/lib/navbar-queries.ts similarity index 86% rename from src/features/dashboard/navbar-queries.ts rename to src/features/dashboard/lib/navbar-queries.ts index 0726af5..6f7d02b 100644 --- a/src/features/dashboard/navbar-queries.ts +++ b/src/features/dashboard/lib/navbar-queries.ts @@ -8,11 +8,11 @@ import { getBusinessDateString } from "@/shared/utils/date"; import { type DashboardNotificationsSnapshot, fetchDashboardNotifications, -} from "./notifications/notifications-queries"; +} from "../notifications/notifications-queries"; type DashboardNavbarData = { - pagadorAvatarUrl: string | null; - preLancamentosCount: number; + payerAvatarUrl: string | null; + inboxPendingCount: number; notificationsSnapshot: DashboardNotificationsSnapshot; }; @@ -39,7 +39,7 @@ async function fetchDashboardNavbarDataInternal( userId: string, ): Promise { const currentPeriod = getBusinessDateString().slice(0, 7); - const [pagadorAvatarUrl, notificationsSnapshot, preLancamentosCount] = + const [payerAvatarUrl, notificationsSnapshot, inboxPendingCount] = await Promise.all([ fetchAdminPayerAvatarUrl(userId), fetchDashboardNotifications(userId, currentPeriod), @@ -47,8 +47,8 @@ async function fetchDashboardNavbarDataInternal( ]); return { - pagadorAvatarUrl, - preLancamentosCount, + payerAvatarUrl, + inboxPendingCount, notificationsSnapshot, }; } diff --git a/src/features/dashboard/payers-queries.ts b/src/features/dashboard/lib/payers-queries.ts similarity index 98% rename from src/features/dashboard/payers-queries.ts rename to src/features/dashboard/lib/payers-queries.ts index b7b54bf..38a8003 100644 --- a/src/features/dashboard/payers-queries.ts +++ b/src/features/dashboard/lib/payers-queries.ts @@ -1,6 +1,6 @@ import { and, desc, eq, inArray, isNull, or, sql } from "drizzle-orm"; import { financialAccounts, payers, transactions } from "@/db/schema"; -import { excludeTransactionsFromExcludedAccounts } from "@/features/dashboard/transaction-filters"; +import { excludeTransactionsFromExcludedAccounts } from "@/features/dashboard/lib/transaction-filters"; import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/shared/lib/accounts/constants"; import { db } from "@/shared/lib/db"; import { PAYER_ROLE_ADMIN } from "@/shared/lib/payers/constants"; diff --git a/src/features/dashboard/preferences-queries.ts b/src/features/dashboard/lib/preferences-queries.ts similarity index 100% rename from src/features/dashboard/preferences-queries.ts rename to src/features/dashboard/lib/preferences-queries.ts diff --git a/src/features/dashboard/top-establishments-queries.ts b/src/features/dashboard/lib/top-establishments-queries.ts similarity index 83% rename from src/features/dashboard/top-establishments-queries.ts rename to src/features/dashboard/lib/top-establishments-queries.ts index b7c1183..967b152 100644 --- a/src/features/dashboard/top-establishments-queries.ts +++ b/src/features/dashboard/lib/top-establishments-queries.ts @@ -1,4 +1,4 @@ -export type TopEstablishment = { +type TopEstablishment = { id: string; name: string; amount: number; diff --git a/src/features/dashboard/transaction-filters.ts b/src/features/dashboard/lib/transaction-filters.ts similarity index 100% rename from src/features/dashboard/transaction-filters.ts rename to src/features/dashboard/lib/transaction-filters.ts diff --git a/src/features/dashboard/notes/notes-mappers.ts b/src/features/dashboard/notes/notes-mappers.ts index a7b740f..d743920 100644 --- a/src/features/dashboard/notes/notes-mappers.ts +++ b/src/features/dashboard/notes/notes-mappers.ts @@ -1,7 +1,7 @@ import type { DashboardNote } from "@/features/dashboard/notes/notes-queries"; import type { Note } from "@/features/notes/components/types"; -export const mapDashboardNoteToNote = (note: DashboardNote): Note => ({ +const mapDashboardNoteToNote = (note: DashboardNote): Note => ({ id: note.id, title: note.title, description: note.description, diff --git a/src/features/dashboard/notes/notes-queries.ts b/src/features/dashboard/notes/notes-queries.ts index 7c4b93e..dacbd29 100644 --- a/src/features/dashboard/notes/notes-queries.ts +++ b/src/features/dashboard/notes/notes-queries.ts @@ -2,7 +2,7 @@ import { and, eq } from "drizzle-orm"; import { notes } from "@/db/schema"; import { db } from "@/shared/lib/db"; -export type DashboardTask = { +type DashboardTask = { id: string; text: string; completed: boolean; diff --git a/src/features/dashboard/notifications/notifications-queries.ts b/src/features/dashboard/notifications/notifications-queries.ts index ceca14d..6556518 100644 --- a/src/features/dashboard/notifications/notifications-queries.ts +++ b/src/features/dashboard/notifications/notifications-queries.ts @@ -31,13 +31,7 @@ import { getNextPeriod, } from "@/shared/utils/period"; -export type { - BudgetNotification, - BudgetStatus, - DashboardNotification, - DashboardNotificationsSnapshot, - NotificationType, -} from "@/shared/lib/types/notifications"; +export type { DashboardNotificationsSnapshot } from "@/shared/lib/types/notifications"; const PAYMENT_METHOD_BOLETO = "Boleto"; const BUDGET_CRITICAL_THRESHOLD = 80; diff --git a/src/features/dashboard/overview/current-period-overview-queries.ts b/src/features/dashboard/overview/current-period-overview-queries.ts index e099d43..7f2dd26 100644 --- a/src/features/dashboard/overview/current-period-overview-queries.ts +++ b/src/features/dashboard/overview/current-period-overview-queries.ts @@ -13,11 +13,11 @@ import type { TopExpense, TopExpensesData, } from "@/features/dashboard/expenses/top-expenses-queries"; +import type { TopEstablishmentsData } from "@/features/dashboard/lib/top-establishments-queries"; +import { excludeTransactionsFromExcludedAccounts } from "@/features/dashboard/lib/transaction-filters"; import type { PaymentConditionsData } from "@/features/dashboard/payments/payment-conditions-queries"; import type { PaymentMethodsData } from "@/features/dashboard/payments/payment-methods-queries"; import type { PaymentStatusData } from "@/features/dashboard/payments/payment-status-queries"; -import type { TopEstablishmentsData } from "@/features/dashboard/top-establishments-queries"; -import { excludeTransactionsFromExcludedAccounts } from "@/features/dashboard/transaction-filters"; import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX, INITIAL_BALANCE_NOTE, diff --git a/src/features/dashboard/overview/period-overview-queries.ts b/src/features/dashboard/overview/period-overview-queries.ts index ad96474..091e0e7 100644 --- a/src/features/dashboard/overview/period-overview-queries.ts +++ b/src/features/dashboard/overview/period-overview-queries.ts @@ -1,16 +1,16 @@ import { and, asc, eq, gte, inArray, lte, sql } from "drizzle-orm"; import { financialAccounts, transactions } from "@/db/schema"; -import type { DashboardCardMetrics } from "@/features/dashboard/overview/dashboard-metrics-queries"; -import type { - IncomeExpenseBalanceData, - MonthData, -} from "@/features/dashboard/overview/income-expense-balance-queries"; import { buildDashboardAdminFilters, excludeAutoInvoiceEntries, excludeInitialBalanceWhenConfigured, excludeTransactionsFromExcludedAccounts, -} from "@/features/dashboard/transaction-filters"; +} from "@/features/dashboard/lib/transaction-filters"; +import type { DashboardCardMetrics } from "@/features/dashboard/overview/dashboard-metrics-queries"; +import type { + IncomeExpenseBalanceData, + MonthData, +} from "@/features/dashboard/overview/income-expense-balance-queries"; import { REFUND_NOTE_PREFIX } from "@/shared/lib/accounts/constants"; import { db } from "@/shared/lib/db"; import { getAdminPayerId } from "@/shared/lib/payers/get-admin-id"; diff --git a/src/features/dashboard/page-data-queries.ts b/src/features/dashboard/page-data-queries.ts index 552c88b..11a1727 100644 --- a/src/features/dashboard/page-data-queries.ts +++ b/src/features/dashboard/page-data-queries.ts @@ -1,10 +1,10 @@ import { cacheLife, cacheTag } from "next/cache"; import { fetchDashboardData } from "@/features/dashboard/fetch-dashboard-data"; -import { fetchUserDashboardPreferences } from "@/features/dashboard/preferences-queries"; +import { fetchUserDashboardPreferences } from "@/features/dashboard/lib/preferences-queries"; import { buildOptionSets, buildSluggedFilters, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import { fetchRecentEstablishments, fetchTransactionFilterSources, @@ -52,7 +52,7 @@ async function fetchDashboardQuickActionOptionsInternal( }; } -export async function fetchDashboardQuickActionOptions(userId: string) { +async function fetchDashboardQuickActionOptions(userId: string) { "use cache"; cacheTag(`dashboard-${userId}`); cacheLife({ revalidate: 3 }); diff --git a/src/features/dashboard/payments/payment-conditions-queries.ts b/src/features/dashboard/payments/payment-conditions-queries.ts index c226282..a9b32cc 100644 --- a/src/features/dashboard/payments/payment-conditions-queries.ts +++ b/src/features/dashboard/payments/payment-conditions-queries.ts @@ -1,4 +1,4 @@ -export type PaymentConditionSummary = { +type PaymentConditionSummary = { condition: string; amount: number; percentage: number; diff --git a/src/features/dashboard/payments/payment-methods-queries.ts b/src/features/dashboard/payments/payment-methods-queries.ts index 94a0dc3..de673bd 100644 --- a/src/features/dashboard/payments/payment-methods-queries.ts +++ b/src/features/dashboard/payments/payment-methods-queries.ts @@ -1,4 +1,4 @@ -export type PaymentMethodSummary = { +type PaymentMethodSummary = { paymentMethod: string; amount: number; percentage: number; diff --git a/src/features/dashboard/payments/payment-status-queries.ts b/src/features/dashboard/payments/payment-status-queries.ts index f0afa04..366da87 100644 --- a/src/features/dashboard/payments/payment-status-queries.ts +++ b/src/features/dashboard/payments/payment-status-queries.ts @@ -1,4 +1,4 @@ -export type PaymentStatusCategory = { +type PaymentStatusCategory = { total: number; confirmed: number; pending: number; diff --git a/src/features/inbox/components/inbox-items-list.tsx b/src/features/inbox/components/inbox-items-list.tsx index 0dd150d..0809107 100644 --- a/src/features/inbox/components/inbox-items-list.tsx +++ b/src/features/inbox/components/inbox-items-list.tsx @@ -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"; diff --git a/src/features/inbox/components/inbox-pagination.tsx b/src/features/inbox/components/inbox-pagination.tsx index d6120f8..0bd9db7 100644 --- a/src/features/inbox/components/inbox-pagination.tsx +++ b/src/features/inbox/components/inbox-pagination.tsx @@ -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({
); } - -// Re-export para facilitar uso externo -export { INBOX_DEFAULT_PAGE_SIZE }; diff --git a/src/features/inbox/components/inbox-tabs.tsx b/src/features/inbox/components/inbox-tabs.tsx index 10b364b..eda92b0 100644 --- a/src/features/inbox/components/inbox-tabs.tsx +++ b/src/features/inbox/components/inbox-tabs.tsx @@ -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) { ); } - -export type { InboxStatus, InboxStatusCounts }; diff --git a/src/features/inbox/components/types.ts b/src/features/inbox/components/types.ts index 74251ba..b8ad306 100644 --- a/src/features/inbox/components/types.ts +++ b/src/features/inbox/components/types.ts @@ -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; diff --git a/src/features/inbox/page-helpers.ts b/src/features/inbox/page-helpers.ts index 592a14e..e9b374f 100644 --- a/src/features/inbox/page-helpers.ts +++ b/src/features/inbox/page-helpers.ts @@ -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 => { diff --git a/src/features/inbox/queries.ts b/src/features/inbox/queries.ts index 917c2f9..4d9d01c 100644 --- a/src/features/inbox/queries.ts +++ b/src/features/inbox/queries.ts @@ -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 { - 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 { - 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 { - 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 { - 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> { diff --git a/src/features/insights/actions.ts b/src/features/insights/actions.ts index ec2c201..6230ab0 100644 --- a/src/features/insights/actions.ts +++ b/src/features/insights/actions.ts @@ -1,32 +1,5 @@ -"use server"; - -import { generateInsightsAction as generateInsightsActionImpl } from "./actions/generate"; -import { - deleteSavedInsightsAction as deleteSavedInsightsActionImpl, - loadSavedInsightsAction as loadSavedInsightsActionImpl, - saveInsightsAction as saveInsightsActionImpl, +export { generateInsightsAction } from "./actions/generate"; +export { + deleteSavedInsightsAction, + saveInsightsAction, } from "./actions/storage"; - -export async function generateInsightsAction( - ...args: Parameters -): ReturnType { - return generateInsightsActionImpl(...args); -} - -export async function saveInsightsAction( - ...args: Parameters -): ReturnType { - return saveInsightsActionImpl(...args); -} - -export async function loadSavedInsightsAction( - ...args: Parameters -): ReturnType { - return loadSavedInsightsActionImpl(...args); -} - -export async function deleteSavedInsightsAction( - ...args: Parameters -): ReturnType { - return deleteSavedInsightsActionImpl(...args); -} diff --git a/src/features/insights/actions/storage.ts b/src/features/insights/actions/storage.ts index aedcc97..3aa3e45 100644 --- a/src/features/insights/actions/storage.ts +++ b/src/features/insights/actions/storage.ts @@ -5,10 +5,7 @@ import { z } from "zod"; import { savedInsights } from "@/db/schema"; import { getUser } from "@/shared/lib/auth/server"; import { db } from "@/shared/lib/db"; -import { - type InsightsResponse, - InsightsResponseSchema, -} from "@/shared/lib/schemas/insights"; +import type { InsightsResponse } from "@/shared/lib/schemas/insights"; import type { ActionResult } from "./types"; const periodSchema = z @@ -115,62 +112,6 @@ export async function saveInsightsAction( } } -export async function loadSavedInsightsAction(period: string): Promise< - ActionResult<{ - insights: InsightsResponse; - modelId: string; - createdAt: Date; - } | null> -> { - try { - const user = await getUser(); - const validatedPeriod = periodSchema.safeParse(period); - if (!validatedPeriod.success) { - return { - success: false, - error: validatedPeriod.error.issues[0]?.message ?? "Período inválido", - }; - } - period = validatedPeriod.data; - - const result = await db - .select() - .from(savedInsights) - .where( - and( - eq(savedInsights.userId, user.id), - eq(savedInsights.period, period), - ), - ) - .limit(1); - - if (result.length === 0) { - return { - success: true, - data: null, - }; - } - - const saved = result[0]; - const insights = InsightsResponseSchema.parse(JSON.parse(saved.data)); - - return { - success: true, - data: { - insights, - modelId: saved.modelId, - createdAt: saved.createdAt, - }, - }; - } catch (error) { - console.error("Error loading saved insights:", error); - return { - success: false, - error: "Erro ao carregar análise salva. Tente novamente.", - }; - } -} - export async function deleteSavedInsightsAction( period: string, ): Promise> { diff --git a/src/features/insights/components/insights-page.tsx b/src/features/insights/components/insights-page.tsx index 90ebd93..86c422a 100644 --- a/src/features/insights/components/insights-page.tsx +++ b/src/features/insights/components/insights-page.tsx @@ -21,7 +21,7 @@ import { savedInsightsQueryKey, useSavedInsights, } from "@/features/insights/hooks/use-saved-insights"; -import { EmptyState } from "@/shared/components/empty-state"; +import { EmptyState } from "@/shared/components/feedback/empty-state"; import { Alert, AlertDescription } from "@/shared/components/ui/alert"; import { Button } from "@/shared/components/ui/button"; import { Card, CardContent, CardHeader } from "@/shared/components/ui/card"; diff --git a/src/features/insights/hooks/use-saved-insights.ts b/src/features/insights/hooks/use-saved-insights.ts index 9d818e3..329f7f7 100644 --- a/src/features/insights/hooks/use-saved-insights.ts +++ b/src/features/insights/hooks/use-saved-insights.ts @@ -3,8 +3,8 @@ import { useQuery } from "@tanstack/react-query"; import { z } from "zod"; import type { SavedInsightsRecord } from "@/features/insights/queries"; -import { fetchJson } from "@/shared/lib/fetch-json"; import { InsightsResponseSchema } from "@/shared/lib/schemas/insights"; +import { fetchJson } from "@/shared/utils/fetch-json"; const savedInsightsRecordSchema = z.object({ insights: InsightsResponseSchema, diff --git a/src/features/invoices/components/invoice-summary-card.tsx b/src/features/invoices/components/invoice-summary-card.tsx index 96f9266..0659cc6 100644 --- a/src/features/invoices/components/invoice-summary-card.tsx +++ b/src/features/invoices/components/invoice-summary-card.tsx @@ -11,8 +11,8 @@ import { updatePaymentDateAction, } from "@/features/invoices/actions"; import { AccountCardSelectContent } from "@/features/transactions/components/select-items"; +import StatusDot from "@/shared/components/feedback/status-dot"; import MoneyValues from "@/shared/components/money-values"; -import StatusDot from "@/shared/components/status-dot"; import { Badge } from "@/shared/components/ui/badge"; import { Button } from "@/shared/components/ui/button"; import { Card, CardContent } from "@/shared/components/ui/card"; diff --git a/src/features/landing/components/mobile-nav.tsx b/src/features/landing/components/mobile-nav.tsx index b0d2756..f2f9fec 100644 --- a/src/features/landing/components/mobile-nav.tsx +++ b/src/features/landing/components/mobile-nav.tsx @@ -3,7 +3,7 @@ import { RiArrowRightSLine, RiMenuLine } from "@remixicon/react"; import Link from "next/link"; import { useState } from "react"; -import { Logo } from "@/shared/components/logo"; +import { Logo } from "@/shared/components/brand/logo"; import { Button } from "@/shared/components/ui/button"; import { Sheet, diff --git a/src/features/landing/constants.ts b/src/features/landing/constants.ts index 99cdd3b..85faded 100644 --- a/src/features/landing/constants.ts +++ b/src/features/landing/constants.ts @@ -28,7 +28,7 @@ import { } from "@remixicon/react"; import type { ComponentType } from "react"; -export type FeatureItem = { +type FeatureItem = { icon: ComponentType<{ className?: string; style?: React.CSSProperties }>; title: string; description: string; diff --git a/src/features/notes/components/notes-page.tsx b/src/features/notes/components/notes-page.tsx index c9aa53d..dbf1183 100644 --- a/src/features/notes/components/notes-page.tsx +++ b/src/features/notes/components/notes-page.tsx @@ -5,7 +5,7 @@ import { useState } from "react"; import { toast } from "sonner"; import { archiveNoteAction, deleteNoteAction } from "@/features/notes/actions"; import { ConfirmActionDialog } from "@/shared/components/confirm-action-dialog"; -import { EmptyState } from "@/shared/components/empty-state"; +import { EmptyState } from "@/shared/components/feedback/empty-state"; import { Button } from "@/shared/components/ui/button"; import { Card } from "@/shared/components/ui/card"; import { diff --git a/src/features/notes/components/types.ts b/src/features/notes/components/types.ts index 1cafebf..01e1500 100644 --- a/src/features/notes/components/types.ts +++ b/src/features/notes/components/types.ts @@ -1,4 +1,4 @@ -export type NoteType = "nota" | "tarefa"; +type NoteType = "nota" | "tarefa"; export interface Task { id: string; diff --git a/src/features/notes/queries.ts b/src/features/notes/queries.ts index e402e5a..1e898c7 100644 --- a/src/features/notes/queries.ts +++ b/src/features/notes/queries.ts @@ -2,13 +2,13 @@ import { and, eq } from "drizzle-orm"; import { type Note, notes } from "@/db/schema"; import { db } from "@/shared/lib/db"; -export type Task = { +type Task = { id: string; text: string; completed: boolean; }; -export type NoteData = { +type NoteData = { id: string; title: string; description: string; @@ -43,7 +43,7 @@ function toNoteData(note: Note): NoteData { }; } -export async function fetchNotesForUser(userId: string): Promise { +async function fetchNotesForUser(userId: string): Promise { const noteRows = await db.query.notes.findMany({ where: and(eq(notes.userId, userId), eq(notes.archived, false)), orderBy: (table, { desc }) => [desc(table.createdAt)], @@ -63,9 +63,7 @@ export async function fetchAllNotesForUser( return { activeNotes, archivedNotes }; } -export async function fetchArchivedForUser( - userId: string, -): Promise { +async function fetchArchivedForUser(userId: string): Promise { const noteRows = await db.query.notes.findMany({ where: and(eq(notes.userId, userId), eq(notes.archived, true)), orderBy: (table, { desc }) => [desc(table.createdAt)], diff --git a/src/features/payers/components/details/payer-card-usage-card.tsx b/src/features/payers/components/details/payer-card-usage-card.tsx index 2774ba7..3a7ecd3 100644 --- a/src/features/payers/components/details/payer-card-usage-card.tsx +++ b/src/features/payers/components/details/payer-card-usage-card.tsx @@ -2,16 +2,16 @@ import { RiBankCard2Line } from "@remixicon/react"; import Image from "next/image"; import MoneyValues from "@/shared/components/money-values"; import { CardContent } from "@/shared/components/ui/card"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { resolveLogoSrc } from "@/shared/lib/logo"; import type { PayerCardUsageItem } from "@/shared/lib/payers/details"; import { buildInitials } from "@/shared/utils/initials"; -type PagadorCardUsageCardProps = { +type PayerCardUsageCardProps = { items: PayerCardUsageItem[]; }; -export function PayerCardUsageCard({ items }: PagadorCardUsageCardProps) { +export function PayerCardUsageCard({ items }: PayerCardUsageCardProps) { if (items.length === 0) { return ( diff --git a/src/features/payers/components/details/payer-header-card.tsx b/src/features/payers/components/details/payer-header-card.tsx index 1f1d033..805bc81 100644 --- a/src/features/payers/components/details/payer-header-card.tsx +++ b/src/features/payers/components/details/payer-header-card.tsx @@ -13,7 +13,7 @@ import Link from "next/link"; import { useRouter } from "next/navigation"; import { useState, useTransition } from "react"; import { toast } from "sonner"; -import { sendPayerSummaryAction } from "@/features/payers/detail-actions"; +import { sendPayerSummaryAction } from "@/features/payers/lib/detail-actions"; import { Badge } from "@/shared/components/ui/badge"; import { Button } from "@/shared/components/ui/button"; import { diff --git a/src/features/payers/components/details/payer-history-card.tsx b/src/features/payers/components/details/payer-history-card.tsx index fd19f1a..1fd4767 100644 --- a/src/features/payers/components/details/payer-history-card.tsx +++ b/src/features/payers/components/details/payer-history-card.tsx @@ -20,7 +20,7 @@ import { ChartTooltip, ChartTooltipContent, } from "@/shared/components/ui/chart"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import type { PayerHistoryPoint } from "@/shared/lib/payers/details"; import { currencyFormatter } from "@/shared/utils/currency"; @@ -31,7 +31,7 @@ const chartConfig = { }, }; -type PagadorHistoryCardProps = { +type PayerHistoryCardProps = { data: PayerHistoryPoint[]; }; @@ -57,7 +57,7 @@ const ValueLabel = (props: LabelProps) => { ); }; -export function PayerHistoryCard({ data }: PagadorHistoryCardProps) { +export function PayerHistoryCard({ data }: PayerHistoryCardProps) { const hasData = data.length > 0; return ( diff --git a/src/features/payers/components/details/payer-info-card.tsx b/src/features/payers/components/details/payer-info-card.tsx index 33afea3..65cbc28 100644 --- a/src/features/payers/components/details/payer-info-card.tsx +++ b/src/features/payers/components/details/payer-info-card.tsx @@ -17,7 +17,7 @@ type PayerInfoCardProps = { payer: PayerInfo; }; -export function PagadorInfoCard({ payer }: PayerInfoCardProps) { +export function PayerInfoCard({ payer }: PayerInfoCardProps) { const showSensitiveDetails = payer.canEdit; const getStatusBadgeVariant = (status: string): "success" | "outline" => { diff --git a/src/features/payers/components/details/payer-leave-share-card.tsx b/src/features/payers/components/details/payer-leave-share-card.tsx index 63c3f6c..0b03582 100644 --- a/src/features/payers/components/details/payer-leave-share-card.tsx +++ b/src/features/payers/components/details/payer-leave-share-card.tsx @@ -14,7 +14,7 @@ import { } from "@/shared/components/ui/card"; import { formatDateTime } from "@/shared/utils/date"; -interface PagadorLeaveShareCardProps { +interface PayerLeaveShareCardProps { shareId: string; pagadorName: string; createdAt: string; @@ -24,7 +24,7 @@ export function PayerLeaveShareCard({ shareId, pagadorName, createdAt, -}: PagadorLeaveShareCardProps) { +}: PayerLeaveShareCardProps) { const router = useRouter(); const [isPending, startTransition] = useTransition(); const [showConfirm, setShowConfirm] = useState(false); diff --git a/src/features/payers/components/details/payer-monthly-summary-card.tsx b/src/features/payers/components/details/payer-monthly-summary-card.tsx index 4b64fbf..a6de5e2 100644 --- a/src/features/payers/components/details/payer-monthly-summary-card.tsx +++ b/src/features/payers/components/details/payer-monthly-summary-card.tsx @@ -24,7 +24,7 @@ const segmentConfig = { }, } as const; -type PagadorMonthlySummaryCardProps = { +type PayerMonthlySummaryCardProps = { periodLabel: string; breakdown: PayerMonthlyBreakdown; }; @@ -32,7 +32,7 @@ type PagadorMonthlySummaryCardProps = { export function PayerMonthlySummaryCard({ periodLabel, breakdown, -}: PagadorMonthlySummaryCardProps) { +}: PayerMonthlySummaryCardProps) { const splittableEntries = ( Object.keys(segmentConfig) as Array ).map((key) => ({ diff --git a/src/features/payers/components/details/payer-payment-method-cards.tsx b/src/features/payers/components/details/payer-payment-method-cards.tsx index 6951f8d..5174a31 100644 --- a/src/features/payers/components/details/payer-payment-method-cards.tsx +++ b/src/features/payers/components/details/payer-payment-method-cards.tsx @@ -10,7 +10,7 @@ import MoneyValues from "@/shared/components/money-values"; import { CardContent } from "@/shared/components/ui/card"; import { Progress } from "@/shared/components/ui/progress"; import { Separator } from "@/shared/components/ui/separator"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import type { PayerBoletoItem, PayerPaymentStatusData, @@ -19,11 +19,11 @@ import { cn } from "@/shared/utils/ui"; // --- PayerBoletoCard --- -type PagadorBoletoCardProps = { +type PayerBoletoCardProps = { items: PayerBoletoItem[]; }; -export function PayerBoletoCard({ items }: PagadorBoletoCardProps) { +export function PayerBoletoCard({ items }: PayerBoletoCardProps) { if (items.length === 0) { return ( @@ -72,13 +72,11 @@ export function PayerBoletoCard({ items }: PagadorBoletoCardProps) { // --- PayerPaymentStatusCard --- -type PagadorPaymentStatusCardProps = { +type PayerPaymentStatusCardProps = { data: PayerPaymentStatusData; }; -export function PayerPaymentStatusCard({ - data, -}: PagadorPaymentStatusCardProps) { +export function PayerPaymentStatusCard({ data }: PayerPaymentStatusCardProps) { const { paidAmount, paidCount, pendingAmount, pendingCount, totalAmount } = data; diff --git a/src/features/payers/components/details/payer-sharing-card.tsx b/src/features/payers/components/details/payer-sharing-card.tsx index 3c963cc..a288ec3 100644 --- a/src/features/payers/components/details/payer-sharing-card.tsx +++ b/src/features/payers/components/details/payer-sharing-card.tsx @@ -16,7 +16,7 @@ import { CardTitle, } from "@/shared/components/ui/card"; -type PagadorShare = { +type PayerShare = { id: string; userId: string; name: string; @@ -24,17 +24,17 @@ type PagadorShare = { createdAt: string; }; -interface PagadorSharingCardProps { +interface PayerSharingCardProps { payerId: string; shareCode: string; - shares: PagadorShare[]; + shares: PayerShare[]; } export function PayerSharingCard({ payerId, shareCode, shares, -}: PagadorSharingCardProps) { +}: PayerSharingCardProps) { const router = useRouter(); const [currentCode, setCurrentCode] = useState(shareCode); const [regeneratePending, startRegenerate] = useTransition(); diff --git a/src/features/payers/components/payer-select-items.tsx b/src/features/payers/components/payer-select-items.tsx index 1774100..9f1d43c 100644 --- a/src/features/payers/components/payer-select-items.tsx +++ b/src/features/payers/components/payer-select-items.tsx @@ -1,6 +1,6 @@ "use client"; -import StatusDot from "@/shared/components/status-dot"; +import StatusDot from "@/shared/components/feedback/status-dot"; export function StatusSelectContent({ label }: { label: string }) { const isActive = label === "Ativo"; diff --git a/src/features/payers/lib/build-readonly-option-sets.ts b/src/features/payers/lib/build-readonly-option-sets.ts index dcc8741..c30f4b9 100644 --- a/src/features/payers/lib/build-readonly-option-sets.ts +++ b/src/features/payers/lib/build-readonly-option-sets.ts @@ -5,7 +5,7 @@ import type { TransactionFilterOption, TransactionItem, } from "@/features/transactions/components/types"; -import type { buildOptionSets } from "@/features/transactions/page-helpers"; +import type { buildOptionSets } from "@/features/transactions/lib/page-helpers"; type OptionSet = ReturnType; diff --git a/src/features/payers/detail-actions.ts b/src/features/payers/lib/detail-actions.ts similarity index 98% rename from src/features/payers/detail-actions.ts rename to src/features/payers/lib/detail-actions.ts index b253517..3f1fc8b 100644 --- a/src/features/payers/detail-actions.ts +++ b/src/features/payers/lib/detail-actions.ts @@ -9,8 +9,8 @@ import { getUser } from "@/shared/lib/auth/server"; import { db } from "@/shared/lib/db"; import { getResendFromEmail } from "@/shared/lib/email/resend"; import { - fetchPagadorBoletoStats, - fetchPagadorCardUsage, + fetchPayerBoletoStats, + fetchPayerCardUsage, fetchPayerHistory, fetchPayerMonthlyBreakdown, } from "@/shared/lib/payers/details"; @@ -50,7 +50,7 @@ const escapeHtml = (text: string | null | undefined): string => { .replace(/'/g, "'"); }; -type LancamentoRow = { +type TransactionRow = { id: string; name: string | null; paymentMethod: string | null; @@ -80,10 +80,10 @@ type SummaryPayload = { periodLabel: string; monthlyBreakdown: Awaited>; historyData: Awaited>; - cardUsage: Awaited>; - boletoStats: Awaited>; + cardUsage: Awaited>; + boletoStats: Awaited>; boletos: BoletoItem[]; - transactions: LancamentoRow[]; + transactions: TransactionRow[]; parcelados: ParceladoItem[]; }; @@ -445,12 +445,12 @@ export async function sendPayerSummaryAction( payerId, period, }), - fetchPagadorCardUsage({ + fetchPayerCardUsage({ userId: user.id, payerId, period, }), - fetchPagadorBoletoStats({ + fetchPayerBoletoStats({ userId: user.id, payerId, period, @@ -523,7 +523,7 @@ export async function sendPayerSummaryAction( dueDate: row.dueDate, })); - const normalizedLancamentos: LancamentoRow[] = ( + const normalizedLancamentos: TransactionRow[] = ( transactionRows as Array<{ id: string; name: string | null; diff --git a/src/features/payers/detail-queries.ts b/src/features/payers/lib/detail-queries.ts similarity index 96% rename from src/features/payers/detail-queries.ts rename to src/features/payers/lib/detail-queries.ts index 60e7377..d57ffa9 100644 --- a/src/features/payers/detail-queries.ts +++ b/src/features/payers/lib/detail-queries.ts @@ -11,7 +11,7 @@ import { } from "@/db/schema"; import { db } from "@/shared/lib/db"; -export type ShareData = { +type ShareData = { id: string; userId: string; name: string; @@ -66,7 +66,7 @@ export async function fetchCurrentUserShare( }; } -export async function fetchPagadorLancamentos(filters: SQL[]) { +export async function fetchPayerTransactions(filters: SQL[]) { const transactionRows = await db .select({ transaction: transactions, diff --git a/src/features/reports/components/cards/card-category-breakdown.tsx b/src/features/reports/components/cards/card-category-breakdown.tsx index 24ad7f1..730cd72 100644 --- a/src/features/reports/components/cards/card-category-breakdown.tsx +++ b/src/features/reports/components/cards/card-category-breakdown.tsx @@ -1,7 +1,7 @@ "use client"; import { RiPieChartLine } from "@remixicon/react"; -import type { CardDetailData } from "@/features/reports/cards-report-queries"; +import type { CardDetailData } from "@/features/reports/lib/cards-report-queries"; import { CategoryIconBadge } from "@/shared/components/entity-avatar"; import MoneyValues from "@/shared/components/money-values"; import { @@ -11,7 +11,7 @@ import { CardTitle, } from "@/shared/components/ui/card"; import { Progress } from "@/shared/components/ui/progress"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; type CardCategoryBreakdownProps = { data: CardDetailData["categoryBreakdown"]; diff --git a/src/features/reports/components/cards/card-invoice-status.tsx b/src/features/reports/components/cards/card-invoice-status.tsx index 84adca0..9558d63 100644 --- a/src/features/reports/components/cards/card-invoice-status.tsx +++ b/src/features/reports/components/cards/card-invoice-status.tsx @@ -1,7 +1,7 @@ "use client"; import { RiCalendarCheckLine } from "@remixicon/react"; -import type { CardDetailData } from "@/features/reports/cards-report-queries"; +import type { CardDetailData } from "@/features/reports/lib/cards-report-queries"; import { Card, CardContent, diff --git a/src/features/reports/components/cards/card-top-expenses.tsx b/src/features/reports/components/cards/card-top-expenses.tsx index 53fcf3e..5cfc30d 100644 --- a/src/features/reports/components/cards/card-top-expenses.tsx +++ b/src/features/reports/components/cards/card-top-expenses.tsx @@ -1,7 +1,7 @@ "use client"; import { RiShoppingBag3Line } from "@remixicon/react"; -import type { CardDetailData } from "@/features/reports/cards-report-queries"; +import type { CardDetailData } from "@/features/reports/lib/cards-report-queries"; import MoneyValues from "@/shared/components/money-values"; import { Badge } from "@/shared/components/ui/badge"; import { @@ -11,7 +11,7 @@ import { CardTitle, } from "@/shared/components/ui/card"; import { Progress } from "@/shared/components/ui/progress"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; type CardTopExpensesProps = { data: CardDetailData["topExpenses"]; diff --git a/src/features/reports/components/cards/card-usage-chart.tsx b/src/features/reports/components/cards/card-usage-chart.tsx index 78e045d..e430240 100644 --- a/src/features/reports/components/cards/card-usage-chart.tsx +++ b/src/features/reports/components/cards/card-usage-chart.tsx @@ -10,7 +10,7 @@ import { XAxis, YAxis, } from "recharts"; -import type { CardDetailData } from "@/features/reports/cards-report-queries"; +import type { CardDetailData } from "@/features/reports/lib/cards-report-queries"; import { Card, CardContent, diff --git a/src/features/reports/components/cards/cards-overview.tsx b/src/features/reports/components/cards/cards-overview.tsx index b2d6f80..a4e9e08 100644 --- a/src/features/reports/components/cards/cards-overview.tsx +++ b/src/features/reports/components/cards/cards-overview.tsx @@ -4,7 +4,7 @@ import { RiBankCard2Line } from "@remixicon/react"; import Image from "next/image"; import Link from "next/link"; import { useSearchParams } from "next/navigation"; -import type { CartoesReportData } from "@/features/reports/cards-report-queries"; +import type { CartoesReportData } from "@/features/reports/lib/cards-report-queries"; import MoneyValues from "@/shared/components/money-values"; import { Card, CardContent } from "@/shared/components/ui/card"; import { Progress } from "@/shared/components/ui/progress"; diff --git a/src/features/reports/components/category-cell.tsx b/src/features/reports/components/category-cell.tsx index 379c7aa..e9bcf9d 100644 --- a/src/features/reports/components/category-cell.tsx +++ b/src/features/reports/components/category-cell.tsx @@ -1,7 +1,7 @@ "use client"; import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator"; -import { formatPercentageChange } from "@/features/reports/utils"; +import { formatPercentageChange } from "@/features/reports/lib/utils"; import { Tooltip, TooltipContent, diff --git a/src/features/reports/components/category-report-cards.tsx b/src/features/reports/components/category-report-cards.tsx index 87afa26..3e1e838 100644 --- a/src/features/reports/components/category-report-cards.tsx +++ b/src/features/reports/components/category-report-cards.tsx @@ -2,7 +2,7 @@ import Link from "next/link"; import { useMemo } from "react"; -import { formatPeriodLabel } from "@/features/reports/utils"; +import { formatPeriodLabel } from "@/features/reports/lib/utils"; import { CategoryIconBadge } from "@/shared/components/entity-avatar"; import { Card, diff --git a/src/features/reports/components/category-report-chart.tsx b/src/features/reports/components/category-report-chart.tsx index fe4b4d6..56142b2 100644 --- a/src/features/reports/components/category-report-chart.tsx +++ b/src/features/reports/components/category-report-chart.tsx @@ -11,8 +11,8 @@ import { type TooltipValueType, XAxis, } from "recharts"; -import type { CategoryChartData } from "@/features/reports/category-chart-queries"; -import { EmptyState } from "@/shared/components/empty-state"; +import type { CategoryChartData } from "@/features/reports/lib/category-chart-queries"; +import { EmptyState } from "@/shared/components/feedback/empty-state"; import { Card, CardContent, diff --git a/src/features/reports/components/category-report-export.tsx b/src/features/reports/components/category-report-export.tsx index c0b6fff..751ba93 100644 --- a/src/features/reports/components/category-report-export.tsx +++ b/src/features/reports/components/category-report-export.tsx @@ -11,7 +11,7 @@ import { toast } from "sonner"; import { formatPercentageChange, formatPeriodLabel, -} from "@/features/reports/utils"; +} from "@/features/reports/lib/utils"; import { Button } from "@/shared/components/ui/button"; import { DropdownMenu, diff --git a/src/features/reports/components/category-report-filters.tsx b/src/features/reports/components/category-report-filters.tsx index 4a227e0..6bdb720 100644 --- a/src/features/reports/components/category-report-filters.tsx +++ b/src/features/reports/components/category-report-filters.tsx @@ -7,7 +7,7 @@ import { } from "@remixicon/react"; import type { ReactNode } from "react"; import { useMemo, useState } from "react"; -import { validateDateRange } from "@/features/reports/utils"; +import { validateDateRange } from "@/features/reports/lib/utils"; import { Button } from "@/shared/components/ui/button"; import { Command, diff --git a/src/features/reports/components/category-report-page.tsx b/src/features/reports/components/category-report-page.tsx index fcf24c7..118cfe8 100644 --- a/src/features/reports/components/category-report-page.tsx +++ b/src/features/reports/components/category-report-page.tsx @@ -7,8 +7,8 @@ import { } from "@remixicon/react"; import { useRouter, useSearchParams } from "next/navigation"; import { useEffect, useRef, useState, useTransition } from "react"; -import type { CategoryChartData } from "@/features/reports/category-chart-queries"; -import { EmptyState } from "@/shared/components/empty-state"; +import type { CategoryChartData } from "@/features/reports/lib/category-chart-queries"; +import { EmptyState } from "@/shared/components/feedback/empty-state"; import { CategoryReportSkeleton } from "@/shared/components/skeletons/category-report-skeleton"; import { Card } from "@/shared/components/ui/card"; import { diff --git a/src/features/reports/components/category-table.tsx b/src/features/reports/components/category-table.tsx index 9170a83..0327fec 100644 --- a/src/features/reports/components/category-table.tsx +++ b/src/features/reports/components/category-table.tsx @@ -3,9 +3,9 @@ import { RiInformationLine } from "@remixicon/react"; import Link from "next/link"; import { useMemo } from "react"; -import { formatPeriodLabel } from "@/features/reports/utils"; +import { formatPeriodLabel } from "@/features/reports/lib/utils"; import { CategoryIconBadge } from "@/shared/components/entity-avatar"; -import StatusDot from "@/shared/components/status-dot"; +import StatusDot from "@/shared/components/feedback/status-dot"; import { Card } from "@/shared/components/ui/card"; import { Table, @@ -26,7 +26,7 @@ import { formatCurrency } from "@/shared/utils/currency"; import { formatPeriodForUrl } from "@/shared/utils/period"; import { CategoryCell } from "./category-cell"; -export interface CategoryTableProps { +interface CategoryTableProps { title: string; categories: CategoryReportItem[]; periods: string[]; diff --git a/src/features/reports/components/establishments/establishments-list.tsx b/src/features/reports/components/establishments/establishments-list.tsx index 546e538..90cd463 100644 --- a/src/features/reports/components/establishments/establishments-list.tsx +++ b/src/features/reports/components/establishments/establishments-list.tsx @@ -1,7 +1,7 @@ "use client"; import { RiStore2Line } from "@remixicon/react"; -import type { TopEstabelecimentosData } from "@/features/reports/establishments/queries"; +import type { TopEstablishmentsData } from "@/features/reports/establishments/queries"; import MoneyValues from "@/shared/components/money-values"; import { Badge } from "@/shared/components/ui/badge"; import { @@ -11,11 +11,11 @@ import { CardTitle, } from "@/shared/components/ui/card"; import { Progress } from "@/shared/components/ui/progress"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; import { buildInitials } from "@/shared/utils/initials"; type EstablishmentsListProps = { - establishments: TopEstabelecimentosData["establishments"]; + establishments: TopEstablishmentsData["establishments"]; }; export function EstablishmentsList({ diff --git a/src/features/reports/components/establishments/highlights-cards.tsx b/src/features/reports/components/establishments/highlights-cards.tsx index 0cca1be..8b71f62 100644 --- a/src/features/reports/components/establishments/highlights-cards.tsx +++ b/src/features/reports/components/establishments/highlights-cards.tsx @@ -1,11 +1,11 @@ "use client"; import { RiFireLine, RiTrophyLine } from "@remixicon/react"; -import type { TopEstabelecimentosData } from "@/features/reports/establishments/queries"; +import type { TopEstablishmentsData } from "@/features/reports/establishments/queries"; import { Card, CardContent } from "@/shared/components/ui/card"; type HighlightsCardsProps = { - summary: TopEstabelecimentosData["summary"]; + summary: TopEstablishmentsData["summary"]; }; export function HighlightsCards({ summary }: HighlightsCardsProps) { diff --git a/src/features/reports/components/establishments/summary-cards.tsx b/src/features/reports/components/establishments/summary-cards.tsx index 7c4c466..abf9b7c 100644 --- a/src/features/reports/components/establishments/summary-cards.tsx +++ b/src/features/reports/components/establishments/summary-cards.tsx @@ -6,12 +6,12 @@ import { RiRepeatLine, RiStore2Line, } from "@remixicon/react"; -import type { TopEstabelecimentosData } from "@/features/reports/establishments/queries"; +import type { TopEstablishmentsData } from "@/features/reports/establishments/queries"; import MoneyValues from "@/shared/components/money-values"; import { Card, CardContent } from "@/shared/components/ui/card"; type SummaryCardsProps = { - summary: TopEstabelecimentosData["summary"]; + summary: TopEstablishmentsData["summary"]; }; export function SummaryCards({ summary }: SummaryCardsProps) { diff --git a/src/features/reports/components/establishments/top-categories.tsx b/src/features/reports/components/establishments/top-categories.tsx index 9a8607a..8685281 100644 --- a/src/features/reports/components/establishments/top-categories.tsx +++ b/src/features/reports/components/establishments/top-categories.tsx @@ -1,7 +1,7 @@ "use client"; import { RiPriceTag3Line } from "@remixicon/react"; -import type { TopEstabelecimentosData } from "@/features/reports/establishments/queries"; +import type { TopEstablishmentsData } from "@/features/reports/establishments/queries"; import { CategoryIconBadge } from "@/shared/components/entity-avatar"; import MoneyValues from "@/shared/components/money-values"; import { @@ -11,10 +11,10 @@ import { CardTitle, } from "@/shared/components/ui/card"; import { Progress } from "@/shared/components/ui/progress"; -import { WidgetEmptyState } from "@/shared/components/widget-empty-state"; +import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state"; type TopCategoriesProps = { - categories: TopEstabelecimentosData["topCategories"]; + categories: TopEstablishmentsData["topCategories"]; }; export function TopCategories({ categories }: TopCategoriesProps) { diff --git a/src/features/reports/establishments/queries.ts b/src/features/reports/establishments/queries.ts index 7e49f15..a0343e1 100644 --- a/src/features/reports/establishments/queries.ts +++ b/src/features/reports/establishments/queries.ts @@ -27,7 +27,7 @@ import { getPreviousPeriod } from "@/shared/utils/period"; const DESPESA = "Despesa"; -export type EstablishmentData = { +type EstablishmentData = { name: string; count: number; totalAmount: number; @@ -35,7 +35,7 @@ export type EstablishmentData = { categories: { name: string; count: number }[]; }; -export type TopCategoryData = { +type TopCategoryData = { id: string; name: string; icon: string | null; @@ -43,7 +43,7 @@ export type TopCategoryData = { transactionCount: number; }; -export type TopEstabelecimentosData = { +export type TopEstablishmentsData = { establishments: EstablishmentData[]; topCategories: TopCategoryData[]; summary: { @@ -73,7 +73,7 @@ export async function fetchTopEstablishmentsData( userId: string, currentPeriod: string, periodFilter: PeriodFilter = "6", -): Promise { +): Promise { const months = parseInt(periodFilter, 10); const periods = buildPeriodRange(currentPeriod, months); const startPeriod = periods[0]; diff --git a/src/features/reports/cards-report-queries.ts b/src/features/reports/lib/cards-report-queries.ts similarity index 99% rename from src/features/reports/cards-report-queries.ts rename to src/features/reports/lib/cards-report-queries.ts index db1a2af..8a9e312 100644 --- a/src/features/reports/cards-report-queries.ts +++ b/src/features/reports/lib/cards-report-queries.ts @@ -23,7 +23,7 @@ import { const DESPESA = "Despesa"; -export type CardSummary = { +type CardSummary = { id: string; name: string; brand: string | null; diff --git a/src/features/reports/category-chart-queries.ts b/src/features/reports/lib/category-chart-queries.ts similarity index 100% rename from src/features/reports/category-chart-queries.ts rename to src/features/reports/lib/category-chart-queries.ts diff --git a/src/features/reports/category-report-queries.ts b/src/features/reports/lib/category-report-queries.ts similarity index 99% rename from src/features/reports/category-report-queries.ts rename to src/features/reports/lib/category-report-queries.ts index bccce63..a8ad873 100644 --- a/src/features/reports/category-report-queries.ts +++ b/src/features/reports/lib/category-report-queries.ts @@ -4,13 +4,13 @@ import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/shared/lib/accounts/constant import { excludeTransactionsFromExcludedAccounts } from "@/shared/lib/accounts/query-filters"; import { db } from "@/shared/lib/db"; import { getAdminPayerId } from "@/shared/lib/payers/get-admin-id"; -import { safeToNumber as toNumber } from "@/shared/utils/number"; import type { CategoryReportData, CategoryReportFilters, CategoryReportItem, MonthlyData, -} from "./types"; +} from "@/shared/lib/types/reports"; +import { safeToNumber as toNumber } from "@/shared/utils/number"; import { calculatePercentageChange, generatePeriodRange } from "./utils"; /** diff --git a/src/features/reports/category-trends-queries.ts b/src/features/reports/lib/category-trends-queries.ts similarity index 100% rename from src/features/reports/category-trends-queries.ts rename to src/features/reports/lib/category-trends-queries.ts diff --git a/src/features/reports/utils.ts b/src/features/reports/lib/utils.ts similarity index 100% rename from src/features/reports/utils.ts rename to src/features/reports/lib/utils.ts diff --git a/src/features/reports/types.ts b/src/features/reports/types.ts deleted file mode 100644 index fd7c1a0..0000000 --- a/src/features/reports/types.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type { - CategoryReportData, - CategoryReportFilters, - CategoryReportItem, - DateRangeValidation, - MonthlyData, -} from "@/shared/lib/types/reports"; diff --git a/src/features/settings/components/preferences-form.tsx b/src/features/settings/components/preferences-form.tsx index e46a8b4..5c5b5f2 100644 --- a/src/features/settings/components/preferences-form.tsx +++ b/src/features/settings/components/preferences-form.tsx @@ -24,11 +24,11 @@ import { updatePreferencesAction } from "@/features/settings/actions"; import { ATTACHMENT_SIZE_OPTIONS, type AttachmentSizeOption, -} from "@/features/transactions/attachments-config"; +} from "@/features/transactions/lib/attachments-config"; import { - DEFAULT_LANCAMENTOS_COLUMN_ORDER, - LANCAMENTOS_COLUMN_LABELS, -} from "@/features/transactions/column-order"; + DEFAULT_TRANSACTIONS_COLUMN_ORDER, + TRANSACTIONS_COLUMN_LABELS, +} from "@/features/transactions/lib/column-order"; import { Button } from "@/shared/components/ui/button"; import { Label } from "@/shared/components/ui/label"; import { Separator } from "@/shared/components/ui/separator"; @@ -59,7 +59,7 @@ function SortableColumnItem({ id }: { id: string }) { transition, }; - const label = LANCAMENTOS_COLUMN_LABELS[id] ?? id; + const label = TRANSACTIONS_COLUMN_LABELS[id] ?? id; return (
( initialColumnOrder && initialColumnOrder.length > 0 ? initialColumnOrder - : DEFAULT_LANCAMENTOS_COLUMN_ORDER, + : DEFAULT_TRANSACTIONS_COLUMN_ORDER, ); const [attachmentMaxSizeMb, setAttachmentMaxSizeMb] = useState( diff --git a/src/features/settings/lib/parse-changelog.ts b/src/features/settings/lib/parse-changelog.ts index ab88604..c9a7694 100644 --- a/src/features/settings/lib/parse-changelog.ts +++ b/src/features/settings/lib/parse-changelog.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; import path from "node:path"; -export type ChangelogSection = { +type ChangelogSection = { type: string; items: string[]; }; diff --git a/src/features/settings/queries.ts b/src/features/settings/queries.ts index 02f8c4a..ce5e768 100644 --- a/src/features/settings/queries.ts +++ b/src/features/settings/queries.ts @@ -2,13 +2,13 @@ import { desc, eq } from "drizzle-orm"; import { apiTokens } from "@/db/schema"; import { db, schema } from "@/shared/lib/db"; -export interface UserPreferences { +interface UserPreferences { statementNoteAsColumn: boolean; transactionsColumnOrder: string[] | null; attachmentMaxSizeMb: number; } -export interface ApiToken { +interface ApiToken { id: string; name: string; tokenPrefix: string; @@ -19,7 +19,7 @@ export interface ApiToken { revokedAt: Date | null; } -export async function fetchAuthProvider(userId: string): Promise { +async function fetchAuthProvider(userId: string): Promise { const userAccount = await db.query.account.findFirst({ where: eq(schema.account.userId, userId), }); @@ -44,7 +44,7 @@ export async function fetchUserPreferences( return result[0]; } -export async function fetchApiTokens(userId: string): Promise { +async function fetchApiTokens(userId: string): Promise { return db .select({ id: apiTokens.id, diff --git a/src/features/transactions/actions.ts b/src/features/transactions/actions.ts index 26169e1..582e4d3 100644 --- a/src/features/transactions/actions.ts +++ b/src/features/transactions/actions.ts @@ -1,76 +1,14 @@ -"use server"; - -import { - createMassTransactionsAction as createMassTransactionsActionImpl, - deleteMultipleTransactionsAction as deleteMultipleTransactionsActionImpl, - deleteTransactionBulkAction as deleteTransactionBulkActionImpl, - updateTransactionBulkAction as updateTransactionBulkActionImpl, +export { + createMassTransactionsAction, + deleteMultipleTransactionsAction, + deleteTransactionBulkAction, + updateTransactionBulkAction, } from "./actions/bulk-actions"; -import { exportTransactionsDataAction as exportTransactionsDataActionImpl } from "./actions/export-actions"; -import { - createTransactionAction as createTransactionActionImpl, - deleteTransactionAction as deleteTransactionActionImpl, - toggleTransactionSettlementAction as toggleTransactionSettlementActionImpl, - updateTransactionAction as updateTransactionActionImpl, - updateTransactionSplitPairAction as updateTransactionSplitPairActionImpl, +export { exportTransactionsDataAction } from "./actions/export-actions"; +export { + createTransactionAction, + deleteTransactionAction, + toggleTransactionSettlementAction, + updateTransactionAction, + updateTransactionSplitPairAction, } from "./actions/single-actions"; - -export async function createTransactionAction( - ...args: Parameters -): ReturnType { - return createTransactionActionImpl(...args); -} - -export async function updateTransactionAction( - ...args: Parameters -): ReturnType { - return updateTransactionActionImpl(...args); -} - -export async function deleteTransactionAction( - ...args: Parameters -): ReturnType { - return deleteTransactionActionImpl(...args); -} - -export async function toggleTransactionSettlementAction( - ...args: Parameters -): ReturnType { - return toggleTransactionSettlementActionImpl(...args); -} - -export async function deleteTransactionBulkAction( - ...args: Parameters -): ReturnType { - return deleteTransactionBulkActionImpl(...args); -} - -export async function updateTransactionBulkAction( - ...args: Parameters -): ReturnType { - return updateTransactionBulkActionImpl(...args); -} - -export async function createMassTransactionsAction( - ...args: Parameters -): ReturnType { - return createMassTransactionsActionImpl(...args); -} - -export async function deleteMultipleTransactionsAction( - ...args: Parameters -): ReturnType { - return deleteMultipleTransactionsActionImpl(...args); -} - -export async function updateTransactionSplitPairAction( - ...args: Parameters -): ReturnType { - return updateTransactionSplitPairActionImpl(...args); -} - -export async function exportTransactionsDataAction( - ...args: Parameters -): ReturnType { - return exportTransactionsDataActionImpl(...args); -} diff --git a/src/features/transactions/anticipation-actions.ts b/src/features/transactions/actions/anticipation.ts similarity index 79% rename from src/features/transactions/anticipation-actions.ts rename to src/features/transactions/actions/anticipation.ts index 7fe9403..0e2f55f 100644 --- a/src/features/transactions/anticipation-actions.ts +++ b/src/features/transactions/actions/anticipation.ts @@ -1,6 +1,6 @@ "use server"; -import { and, asc, desc, eq, inArray, isNull, or } from "drizzle-orm"; +import { and, asc, eq, inArray, isNull, or } from "drizzle-orm"; import { z } from "zod"; import { categories, @@ -22,7 +22,6 @@ import type { CancelAnticipationInput, CreateAnticipationInput, EligibleInstallment, - InstallmentAnticipationWithRelations, } from "@/shared/lib/installments/anticipation-types"; import { uuidSchema } from "@/shared/lib/schemas/common"; import type { ActionResult } from "@/shared/lib/types/actions"; @@ -326,71 +325,6 @@ export async function createInstallmentAnticipationAction( } } -/** - * Busca histórico de antecipações de uma série - */ -export async function getInstallmentAnticipationsAction( - seriesId: string, -): Promise> { - try { - const user = await getUser(); - - // Validar seriesId - const validatedSeriesId = uuidSchema("Série").parse(seriesId); - - // Usar query builder ao invés de db.query para evitar problemas de tipagem - const anticipations = await db - .select({ - id: installmentAnticipations.id, - seriesId: installmentAnticipations.seriesId, - anticipationPeriod: installmentAnticipations.anticipationPeriod, - anticipationDate: installmentAnticipations.anticipationDate, - anticipatedInstallmentIds: - installmentAnticipations.anticipatedInstallmentIds, - totalAmount: installmentAnticipations.totalAmount, - installmentCount: installmentAnticipations.installmentCount, - discount: installmentAnticipations.discount, - transactionId: installmentAnticipations.transactionId, - payerId: installmentAnticipations.payerId, - categoryId: installmentAnticipations.categoryId, - note: installmentAnticipations.note, - userId: installmentAnticipations.userId, - createdAt: installmentAnticipations.createdAt, - // Joins - transaction: transactions, - payer: payers, - category: categories, - }) - .from(installmentAnticipations) - .leftJoin( - transactions, - eq(installmentAnticipations.transactionId, transactions.id), - ) - .leftJoin(payers, eq(installmentAnticipations.payerId, payers.id)) - .leftJoin( - categories, - eq(installmentAnticipations.categoryId, categories.id), - ) - .where( - and( - eq(installmentAnticipations.seriesId, validatedSeriesId), - eq(installmentAnticipations.userId, user.id), - ), - ) - .orderBy(desc(installmentAnticipations.createdAt)); - - return { - success: true, - message: "Antecipações carregadas.", - data: anticipations, - }; - } catch (error) { - return handleActionError(error) as ActionResult< - InstallmentAnticipationWithRelations[] - >; - } -} - /** * Cancela uma antecipação de parcelas * Remove o lançamento de antecipação e restaura as parcelas originais @@ -503,46 +437,3 @@ export async function cancelInstallmentAnticipationAction( return handleActionError(error); } } - -/** - * Busca detalhes de uma antecipação específica - */ -export async function getAnticipationDetailsAction( - anticipationId: string, -): Promise> { - try { - const user = await getUser(); - - // Validar anticipationId - const validatedId = uuidSchema("Antecipação").parse(anticipationId); - - const anticipation = await db.query.installmentAnticipations.findFirst({ - where: and( - eq(installmentAnticipations.id, validatedId), - eq(installmentAnticipations.userId, user.id), - ), - with: { - transaction: true, - payer: true, - category: true, - }, - }); - - if (!anticipation) { - return { - success: false, - error: "Antecipação não encontrada.", - }; - } - - return { - success: true, - message: "Detalhes da antecipação carregados.", - data: anticipation, - }; - } catch (error) { - return handleActionError( - error, - ) as ActionResult; - } -} diff --git a/src/features/transactions/actions/attachments.ts b/src/features/transactions/actions/attachments.ts index 9bcee6a..3b2e6e4 100644 --- a/src/features/transactions/actions/attachments.ts +++ b/src/features/transactions/actions/attachments.ts @@ -7,7 +7,7 @@ import { attachments, transactionAttachments, transactions } from "@/db/schema"; import { ALLOWED_MIME_TYPES, MAX_FILE_SIZE, -} from "@/features/transactions/attachments-config"; +} from "@/features/transactions/lib/attachments-config"; import { handleActionError, revalidateForEntity, diff --git a/src/features/transactions/actions/bulk-actions.ts b/src/features/transactions/actions/bulk-actions.ts index 79120cd..0be31e8 100644 --- a/src/features/transactions/actions/bulk-actions.ts +++ b/src/features/transactions/actions/bulk-actions.ts @@ -6,7 +6,7 @@ import { PAYMENT_METHODS, TRANSACTION_CONDITIONS, TRANSACTION_TYPES, -} from "@/features/transactions/constants"; +} from "@/features/transactions/lib/constants"; import { handleActionError } from "@/shared/lib/actions/helpers"; import { getUser } from "@/shared/lib/auth/server"; import { db } from "@/shared/lib/db"; @@ -705,7 +705,7 @@ export async function createMassTransactionsAction( await sendPayerAutoEmails({ userLabel: resolveUserLabel(user), action: "created", - entriesByPagador: notificationEntries, + entriesByPayer: notificationEntries, }); } @@ -799,7 +799,7 @@ export async function deleteMultipleTransactionsAction( await sendPayerAutoEmails({ userLabel: resolveUserLabel(user), action: "deleted", - entriesByPagador: notificationEntries, + entriesByPayer: notificationEntries, }); } diff --git a/src/features/transactions/actions/core.ts b/src/features/transactions/actions/core.ts index 3c0f4a8..65d1b79 100644 --- a/src/features/transactions/actions/core.ts +++ b/src/features/transactions/actions/core.ts @@ -13,7 +13,7 @@ import { PAYMENT_METHODS, TRANSACTION_CONDITIONS, TRANSACTION_TYPES, -} from "@/features/transactions/constants"; +} from "@/features/transactions/lib/constants"; import { INITIAL_BALANCE_CONDITION, INITIAL_BALANCE_NOTE, @@ -31,7 +31,7 @@ import { addMonthsToPeriod, MONTH_NAMES } from "@/shared/utils/period"; // Authorization Validation Functions // ============================================================================ -export async function validatePagadorOwnership( +export async function validatePayerOwnership( userId: string, payerId: string | null | undefined, ): Promise { @@ -65,19 +65,6 @@ export async function fetchOwnedPayerIds( return new Set(rows.map((row) => row.id)); } -export async function validateCategoriaOwnership( - userId: string, - categoryId: string | null | undefined, -): Promise { - if (!categoryId) return true; - - const categoria = await db.query.categories.findFirst({ - where: and(eq(categories.id, categoryId), eq(categories.userId, userId)), - }); - - return !!categoria; -} - export async function fetchOwnedCategoryIds( userId: string, categoryIds: Array, @@ -298,10 +285,10 @@ export const resolvePeriod = (purchaseDate: string, period?: string | null) => { return `${year}-${month}`; }; -export const isValidDateInput = (value: string) => +const isValidDateInput = (value: string) => !Number.isNaN(parseLocalDateString(value).getTime()); -export const baseFields = z.object({ +const baseFields = z.object({ purchaseDate: z .string({ message: "Informe a data da transação." }) .trim() @@ -498,7 +485,7 @@ export const toggleSettlementSchema = z.object({ .optional(), }); -export type BaseInput = z.infer; +type BaseInput = z.infer; export type CreateInput = z.infer; export type UpdateInput = z.infer; export type DeleteInput = z.infer; @@ -527,7 +514,7 @@ type InitialCandidate = { paymentMethod: string | null; }; -export const isInitialBalanceLancamento = (record?: InitialCandidate | null) => +export const isInitialBalanceTransaction = (record?: InitialCandidate | null) => !!record && record.note === INITIAL_BALANCE_NOTE && record.transactionType === INITIAL_BALANCE_TRANSACTION_TYPE && @@ -554,7 +541,7 @@ const splitAmount = (totalCents: number, parts: number) => { ); }; -export type Share = { +type Share = { payerId: string | null; amountCents: number; }; @@ -617,7 +604,7 @@ type BuildTransactionRecordsParams = { export type TransactionInsert = typeof transactions.$inferInsert; -export const buildLancamentoRecords = ({ +export const buildTransactionRecords = ({ data, userId, period, @@ -859,7 +846,7 @@ export const updateBulkSchema = z.object({ export type UpdateBulkInput = z.infer; -export const massAddTransactionSchema = z.object({ +const massAddTransactionSchema = z.object({ purchaseDate: z .string({ message: "Informe a data da transação." }) .trim() diff --git a/src/features/transactions/actions/export-actions.ts b/src/features/transactions/actions/export-actions.ts index 37bdad4..2ab65ce 100644 --- a/src/features/transactions/actions/export-actions.ts +++ b/src/features/transactions/actions/export-actions.ts @@ -1,14 +1,14 @@ "use server"; import { z } from "zod"; -import { fetchAccountLancamentos } from "@/features/accounts/statement-queries"; -import type { TransactionsExportContext } from "@/features/transactions/export-types"; +import { fetchAccountTransactions } from "@/features/accounts/statement-queries"; +import type { TransactionsExportContext } from "@/features/transactions/lib/export-types"; import { buildSluggedFilters, buildSlugMaps, buildTransactionWhere, mapTransactionsData, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import { fetchTransactionFilterSources, fetchTransactions, @@ -66,7 +66,7 @@ export async function exportTransactionsDataAction( const rows = validated.source === "account-statement" - ? await fetchAccountLancamentos(filters, validated.settledOnly ?? true) + ? await fetchAccountTransactions(filters, validated.settledOnly ?? true) : await fetchTransactions(filters); return { diff --git a/src/features/transactions/actions/fetch-by-id.ts b/src/features/transactions/actions/fetch-by-id.ts index 3ed8594..c478082 100644 --- a/src/features/transactions/actions/fetch-by-id.ts +++ b/src/features/transactions/actions/fetch-by-id.ts @@ -2,7 +2,7 @@ import { eq } from "drizzle-orm"; import { transactions } from "@/db/schema"; -import { mapTransactionsData } from "@/features/transactions/page-helpers"; +import { mapTransactionsData } from "@/features/transactions/lib/page-helpers"; import { fetchTransactionsWithRelations } from "@/features/transactions/queries"; import { getUser } from "@/shared/lib/auth/server"; import type { TransactionItem } from "../components/types"; diff --git a/src/features/transactions/actions/fetch-dialog-options.ts b/src/features/transactions/actions/fetch-dialog-options.ts index 3246cbe..e495a72 100644 --- a/src/features/transactions/actions/fetch-dialog-options.ts +++ b/src/features/transactions/actions/fetch-dialog-options.ts @@ -3,7 +3,7 @@ import { buildOptionSets, buildSluggedFilters, -} from "@/features/transactions/page-helpers"; +} from "@/features/transactions/lib/page-helpers"; import { fetchRecentEstablishments, fetchTransactionFilterSources, diff --git a/src/features/transactions/actions/import-action.ts b/src/features/transactions/actions/import-action.ts index 599c8b9..97b4737 100644 --- a/src/features/transactions/actions/import-action.ts +++ b/src/features/transactions/actions/import-action.ts @@ -6,7 +6,7 @@ import { transactions } from "@/db/schema"; import { validateCartaoOwnership, validateContaOwnership, - validatePagadorOwnership, + validatePayerOwnership, } from "@/features/transactions/actions/core"; import { revalidateForEntity } from "@/shared/lib/actions/helpers"; import { getUserId } from "@/shared/lib/auth/server"; @@ -36,8 +36,7 @@ const importSchema = z.object({ .optional(), }); -export type ImportRow = z.infer; -export type ImportInput = z.infer; +type ImportInput = z.infer; type ImportResult = | { success: true; imported: number; skipped: number; importBatchId: string } @@ -79,7 +78,7 @@ export async function importTransactionsAction( // Valida ownership const [payerOk, accountOk, cardOk] = await Promise.all([ - validatePagadorOwnership(userId, payerId), + validatePayerOwnership(userId, payerId), validateContaOwnership(userId, accountId), validateCartaoOwnership(userId, cardId), ]); diff --git a/src/features/transactions/actions/single-actions.ts b/src/features/transactions/actions/single-actions.ts index 452e26d..b875778 100644 --- a/src/features/transactions/actions/single-actions.ts +++ b/src/features/transactions/actions/single-actions.ts @@ -21,11 +21,11 @@ import { getBusinessTodayDate, parseLocalDateString, } from "@/shared/utils/date"; -import { copyAttachmentsForImport } from "../attachment-copy"; +import { copyAttachmentsForImport } from "../lib/attachment-copy"; import { cleanupAttachmentsAfterTransactionDelete } from "./attachments"; import { - buildLancamentoRecords, buildShares, + buildTransactionRecords, type CreateInput, centsToDecimalString, createSchema, @@ -33,7 +33,7 @@ import { deleteSchema, formatPaidInvoicePeriods, getPaidInvoicePeriods, - isInitialBalanceLancamento, + isInitialBalanceTransaction, resolvePeriod, resolveUserLabel, revalidate, @@ -95,7 +95,7 @@ export async function createTransactionAction( data.condition === "Parcelado" || data.condition === "Recorrente"; const seriesId = isSeriesLancamento ? randomUUID() : null; - const records = buildLancamentoRecords({ + const records = buildTransactionRecords({ data, userId: user.id, period, @@ -180,7 +180,7 @@ export async function createTransactionAction( await sendPayerAutoEmails({ userLabel: resolveUserLabel(user), action: "created", - entriesByPagador: notificationEntries, + entriesByPayer: notificationEntries, }); } @@ -343,7 +343,7 @@ export async function updateTransactionAction( and(eq(transactions.id, data.id), eq(transactions.userId, user.id)), ); - if (isInitialBalanceLancamento(existing) && existing.accountId) { + if (isInitialBalanceTransaction(existing) && existing.accountId) { const updatedInitialBalance = formatDecimalForDbRequired( Math.abs(data.amount ?? 0), ); @@ -465,7 +465,7 @@ export async function deleteTransactionAction( await sendPayerAutoEmails({ userLabel: resolveUserLabel(user), action: "deleted", - entriesByPagador: notificationEntries, + entriesByPayer: notificationEntries, }); } diff --git a/src/features/transactions/components/attachments/attachment-file-picker.tsx b/src/features/transactions/components/attachments/attachment-file-picker.tsx index 6485a21..94fce57 100644 --- a/src/features/transactions/components/attachments/attachment-file-picker.tsx +++ b/src/features/transactions/components/attachments/attachment-file-picker.tsx @@ -6,7 +6,7 @@ import { toast } from "sonner"; import { ALLOWED_MIME_TYPES, DEFAULT_MAX_FILE_SIZE_MB, -} from "@/features/transactions/attachments-config"; +} from "@/features/transactions/lib/attachments-config"; import { Button } from "@/shared/components/ui/button"; interface AttachmentFilePickerProps { diff --git a/src/features/transactions/components/attachments/attachment-upload.tsx b/src/features/transactions/components/attachments/attachment-upload.tsx index abd41d1..e3101bc 100644 --- a/src/features/transactions/components/attachments/attachment-upload.tsx +++ b/src/features/transactions/components/attachments/attachment-upload.tsx @@ -10,7 +10,7 @@ import { import { ALLOWED_MIME_TYPES, DEFAULT_MAX_FILE_SIZE_MB, -} from "@/features/transactions/attachments-config"; +} from "@/features/transactions/lib/attachments-config"; interface AttachmentUploadProps { transactionId: string; diff --git a/src/features/transactions/components/dialogs/anticipate-installments-dialog/anticipate-installments-dialog.tsx b/src/features/transactions/components/dialogs/anticipate-installments-dialog/anticipate-installments-dialog.tsx index 2e55316..2f270a7 100644 --- a/src/features/transactions/components/dialogs/anticipate-installments-dialog/anticipate-installments-dialog.tsx +++ b/src/features/transactions/components/dialogs/anticipate-installments-dialog/anticipate-installments-dialog.tsx @@ -7,7 +7,7 @@ import { CategoryIcon } from "@/features/categories/components/category-icon"; import { createInstallmentAnticipationAction, getEligibleInstallmentsAction, -} from "@/features/transactions/anticipation-actions"; +} from "@/features/transactions/actions/anticipation"; import MoneyValues from "@/shared/components/money-values"; import { PeriodPicker } from "@/shared/components/period-picker"; import { Button } from "@/shared/components/ui/button"; diff --git a/src/features/transactions/components/dialogs/bulk-import-dialog.tsx b/src/features/transactions/components/dialogs/bulk-import-dialog.tsx index 68c13b2..862f48b 100644 --- a/src/features/transactions/components/dialogs/bulk-import-dialog.tsx +++ b/src/features/transactions/components/dialogs/bulk-import-dialog.tsx @@ -3,7 +3,7 @@ import { useMemo, useState, useTransition } from "react"; import { toast } from "sonner"; import { createTransactionAction } from "@/features/transactions/actions"; -import { groupAndSortCategories } from "@/features/transactions/category-helpers"; +import { groupAndSortCategories } from "@/features/transactions/lib/category-helpers"; import { Button } from "@/shared/components/ui/button"; import { Dialog, diff --git a/src/features/transactions/components/dialogs/mass-add-dialog.tsx b/src/features/transactions/components/dialogs/mass-add-dialog.tsx index af203f8..51976e0 100644 --- a/src/features/transactions/components/dialogs/mass-add-dialog.tsx +++ b/src/features/transactions/components/dialogs/mass-add-dialog.tsx @@ -3,11 +3,11 @@ import { RiAddLine, RiDeleteBinLine } from "@remixicon/react"; import { useMemo, useState } from "react"; import { toast } from "sonner"; -import { groupAndSortCategories } from "@/features/transactions/category-helpers"; +import { groupAndSortCategories } from "@/features/transactions/lib/category-helpers"; import { PAYMENT_METHODS, type TRANSACTION_TYPES, -} from "@/features/transactions/constants"; +} from "@/features/transactions/lib/constants"; import { Button } from "@/shared/components/ui/button"; import { CurrencyInput } from "@/shared/components/ui/currency-input"; import { DatePicker } from "@/shared/components/ui/date-picker"; @@ -51,7 +51,7 @@ import { PaymentMethodSelectContent, TransactionTypeSelectContent, } from "../select-items"; -import { EstabelecimentoInput } from "../shared/establishment-input"; +import { EstablishmentInput } from "../shared/establishment-input"; import type { SelectOption } from "../types"; /** Payment methods sem Boleto para este modal */ @@ -490,7 +490,7 @@ export function MassAddDialog({ > Estabelecimento {index + 1} -
- onFieldChange("name", value)} diff --git a/src/features/transactions/components/dialogs/transaction-dialog/category-section.tsx b/src/features/transactions/components/dialogs/transaction-dialog/category-section.tsx index d44a03f..b253b85 100644 --- a/src/features/transactions/components/dialogs/transaction-dialog/category-section.tsx +++ b/src/features/transactions/components/dialogs/transaction-dialog/category-section.tsx @@ -1,6 +1,6 @@ "use client"; -import { TRANSACTION_TYPES } from "@/features/transactions/constants"; +import { TRANSACTION_TYPES } from "@/features/transactions/lib/constants"; import { Label } from "@/shared/components/ui/label"; import { Select, diff --git a/src/features/transactions/components/dialogs/transaction-dialog/condition-section.tsx b/src/features/transactions/components/dialogs/transaction-dialog/condition-section.tsx index 58ca628..d2871f4 100644 --- a/src/features/transactions/components/dialogs/transaction-dialog/condition-section.tsx +++ b/src/features/transactions/components/dialogs/transaction-dialog/condition-section.tsx @@ -1,6 +1,6 @@ "use client"; -import { TRANSACTION_CONDITIONS } from "@/features/transactions/constants"; +import { TRANSACTION_CONDITIONS } from "@/features/transactions/lib/constants"; import { Label } from "@/shared/components/ui/label"; import { Select, diff --git a/src/features/transactions/components/dialogs/transaction-dialog/payment-method-section.tsx b/src/features/transactions/components/dialogs/transaction-dialog/payment-method-section.tsx index 66f9b5c..808a261 100644 --- a/src/features/transactions/components/dialogs/transaction-dialog/payment-method-section.tsx +++ b/src/features/transactions/components/dialogs/transaction-dialog/payment-method-section.tsx @@ -5,7 +5,7 @@ import { RiCheckboxCircleFill, } from "@remixicon/react"; import { useState } from "react"; -import { PAYMENT_METHODS } from "@/features/transactions/constants"; +import { PAYMENT_METHODS } from "@/features/transactions/lib/constants"; import { Button } from "@/shared/components/ui/button"; import { Label } from "@/shared/components/ui/label"; import { MonthPicker } from "@/shared/components/ui/month-picker"; diff --git a/src/features/transactions/components/dialogs/transaction-dialog/transaction-dialog-types.ts b/src/features/transactions/components/dialogs/transaction-dialog/transaction-dialog-types.ts index fddcff4..f1d1aaf 100644 --- a/src/features/transactions/components/dialogs/transaction-dialog/transaction-dialog-types.ts +++ b/src/features/transactions/components/dialogs/transaction-dialog/transaction-dialog-types.ts @@ -1,4 +1,4 @@ -import type { TransactionFormState } from "@/features/transactions/form-helpers"; +import type { TransactionFormState } from "@/features/transactions/lib/form-helpers"; import type { SelectOption, TransactionItem } from "../../types"; export type FormState = TransactionFormState; @@ -71,7 +71,7 @@ export interface TransactionDialogProps { }) => void; } -export interface BaseFieldSectionProps { +interface BaseFieldSectionProps { formState: FormState; onFieldChange: ( key: Key, diff --git a/src/features/transactions/components/dialogs/transaction-dialog/transaction-dialog.tsx b/src/features/transactions/components/dialogs/transaction-dialog/transaction-dialog.tsx index adc31ab..eb98ed6 100644 --- a/src/features/transactions/components/dialogs/transaction-dialog/transaction-dialog.tsx +++ b/src/features/transactions/components/dialogs/transaction-dialog/transaction-dialog.tsx @@ -14,12 +14,12 @@ import { import { filterSecondaryPayerOptions, groupAndSortCategories, -} from "@/features/transactions/category-helpers"; +} from "@/features/transactions/lib/category-helpers"; import { applyFieldDependencies, buildTransactionInitialState, deriveCreditCardPeriod, -} from "@/features/transactions/form-helpers"; +} from "@/features/transactions/lib/form-helpers"; import { Button } from "@/shared/components/ui/button"; import { Collapsible, diff --git a/src/features/transactions/components/import/global-fields.tsx b/src/features/transactions/components/import/global-fields.tsx index 290a413..ead1a13 100644 --- a/src/features/transactions/components/import/global-fields.tsx +++ b/src/features/transactions/components/import/global-fields.tsx @@ -19,7 +19,7 @@ import { SelectValue, } from "@/shared/components/ui/select"; -export type AccountCardValue = `card:${string}` | `account:${string}`; +type AccountCardValue = `card:${string}` | `account:${string}`; export function encodeAccountCard( type: "card" | "account", diff --git a/src/features/transactions/components/page/transactions-page.tsx b/src/features/transactions/components/page/transactions-page.tsx index c5087ca..e9c8842 100644 --- a/src/features/transactions/components/page/transactions-page.tsx +++ b/src/features/transactions/components/page/transactions-page.tsx @@ -21,7 +21,7 @@ import { ConfirmActionDialog } from "@/shared/components/confirm-action-dialog"; import type { TransactionsExportContext, TransactionsPaginationState, -} from "../../export-types"; +} from "../../lib/export-types"; import { AnticipateInstallmentsDialog } from "../dialogs/anticipate-installments-dialog/anticipate-installments-dialog"; import { AnticipationHistoryDialog } from "../dialogs/anticipate-installments-dialog/anticipation-history-dialog"; import { diff --git a/src/features/transactions/components/select-items.tsx b/src/features/transactions/components/select-items.tsx index 336f24b..d371a46 100644 --- a/src/features/transactions/components/select-items.tsx +++ b/src/features/transactions/components/select-items.tsx @@ -3,7 +3,7 @@ import { RiBankCard2Line, RiBankLine } from "@remixicon/react"; import Image from "next/image"; import { CategoryIcon } from "@/features/categories/components/category-icon"; -import StatusDot from "@/shared/components/status-dot"; +import StatusDot from "@/shared/components/feedback/status-dot"; import { Avatar, AvatarFallback, diff --git a/src/features/transactions/components/shared/anticipation-card.tsx b/src/features/transactions/components/shared/anticipation-card.tsx index c775410..f65a6e1 100644 --- a/src/features/transactions/components/shared/anticipation-card.tsx +++ b/src/features/transactions/components/shared/anticipation-card.tsx @@ -5,7 +5,7 @@ import { format } from "date-fns"; import { ptBR } from "date-fns/locale"; import { useTransition } from "react"; import { toast } from "sonner"; -import { cancelInstallmentAnticipationAction } from "@/features/transactions/anticipation-actions"; +import { cancelInstallmentAnticipationAction } from "@/features/transactions/actions/anticipation"; import type { InstallmentAnticipationListItem } from "@/features/transactions/hooks/use-installment-anticipations"; import { ConfirmActionDialog } from "@/shared/components/confirm-action-dialog"; import MoneyValues from "@/shared/components/money-values"; diff --git a/src/features/transactions/components/shared/establishment-input.tsx b/src/features/transactions/components/shared/establishment-input.tsx index 1258eb5..6f5b20f 100644 --- a/src/features/transactions/components/shared/establishment-input.tsx +++ b/src/features/transactions/components/shared/establishment-input.tsx @@ -17,7 +17,7 @@ import { PopoverTrigger, } from "@/shared/components/ui/popover"; -export interface EstabelecimentoInputProps { +interface EstablishmentInputProps { id?: string; value: string; onChange: (value: string) => void; @@ -27,7 +27,7 @@ export interface EstabelecimentoInputProps { maxLength?: number; } -export function EstabelecimentoInput({ +export function EstablishmentInput({ id, value, onChange, @@ -35,7 +35,7 @@ export function EstabelecimentoInput({ placeholder = "Ex.: Padaria, Transferência, Saldo inicial", required = false, maxLength = 20, -}: EstabelecimentoInputProps) { +}: EstablishmentInputProps) { const [open, setOpen] = React.useState(false); const [searchValue, setSearchValue] = React.useState(""); const [width, setWidth] = React.useState(); diff --git a/src/features/transactions/components/table/transactions-columns.tsx b/src/features/transactions/components/table/transactions-columns.tsx index 535262a..606111f 100644 --- a/src/features/transactions/components/table/transactions-columns.tsx +++ b/src/features/transactions/components/table/transactions-columns.tsx @@ -18,11 +18,11 @@ import { import type { ColumnDef } from "@tanstack/react-table"; import Image from "next/image"; import Link from "next/link"; -import { DEFAULT_LANCAMENTOS_COLUMN_ORDER } from "@/features/transactions/column-order"; +import { DEFAULT_TRANSACTIONS_COLUMN_ORDER } from "@/features/transactions/lib/column-order"; import { CREDIT_CARD_PAYMENT_METHOD, SETTLEABLE_PAYMENT_METHODS, -} from "@/features/transactions/constants"; +} from "@/features/transactions/lib/constants"; import { CategoryIconBadge, EstablishmentLogo, @@ -58,7 +58,7 @@ import { getConditionIcon, getPaymentMethodIcon } from "@/shared/utils/icons"; import { cn } from "@/shared/utils/ui"; import type { TransactionItem } from "../types"; -export type BuildColumnsArgs = { +type BuildColumnsArgs = { currentUserId: string; noteAsColumn: boolean; onEdit?: (item: TransactionItem) => void; @@ -748,6 +748,6 @@ export function getTransactionColumns( const built = buildColumns(args); const order = args.columnOrder?.length ? args.columnOrder - : DEFAULT_LANCAMENTOS_COLUMN_ORDER; + : DEFAULT_TRANSACTIONS_COLUMN_ORDER; return reorderColumnsByPreference(built, order); } diff --git a/src/features/transactions/components/table/transactions-filters.tsx b/src/features/transactions/components/table/transactions-filters.tsx index 8ca36e2..ccc093d 100644 --- a/src/features/transactions/components/table/transactions-filters.tsx +++ b/src/features/transactions/components/table/transactions-filters.tsx @@ -18,7 +18,7 @@ import { SETTLED_FILTER_VALUES, TRANSACTION_CONDITIONS, TRANSACTION_TYPES, -} from "@/features/transactions/constants"; +} from "@/features/transactions/lib/constants"; import { Button } from "@/shared/components/ui/button"; import { Command, diff --git a/src/features/transactions/components/table/transactions-table.tsx b/src/features/transactions/components/table/transactions-table.tsx index 9ba327e..c893496 100644 --- a/src/features/transactions/components/table/transactions-table.tsx +++ b/src/features/transactions/components/table/transactions-table.tsx @@ -20,8 +20,8 @@ import { useMemo, useState } from "react"; import type { TransactionsExportContext, TransactionsPaginationState, -} from "@/features/transactions/export-types"; -import { EmptyState } from "@/shared/components/empty-state"; +} from "@/features/transactions/lib/export-types"; +import { EmptyState } from "@/shared/components/feedback/empty-state"; import { Button } from "@/shared/components/ui/button"; import { Card, CardContent } from "@/shared/components/ui/card"; import { @@ -50,7 +50,7 @@ import { getTransactionColumns } from "./transactions-columns"; import { TransactionsFilters } from "./transactions-filters"; import { TransactionsPagination } from "./transactions-pagination"; -type LancamentosTableProps = { +type TransactionsTableProps = { data: TransactionItem[]; currentUserId: string; noteAsColumn?: boolean; @@ -106,7 +106,7 @@ export function TransactionsTable({ isSettlementLoading, showActions = true, showFilters = true, -}: LancamentosTableProps) { +}: TransactionsTableProps) { const router = useRouter(); const pathname = usePathname(); const searchParams = useSearchParams(); diff --git a/src/features/transactions/components/transactions-export.tsx b/src/features/transactions/components/transactions-export.tsx index f0adf69..dc22607 100644 --- a/src/features/transactions/components/transactions-export.tsx +++ b/src/features/transactions/components/transactions-export.tsx @@ -9,8 +9,8 @@ import { import { useState } from "react"; import { toast } from "sonner"; import { exportTransactionsDataAction } from "@/features/transactions/actions"; -import type { TransactionsExportContext } from "@/features/transactions/export-types"; -import { formatCurrency } from "@/features/transactions/formatting-helpers"; +import type { TransactionsExportContext } from "@/features/transactions/lib/export-types"; +import { formatCurrency } from "@/features/transactions/lib/formatting-helpers"; import { Button } from "@/shared/components/ui/button"; import { DropdownMenu, @@ -26,7 +26,7 @@ import { import { displayPeriod } from "@/shared/utils/period"; import type { TransactionItem } from "./types"; -interface LancamentosExportProps { +interface TransactionsExportProps { lancamentos: TransactionItem[]; period: string; exportContext?: TransactionsExportContext; @@ -47,7 +47,7 @@ export function TransactionsExport({ lancamentos, period, exportContext, -}: LancamentosExportProps) { +}: TransactionsExportProps) { const [isExporting, setIsExporting] = useState(false); const getFileName = (extension: string) => { diff --git a/src/features/transactions/hooks/use-installment-anticipations.ts b/src/features/transactions/hooks/use-installment-anticipations.ts index efa4b35..fc693a6 100644 --- a/src/features/transactions/hooks/use-installment-anticipations.ts +++ b/src/features/transactions/hooks/use-installment-anticipations.ts @@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query"; import { z } from "zod"; -import { fetchJson } from "@/shared/lib/fetch-json"; +import { fetchJson } from "@/shared/utils/fetch-json"; const anticipationItemSchema = z.object({ id: z.string().uuid(), diff --git a/src/features/transactions/hooks/use-transaction-attachments.ts b/src/features/transactions/hooks/use-transaction-attachments.ts index cf1b82b..ed0a336 100644 --- a/src/features/transactions/hooks/use-transaction-attachments.ts +++ b/src/features/transactions/hooks/use-transaction-attachments.ts @@ -1,8 +1,8 @@ "use client"; import { useQuery } from "@tanstack/react-query"; -import type { TransactionAttachmentListItem } from "@/features/transactions/attachment-queries"; -import { fetchJson } from "@/shared/lib/fetch-json"; +import type { TransactionAttachmentListItem } from "@/features/transactions/lib/attachment-queries"; +import { fetchJson } from "@/shared/utils/fetch-json"; export const transactionAttachmentsQueryKey = (transactionId: string) => ["transactions", "attachments", transactionId] as const; diff --git a/src/features/transactions/anticipation-queries.ts b/src/features/transactions/lib/anticipation-queries.ts similarity index 98% rename from src/features/transactions/anticipation-queries.ts rename to src/features/transactions/lib/anticipation-queries.ts index 8f322e1..ab64be6 100644 --- a/src/features/transactions/anticipation-queries.ts +++ b/src/features/transactions/lib/anticipation-queries.ts @@ -8,7 +8,7 @@ import { import { db } from "@/shared/lib/db"; import { uuidSchema } from "@/shared/lib/schemas/common"; -export type InstallmentAnticipationListItem = { +type InstallmentAnticipationListItem = { id: string; anticipationPeriod: string; anticipationDate: string; diff --git a/src/features/transactions/attachment-copy.ts b/src/features/transactions/lib/attachment-copy.ts similarity index 100% rename from src/features/transactions/attachment-copy.ts rename to src/features/transactions/lib/attachment-copy.ts diff --git a/src/features/transactions/attachment-queries.ts b/src/features/transactions/lib/attachment-queries.ts similarity index 100% rename from src/features/transactions/attachment-queries.ts rename to src/features/transactions/lib/attachment-queries.ts diff --git a/src/features/transactions/attachments-config.ts b/src/features/transactions/lib/attachments-config.ts similarity index 100% rename from src/features/transactions/attachments-config.ts rename to src/features/transactions/lib/attachments-config.ts diff --git a/src/features/transactions/category-helpers.ts b/src/features/transactions/lib/category-helpers.ts similarity index 100% rename from src/features/transactions/category-helpers.ts rename to src/features/transactions/lib/category-helpers.ts diff --git a/src/features/transactions/column-order.ts b/src/features/transactions/lib/column-order.ts similarity index 71% rename from src/features/transactions/column-order.ts rename to src/features/transactions/lib/column-order.ts index 8c2f02b..bafd602 100644 --- a/src/features/transactions/column-order.ts +++ b/src/features/transactions/lib/column-order.ts @@ -2,7 +2,7 @@ * Ids das colunas reordenáveis da tabela de lançamentos (extrato). * select, purchaseDate e actions são fixos (início, oculto, fim). */ -export const LANCAMENTOS_REORDERABLE_COLUMN_IDS = [ +const TRANSACTIONS_REORDERABLE_COLUMN_IDS = [ "name", "transactionType", "amount", @@ -14,7 +14,7 @@ export const LANCAMENTOS_REORDERABLE_COLUMN_IDS = [ "contaCartao", ] as const; -export const LANCAMENTOS_COLUMN_LABELS: Record = { +export const TRANSACTIONS_COLUMN_LABELS: Record = { name: "Estabelecimento", transactionType: "Transação", amount: "Valor", @@ -26,6 +26,6 @@ export const LANCAMENTOS_COLUMN_LABELS: Record = { contaCartao: "Conta/Cartão", }; -export const DEFAULT_LANCAMENTOS_COLUMN_ORDER: string[] = [ - ...LANCAMENTOS_REORDERABLE_COLUMN_IDS, +export const DEFAULT_TRANSACTIONS_COLUMN_ORDER: string[] = [ + ...TRANSACTIONS_REORDERABLE_COLUMN_IDS, ]; diff --git a/src/features/transactions/constants.ts b/src/features/transactions/lib/constants.ts similarity index 100% rename from src/features/transactions/constants.ts rename to src/features/transactions/lib/constants.ts diff --git a/src/features/transactions/export-types.ts b/src/features/transactions/lib/export-types.ts similarity index 94% rename from src/features/transactions/export-types.ts rename to src/features/transactions/lib/export-types.ts index c1fd607..bf3f672 100644 --- a/src/features/transactions/export-types.ts +++ b/src/features/transactions/lib/export-types.ts @@ -1,4 +1,4 @@ -export type TransactionExportFilters = { +type TransactionExportFilters = { transactionFilter: string | null; conditionFilter: string | null; paymentFilter: string | null; diff --git a/src/features/transactions/form-helpers.ts b/src/features/transactions/lib/form-helpers.ts similarity index 99% rename from src/features/transactions/form-helpers.ts rename to src/features/transactions/lib/form-helpers.ts index 2771faa..47de855 100644 --- a/src/features/transactions/form-helpers.ts +++ b/src/features/transactions/lib/form-helpers.ts @@ -90,7 +90,7 @@ export type TransactionFormState = { /** * Initial state overrides for lancamento form */ -export type LancamentoFormOverrides = { +type TransactionFormOverrides = { defaultCardId?: string | null; defaultPaymentMethod?: string | null; defaultPurchaseDate?: string | null; @@ -107,7 +107,7 @@ export function buildTransactionInitialState( transaction?: TransactionItem, defaultPayerId?: string | null, preferredPeriod?: string, - overrides?: LancamentoFormOverrides, + overrides?: TransactionFormOverrides, ): TransactionFormState { const purchaseDate = transaction?.purchaseDate ? transaction.purchaseDate.slice(0, 10) diff --git a/src/features/transactions/formatting-helpers.ts b/src/features/transactions/lib/formatting-helpers.ts similarity index 100% rename from src/features/transactions/formatting-helpers.ts rename to src/features/transactions/lib/formatting-helpers.ts diff --git a/src/features/transactions/page-helpers.ts b/src/features/transactions/lib/page-helpers.ts similarity index 98% rename from src/features/transactions/page-helpers.ts rename to src/features/transactions/lib/page-helpers.ts index cd468fc..2f8e767 100644 --- a/src/features/transactions/page-helpers.ts +++ b/src/features/transactions/lib/page-helpers.ts @@ -14,7 +14,7 @@ import { SETTLED_FILTER_VALUES, TRANSACTION_CONDITIONS, TRANSACTION_TYPES, -} from "@/features/transactions/constants"; +} from "@/features/transactions/lib/constants"; import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/shared/lib/accounts/constants"; import { PAYER_ROLE_ADMIN, @@ -32,8 +32,8 @@ export type ResolvedSearchParams = | Record | undefined; -export const TRANSACTIONS_DEFAULT_PAGE_SIZE = 30; -export const TRANSACTIONS_PAGE_SIZE_OPTIONS = [5, 10, 20, 30, 40, 50, 100]; +const TRANSACTIONS_DEFAULT_PAGE_SIZE = 30; +const TRANSACTIONS_PAGE_SIZE_OPTIONS = [5, 10, 20, 30, 40, 50, 100]; export type TransactionSearchFilters = { transactionFilter: string | null; @@ -91,16 +91,16 @@ export type SlugMaps = { card: Map; }; -export type FilterOption = { +type FilterOption = { slug: string; label: string; }; -export type AccountCardFilterOption = FilterOption & { +type AccountCardFilterOption = FilterOption & { kind: "conta" | "cartao"; }; -export type TransactionOptionSets = { +type TransactionOptionSets = { payerOptions: SelectOption[]; splitPayerOptions: SelectOption[]; defaultPayerId: string | null; @@ -186,7 +186,7 @@ const createSlugGenerator = () => { }; }; -export const toOption = ( +const toOption = ( value: string, label: string | null | undefined, role?: string | null, diff --git a/src/features/transactions/queries.ts b/src/features/transactions/queries.ts index 1242205..bd623c0 100644 --- a/src/features/transactions/queries.ts +++ b/src/features/transactions/queries.ts @@ -32,7 +32,7 @@ type TransactionQueryInput = BaseTransactionQueryInput & { offset?: number; }; -export type PaginatedTransactionsResult = { +type PaginatedTransactionsResult = { rows: Awaited>; totalItems: number; page: number; diff --git a/src/shared/components/logo-icon.tsx b/src/shared/components/brand/logo-icon.tsx similarity index 100% rename from src/shared/components/logo-icon.tsx rename to src/shared/components/brand/logo-icon.tsx diff --git a/src/shared/components/logo-text.tsx b/src/shared/components/brand/logo-text.tsx similarity index 100% rename from src/shared/components/logo-text.tsx rename to src/shared/components/brand/logo-text.tsx diff --git a/src/shared/components/logo.tsx b/src/shared/components/brand/logo.tsx similarity index 92% rename from src/shared/components/logo.tsx rename to src/shared/components/brand/logo.tsx index d807d2f..6ba8506 100644 --- a/src/shared/components/logo.tsx +++ b/src/shared/components/brand/logo.tsx @@ -1,5 +1,5 @@ -import { LogoIcon } from "@/shared/components/logo-icon"; -import { LogoText } from "@/shared/components/logo-text"; +import { LogoIcon } from "@/shared/components/brand/logo-icon"; +import { LogoText } from "@/shared/components/brand/logo-text"; import { cn } from "@/shared/utils/ui"; interface LogoProps { diff --git a/src/shared/components/entity-avatar/category-icon-badge.tsx b/src/shared/components/entity-avatar/category-icon-badge.tsx index f5c29d0..ef3ccdd 100644 --- a/src/shared/components/entity-avatar/category-icon-badge.tsx +++ b/src/shared/components/entity-avatar/category-icon-badge.tsx @@ -27,9 +27,9 @@ const sizeVariants = { }, } as const; -export type CategoryIconBadgeSize = keyof typeof sizeVariants; +type CategoryIconBadgeSize = keyof typeof sizeVariants; -export interface CategoryIconBadgeProps { +interface CategoryIconBadgeProps { /** Nome do ícone Remix (ex: "RiShoppingBag3Line") */ icon?: string | null; /** Nome da categoria — define cor e iniciais de fallback */ diff --git a/src/shared/components/entity-avatar/index.ts b/src/shared/components/entity-avatar/index.ts index ecdfdf1..a98c100 100644 --- a/src/shared/components/entity-avatar/index.ts +++ b/src/shared/components/entity-avatar/index.ts @@ -1,8 +1,3 @@ -export type { - CategoryIconBadgeProps, - CategoryIconBadgeSize, -} from "./category-icon-badge"; export { CategoryIconBadge } from "./category-icon-badge"; export { EstablishmentLogo } from "./establishment-logo"; -export { EstablishmentLogoPicker } from "./establishment-logo-picker"; export { LogoPrefetchProvider } from "./logo-prefetch-provider"; diff --git a/src/shared/components/empty-state.tsx b/src/shared/components/feedback/empty-state.tsx similarity index 100% rename from src/shared/components/empty-state.tsx rename to src/shared/components/feedback/empty-state.tsx diff --git a/src/shared/components/payment-success.tsx b/src/shared/components/feedback/payment-success.tsx similarity index 100% rename from src/shared/components/payment-success.tsx rename to src/shared/components/feedback/payment-success.tsx diff --git a/src/shared/components/status-dot.tsx b/src/shared/components/feedback/status-dot.tsx similarity index 100% rename from src/shared/components/status-dot.tsx rename to src/shared/components/feedback/status-dot.tsx diff --git a/src/shared/components/month-picker/use-month-period.ts b/src/shared/components/month-picker/use-month-period.ts index 05fee1a..1d37747 100644 --- a/src/shared/components/month-picker/use-month-period.ts +++ b/src/shared/components/month-picker/use-month-period.ts @@ -41,5 +41,3 @@ export function useMonthPeriod() { buildHref, }; } - -export { PERIOD_PARAM as MONTH_PERIOD_PARAM }; diff --git a/src/shared/components/navigation/navbar/app-navbar.tsx b/src/shared/components/navigation/navbar/app-navbar.tsx index 57e136b..97f2d1d 100644 --- a/src/shared/components/navigation/navbar/app-navbar.tsx +++ b/src/shared/components/navigation/navbar/app-navbar.tsx @@ -14,15 +14,15 @@ type AppNavbarProps = { email: string; image: string | null; }; - pagadorAvatarUrl: string | null; - preLancamentosCount?: number; + payerAvatarUrl: string | null; + inboxPendingCount?: number; notificationsSnapshot: DashboardNotificationsSnapshot; }; export async function AppNavbar({ user, - pagadorAvatarUrl, - preLancamentosCount = 0, + payerAvatarUrl, + inboxPendingCount = 0, notificationsSnapshot, }: AppNavbarProps) { const updateCheck = await checkForUpdate(); @@ -36,14 +36,14 @@ export async function AppNavbar({ unreadCount={notificationsSnapshot.unreadCount} visibleCount={notificationsSnapshot.visibleCount} budgetNotifications={notificationsSnapshot.budgetNotifications} - preLancamentosCount={preLancamentosCount} + inboxPendingCount={inboxPendingCount} />
diff --git a/src/shared/components/navigation/navbar/nav-items.tsx b/src/shared/components/navigation/navbar/nav-items.tsx index 4d4a4e6..bc23eab 100644 --- a/src/shared/components/navigation/navbar/nav-items.tsx +++ b/src/shared/components/navigation/navbar/nav-items.tsx @@ -26,7 +26,7 @@ export type NavItem = { hideOnMobile?: boolean; }; -export type NavSection = { +type NavSection = { label: string; items: NavItem[]; }; diff --git a/src/shared/components/navigation/navbar/navbar-shell.tsx b/src/shared/components/navigation/navbar/navbar-shell.tsx index fe8f360..a5f6fbf 100644 --- a/src/shared/components/navigation/navbar/navbar-shell.tsx +++ b/src/shared/components/navigation/navbar/navbar-shell.tsx @@ -1,5 +1,5 @@ import Link from "next/link"; -import { Logo } from "@/shared/components/logo"; +import { Logo } from "@/shared/components/brand/logo"; type NavbarShellProps = { logoHref?: string; diff --git a/src/shared/components/navigation/navbar/navbar-user.tsx b/src/shared/components/navigation/navbar/navbar-user.tsx index d5523cd..20a9098 100644 --- a/src/shared/components/navigation/navbar/navbar-user.tsx +++ b/src/shared/components/navigation/navbar/navbar-user.tsx @@ -45,13 +45,13 @@ type NavbarUserProps = { email: string; image: string | null; }; - pagadorAvatarUrl: string | null; + payerAvatarUrl: string | null; updateCheck: UpdateCheckResult; }; export function NavbarUser({ user, - pagadorAvatarUrl, + payerAvatarUrl, updateCheck, }: NavbarUserProps) { const router = useRouter(); @@ -65,8 +65,8 @@ export function NavbarUser({ setTimeout(() => setCopied(false), 2000); } - const avatarSrc = pagadorAvatarUrl - ? getAvatarSrc(pagadorAvatarUrl) + const avatarSrc = payerAvatarUrl + ? getAvatarSrc(payerAvatarUrl) : user.image || getAvatarSrc(null); const isDataUrl = avatarSrc.startsWith("data:"); diff --git a/src/shared/components/navigation/navbar/notification-bell.tsx b/src/shared/components/navigation/navbar/notification-bell.tsx index 593c7c1..4191487 100644 --- a/src/shared/components/navigation/navbar/notification-bell.tsx +++ b/src/shared/components/navigation/navbar/notification-bell.tsx @@ -25,7 +25,7 @@ export function NotificationBell(props: NotificationBellProps) { hasArchivedItems, archivedDashboardCount, hasVisibleItems, - displayedPreLancamentosCount, + displayedInboxPendingCount, displayedBudgetNotifications, invoiceNotifications, boletoNotifications, @@ -62,7 +62,7 @@ export function NotificationBell(props: NotificationBellProps) { {hasVisibleItems ? ( - {displayedPreLancamentosCount > 0 && ( + {displayedInboxPendingCount > 0 && (
} @@ -382,9 +382,9 @@ export function NotificationBellContent({ icon={} isOverdue={false} title={ - displayedPreLancamentosCount === 1 + displayedInboxPendingCount === 1 ? "1 pré-lançamento pendente" - : `${displayedPreLancamentosCount} pré-lançamentos pendentes` + : `${displayedInboxPendingCount} pré-lançamentos pendentes` } detail="Aguardando revisão" onNavigate={onInboxNavigate} diff --git a/src/shared/components/navigation/navbar/notification-bell/types.ts b/src/shared/components/navigation/navbar/notification-bell/types.ts index 37e2506..e24c4d8 100644 --- a/src/shared/components/navigation/navbar/notification-bell/types.ts +++ b/src/shared/components/navigation/navbar/notification-bell/types.ts @@ -34,5 +34,5 @@ export type NotificationBellProps = { unreadCount: number; visibleCount: number; budgetNotifications: BudgetNotification[]; - preLancamentosCount?: number; + inboxPendingCount?: number; }; diff --git a/src/shared/components/navigation/navbar/notification-bell/use-notification-bell.ts b/src/shared/components/navigation/navbar/notification-bell/use-notification-bell.ts index 0b4cad4..8686ee2 100644 --- a/src/shared/components/navigation/navbar/notification-bell/use-notification-bell.ts +++ b/src/shared/components/navigation/navbar/notification-bell/use-notification-bell.ts @@ -33,7 +33,7 @@ type UseNotificationBellReturn = { hasArchivedItems: boolean; archivedDashboardCount: number; hasVisibleItems: boolean; - displayedPreLancamentosCount: number; + displayedInboxPendingCount: number; displayedBudgetNotifications: ResolvedBudgetNotification[]; invoiceNotifications: ResolvedDashboardNotification[]; boletoNotifications: ResolvedDashboardNotification[]; @@ -82,7 +82,7 @@ export function useNotificationBell({ unreadCount: initialUnreadCount, visibleCount: initialVisibleCount, budgetNotifications, - preLancamentosCount = 0, + inboxPendingCount = 0, }: NotificationBellProps): UseNotificationBellReturn { const [open, setOpen] = useState(false); const [viewMode, setViewMode] = useState("active"); @@ -178,19 +178,19 @@ export function useNotificationBell({ const displayedDashboardCount = showArchived ? displayedDashboardCountFromItems : activeDashboardCount; - const displayedPreLancamentosCount = showArchived ? 0 : preLancamentosCount; - const effectiveUnreadCount = unreadDashboardCountValue + preLancamentosCount; + const displayedInboxPendingCount = showArchived ? 0 : inboxPendingCount; + const effectiveUnreadCount = unreadDashboardCountValue + inboxPendingCount; const displayCount = effectiveUnreadCount > 99 ? "99+" : effectiveUnreadCount.toString(); const hasUnreadNotifications = effectiveUnreadCount > 0; const hasVisibleItems = - displayedDashboardCount + displayedPreLancamentosCount > 0; + displayedDashboardCount + displayedInboxPendingCount > 0; const hasArchivedItems = archivedDashboardCount > 0; const hasDashboardNotificationItems = dashboardNotificationCount > 0; const hasAnySourceItems = allResolvedNotifications.length + allResolvedBudgetNotifications.length + - preLancamentosCount > + inboxPendingCount > 0; const headerCountLabel = `${effectiveUnreadCount} ${effectiveUnreadCount === 1 ? "pendente" : "pendentes"}`; @@ -306,7 +306,7 @@ export function useNotificationBell({ hasArchivedItems, archivedDashboardCount, hasVisibleItems, - displayedPreLancamentosCount, + displayedInboxPendingCount, displayedBudgetNotifications, invoiceNotifications, boletoNotifications, diff --git a/src/shared/components/skeletons/index.ts b/src/shared/components/skeletons/index.ts index 7876a43..6399750 100644 --- a/src/shared/components/skeletons/index.ts +++ b/src/shared/components/skeletons/index.ts @@ -3,10 +3,8 @@ * Facilita a importação em outros componentes */ export { AccountStatementCardSkeleton } from "./account-statement-card-skeleton"; -export { CategoryReportSkeleton } from "./category-report-skeleton"; export { DashboardGridSkeleton } from "./dashboard-grid-skeleton"; export { DashboardMetricsCardsSkeleton } from "./dashboard-metrics-cards-skeleton"; export { FilterSkeleton } from "./filter-skeleton"; export { InvoiceSummaryCardSkeleton } from "./invoice-summary-card-skeleton"; export { TransactionsTableSkeleton } from "./transactions-table-skeleton"; -export { WidgetSkeleton } from "./widget-skeleton"; diff --git a/src/shared/components/expandable-widget-card.tsx b/src/shared/components/widgets/expandable-widget-card.tsx similarity index 97% rename from src/shared/components/expandable-widget-card.tsx rename to src/shared/components/widgets/expandable-widget-card.tsx index 2431bc2..6f21d71 100644 --- a/src/shared/components/expandable-widget-card.tsx +++ b/src/shared/components/widgets/expandable-widget-card.tsx @@ -9,8 +9,8 @@ import { DialogHeader, DialogTitle, } from "@/shared/components/ui/dialog"; -import type { WidgetCardProps } from "@/shared/components/widget-card"; -import WidgetCard from "@/shared/components/widget-card"; +import type { WidgetCardProps } from "@/shared/components/widgets/widget-card"; +import WidgetCard from "@/shared/components/widgets/widget-card"; const OVERFLOW_THRESHOLD_PX = 16; const EXPANDABLE_CONTENT_CLASSNAME = diff --git a/src/shared/components/widget-card.tsx b/src/shared/components/widgets/widget-card.tsx similarity index 100% rename from src/shared/components/widget-card.tsx rename to src/shared/components/widgets/widget-card.tsx diff --git a/src/shared/components/widget-empty-state.tsx b/src/shared/components/widgets/widget-empty-state.tsx similarity index 100% rename from src/shared/components/widget-empty-state.tsx rename to src/shared/components/widgets/widget-empty-state.tsx diff --git a/src/shared/lib/accounts/constants.ts b/src/shared/lib/accounts/constants.ts index b9262ba..be621cd 100644 --- a/src/shared/lib/accounts/constants.ts +++ b/src/shared/lib/accounts/constants.ts @@ -2,7 +2,7 @@ import { PAYMENT_METHODS, TRANSACTION_CONDITIONS, TRANSACTION_TYPES, -} from "@/features/transactions/constants"; +} from "@/features/transactions/lib/constants"; export const INITIAL_BALANCE_CATEGORY_NAME = "Saldo inicial"; export const INITIAL_BALANCE_NOTE = "saldo inicial"; diff --git a/src/shared/lib/actions/helpers.ts b/src/shared/lib/actions/helpers.ts index cd976c6..08fffe0 100644 --- a/src/shared/lib/actions/helpers.ts +++ b/src/shared/lib/actions/helpers.ts @@ -23,7 +23,7 @@ export function handleActionError(error: unknown): ActionResult { /** * Configuration for revalidation after mutations */ -export const revalidateConfig = { +const revalidateConfig = { cards: ["/cards", "/accounts", "/transactions"], accounts: ["/accounts", "/transactions"], categories: ["/categories"], diff --git a/src/shared/lib/auth/config.ts b/src/shared/lib/auth/config.ts index 63ccd0d..a07a9bf 100644 --- a/src/shared/lib/auth/config.ts +++ b/src/shared/lib/auth/config.ts @@ -4,7 +4,7 @@ import { drizzleAdapter } from "better-auth/adapters/drizzle"; import type { GoogleProfile } from "better-auth/social-providers"; import { seedDefaultCategoriesForUser } from "@/shared/lib/categories/defaults"; import { db, schema } from "@/shared/lib/db"; -import { ensureDefaultPagadorForUser } from "@/shared/lib/payers/defaults"; +import { ensureDefaultPayerForUser } from "@/shared/lib/payers/defaults"; import { normalizeNameFromEmail } from "@/shared/lib/payers/utils"; // ============================================================================ @@ -131,7 +131,7 @@ export const auth = betterAuth({ // Se falhar aqui, o usuário já foi criado - considere usar queue para retry try { await seedDefaultCategoriesForUser(user.id); - await ensureDefaultPagadorForUser({ + await ensureDefaultPayerForUser({ id: user.id, name: user.name ?? undefined, email: user.email ?? undefined, diff --git a/src/shared/lib/categories/icons.ts b/src/shared/lib/categories/icons.ts index a236df0..b2ed7ab 100644 --- a/src/shared/lib/categories/icons.ts +++ b/src/shared/lib/categories/icons.ts @@ -5,12 +5,12 @@ * - /lib/category-icons.ts */ -export type CategoryIconOption = { +type CategoryIconOption = { label: string; value: string; }; -export const CATEGORY_ICON_OPTIONS: CategoryIconOption[] = [ +const CATEGORY_ICON_OPTIONS: CategoryIconOption[] = [ // Finanças { label: "Dinheiro", value: "RiMoneyDollarCircleLine" }, { label: "Carteira", value: "RiWallet3Line" }, @@ -156,7 +156,7 @@ export const CATEGORY_ICON_OPTIONS: CategoryIconOption[] = [ { label: "Nuvem Upload", value: "RiCloudUploadLine" }, ]; -export type CategoryIconGroup = { +type CategoryIconGroup = { label: string; icons: CategoryIconOption[]; }; diff --git a/src/shared/lib/installments/anticipation-helpers.ts b/src/shared/lib/installments/anticipation-helpers.ts index 7bb00a1..090e708 100644 --- a/src/shared/lib/installments/anticipation-helpers.ts +++ b/src/shared/lib/installments/anticipation-helpers.ts @@ -4,7 +4,7 @@ import type { EligibleInstallment } from "./anticipation-types"; * Formata o resumo de parcelas antecipadas * Exemplo: "Parcelas 1-3 de 12" ou "Parcela 5 de 12" */ -export function formatAnticipatedInstallmentsRange( +function formatAnticipatedInstallmentsRange( installments: EligibleInstallment[], ): string { const numbers = installments @@ -35,16 +35,6 @@ export function formatAnticipatedInstallmentsRange( } } -/** - * Calcula quantas parcelas restam após uma antecipação - */ -export function calculateRemainingInstallments( - totalInstallments: number, - anticipatedCount: number, -): number { - return Math.max(0, totalInstallments - anticipatedCount); -} - /** * Gera descrição automática para o lançamento de antecipação */ diff --git a/src/shared/lib/installments/anticipation-types.ts b/src/shared/lib/installments/anticipation-types.ts index ad68197..3ba40b0 100644 --- a/src/shared/lib/installments/anticipation-types.ts +++ b/src/shared/lib/installments/anticipation-types.ts @@ -1,10 +1,3 @@ -import type { - Category, - InstallmentAnticipation, - Payer, - Transaction, -} from "@/db/schema"; - /** * Parcela elegível para antecipação */ @@ -22,15 +15,6 @@ export type EligibleInstallment = { payerId: string | null; }; -/** - * Antecipação com dados completos - */ -export type InstallmentAnticipationWithRelations = InstallmentAnticipation & { - transaction: Transaction | null; - payer: Payer | null; - category: Category | null; -}; - /** * Input para criar antecipação */ diff --git a/src/shared/lib/logo/establishment-logo-queries.ts b/src/shared/lib/logo/establishment-logo-queries.ts index c70d7d1..7c64dce 100644 --- a/src/shared/lib/logo/establishment-logo-queries.ts +++ b/src/shared/lib/logo/establishment-logo-queries.ts @@ -3,8 +3,6 @@ import { establishmentLogos } from "@/db/schema"; import { db } from "@/shared/lib/db"; import { toNameKey } from "@/shared/lib/logo"; -export { toNameKey }; - /** * Busca o domínio salvo para um único estabelecimento. */ diff --git a/src/shared/lib/payers/access.ts b/src/shared/lib/payers/access.ts index 4bc2516..a806f6c 100644 --- a/src/shared/lib/payers/access.ts +++ b/src/shared/lib/payers/access.ts @@ -2,7 +2,7 @@ import { and, eq } from "drizzle-orm"; import { payerShares, payers, user as usersTable } from "@/db/schema"; import { db } from "@/shared/lib/db"; -export type PayerWithAccess = Omit & { +type PayerWithAccess = Omit & { shareCode: string | null; canEdit: boolean; sharedByName: string | null; diff --git a/src/shared/lib/payers/defaults.ts b/src/shared/lib/payers/defaults.ts index 16ce75d..7afddcc 100644 --- a/src/shared/lib/payers/defaults.ts +++ b/src/shared/lib/payers/defaults.ts @@ -18,7 +18,7 @@ interface SeedUserLike { image?: string | null; } -export async function ensureDefaultPagadorForUser(user: SeedUserLike) { +export async function ensureDefaultPayerForUser(user: SeedUserLike) { const userId = user.id; if (!userId) { diff --git a/src/shared/lib/payers/details.ts b/src/shared/lib/payers/details.ts index 6200547..2dc1752 100644 --- a/src/shared/lib/payers/details.ts +++ b/src/shared/lib/payers/details.ts @@ -47,7 +47,7 @@ export type PayerCardUsageItem = { amount: number; }; -export type PayerBoletoStats = { +type PayerBoletoStats = { totalAmount: number; paidAmount: number; pendingAmount: number; @@ -196,7 +196,7 @@ export async function fetchPayerHistory({ })); } -export async function fetchPagadorCardUsage({ +export async function fetchPayerCardUsage({ userId, payerId, period, @@ -239,7 +239,7 @@ export async function fetchPagadorCardUsage({ return items.sort((a, b) => b.amount - a.amount); } -export async function fetchPagadorBoletoStats({ +export async function fetchPayerBoletoStats({ userId, payerId, period, @@ -288,7 +288,7 @@ export async function fetchPagadorBoletoStats({ }; } -export async function fetchPagadorBoletoItems({ +export async function fetchPayerBoletoItems({ userId, payerId, period, @@ -330,7 +330,7 @@ export async function fetchPagadorBoletoItems({ return items; } -export async function fetchPagadorPaymentStatus({ +export async function fetchPayerPaymentStatus({ userId, payerId, period, diff --git a/src/shared/lib/payers/notifications.ts b/src/shared/lib/payers/notifications.ts index bff2c6c..58bed18 100644 --- a/src/shared/lib/payers/notifications.ts +++ b/src/shared/lib/payers/notifications.ts @@ -8,7 +8,7 @@ import { formatDateTime } from "@/shared/utils/date"; type ActionType = "created" | "deleted"; -export type NotificationEntry = { +type NotificationEntry = { payerId: string; name: string | null; amount: number; @@ -20,10 +20,10 @@ export type NotificationEntry = { note: string | null; }; -export type PayerNotificationRequest = { +type PayerNotificationRequest = { userLabel: string; action: ActionType; - entriesByPagador: Map; + entriesByPayer: Map; }; type PayerNotificationRecipient = { @@ -113,11 +113,11 @@ const buildHtmlBody = ({ export async function sendPayerAutoEmails({ userLabel, action, - entriesByPagador, + entriesByPayer, }: PayerNotificationRequest) { "use server"; - if (entriesByPagador.size === 0) { + if (entriesByPayer.size === 0) { return; } @@ -131,7 +131,7 @@ export async function sendPayerAutoEmails({ return; } - const pagadorIds = Array.from(entriesByPagador.keys()); + const pagadorIds = Array.from(entriesByPayer.keys()); if (pagadorIds.length === 0) { return; } @@ -154,7 +154,7 @@ export async function sendPayerAutoEmails({ return; } - const entries = entriesByPagador.get(payer.id); + const entries = entriesByPayer.get(payer.id); if (!entries || entries.length === 0) { return; } @@ -186,7 +186,7 @@ export async function sendPayerAutoEmails({ }); } -export type RawNotificationRecord = { +type RawNotificationRecord = { payerId: string | null; name: string | null; amount: string | number | null; diff --git a/src/shared/lib/schemas/common.ts b/src/shared/lib/schemas/common.ts index 175da39..f9f0413 100644 --- a/src/shared/lib/schemas/common.ts +++ b/src/shared/lib/schemas/common.ts @@ -12,25 +12,6 @@ export const uuidSchema = (entityName: string = "ID") => .string({ message: `${entityName} inválido.` }) .uuid(`${entityName} inválido.`); -/** - * Optional/nullable decimal string schema - */ -export const optionalDecimalSchema = z.union([ - z.number().nullable(), - z - .string() - .trim() - .optional() - .transform((value) => - value && value.length > 0 ? value.replace(",", ".") : null, - ) - .refine( - (value) => value === null || !Number.isNaN(Number.parseFloat(value)), - "Informe um valor numérico válido.", - ) - .transform((value) => (value === null ? null : Number.parseFloat(value))), -]); - /** * Required positive decimal schema — accepts number or numeric string. */ diff --git a/src/shared/lib/schemas/insights.ts b/src/shared/lib/schemas/insights.ts index 1794aa7..61d3def 100644 --- a/src/shared/lib/schemas/insights.ts +++ b/src/shared/lib/schemas/insights.ts @@ -35,14 +35,14 @@ export type InsightCategoryId = keyof typeof INSIGHT_CATEGORIES; /** * Schema para item individual de insight */ -export const InsightItemSchema = z.object({ +const InsightItemSchema = z.object({ text: z.string().min(1), }); /** * Schema para categoria de insights */ -export const InsightCategorySchema = z.object({ +const InsightCategorySchema = z.object({ category: z.enum([ "behaviors", "triggers", diff --git a/src/shared/lib/types/notifications.ts b/src/shared/lib/types/notifications.ts index 08ba9b8..76b3b06 100644 --- a/src/shared/lib/types/notifications.ts +++ b/src/shared/lib/types/notifications.ts @@ -1,8 +1,8 @@ -export type NotificationType = "overdue" | "due_soon"; +type NotificationType = "overdue" | "due_soon"; -export type BudgetStatus = "exceeded" | "critical"; +type BudgetStatus = "exceeded" | "critical"; -export type DashboardNotificationStateFields = { +type DashboardNotificationStateFields = { notificationKey: string; fingerprint: string; href: string; diff --git a/src/shared/utils/currency.ts b/src/shared/utils/currency.ts index c688532..5968ad1 100644 --- a/src/shared/utils/currency.ts +++ b/src/shared/utils/currency.ts @@ -15,13 +15,6 @@ export const currencyFormatter = new Intl.NumberFormat("pt-BR", { maximumFractionDigits: 2, }); -export const currencyFormatterNoCents = new Intl.NumberFormat("pt-BR", { - style: "currency", - currency: "BRL", - minimumFractionDigits: 0, - maximumFractionDigits: 0, -}); - export const formatCurrency = ( value: number, options: CurrencyFormatOptions = {}, @@ -47,19 +40,6 @@ export const formatCurrencyCompact = ( /** * Formats a decimal number for database storage (2 decimal places) * @param value - The number to format - * @returns Formatted string with 2 decimal places, or null if input is null - */ -export function formatDecimalForDb(value: number | null): string | null { - if (value === null) { - return null; - } - - return (Math.round(value * 100) / 100).toFixed(2); -} - -/** - * Formats a decimal number for database storage (non-nullable version) - * @param value - The number to format * @returns Formatted string with 2 decimal places */ export function formatDecimalForDbRequired(value: number): string { diff --git a/src/shared/lib/fetch-json.ts b/src/shared/utils/fetch-json.ts similarity index 100% rename from src/shared/lib/fetch-json.ts rename to src/shared/utils/fetch-json.ts diff --git a/src/shared/utils/period/index.ts b/src/shared/utils/period/index.ts index fb585e4..991cd35 100644 --- a/src/shared/utils/period/index.ts +++ b/src/shared/utils/period/index.ts @@ -205,7 +205,7 @@ const MONTH_MAP = new Map( const normalize = (value: string | null | undefined) => (value ?? "").trim().toLowerCase(); -export type ParsedPeriod = { +type ParsedPeriod = { period: string; monthName: string; year: number; @@ -254,7 +254,7 @@ export function parsePeriodParam( * @param year - Year number * @returns URL param string in "mes-ano" format */ -export function formatPeriodParam(monthName: string, year: number): string { +function formatPeriodParam(monthName: string, year: number): string { return `${normalize(monthName)}-${year}`; } @@ -323,15 +323,6 @@ export function displayPeriod(period: string): string { return `${capitalize(monthName)} de ${year}`; } -/** - * Alias for displayPeriod - formats period for display - * @example - * formatMonthLabel("2024-01") // "Janeiro de 2024" - */ -export function formatMonthLabel(period: string): string { - return displayPeriod(period); -} - /** * Formats period for short display with full year * @example