refactor: reorganiza componentes compartilhados e caminhos do app
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { RiSettings2Line } from "@remixicon/react";
|
import { RiSettings2Line } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Ajustes | OpenMonetis",
|
title: "Ajustes | OpenMonetis",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiTodoLine } from "@remixicon/react";
|
import { RiTodoLine } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Anotações | OpenMonetis",
|
title: "Anotações | OpenMonetis",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiCalendarEventLine } from "@remixicon/react";
|
import { RiCalendarEventLine } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Calendário | OpenMonetis",
|
title: "Calendário | OpenMonetis",
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import {
|
|||||||
lancamentos,
|
lancamentos,
|
||||||
pagadores,
|
pagadores,
|
||||||
} from "@/db/schema";
|
} from "@/db/schema";
|
||||||
import { buildInvoicePaymentNote } from "@/lib/accounts/constants";
|
|
||||||
import { revalidateForEntity } from "@/lib/actions/helpers";
|
import { revalidateForEntity } from "@/lib/actions/helpers";
|
||||||
import { getUser } from "@/lib/auth/server";
|
import { getUser } from "@/lib/auth/server";
|
||||||
|
import { buildInvoicePaymentNote } from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import {
|
import {
|
||||||
INVOICE_PAYMENT_STATUS,
|
INVOICE_PAYMENT_STATUS,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { and, desc, eq, type SQL, sum } from "drizzle-orm";
|
import { and, desc, eq, type SQL, sum } from "drizzle-orm";
|
||||||
import { cartoes, faturas, lancamentos } from "@/db/schema";
|
import { cartoes, faturas, lancamentos } from "@/db/schema";
|
||||||
import { buildInvoicePaymentNote } from "@/lib/accounts/constants";
|
import { buildInvoicePaymentNote } from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import {
|
import {
|
||||||
INVOICE_PAYMENT_STATUS,
|
INVOICE_PAYMENT_STATUS,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
FilterSkeleton,
|
FilterSkeleton,
|
||||||
InvoiceSummaryCardSkeleton,
|
InvoiceSummaryCardSkeleton,
|
||||||
TransactionsTableSkeleton,
|
TransactionsTableSkeleton,
|
||||||
} from "@/components/skeletons";
|
} from "@/components/shared/skeletons";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiBankCard2Line } from "@remixicon/react";
|
import { RiBankCard2Line } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Cartões | OpenMonetis",
|
title: "Cartões | OpenMonetis",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiPriceTag3Line } from "@remixicon/react";
|
import { RiPriceTag3Line } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Categorias | OpenMonetis",
|
title: "Categorias | OpenMonetis",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiHistoryLine } from "@remixicon/react";
|
import { RiHistoryLine } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Cartões | OpenMonetis",
|
title: "Cartões | OpenMonetis",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { and, desc, eq, lt, type SQL, sql } from "drizzle-orm";
|
import { and, desc, eq, lt, type SQL, sql } from "drizzle-orm";
|
||||||
import { contas, lancamentos, pagadores } from "@/db/schema";
|
import { contas, lancamentos, pagadores } from "@/db/schema";
|
||||||
import { INITIAL_BALANCE_NOTE } from "@/lib/accounts/constants";
|
import { INITIAL_BALANCE_NOTE } from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
AccountStatementCardSkeleton,
|
AccountStatementCardSkeleton,
|
||||||
FilterSkeleton,
|
FilterSkeleton,
|
||||||
TransactionsTableSkeleton,
|
TransactionsTableSkeleton,
|
||||||
} from "@/components/skeletons";
|
} from "@/components/shared/skeletons";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,19 +3,19 @@
|
|||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { categorias, contas, lancamentos, pagadores } from "@/db/schema";
|
import { categorias, contas, lancamentos, pagadores } from "@/db/schema";
|
||||||
import {
|
|
||||||
INITIAL_BALANCE_CATEGORY_NAME,
|
|
||||||
INITIAL_BALANCE_CONDITION,
|
|
||||||
INITIAL_BALANCE_NOTE,
|
|
||||||
INITIAL_BALANCE_PAYMENT_METHOD,
|
|
||||||
INITIAL_BALANCE_TRANSACTION_TYPE,
|
|
||||||
} from "@/lib/accounts/constants";
|
|
||||||
import {
|
import {
|
||||||
type ActionResult,
|
type ActionResult,
|
||||||
handleActionError,
|
handleActionError,
|
||||||
revalidateForEntity,
|
revalidateForEntity,
|
||||||
} from "@/lib/actions/helpers";
|
} from "@/lib/actions/helpers";
|
||||||
import { getUser } from "@/lib/auth/server";
|
import { getUser } from "@/lib/auth/server";
|
||||||
|
import {
|
||||||
|
INITIAL_BALANCE_CATEGORY_NAME,
|
||||||
|
INITIAL_BALANCE_CONDITION,
|
||||||
|
INITIAL_BALANCE_NOTE,
|
||||||
|
INITIAL_BALANCE_PAYMENT_METHOD,
|
||||||
|
INITIAL_BALANCE_TRANSACTION_TYPE,
|
||||||
|
} from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
||||||
import { noteSchema, uuidSchema } from "@/lib/schemas/common";
|
import { noteSchema, uuidSchema } from "@/lib/schemas/common";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { and, eq, ilike, not, sql } from "drizzle-orm";
|
import { and, eq, ilike, not, sql } from "drizzle-orm";
|
||||||
import { contas, lancamentos, pagadores } from "@/db/schema";
|
import { contas, lancamentos, pagadores } from "@/db/schema";
|
||||||
import { INITIAL_BALANCE_NOTE } from "@/lib/accounts/constants";
|
import { INITIAL_BALANCE_NOTE } from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { loadLogoOptions } from "@/lib/logo/options";
|
import { loadLogoOptions } from "@/lib/logo/options";
|
||||||
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiBankLine } from "@remixicon/react";
|
import { RiBankLine } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Contas | OpenMonetis",
|
title: "Contas | OpenMonetis",
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import { DashboardGridSkeleton } from "@/components/skeletons";
|
import { DashboardGridSkeleton } from "@/components/shared/skeletons";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
|
||||||
/**
|
|
||||||
* Loading state para a página do dashboard
|
|
||||||
* Estrutura: Welcome Banner → Month Picker → Section Cards → Widget Grid
|
|
||||||
*/
|
|
||||||
export default function DashboardLoading() {
|
export default function DashboardLoading() {
|
||||||
return (
|
return (
|
||||||
<main className="flex flex-col gap-4">
|
<main className="flex flex-col gap-4">
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import {
|
|||||||
orcamentos,
|
orcamentos,
|
||||||
pagadores,
|
pagadores,
|
||||||
} from "@/db/schema";
|
} from "@/db/schema";
|
||||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
|
||||||
import { getUser } from "@/lib/auth/server";
|
import { getUser } from "@/lib/auth/server";
|
||||||
|
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiSparklingLine } from "@remixicon/react";
|
import { RiSparklingLine } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Insights | OpenMonetis",
|
title: "Insights | OpenMonetis",
|
||||||
|
|||||||
@@ -10,15 +10,15 @@ import {
|
|||||||
lancamentos,
|
lancamentos,
|
||||||
pagadores,
|
pagadores,
|
||||||
} from "@/db/schema";
|
} from "@/db/schema";
|
||||||
|
import { handleActionError, revalidateForEntity } from "@/lib/actions/helpers";
|
||||||
|
import type { ActionResult } from "@/lib/actions/types";
|
||||||
|
import { getUser } from "@/lib/auth/server";
|
||||||
import {
|
import {
|
||||||
INITIAL_BALANCE_CONDITION,
|
INITIAL_BALANCE_CONDITION,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
INITIAL_BALANCE_PAYMENT_METHOD,
|
INITIAL_BALANCE_PAYMENT_METHOD,
|
||||||
INITIAL_BALANCE_TRANSACTION_TYPE,
|
INITIAL_BALANCE_TRANSACTION_TYPE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { handleActionError, revalidateForEntity } from "@/lib/actions/helpers";
|
|
||||||
import type { ActionResult } from "@/lib/actions/types";
|
|
||||||
import { getUser } from "@/lib/auth/server";
|
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import {
|
import {
|
||||||
LANCAMENTO_CONDITIONS,
|
LANCAMENTO_CONDITIONS,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
lancamentos,
|
lancamentos,
|
||||||
pagadores,
|
pagadores,
|
||||||
} from "@/db/schema";
|
} from "@/db/schema";
|
||||||
import { INITIAL_BALANCE_NOTE } from "@/lib/accounts/constants";
|
import { INITIAL_BALANCE_NOTE } from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
|
|
||||||
export async function fetchLancamentos(filters: SQL[]) {
|
export async function fetchLancamentos(filters: SQL[]) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiArrowLeftRightLine } from "@remixicon/react";
|
import { RiArrowLeftRightLine } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Lançamentos | OpenMonetis",
|
title: "Lançamentos | OpenMonetis",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
FilterSkeleton,
|
FilterSkeleton,
|
||||||
TransactionsTableSkeleton,
|
TransactionsTableSkeleton,
|
||||||
} from "@/components/skeletons";
|
} from "@/components/shared/skeletons";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { FontProvider } from "@/components/font-provider";
|
import { FontProvider } from "@/components/font-provider";
|
||||||
import { AppNavbar } from "@/components/navbar/app-navbar";
|
import { AppNavbar } from "@/components/navigation/navbar/app-navbar";
|
||||||
import { PrivacyProvider } from "@/components/privacy-provider";
|
import { PrivacyProvider } from "@/components/privacy-provider";
|
||||||
import { getUserSession } from "@/lib/auth/server";
|
import { getUserSession } from "@/lib/auth/server";
|
||||||
import { fetchDashboardNotifications } from "@/lib/dashboard/notifications";
|
import { fetchDashboardNotifications } from "@/lib/dashboard/notifications";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
orcamentos,
|
orcamentos,
|
||||||
pagadores,
|
pagadores,
|
||||||
} from "@/db/schema";
|
} from "@/db/schema";
|
||||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiBarChart2Line } from "@remixicon/react";
|
import { RiBarChart2Line } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Orçamentos | OpenMonetis",
|
title: "Orçamentos | OpenMonetis",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiGroupLine } from "@remixicon/react";
|
import { RiGroupLine } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Pagadores | OpenMonetis",
|
title: "Pagadores | OpenMonetis",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiAtLine } from "@remixicon/react";
|
import { RiAtLine } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Pré-Lançamentos | OpenMonetis",
|
title: "Pré-Lançamentos | OpenMonetis",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiSecurePaymentLine } from "@remixicon/react";
|
import { RiSecurePaymentLine } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Análise de Parcelas | OpenMonetis",
|
title: "Análise de Parcelas | OpenMonetis",
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiStore2Line } from "@remixicon/react";
|
import { RiStore2Line } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Top Estabelecimentos | OpenMonetis",
|
title: "Top Estabelecimentos | OpenMonetis",
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { EstablishmentsList } from "@/components/top-estabelecimentos/establishments-list";
|
import { EstablishmentsList } from "@/components/relatorios/estabelecimentos/establishments-list";
|
||||||
import { HighlightsCards } from "@/components/top-estabelecimentos/highlights-cards";
|
import { HighlightsCards } from "@/components/relatorios/estabelecimentos/highlights-cards";
|
||||||
import { PeriodFilterButtons } from "@/components/top-estabelecimentos/period-filter";
|
import { PeriodFilterButtons } from "@/components/relatorios/estabelecimentos/period-filter";
|
||||||
import { SummaryCards } from "@/components/top-estabelecimentos/summary-cards";
|
import { SummaryCards } from "@/components/relatorios/estabelecimentos/summary-cards";
|
||||||
import { TopCategories } from "@/components/top-estabelecimentos/top-categories";
|
import { TopCategories } from "@/components/relatorios/estabelecimentos/top-categories";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "@/components/ui/card";
|
||||||
import { getUser } from "@/lib/auth/server";
|
import { getUser } from "@/lib/auth/server";
|
||||||
import {
|
import {
|
||||||
fetchTopEstabelecimentosData,
|
fetchTopEstabelecimentosData,
|
||||||
type PeriodFilter,
|
type PeriodFilter,
|
||||||
} from "@/lib/top-estabelecimentos/fetch-data";
|
} from "@/lib/relatorios/estabelecimentos/fetch-data";
|
||||||
import { parsePeriodParam } from "@/lib/utils/period";
|
import { parsePeriodParam } from "@/lib/utils/period";
|
||||||
|
|
||||||
type PageSearchParams = Promise<Record<string, string | string[] | undefined>>;
|
type PageSearchParams = Promise<Record<string, string | string[] | undefined>>;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiFileChartLine } from "@remixicon/react";
|
import { RiFileChartLine } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Tendências | OpenMonetis",
|
title: "Tendências | OpenMonetis",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { CategoryReportSkeleton } from "@/components/skeletons/category-report-skeleton";
|
import { CategoryReportSkeleton } from "@/components/shared/skeletons/category-report-skeleton";
|
||||||
|
|
||||||
export default function Loading() {
|
export default function Loading() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RiBankCard2Line } from "@remixicon/react";
|
import { RiBankCard2Line } from "@remixicon/react";
|
||||||
import PageDescription from "@/components/page-description";
|
import PageDescription from "@/components/shared/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Uso de Cartões | OpenMonetis",
|
title: "Uso de Cartões | OpenMonetis",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
deleteNoteAction,
|
deleteNoteAction,
|
||||||
} from "@/app/(dashboard)/anotacoes/actions";
|
} from "@/app/(dashboard)/anotacoes/actions";
|
||||||
import { ConfirmActionDialog } from "@/components/confirm-action-dialog";
|
import { ConfirmActionDialog } from "@/components/confirm-action-dialog";
|
||||||
import { EmptyState } from "@/components/empty-state";
|
import { EmptyState } from "@/components/shared/empty-state";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { Card } from "../ui/card";
|
import { Card } from "../ui/card";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useCallback, useMemo, useState } from "react";
|
|||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { deleteCardAction } from "@/app/(dashboard)/cartoes/actions";
|
import { deleteCardAction } from "@/app/(dashboard)/cartoes/actions";
|
||||||
import { ConfirmActionDialog } from "@/components/confirm-action-dialog";
|
import { ConfirmActionDialog } from "@/components/confirm-action-dialog";
|
||||||
import { EmptyState } from "@/components/empty-state";
|
import { EmptyState } from "@/components/shared/empty-state";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "@/components/ui/card";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { toast } from "sonner";
|
|||||||
import { deleteAccountAction } from "@/app/(dashboard)/contas/actions";
|
import { deleteAccountAction } from "@/app/(dashboard)/contas/actions";
|
||||||
import { ConfirmActionDialog } from "@/components/confirm-action-dialog";
|
import { ConfirmActionDialog } from "@/components/confirm-action-dialog";
|
||||||
import { AccountCard } from "@/components/contas/account-card";
|
import { AccountCard } from "@/components/contas/account-card";
|
||||||
import { EmptyState } from "@/components/empty-state";
|
import { EmptyState } from "@/components/shared/empty-state";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { getCurrentPeriod } from "@/lib/utils/period";
|
import { getCurrentPeriod } from "@/lib/utils/period";
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ import {
|
|||||||
saveInsightsAction,
|
saveInsightsAction,
|
||||||
} from "@/app/(dashboard)/insights/actions";
|
} from "@/app/(dashboard)/insights/actions";
|
||||||
import { DEFAULT_MODEL } from "@/app/(dashboard)/insights/data";
|
import { DEFAULT_MODEL } from "@/app/(dashboard)/insights/data";
|
||||||
|
import { EmptyState } from "@/components/shared/empty-state";
|
||||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import type { InsightsResponse } from "@/lib/schemas/insights";
|
import type { InsightsResponse } from "@/lib/schemas/insights";
|
||||||
import { EmptyState } from "../empty-state";
|
|
||||||
import { InsightsGrid } from "./insights-grid";
|
import { InsightsGrid } from "./insights-grid";
|
||||||
import { ModelSelector } from "./model-selector";
|
import { ModelSelector } from "./model-selector";
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { MonthPicker } from "@/components/ui/monthpicker";
|
import { MonthPicker } from "@/components/ui/month-picker";
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { MonthPicker } from "@/components/ui/monthpicker";
|
import { MonthPicker } from "@/components/ui/month-picker";
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
@@ -36,7 +36,6 @@ import { groupAndSortCategorias } from "@/lib/lancamentos/categoria-helpers";
|
|||||||
import { LANCAMENTO_PAYMENT_METHODS } from "@/lib/lancamentos/constants";
|
import { LANCAMENTO_PAYMENT_METHODS } from "@/lib/lancamentos/constants";
|
||||||
import { getTodayDateString } from "@/lib/utils/date";
|
import { getTodayDateString } from "@/lib/utils/date";
|
||||||
import { displayPeriod } from "@/lib/utils/period";
|
import { displayPeriod } from "@/lib/utils/period";
|
||||||
import type { SelectOption } from "../../types";
|
|
||||||
import {
|
import {
|
||||||
CategoriaSelectContent,
|
CategoriaSelectContent,
|
||||||
ContaCartaoSelectContent,
|
ContaCartaoSelectContent,
|
||||||
@@ -45,6 +44,7 @@ import {
|
|||||||
TransactionTypeSelectContent,
|
TransactionTypeSelectContent,
|
||||||
} from "../select-items";
|
} from "../select-items";
|
||||||
import { EstabelecimentoInput } from "../shared/estabelecimento-input";
|
import { EstabelecimentoInput } from "../shared/estabelecimento-input";
|
||||||
|
import type { SelectOption } from "../types";
|
||||||
|
|
||||||
/** Payment methods sem Boleto para este modal */
|
/** Payment methods sem Boleto para este modal */
|
||||||
const MASS_ADD_PAYMENT_METHODS = LANCAMENTO_PAYMENT_METHODS.filter(
|
const MASS_ADD_PAYMENT_METHODS = LANCAMENTO_PAYMENT_METHODS.filter(
|
||||||
|
|||||||
@@ -1,103 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { RiCalculatorLine, RiEyeLine, RiEyeOffLine } from "@remixicon/react";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { CalculatorDialogContent } from "@/components/calculadora/calculator-dialog";
|
|
||||||
import { usePrivacyMode } from "@/components/privacy-provider";
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import { Dialog, DialogTrigger } from "@/components/ui/dialog";
|
|
||||||
import { cn } from "@/lib/utils/ui";
|
|
||||||
|
|
||||||
const itemClass =
|
|
||||||
"flex w-full items-center gap-2.5 rounded-sm px-2 py-2 text-sm text-foreground hover:bg-accent transition-colors cursor-pointer";
|
|
||||||
|
|
||||||
export function NavToolsDropdown() {
|
|
||||||
const { privacyMode, toggle } = usePrivacyMode();
|
|
||||||
const [calcOpen, setCalcOpen] = useState(false);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog open={calcOpen} onOpenChange={setCalcOpen}>
|
|
||||||
<ul className="grid w-52 gap-0.5 p-2">
|
|
||||||
<li>
|
|
||||||
<DialogTrigger asChild>
|
|
||||||
<button type="button" className={cn(itemClass)}>
|
|
||||||
<span className="text-muted-foreground shrink-0">
|
|
||||||
<RiCalculatorLine className="size-4" />
|
|
||||||
</span>
|
|
||||||
<span className="flex-1 text-left">calculadora</span>
|
|
||||||
</button>
|
|
||||||
</DialogTrigger>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<button type="button" onClick={toggle} className={cn(itemClass)}>
|
|
||||||
<span className="text-muted-foreground shrink-0">
|
|
||||||
{privacyMode ? (
|
|
||||||
<RiEyeOffLine className="size-4" />
|
|
||||||
) : (
|
|
||||||
<RiEyeLine className="size-4" />
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
<span className="flex-1 text-left">privacidade</span>
|
|
||||||
{privacyMode && (
|
|
||||||
<Badge
|
|
||||||
variant="secondary"
|
|
||||||
className="text-[10px] px-1.5 py-0 h-4"
|
|
||||||
>
|
|
||||||
Ativo
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<CalculatorDialogContent open={calcOpen} />
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
type MobileToolsProps = {
|
|
||||||
onClose: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function MobileTools({ onClose }: MobileToolsProps) {
|
|
||||||
const { privacyMode, toggle } = usePrivacyMode();
|
|
||||||
const [calcOpen, setCalcOpen] = useState(false);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog open={calcOpen} onOpenChange={setCalcOpen}>
|
|
||||||
<DialogTrigger asChild>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="flex w-full items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors text-muted-foreground hover:text-foreground hover:bg-accent"
|
|
||||||
>
|
|
||||||
<span className="text-muted-foreground shrink-0">
|
|
||||||
<RiCalculatorLine className="size-4" />
|
|
||||||
</span>
|
|
||||||
<span className="flex-1 text-left">calculadora</span>
|
|
||||||
</button>
|
|
||||||
</DialogTrigger>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => {
|
|
||||||
toggle();
|
|
||||||
onClose();
|
|
||||||
}}
|
|
||||||
className="flex w-full items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors text-muted-foreground hover:text-foreground hover:bg-accent"
|
|
||||||
>
|
|
||||||
<span className="text-muted-foreground shrink-0">
|
|
||||||
{privacyMode ? (
|
|
||||||
<RiEyeOffLine className="size-4" />
|
|
||||||
) : (
|
|
||||||
<RiEyeLine className="size-4" />
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
<span className="flex-1 text-left">privacidade</span>
|
|
||||||
{privacyMode && (
|
|
||||||
<Badge variant="secondary" className="text-[10px] px-1.5 py-0 h-4">
|
|
||||||
Ativo
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
<CalculatorDialogContent open={calcOpen} />
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { AnimatedThemeToggler } from "@/components/animated-theme-toggler";
|
import { AnimatedThemeToggler } from "@/components/animated-theme-toggler";
|
||||||
|
import { Logo } from "@/components/logo";
|
||||||
import { NotificationBell } from "@/components/notificacoes/notification-bell";
|
import { NotificationBell } from "@/components/notificacoes/notification-bell";
|
||||||
import { RefreshPageButton } from "@/components/refresh-page-button";
|
import { RefreshPageButton } from "@/components/shared/refresh-page-button";
|
||||||
import type { DashboardNotificationsSnapshot } from "@/lib/dashboard/notifications";
|
import type { DashboardNotificationsSnapshot } from "@/lib/dashboard/notifications";
|
||||||
import { Logo } from "../logo";
|
|
||||||
import { NavMenu } from "./nav-menu";
|
import { NavMenu } from "./nav-menu";
|
||||||
import { NavbarUser } from "./navbar-user";
|
import { NavbarUser } from "./navbar-user";
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
RiFileChartLine,
|
RiFileChartLine,
|
||||||
RiGroupLine,
|
RiGroupLine,
|
||||||
RiPriceTag3Line,
|
RiPriceTag3Line,
|
||||||
|
RiSecurePaymentLine,
|
||||||
RiSparklingLine,
|
RiSparklingLine,
|
||||||
RiStore2Line,
|
RiStore2Line,
|
||||||
RiTodoLine,
|
RiTodoLine,
|
||||||
@@ -111,6 +112,11 @@ export const NAV_SECTIONS: NavSection[] = [
|
|||||||
icon: <RiBankCard2Line className="size-4" />,
|
icon: <RiBankCard2Line className="size-4" />,
|
||||||
preservePeriod: true,
|
preservePeriod: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
href: "/relatorios/analise-parcelas",
|
||||||
|
label: "análise de parcelas",
|
||||||
|
icon: <RiSecurePaymentLine className="size-4" />,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
href: "/relatorios/estabelecimentos",
|
href: "/relatorios/estabelecimentos",
|
||||||
label: "estabelecimentos",
|
label: "estabelecimentos",
|
||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
import { RiDashboardLine, RiMenuLine } from "@remixicon/react";
|
import { RiDashboardLine, RiMenuLine } from "@remixicon/react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { CalculatorDialogContent } from "@/components/calculadora/calculator-dialog";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Dialog } from "@/components/ui/dialog";
|
||||||
import {
|
import {
|
||||||
NavigationMenu,
|
NavigationMenu,
|
||||||
NavigationMenuContent,
|
NavigationMenuContent,
|
||||||
@@ -26,7 +28,9 @@ import { MobileTools, NavToolsDropdown } from "./nav-tools";
|
|||||||
|
|
||||||
export function NavMenu() {
|
export function NavMenu() {
|
||||||
const [sheetOpen, setSheetOpen] = useState(false);
|
const [sheetOpen, setSheetOpen] = useState(false);
|
||||||
|
const [calculatorOpen, setCalculatorOpen] = useState(false);
|
||||||
const close = () => setSheetOpen(false);
|
const close = () => setSheetOpen(false);
|
||||||
|
const openCalculator = () => setCalculatorOpen(true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -56,7 +60,7 @@ export function NavMenu() {
|
|||||||
Ferramentas
|
Ferramentas
|
||||||
</NavigationMenuTrigger>
|
</NavigationMenuTrigger>
|
||||||
<NavigationMenuContent>
|
<NavigationMenuContent>
|
||||||
<NavToolsDropdown />
|
<NavToolsDropdown onOpenCalculator={openCalculator} />
|
||||||
</NavigationMenuContent>
|
</NavigationMenuContent>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
</NavigationMenuList>
|
</NavigationMenuList>
|
||||||
@@ -114,10 +118,14 @@ export function NavMenu() {
|
|||||||
})}
|
})}
|
||||||
|
|
||||||
<MobileSectionLabel label="Ferramentas" />
|
<MobileSectionLabel label="Ferramentas" />
|
||||||
<MobileTools onClose={close} />
|
<MobileTools onClose={close} onOpenCalculator={openCalculator} />
|
||||||
</nav>
|
</nav>
|
||||||
</SheetContent>
|
</SheetContent>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
|
|
||||||
|
<Dialog open={calculatorOpen} onOpenChange={setCalculatorOpen}>
|
||||||
|
<CalculatorDialogContent open={calculatorOpen} />
|
||||||
|
</Dialog>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
106
components/navigation/navbar/nav-tools.tsx
Normal file
106
components/navigation/navbar/nav-tools.tsx
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { RiCalculatorLine, RiEyeLine, RiEyeOffLine } from "@remixicon/react";
|
||||||
|
import { usePrivacyMode } from "@/components/privacy-provider";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { cn } from "@/lib/utils/ui";
|
||||||
|
|
||||||
|
const itemClass =
|
||||||
|
"flex w-full items-center gap-2.5 rounded-sm px-2 py-2 text-sm text-foreground hover:bg-accent transition-colors cursor-pointer";
|
||||||
|
|
||||||
|
type NavToolsDropdownProps = {
|
||||||
|
onOpenCalculator: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function NavToolsDropdown({ onOpenCalculator }: NavToolsDropdownProps) {
|
||||||
|
const { privacyMode, toggle } = usePrivacyMode();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ul className="grid w-52 gap-0.5 p-2">
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={cn(itemClass)}
|
||||||
|
onClick={onOpenCalculator}
|
||||||
|
>
|
||||||
|
<span className="text-muted-foreground shrink-0">
|
||||||
|
<RiCalculatorLine className="size-4" />
|
||||||
|
</span>
|
||||||
|
<span className="flex-1 text-left">calculadora</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button type="button" onClick={toggle} className={cn(itemClass)}>
|
||||||
|
<span className="text-muted-foreground shrink-0">
|
||||||
|
{privacyMode ? (
|
||||||
|
<RiEyeOffLine className="size-4" />
|
||||||
|
) : (
|
||||||
|
<RiEyeLine className="size-4" />
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span className="flex-1 text-left">privacidade</span>
|
||||||
|
{privacyMode && (
|
||||||
|
<Badge
|
||||||
|
variant="secondary"
|
||||||
|
className="text-[10px] px-1.5 py-0 h-4 text-success"
|
||||||
|
>
|
||||||
|
Ativo
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type MobileToolsProps = {
|
||||||
|
onClose: () => void;
|
||||||
|
onOpenCalculator: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function MobileTools({ onClose, onOpenCalculator }: MobileToolsProps) {
|
||||||
|
const { privacyMode, toggle } = usePrivacyMode();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
onClose();
|
||||||
|
onOpenCalculator();
|
||||||
|
}}
|
||||||
|
className="flex w-full items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors text-muted-foreground hover:text-foreground hover:bg-accent"
|
||||||
|
>
|
||||||
|
<span className="text-muted-foreground shrink-0">
|
||||||
|
<RiCalculatorLine className="size-4" />
|
||||||
|
</span>
|
||||||
|
<span className="flex-1 text-left">calculadora</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
toggle();
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
|
className="flex w-full items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors text-muted-foreground hover:text-foreground hover:bg-accent"
|
||||||
|
>
|
||||||
|
<span className="text-muted-foreground shrink-0">
|
||||||
|
{privacyMode ? (
|
||||||
|
<RiEyeOffLine className="size-4" />
|
||||||
|
) : (
|
||||||
|
<RiEyeLine className="size-4" />
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span className="flex-1 text-left">privacidade</span>
|
||||||
|
{privacyMode && (
|
||||||
|
<Badge
|
||||||
|
variant="secondary"
|
||||||
|
className="text-[10px] px-1.5 py-0 h-4 text-success"
|
||||||
|
>
|
||||||
|
Ativo
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import Link from "next/link";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { FeedbackDialogBody } from "@/components/feedback/feedback-dialog";
|
import { FeedbackDialogBody } from "@/components/feedback/feedback-dialog";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Dialog, DialogTrigger } from "@/components/ui/dialog";
|
import { Dialog, DialogTrigger } from "@/components/ui/dialog";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
@@ -24,7 +25,6 @@ import { authClient } from "@/lib/auth/client";
|
|||||||
import { getAvatarSrc } from "@/lib/pagadores/utils";
|
import { getAvatarSrc } from "@/lib/pagadores/utils";
|
||||||
import { cn } from "@/lib/utils/ui";
|
import { cn } from "@/lib/utils/ui";
|
||||||
import { version } from "@/package.json";
|
import { version } from "@/package.json";
|
||||||
import { Badge } from "../ui/badge";
|
|
||||||
|
|
||||||
const itemClass =
|
const itemClass =
|
||||||
"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors hover:bg-accent";
|
"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors hover:bg-accent";
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { Logo } from "@/components/logo";
|
import { Logo } from "@/components/logo";
|
||||||
import { NavMain } from "@/components/sidebar/nav-main";
|
import { NavMain } from "@/components/navigation/sidebar/nav-main";
|
||||||
import { NavSecondary } from "@/components/sidebar/nav-secondary";
|
import { NavSecondary } from "@/components/navigation/sidebar/nav-secondary";
|
||||||
import { NavUser } from "@/components/sidebar/nav-user";
|
import { NavUser } from "@/components/navigation/sidebar/nav-user";
|
||||||
import {
|
import {
|
||||||
Sidebar,
|
Sidebar,
|
||||||
SidebarContent,
|
SidebarContent,
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
RiFundsLine,
|
RiFundsLine,
|
||||||
RiGroupLine,
|
RiGroupLine,
|
||||||
RiPriceTag3Line,
|
RiPriceTag3Line,
|
||||||
|
RiSecurePaymentLine,
|
||||||
RiSettings2Line,
|
RiSettings2Line,
|
||||||
RiSparklingLine,
|
RiSparklingLine,
|
||||||
RiTodoLine,
|
RiTodoLine,
|
||||||
@@ -165,6 +166,11 @@ export function createSidebarNavData(
|
|||||||
url: "/relatorios/uso-cartoes",
|
url: "/relatorios/uso-cartoes",
|
||||||
icon: RiBankCard2Line,
|
icon: RiBankCard2Line,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Análise de Parcelas",
|
||||||
|
url: "/relatorios/analise-parcelas",
|
||||||
|
icon: RiSecurePaymentLine,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
duplicatePreviousMonthBudgetsAction,
|
duplicatePreviousMonthBudgetsAction,
|
||||||
} from "@/app/(dashboard)/orcamentos/actions";
|
} from "@/app/(dashboard)/orcamentos/actions";
|
||||||
import { ConfirmActionDialog } from "@/components/confirm-action-dialog";
|
import { ConfirmActionDialog } from "@/components/confirm-action-dialog";
|
||||||
import { EmptyState } from "@/components/empty-state";
|
import { EmptyState } from "@/components/shared/empty-state";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card } from "../ui/card";
|
import { Card } from "../ui/card";
|
||||||
import { BudgetCard } from "./budget-card";
|
import { BudgetCard } from "./budget-card";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { format } from "date-fns";
|
|||||||
import { ptBR } from "date-fns/locale";
|
import { ptBR } from "date-fns/locale";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { MonthPicker } from "@/components/ui/monthpicker";
|
import { MonthPicker } from "@/components/ui/month-picker";
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
type TooltipProps,
|
type TooltipProps,
|
||||||
XAxis,
|
XAxis,
|
||||||
} from "recharts";
|
} from "recharts";
|
||||||
import { EmptyState } from "@/components/empty-state";
|
import { EmptyState } from "@/components/shared/empty-state";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
CommandItem,
|
CommandItem,
|
||||||
CommandList,
|
CommandList,
|
||||||
} from "@/components/ui/command";
|
} from "@/components/ui/command";
|
||||||
import { MonthPicker } from "@/components/ui/monthpicker";
|
import { MonthPicker } from "@/components/ui/month-picker";
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import {
|
|||||||
} from "@remixicon/react";
|
} from "@remixicon/react";
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
import { useRouter, useSearchParams } from "next/navigation";
|
||||||
import { useCallback, useMemo, useState, useTransition } from "react";
|
import { useCallback, useMemo, useState, useTransition } from "react";
|
||||||
import { EmptyState } from "@/components/empty-state";
|
import { EmptyState } from "@/components/shared/empty-state";
|
||||||
import { CategoryReportSkeleton } from "@/components/skeletons/category-report-skeleton";
|
import { CategoryReportSkeleton } from "@/components/shared/skeletons/category-report-skeleton";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "@/components/ui/card";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import type { CategoryChartData } from "@/lib/relatorios/fetch-category-chart-data";
|
import type { CategoryChartData } from "@/lib/relatorios/fetch-category-chart-data";
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { RiStore2Line } from "@remixicon/react";
|
|
||||||
import MoneyValues from "@/components/money-values";
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
||||||
import { WidgetEmptyState } from "@/components/widget-empty-state";
|
|
||||||
import type { TopEstabelecimentosData } from "@/lib/top-estabelecimentos/fetch-data";
|
|
||||||
import { Progress } from "../ui/progress";
|
|
||||||
|
|
||||||
type EstablishmentsListProps = {
|
|
||||||
establishments: TopEstabelecimentosData["establishments"];
|
|
||||||
};
|
|
||||||
|
|
||||||
const buildInitials = (value: string) => {
|
|
||||||
const parts = value.trim().split(/\s+/).filter(Boolean);
|
|
||||||
if (parts.length === 0) return "ES";
|
|
||||||
if (parts.length === 1) {
|
|
||||||
const firstPart = parts[0];
|
|
||||||
return firstPart ? firstPart.slice(0, 2).toUpperCase() : "ES";
|
|
||||||
}
|
|
||||||
const firstChar = parts[0]?.[0] ?? "";
|
|
||||||
const secondChar = parts[1]?.[0] ?? "";
|
|
||||||
return `${firstChar}${secondChar}`.toUpperCase() || "ES";
|
|
||||||
};
|
|
||||||
|
|
||||||
export function EstablishmentsList({
|
|
||||||
establishments,
|
|
||||||
}: EstablishmentsListProps) {
|
|
||||||
if (establishments.length === 0) {
|
|
||||||
return (
|
|
||||||
<Card className="h-full">
|
|
||||||
<CardHeader className="pb-3">
|
|
||||||
<CardTitle className="flex items-center gap-1.5 text-base">
|
|
||||||
<RiStore2Line className="size-4 text-primary" />
|
|
||||||
Top Estabelecimentos
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<WidgetEmptyState
|
|
||||||
icon={<RiStore2Line className="size-6 text-muted-foreground" />}
|
|
||||||
title="Nenhum estabelecimento encontrado"
|
|
||||||
description="Quando houver compras registradas, elas aparecerão aqui."
|
|
||||||
/>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const maxCount = Math.max(...establishments.map((e) => e.count));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card className="h-full">
|
|
||||||
<CardHeader className="pb-3">
|
|
||||||
<CardTitle className="flex items-center gap-1.5 text-base">
|
|
||||||
<RiStore2Line className="size-4 text-primary" />
|
|
||||||
Top Estabelecimentos por Frequência
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="pt-0">
|
|
||||||
<div className="flex flex-col">
|
|
||||||
{establishments.map((establishment, index) => {
|
|
||||||
const _initials = buildInitials(establishment.name);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={establishment.name}
|
|
||||||
className="flex flex-col py-2 border-b border-dashed last:border-0"
|
|
||||||
>
|
|
||||||
<div className="flex items-center justify-between gap-3">
|
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
||||||
{/* Rank number - same size as icon containers */}
|
|
||||||
<div className="flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-full bg-muted">
|
|
||||||
<span className="text-sm font-semibold text-muted-foreground">
|
|
||||||
{index + 1}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Name and categories */}
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<span className="text-sm font-medium truncate block">
|
|
||||||
{establishment.name}
|
|
||||||
</span>
|
|
||||||
<div className="flex items-center gap-1 mt-0.5 flex-wrap">
|
|
||||||
{establishment.categories
|
|
||||||
.slice(0, 2)
|
|
||||||
.map((cat, catIndex) => (
|
|
||||||
<Badge
|
|
||||||
key={catIndex}
|
|
||||||
variant="secondary"
|
|
||||||
className="text-xs px-1.5 py-0 h-5"
|
|
||||||
>
|
|
||||||
{cat.name}
|
|
||||||
</Badge>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Value and stats */}
|
|
||||||
<div className="flex shrink-0 flex-col items-end gap-0.5">
|
|
||||||
<MoneyValues
|
|
||||||
className="text-foreground"
|
|
||||||
amount={establishment.totalAmount}
|
|
||||||
/>
|
|
||||||
<span className="text-xs text-muted-foreground">
|
|
||||||
{establishment.count}x • Média:{" "}
|
|
||||||
<MoneyValues
|
|
||||||
className="text-xs"
|
|
||||||
amount={establishment.avgAmount}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Progress bar */}
|
|
||||||
<div className="ml-12 mt-1.5">
|
|
||||||
<Progress
|
|
||||||
className="h-1.5"
|
|
||||||
value={(establishment.count / maxCount) * 100}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { RiFireLine, RiTrophyLine } from "@remixicon/react";
|
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
|
||||||
import type { TopEstabelecimentosData } from "@/lib/top-estabelecimentos/fetch-data";
|
|
||||||
|
|
||||||
type HighlightsCardsProps = {
|
|
||||||
summary: TopEstabelecimentosData["summary"];
|
|
||||||
};
|
|
||||||
|
|
||||||
export function HighlightsCards({ summary }: HighlightsCardsProps) {
|
|
||||||
return (
|
|
||||||
<div className="grid gap-3 sm:grid-cols-2">
|
|
||||||
<Card className="bg-linear-to-br from-violet-50 to-violet-50/50 dark:from-violet-950/20 dark:to-violet-950/10">
|
|
||||||
<CardContent className="p-4">
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<div className="flex items-center justify-center size-10 rounded-xl bg-violet-100 dark:bg-violet-900/40">
|
|
||||||
<RiTrophyLine className="size-5 text-violet-600 dark:text-violet-400" />
|
|
||||||
</div>
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<p className="text-xs text-violet-700/80 dark:text-violet-400/80 font-medium">
|
|
||||||
Mais Frequente
|
|
||||||
</p>
|
|
||||||
<p className="font-bold text-xl text-violet-900 dark:text-violet-100 truncate">
|
|
||||||
{summary.mostFrequent || "—"}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card className="bg-linear-to-br from-red-50 to-rose-50/50 dark:from-red-950/20 dark:to-rose-950/10">
|
|
||||||
<CardContent className="p-4">
|
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<div className="flex items-center justify-center size-10 rounded-xl bg-red-100 dark:bg-red-900/40">
|
|
||||||
<RiFireLine className="size-5 text-red-600 dark:text-red-400" />
|
|
||||||
</div>
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<p className="text-xs text-red-700/80 dark:text-red-400/80 font-medium">
|
|
||||||
Maior Gasto Total
|
|
||||||
</p>
|
|
||||||
<p className="font-bold text-xl text-red-900 dark:text-red-100 truncate">
|
|
||||||
{summary.highestSpending || "—"}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import type { PeriodFilter } from "@/lib/top-estabelecimentos/fetch-data";
|
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
|
|
||||||
type PeriodFilterProps = {
|
|
||||||
currentFilter: PeriodFilter;
|
|
||||||
};
|
|
||||||
|
|
||||||
const filterOptions: { value: PeriodFilter; label: string }[] = [
|
|
||||||
{ value: "3", label: "3 meses" },
|
|
||||||
{ value: "6", label: "6 meses" },
|
|
||||||
{ value: "12", label: "12 meses" },
|
|
||||||
];
|
|
||||||
|
|
||||||
export function PeriodFilterButtons({ currentFilter }: PeriodFilterProps) {
|
|
||||||
const router = useRouter();
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
|
|
||||||
const handleFilterChange = (filter: PeriodFilter) => {
|
|
||||||
const params = new URLSearchParams(searchParams.toString());
|
|
||||||
params.set("meses", filter);
|
|
||||||
router.push(`/relatorios/estabelecimentos?${params.toString()}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
{filterOptions.map((option) => (
|
|
||||||
<Button
|
|
||||||
key={option.value}
|
|
||||||
variant={currentFilter === option.value ? "default" : "outline"}
|
|
||||||
size="sm"
|
|
||||||
onClick={() => handleFilterChange(option.value)}
|
|
||||||
className={cn(
|
|
||||||
"h-8",
|
|
||||||
currentFilter === option.value && "pointer-events-none",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{option.label}
|
|
||||||
</Button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import {
|
|
||||||
RiExchangeLine,
|
|
||||||
RiMoneyDollarCircleLine,
|
|
||||||
RiRepeatLine,
|
|
||||||
RiStore2Line,
|
|
||||||
} from "@remixicon/react";
|
|
||||||
import MoneyValues from "@/components/money-values";
|
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
|
||||||
import type { TopEstabelecimentosData } from "@/lib/top-estabelecimentos/fetch-data";
|
|
||||||
|
|
||||||
type SummaryCardsProps = {
|
|
||||||
summary: TopEstabelecimentosData["summary"];
|
|
||||||
};
|
|
||||||
|
|
||||||
export function SummaryCards({ summary }: SummaryCardsProps) {
|
|
||||||
const cards = [
|
|
||||||
{
|
|
||||||
title: "Estabelecimentos",
|
|
||||||
value: summary.totalEstablishments,
|
|
||||||
isMoney: false,
|
|
||||||
icon: RiStore2Line,
|
|
||||||
description: "Locais diferentes",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Transações",
|
|
||||||
value: summary.totalTransactions,
|
|
||||||
isMoney: false,
|
|
||||||
icon: RiExchangeLine,
|
|
||||||
description: "Compras no período",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Total Gasto",
|
|
||||||
value: summary.totalSpent,
|
|
||||||
isMoney: true,
|
|
||||||
icon: RiMoneyDollarCircleLine,
|
|
||||||
description: "Soma de todas as compras",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Ticket Médio",
|
|
||||||
value: summary.avgPerTransaction,
|
|
||||||
isMoney: true,
|
|
||||||
icon: RiRepeatLine,
|
|
||||||
description: "Média por transação",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
|
||||||
{cards.map((card) => (
|
|
||||||
<Card key={card.title}>
|
|
||||||
<CardContent className="px-4 py-2">
|
|
||||||
<div className="flex items-start justify-between gap-3">
|
|
||||||
<div className="space-y-1">
|
|
||||||
<p className="text-xs font-medium text-muted-foreground">
|
|
||||||
{card.title}
|
|
||||||
</p>
|
|
||||||
{card.isMoney ? (
|
|
||||||
<MoneyValues
|
|
||||||
className="text-2xl font-semibold"
|
|
||||||
amount={card.value}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<p className="text-2xl font-semibold">{card.value}</p>
|
|
||||||
)}
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
{card.description}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<card.icon className="size-5 text-muted-foreground shrink-0" />
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { RiPriceTag3Line } from "@remixicon/react";
|
|
||||||
import { CategoryIconBadge } from "@/components/categorias/category-icon-badge";
|
|
||||||
import MoneyValues from "@/components/money-values";
|
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
||||||
import { WidgetEmptyState } from "@/components/widget-empty-state";
|
|
||||||
import type { TopEstabelecimentosData } from "@/lib/top-estabelecimentos/fetch-data";
|
|
||||||
import { Progress } from "../ui/progress";
|
|
||||||
|
|
||||||
type TopCategoriesProps = {
|
|
||||||
categories: TopEstabelecimentosData["topCategories"];
|
|
||||||
};
|
|
||||||
|
|
||||||
export function TopCategories({ categories }: TopCategoriesProps) {
|
|
||||||
if (categories.length === 0) {
|
|
||||||
return (
|
|
||||||
<Card className="h-full">
|
|
||||||
<CardHeader className="pb-3">
|
|
||||||
<CardTitle className="flex items-center gap-1.5 text-base">
|
|
||||||
<RiPriceTag3Line className="size-4 text-primary" />
|
|
||||||
Principais Categorias
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<WidgetEmptyState
|
|
||||||
icon={<RiPriceTag3Line className="size-6 text-muted-foreground" />}
|
|
||||||
title="Nenhuma categoria encontrada"
|
|
||||||
description="Quando houver despesas categorizadas, elas aparecerão aqui."
|
|
||||||
/>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const totalAmount = categories.reduce((acc, c) => acc + c.totalAmount, 0);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card className="h-full">
|
|
||||||
<CardHeader className="pb-3">
|
|
||||||
<CardTitle className="flex items-center gap-1.5 text-base">
|
|
||||||
<RiPriceTag3Line className="size-4 text-primary" />
|
|
||||||
Principais Categorias
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="pt-0">
|
|
||||||
<div className="flex flex-col">
|
|
||||||
{categories.map((category, index) => {
|
|
||||||
const percent =
|
|
||||||
totalAmount > 0 ? (category.totalAmount / totalAmount) * 100 : 0;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={category.id}
|
|
||||||
className="flex flex-col py-2 border-b border-dashed last:border-0"
|
|
||||||
>
|
|
||||||
<div className="flex items-center justify-between gap-3">
|
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
||||||
<CategoryIconBadge
|
|
||||||
icon={category.icon}
|
|
||||||
name={category.name}
|
|
||||||
colorIndex={index}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Name and percentage */}
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<span className="text-sm font-medium truncate block">
|
|
||||||
{category.name}
|
|
||||||
</span>
|
|
||||||
<span className="text-xs text-muted-foreground">
|
|
||||||
{percent.toFixed(0)}% do total •{" "}
|
|
||||||
{category.transactionCount}x
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Value */}
|
|
||||||
<div className="flex shrink-0 flex-col items-end">
|
|
||||||
<MoneyValues
|
|
||||||
className="text-foreground"
|
|
||||||
amount={category.totalAmount}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Progress bar */}
|
|
||||||
<div className="ml-11 mt-1.5">
|
|
||||||
<Progress className="h-1.5" value={percent} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { and, eq, sql } from "drizzle-orm";
|
import { and, eq, sql } from "drizzle-orm";
|
||||||
import { contas, lancamentos, pagadores } from "@/db/schema";
|
import { contas, lancamentos, pagadores } from "@/db/schema";
|
||||||
import { INITIAL_BALANCE_NOTE } from "@/lib/accounts/constants";
|
import { INITIAL_BALANCE_NOTE } from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { and, desc, eq, isNull, ne, or, sql } from "drizzle-orm";
|
import { and, desc, eq, isNull, ne, or, sql } from "drizzle-orm";
|
||||||
import { categorias, contas, lancamentos, pagadores } from "@/db/schema";
|
import { categorias, contas, lancamentos, pagadores } from "@/db/schema";
|
||||||
|
import type { CategoryType } from "@/lib/categorias/constants";
|
||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import type { CategoryType } from "@/lib/categorias/constants";
|
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { mapLancamentosData } from "@/lib/lancamentos/page-helpers";
|
import { mapLancamentosData } from "@/lib/lancamentos/page-helpers";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { addMonths, format } from "date-fns";
|
|||||||
import { ptBR } from "date-fns/locale";
|
import { ptBR } from "date-fns/locale";
|
||||||
import { and, eq, inArray, isNull, or, sql } from "drizzle-orm";
|
import { and, eq, inArray, isNull, or, sql } from "drizzle-orm";
|
||||||
import { categorias, lancamentos, pagadores } from "@/db/schema";
|
import { categorias, lancamentos, pagadores } from "@/db/schema";
|
||||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { and, eq, inArray, isNull, or, sql } from "drizzle-orm";
|
import { and, eq, inArray, isNull, or, sql } from "drizzle-orm";
|
||||||
import { categorias, lancamentos, orcamentos } from "@/db/schema";
|
import { categorias, lancamentos, orcamentos } from "@/db/schema";
|
||||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { categorias, contas, lancamentos, orcamentos } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
import { calculatePercentageChange } from "@/lib/utils/math";
|
import { calculatePercentageChange } from "@/lib/utils/math";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { cartoes, lancamentos, pagadores } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
||||||
@@ -172,8 +172,5 @@ export async function fetchInstallmentAnalysis(
|
|||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return { installmentGroups, totalPendingInstallments };
|
||||||
installmentGroups,
|
|
||||||
totalPendingInstallments,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { lancamentos } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
@@ -65,9 +65,11 @@ export async function fetchInstallmentExpenses(
|
|||||||
)
|
)
|
||||||
.orderBy(desc(lancamentos.purchaseDate), desc(lancamentos.createdAt));
|
.orderBy(desc(lancamentos.purchaseDate), desc(lancamentos.createdAt));
|
||||||
|
|
||||||
|
type InstallmentExpenseRow = (typeof rows)[number];
|
||||||
|
|
||||||
const expenses = rows
|
const expenses = rows
|
||||||
.map(
|
.map(
|
||||||
(row): InstallmentExpense => ({
|
(row: InstallmentExpenseRow): InstallmentExpense => ({
|
||||||
id: row.id,
|
id: row.id,
|
||||||
name: row.name,
|
name: row.name,
|
||||||
amount: Math.abs(toNumber(row.amount)),
|
amount: Math.abs(toNumber(row.amount)),
|
||||||
@@ -79,7 +81,7 @@ export async function fetchInstallmentExpenses(
|
|||||||
period: row.period,
|
period: row.period,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.sort((a, b) => {
|
.sort((a: InstallmentExpense, b: InstallmentExpense) => {
|
||||||
// Calcula parcelas restantes para cada item
|
// Calcula parcelas restantes para cada item
|
||||||
const remainingA =
|
const remainingA =
|
||||||
a.installmentCount && a.currentInstallment
|
a.installmentCount && a.currentInstallment
|
||||||
@@ -94,7 +96,5 @@ export async function fetchInstallmentExpenses(
|
|||||||
return remainingA - remainingB;
|
return remainingA - remainingB;
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return { expenses };
|
||||||
expenses,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { lancamentos } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { cartoes, contas, lancamentos } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { contas, lancamentos } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { and, eq, ilike, isNotNull, sql } from "drizzle-orm";
|
import { and, eq, ilike, isNotNull, sql } from "drizzle-orm";
|
||||||
import { cartoes, faturas, lancamentos, pagadores } from "@/db/schema";
|
import { cartoes, faturas, lancamentos, pagadores } from "@/db/schema";
|
||||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { contas, lancamentos } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
import { safeToNumber } from "@/lib/utils/number";
|
import { safeToNumber } from "@/lib/utils/number";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { and, desc, eq, inArray, isNull, or, sql } from "drizzle-orm";
|
import { and, desc, eq, inArray, isNull, or, sql } from "drizzle-orm";
|
||||||
import { lancamentos, pagadores } from "@/db/schema";
|
import { lancamentos, pagadores } from "@/db/schema";
|
||||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { lancamentos } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { lancamentos } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { and, eq, inArray, sql } from "drizzle-orm";
|
import { and, eq, inArray, sql } from "drizzle-orm";
|
||||||
import { lancamentos } from "@/db/schema";
|
import { lancamentos } from "@/db/schema";
|
||||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { cartoes, categorias, contas, lancamentos } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { cartoes, contas, lancamentos } from "@/db/schema";
|
|||||||
import {
|
import {
|
||||||
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
ACCOUNT_AUTO_INVOICE_NOTE_PREFIX,
|
||||||
INITIAL_BALANCE_NOTE,
|
INITIAL_BALANCE_NOTE,
|
||||||
} from "@/lib/accounts/constants";
|
} from "@/lib/contas/constants";
|
||||||
import { toNumber } from "@/lib/dashboard/common";
|
import { toNumber } from "@/lib/dashboard/common";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
import { getAdminPagadorId } from "@/lib/pagadores/get-admin-id";
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ import {
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import { BoletosWidget } from "@/components/dashboard/boletos-widget";
|
import { BoletosWidget } from "@/components/dashboard/boletos-widget";
|
||||||
|
import { InstallmentExpensesWidget } from "@/components/dashboard/installment-expenses-widget";
|
||||||
import { ExpensesByCategoryWidgetWithChart } from "@/components/dashboard/expenses-by-category-widget-with-chart";
|
import { ExpensesByCategoryWidgetWithChart } from "@/components/dashboard/expenses-by-category-widget-with-chart";
|
||||||
import { GoalsProgressWidget } from "@/components/dashboard/goals-progress-widget";
|
import { GoalsProgressWidget } from "@/components/dashboard/goals-progress-widget";
|
||||||
import { IncomeByCategoryWidgetWithChart } from "@/components/dashboard/income-by-category-widget-with-chart";
|
import { IncomeByCategoryWidgetWithChart } from "@/components/dashboard/income-by-category-widget-with-chart";
|
||||||
import { IncomeExpenseBalanceWidget } from "@/components/dashboard/income-expense-balance-widget";
|
import { IncomeExpenseBalanceWidget } from "@/components/dashboard/income-expense-balance-widget";
|
||||||
import { InstallmentExpensesWidget } from "@/components/dashboard/installment-expenses-widget";
|
|
||||||
import { InvoicesWidget } from "@/components/dashboard/invoices-widget";
|
import { InvoicesWidget } from "@/components/dashboard/invoices-widget";
|
||||||
import { MyAccountsWidget } from "@/components/dashboard/my-accounts-widget";
|
import { MyAccountsWidget } from "@/components/dashboard/my-accounts-widget";
|
||||||
import { NotesWidget } from "@/components/dashboard/notes-widget";
|
import { NotesWidget } from "@/components/dashboard/notes-widget";
|
||||||
@@ -31,7 +31,7 @@ import { PaymentStatusWidget } from "@/components/dashboard/payment-status-widge
|
|||||||
import { PurchasesByCategoryWidget } from "@/components/dashboard/purchases-by-category-widget";
|
import { PurchasesByCategoryWidget } from "@/components/dashboard/purchases-by-category-widget";
|
||||||
import { RecurringExpensesWidget } from "@/components/dashboard/recurring-expenses-widget";
|
import { RecurringExpensesWidget } from "@/components/dashboard/recurring-expenses-widget";
|
||||||
import { SpendingOverviewWidget } from "@/components/dashboard/spending-overview-widget";
|
import { SpendingOverviewWidget } from "@/components/dashboard/spending-overview-widget";
|
||||||
import type { DashboardData } from "./fetch-dashboard-data";
|
import type { DashboardData } from "../fetch-dashboard-data";
|
||||||
|
|
||||||
export type WidgetConfig = {
|
export type WidgetConfig = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -173,15 +173,6 @@ export const widgetsConfig: WidgetConfig[] = [
|
|||||||
component: ({ data }) => (
|
component: ({ data }) => (
|
||||||
<InstallmentExpensesWidget data={data.installmentExpensesData} />
|
<InstallmentExpensesWidget data={data.installmentExpensesData} />
|
||||||
),
|
),
|
||||||
action: (
|
|
||||||
<Link
|
|
||||||
href="/dashboard/analise-parcelas"
|
|
||||||
className="text-sm font-medium text-muted-foreground hover:text-primary transition-colors inline-flex items-center gap-1"
|
|
||||||
>
|
|
||||||
Análise
|
|
||||||
<RiArrowRightLine className="size-4" />
|
|
||||||
</Link>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "spending-overview",
|
id: "spending-overview",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
lancamentos,
|
lancamentos,
|
||||||
pagadores,
|
pagadores,
|
||||||
} from "@/db/schema";
|
} from "@/db/schema";
|
||||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import {
|
import {
|
||||||
LANCAMENTO_CONDITIONS,
|
LANCAMENTO_CONDITIONS,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
sum,
|
sum,
|
||||||
} from "drizzle-orm";
|
} from "drizzle-orm";
|
||||||
import { cartoes, lancamentos } from "@/db/schema";
|
import { cartoes, lancamentos } from "@/db/schema";
|
||||||
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/accounts/constants";
|
import { ACCOUNT_AUTO_INVOICE_NOTE_PREFIX } from "@/lib/contas/constants";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
|
|
||||||
const RECEITA = "Receita";
|
const RECEITA = "Receita";
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user