Compare commits
67 Commits
v2.3.4
...
791fec7751
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
791fec7751 | ||
|
|
114e2b4011 | ||
|
|
f15a003cef | ||
|
|
7f07a9cbf6 | ||
|
|
5fa234884e | ||
|
|
b453b432ed | ||
|
|
7f05d2a681 | ||
|
|
b14f487824 | ||
|
|
5b03824a72 | ||
|
|
74dda549f5 | ||
|
|
137b63f256 | ||
|
|
f747405264 | ||
|
|
cbc17c8513 | ||
|
|
c41fafc319 | ||
|
|
0bc3f06b77 | ||
|
|
2f68bcf039 | ||
|
|
41dcd5cec9 | ||
|
|
6391f07eb6 | ||
|
|
ae9dd364c4 | ||
|
|
e005add233 | ||
|
|
6d81ff8b53 | ||
|
|
5d84ae928a | ||
|
|
ba05985725 | ||
|
|
3e80d5995b | ||
|
|
68daae7926 | ||
|
|
9413c470a8 | ||
|
|
ad1b0aa979 | ||
|
|
4d9a1c0a35 | ||
|
|
5635705c56 | ||
|
|
4c97ed569d | ||
|
|
22a88de993 | ||
|
|
9456aa98bc | ||
|
|
21c6a8d9d0 | ||
|
|
c29ffa9a12 | ||
|
|
8875de843b | ||
|
|
679ea752bb | ||
|
|
1161e97d9e | ||
|
|
55d7dedd9a | ||
|
|
ad2752b7b0 | ||
|
|
58db357cde | ||
|
|
99a9ff5512 | ||
|
|
5bcf4f69d3 | ||
|
|
95099c1a94 | ||
|
|
94912f7edc | ||
|
|
bf6adfa3f1 | ||
|
|
e4b9dd4254 | ||
|
|
f1907c8697 | ||
|
|
805bcb863d | ||
|
|
11b4f8940f | ||
|
|
fba9686fdb | ||
|
|
9b8ac9f71f | ||
|
|
fa41c78a39 | ||
|
|
5f7bfb98da | ||
|
|
9ecafdb15f | ||
|
|
e8cc673e52 | ||
|
|
3bd8117b65 | ||
|
|
a7268d8f05 | ||
|
|
1f9098879e | ||
|
|
7a3bff52ac | ||
|
|
dfb4126b12 | ||
|
|
ffead579fa | ||
|
|
aa85cf8b29 | ||
|
|
9a7ae0fa3d | ||
|
|
98fe6a0f4f | ||
|
|
d10eae13e5 | ||
|
|
43697b4fd2 | ||
|
|
27e3ba5f0d |
19
.env.example
@@ -3,10 +3,10 @@
|
|||||||
# ============================================
|
# ============================================
|
||||||
|
|
||||||
# === Database ===
|
# === Database ===
|
||||||
# PostgreSQL local (Docker): use host "db"
|
# Desenvolvimento local (pnpm dev): use host "localhost" (padrão abaixo)
|
||||||
# PostgreSQL local (sem Docker): use host "localhost"
|
# Docker Compose completo: o compose.yml define DATABASE_URL automaticamente com host "db"
|
||||||
# PostgreSQL remoto: use URL completa do provider
|
# PostgreSQL remoto: use URL completa do provider
|
||||||
DATABASE_URL=postgresql://openmonetis:openmonetis_dev_password@db:5432/openmonetis_db
|
DATABASE_URL=postgresql://openmonetis:openmonetis_dev_password@localhost:5432/openmonetis_db
|
||||||
|
|
||||||
# Credenciais do PostgreSQL (apenas para Docker local) - Alterar
|
# Credenciais do PostgreSQL (apenas para Docker local) - Alterar
|
||||||
POSTGRES_USER=openmonetis
|
POSTGRES_USER=openmonetis
|
||||||
@@ -44,8 +44,19 @@ GOOGLE_CLIENT_SECRET=
|
|||||||
# Se não definido, todas as rotas ficam acessíveis.
|
# Se não definido, todas as rotas ficam acessíveis.
|
||||||
# PUBLIC_DOMAIN=openmonetis.com
|
# PUBLIC_DOMAIN=openmonetis.com
|
||||||
|
|
||||||
|
# === Analytics (Opcional) ===
|
||||||
|
# Umami: https://umami.is — self-hosted ou cloud
|
||||||
|
UMAMI_URL=
|
||||||
|
UMAMI_WEBSITE_ID=
|
||||||
|
UMAMI_DOMAINS=
|
||||||
|
|
||||||
# === AI Providers (Opcional) ===
|
# === AI Providers (Opcional) ===
|
||||||
ANTHROPIC_API_KEY=
|
ANTHROPIC_API_KEY=
|
||||||
OPENAI_API_KEY=
|
OPENAI_API_KEY=
|
||||||
GOOGLE_GENERATIVE_AI_API_KEY=
|
GOOGLE_GENERATIVE_AI_API_KEY=
|
||||||
OPENROUTER_API_KEY=
|
OPENROUTER_API_KEY=
|
||||||
|
|
||||||
|
# === Logo.dev (Opcional) ===
|
||||||
|
# Logos automáticos de estabelecimentos. Cadastre em https://www.logo.dev
|
||||||
|
LOGO_DEV_TOKEN=
|
||||||
|
LOGO_DEV_SECRET_KEY=
|
||||||
4
.gitattributes
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Força LF para arquivos que precisam de line endings Unix no container
|
||||||
|
*.sh text eol=lf
|
||||||
|
docker-entrypoint.sh text eol=lf
|
||||||
|
Dockerfile text eol=lf
|
||||||
168
CHANGELOG.md
@@ -7,6 +7,174 @@ e este projeto adere ao [Versionamento Semântico](https://semver.org/lang/pt-BR
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [2.4.3] - 2026-04-25
|
||||||
|
|
||||||
|
Esta versão amplia o trabalho com lançamentos divididos: anexos passam a ser visíveis para pessoas com acesso compartilhado, a importação para conta própria copia os arquivos de forma independente e a edição ganha a opção de aplicar a alteração nos dois lados do par. Três caminhos de deleção foram corrigidos para não deixar arquivos órfãos no storage. Também traz refresh visual nos badges de tipo e radio buttons, prefetch server-side de logos para reduzir chamadas de API no dashboard, e ajustes pontuais no healthcheck do container e em rótulos da UI.
|
||||||
|
|
||||||
|
### Adicionado
|
||||||
|
|
||||||
|
- Schema: coluna `split_group_id` (uuid, nullable) em `lancamentos` com índice `(user_id, split_group_id)` — liga as shares do mesmo evento de divisão
|
||||||
|
- Split: `buildLancamentoRecords` atribui um `splitGroupId` único por cycle (parcelado, recorrente ou único) para ambas as shares
|
||||||
|
- Split: edição cooperativa via `updateTransactionSplitPairAction` — ao editar um lançamento dividido, novo dialog `SplitPairDialog` permite escolher entre aplicar somente neste lado ou nos dois lados (nome, data, categoria e demais campos compartilhados; valor e payer permanecem por share)
|
||||||
|
- Importação: "Importar para Minha Conta" agora copia os anexos do lançamento-fonte para a conta de quem está importando (novo arquivo, novo `userId`, novo `fileKey` — cópia independente via S3 CopyObject). `createSchema` ganhou campo opcional `importFromTransactionId`; helper `copyAttachmentsForImport` valida acesso à fonte via ownership direto ou `payerShares`
|
||||||
|
- Importação: dialog "Importar para Minha Conta" exibe seção read-only "Anexos que serão copiados" listando os anexos do lançamento-fonte antes da confirmação
|
||||||
|
- Filtros: nova chave `isDivided` na tabela de lançamentos — toggle "Somente divididos" no drawer de filtros mantém o estado na URL
|
||||||
|
- Performance: prefetch server-side de mapeamentos Logo.dev no `/dashboard`, `/transactions` e `/payers/[payerId]` — uma única query SQL em batch (`fetchEstablishmentLogoMap`) semeia o cache do React Query antes do primeiro render, eliminando os N requests para `/api/logo/mapping`
|
||||||
|
|
||||||
|
### Alterado
|
||||||
|
|
||||||
|
- Anexos: `fetchTransactionAttachments` e `fetchTransactionAttachmentsAction` passam a autorizar leitura por acesso à transação (direto ou via `payerShares`), permitindo que pessoas com pagador compartilhado visualizem anexos de lançamentos divididos
|
||||||
|
- Anexos: upload (`confirmAttachmentUploadAction`) e detach em massa (`detachAttachmentBulkAction`) agora expandem `transactionIds` para incluir shares irmãs via `splitGroupId` — o vínculo em `transaction_attachments` é replicado para manter simetria
|
||||||
|
- Anexos: delete/detach continuam restritos ao criador (sem alteração de escrita); dashboard (`fetchAttachmentsForPeriod`) permanece listando apenas os anexos do próprio usuário
|
||||||
|
- Migração: lançamentos divididos criados antes desta versão ficam com `split_group_id` NULL e mantêm o comportamento antigo (anexos não visíveis para a contraparte); apenas splits novos são afetados
|
||||||
|
- Storage: `deleteS3Object` passa a ignorar `NoSuchKey` silenciosamente — providers S3-compatíveis (ex.: Cloudflare R2) lançam esse erro ao deletar objeto inexistente, ao contrário do comportamento idempotente do S3 padrão
|
||||||
|
- UI/Badges: `TransactionTypeBadge` redesenhado — substitui o `StatusDot` por ícones direcionais (`RiArrowRightDownLine` receita, `RiArrowRightUpLine` despesa, `RiArrowLeftRightLine` transferência), com borda visível, shadow sutil e variantes dark mode dessaturadas; rótulo "Transferência" abreviado para "Transf."
|
||||||
|
- UI/Forms: indicador do `RadioGroup` trocado de círculo (`RiCircleLine`) por check (`RiCheckLine`) com fundo sólido `primary` no estado selecionado
|
||||||
|
- UI/Antecipação: tabela de seleção de parcelas reduzida de quatro para três colunas (estabelecimento + fatura + valor) — informações de parcela e vencimento absorvidas pela coluna do estabelecimento
|
||||||
|
- Tipografia: fonte Inter agora carrega explicitamente os pesos 500, 600 e 700 (antes derivava de 400)
|
||||||
|
- Deps: better-auth 1.6.5 → 1.6.9, @aws-sdk/client-s3 3.1032 → 3.1037, @tanstack/react-query 5.99.2 → 5.100.3, @biomejs/biome 2.4.12 → 2.4.13, tailwindcss 4.2.2 → 4.2.4, resend 6.12.0 → 6.12.2
|
||||||
|
|
||||||
|
### Corrigido
|
||||||
|
|
||||||
|
- Anexos: deleção em massa por série (`deleteTransactionBulkAction`) não chamava cleanup de storage — arquivos ficavam órfãos no S3 após apagar "este e futuros" ou "todos" de uma série parcelada/recorrente com anexo
|
||||||
|
- Anexos: deleção múltipla por seleção (`deleteMultipleTransactionsAction`) não chamava cleanup de storage — mesmo problema ao selecionar vários lançamentos com anexo e deletar em lote
|
||||||
|
- Anexos: reset de conta em Ajustes (`resetUserAppData`) não limpava o storage — todos os arquivos do usuário ficavam órfãos no S3 após a operação de zeragem
|
||||||
|
- Página da pessoa (`/payers/[payerId]`): `fetchPagadorLancamentos` agora calcula `hasAttachments` via `EXISTS`, fazendo o ícone de clipe aparecer na tabela de lançamentos (antes só aparecia em `/transactions`)
|
||||||
|
- Categorias: mensagem de sucesso ao atualizar exibia "Category atualizada com sucesso." — corrigido para "Categoria atualizada com sucesso."
|
||||||
|
- Antecipação: rótulos "Category" e "Período" no dialog corrigidos para "Categoria" e "Fatura"
|
||||||
|
- Docker: healthcheck do container `app` agora usa `127.0.0.1:3000` em vez de `localhost:3000`, evitando connection timeout em hosts com IPv6 (resolvendo [#44](https://github.com/felipegcoutinho/openmonetis/issues/44))
|
||||||
|
|
||||||
|
## [2.4.2] - 2026-04-20
|
||||||
|
|
||||||
|
Esta versão é quase toda sobre organização e polimento. O código interno do Dashboard foi reestruturado — módulos espalhados pela raiz da feature foram agrupados em subdiretórios coesos e a arquitetura de widgets foi renovada com um novo `widget-registry`. A sidebar lateral foi aposentada em favor de uma navegação concentrada na navbar. A interface passou por um refinamento visual amplo: cards redesenhados, dark mode mais consistente e efeitos decorativos removidos para uma composição mais limpa. As imagens de preview da landing page foram atualizadas. Por fim, a integração com Logo.dev ganhou uma arquitetura mais segura — o token agora é lido apenas no servidor e nunca chega ao cliente. O conceito de "Pagador" foi renomeado para "Pessoa" em toda a interface.
|
||||||
|
|
||||||
|
### Adicionado
|
||||||
|
|
||||||
|
- Dashboard: nova arquitetura de widgets com `widget-registry` — módulos reorganizados em subdiretórios (`bills/`, `invoices/`, `notes/`, `notifications/`, `overview/`, `payments/`, `goals-progress/`, `categories/`)
|
||||||
|
- Dashboard: novos componentes `category-breakdown-chart`, `category-breakdown-list`, `goals-progress-item` e `percentage-change-indicator`
|
||||||
|
- Logo.dev: `server.ts` com `isLogoDevEnabled()` e `buildLogoDevUrl()` server-side; `LogoDevProvider` propaga flag `enabled` para Client Components
|
||||||
|
- Scripts: `mockup` adicionado ao `package.json` (`tsx scripts/mock-data.ts`)
|
||||||
|
|
||||||
|
### Alterado
|
||||||
|
|
||||||
|
- Nav: sidebar lateral removida — navegação unificada na navbar
|
||||||
|
- UI/Tema: raio de borda global 0.625rem → 0.7rem; ajustes finos em `--card` e `--border` (light e dark)
|
||||||
|
- UI: `DotPattern` removido do layout dashboard, tela de autenticação e landing page
|
||||||
|
- UI: account-card redesenhado com cores de saldo (success/destructive) e tooltip para flags de exclusão
|
||||||
|
- UI: budget-card, card-item e componentes do calendário (day-cell, event-modal) com layout revisado
|
||||||
|
- UI: auth-card-shell simplificado (removido glassmorphism e blob animado)
|
||||||
|
- Landing: imagens de preview atualizadas; `mainFeatures` + `extraFeatures` unificados em grid único; dark mode nos botões de CTA
|
||||||
|
- Navbar: dark mode corrigido no navbar-shell (`dark:bg-card`, `dark:border-b-border/60`)
|
||||||
|
- Logo.dev: `NEXT_PUBLIC_LOGO_DEV_TOKEN` renomeado para `LOGO_DEV_TOKEN` (agora lido em runtime server-side apenas)
|
||||||
|
- UI: conceito "Pagador/Pagadores" renomeado para **"Pessoa/Pessoas"** em toda a interface — labels, títulos, toasts, mensagens de erro, cabeçalhos de tabela e exportações. Código, rotas (`/payers`) e schema do banco (`pagadores`) permanecem inalterados; a divergência entre UI e código é intencional
|
||||||
|
- Deps: next 16.2.3 → 16.2.4, better-auth 1.6.2 → 1.6.5, ai 6.0.159 → 6.0.168 e outros patches menores
|
||||||
|
- Notas/Tarefas: ícone de tarefa concluída em visualização (card e detalhes) simplificado para `RiCheckLine` verde sem caixa; checkbox no modal de edição usa fundo e borda `success` com ícone `success-foreground` (claro no light, escuro no dark)
|
||||||
|
- Notas/Detalhes: botões do footer reordenados ("Cancelar" à esquerda, "Alterar" primário à direita)
|
||||||
|
|
||||||
|
### Removido
|
||||||
|
|
||||||
|
- Nav: componentes sidebar (`app-sidebar`, `nav-main`, `nav-secondary`, `nav-user`, `nav-link`), `sidebar.tsx` e `use-mobile.ts`
|
||||||
|
- Dashboard: ~25 widgets monolíticos obsoletos (`inbox-widget`, `bills-widget`, `notes-widget`, `payers-widget`, `my-accounts-widget` etc.)
|
||||||
|
- Dashboard: arquivos dispersos na raiz da feature movidos para subdiretórios (arquivos antigos removidos)
|
||||||
|
- CSS: variáveis `--data-7` a `--data-10` removidas do tema
|
||||||
|
- CI: build arg `NEXT_PUBLIC_LOGO_DEV_TOKEN` removido do `Dockerfile` e do workflow `docker-publish.yml` — basta configurar `LOGO_DEV_TOKEN` e `LOGO_DEV_SECRET_KEY` como variáveis de runtime no host (Coolify, Railway, etc.)
|
||||||
|
|
||||||
|
## [2.4.1] - 2026-04-16
|
||||||
|
|
||||||
|
### Adicionado
|
||||||
|
|
||||||
|
- UI/Auth: layout animado nas páginas de login e signup com efeito blob (3 círculos coloridos em movimento) e card com glassmorphism; layout compartilhado extraído para `app/(auth)/layout.tsx` eliminando duplicação (PR #42)
|
||||||
|
- DB: 17 índices em foreign keys — evita sequential scans em deletes nas tabelas pai. Impacto maior nas FKs de `lancamentos` (conta_id, categoria_id, antecipacao_id), onde deletes em `categorias` antes provocavam full scan na tabela de lançamentos
|
||||||
|
|
||||||
|
### Alterado
|
||||||
|
|
||||||
|
- UI/Navbar: labels capitalizados (Lançamentos, Categorias, Contas) em vez de caixa baixa — melhora legibilidade (PR #42)
|
||||||
|
|
||||||
|
### Removido
|
||||||
|
|
||||||
|
- DB: 7 índices sem uso — `tokens_api_user_id_idx`, `cartoes_user_id_status_idx`, `contas_user_id_status_idx`, `pagadores_user_id_status_idx`, `pagadores_user_id_role_idx`, `dashboard_notification_states_user_id_archived_idx`, `antecipacoes_parcelas_series_id_idx` (0 scans em 187 dias de estatísticas)
|
||||||
|
- UI/Settings: tab de Integrações órfã removida (não tinha `TabsContent` correspondente)
|
||||||
|
|
||||||
|
### Corrigido
|
||||||
|
|
||||||
|
- Docker: container do PostgreSQL falhava ao iniciar em instalações existentes após atualização da imagem `postgres:18-alpine` — entrypoint passou a recusar dados no caminho legado `/var/lib/postgresql/data`. Adicionada variável `PGDATA` no `docker-compose.yml` para fixar o caminho e preservar dados de quem já tinha o volume populado (resolve #41)
|
||||||
|
|
||||||
|
## [2.4.0] - 2026-04-13
|
||||||
|
|
||||||
|
### Adicionado
|
||||||
|
|
||||||
|
- Estabelecimentos: integração com Logo.dev — logos automáticos de marcas exibidos na coluna de estabelecimentos nos lançamentos
|
||||||
|
- Estabelecimentos: picker de logo por estabelecimento — clique no avatar para buscar e fixar um domínio Logo.dev específico (salvo por usuário no banco)
|
||||||
|
- API: rotas `/api/logo/search` e `/api/logo/mapping` — proxy seguro para Logo.dev Brand Search API (secret key server-side) e consulta de mapeamentos salvos
|
||||||
|
- Schema: tabela `establishment_logos` com PK composta `(user_id, name_key)` para persistir preferências de logo por usuário
|
||||||
|
|
||||||
|
### Corrigido
|
||||||
|
|
||||||
|
- Dev: `.env.example` usava host `db` no `DATABASE_URL`, causando erro `EAI_AGAIN` ao rodar `pnpm dev` localmente — corrigido para `localhost`
|
||||||
|
|
||||||
|
### Documentação
|
||||||
|
|
||||||
|
- README: tabela comparativa entre Perfil 1 (Usar) e Perfil 2 (Desenvolver) com diferenças de setup, `DATABASE_URL` e instruções de atualização
|
||||||
|
- README: seção "Variáveis de Ambiente" esclarecida — distingue contexto Docker (Perfil 1) de desenvolvimento local (Perfil 2)
|
||||||
|
- Logo.dev: crie uma conta em logo.dev para obter as chaves `NEXT_PUBLIC_LOGO_DEV_TOKEN` e `LOGO_DEV_SECRET_KEY` — plano gratuito inclui 500.000 requisições/mês
|
||||||
|
|
||||||
|
## [2.3.8] - 2026-04-12
|
||||||
|
|
||||||
|
### Alterado
|
||||||
|
|
||||||
|
- Docker: `docker-compose.yml` refatorado — removidos profiles, build e dependência de arquivo externo; compose agora é standalone (basta `curl` + `docker compose up -d`)
|
||||||
|
- Docker: `docker-entrypoint.sh` simplificado — extensão `pgcrypto` criada via Node.js antes das migrations; loop de retry reescrito; removido hack `@localhost → @db`
|
||||||
|
- Docker: scripts reduzidos de 10 para 5 — `docker:up`, `docker:db`, `docker:down`, `docker:logs`, `docker:update`
|
||||||
|
- Docs: README reestruturado em dois perfis claros — **Usar** (só Docker) e **Desenvolver** (hot-reload)
|
||||||
|
|
||||||
|
## [2.3.7] - 2026-04-11
|
||||||
|
|
||||||
|
### Adicionado
|
||||||
|
|
||||||
|
- Dashboard: novos widgets configuráveis — Anexos (resumo de arquivos do período), Inbox (snapshot de pré-lançamentos pendentes) e Tendências de Categoria
|
||||||
|
- Lançamentos: filtro por status de pagamento (somente pagos / somente não pagos) e filtro por presença de anexo
|
||||||
|
- Lançamentos: indicador visual no status de liquidação para lançamentos de cartão de crédito com fatura paga — exibe ícone verde com tooltip explicativo
|
||||||
|
- Scripts: `scripts/install-deps.sh` — script de preparação para servidores Ubuntu 24.04 limpos (instala Docker, Node.js 22, pnpm via Homebrew)
|
||||||
|
- Docker: variáveis `PUBLIC_DOMAIN`, `UMAMI_URL`, `UMAMI_WEBSITE_ID` e `UMAMI_DOMAINS` passadas ao container da aplicação no `docker-compose.yml`
|
||||||
|
|
||||||
|
### Alterado
|
||||||
|
|
||||||
|
- Fonte: substituída fonte local `America` por `Inter` (Google Fonts, self-hosted pelo Next.js) — elimina arquivos `.woff2` do repositório
|
||||||
|
- Tipografia: peso tipográfico padronizado de `font-medium` para `font-semibold` em títulos, rótulos e valores monetários em toda a interface
|
||||||
|
- Parcelas: redesenho do card de grupo de parcelas — expandindo para dialog de detalhes com parcelas pagas/pendentes separadas
|
||||||
|
- Inbox: redesenho do card de pré-lançamento — logo maior, hierarquia tipográfica melhorada
|
||||||
|
- Lançamentos: filtros de tipo, condição e forma de pagamento agora usam slugs em URL (ex: `receita` em vez do valor literal com acentos)
|
||||||
|
- Estabelecimento: popover de autocomplete agora respeita a largura do input ao abrir
|
||||||
|
- CSP: adicionado `frame-src` para permitir preview de anexos PDF via S3
|
||||||
|
|
||||||
|
### Corrigido
|
||||||
|
|
||||||
|
- Docker: corrigido crash loop no container com mensagem `exec /app/docker-entrypoint.sh: no such file or directory` causado por CRLF no `docker-entrypoint.sh` em ambientes Windows/WSL2 — adicionado `sed -i 's/\r$//'` no Dockerfile e `.gitattributes` com `eol=lf` para scripts shell
|
||||||
|
- S3: corrigido `Error: Region is missing` ao usar o app sem S3 configurado — `S3_REGION` vazio (string vazia) não era tratado pelo operador `??`; substituído por `||` em todo o `s3-client.ts`
|
||||||
|
- i18n: corrigidas mensagens de erro que exibiam "Payer" em inglês em vez de "Pagador"
|
||||||
|
- Logos: corrigido modal seletor de logos de cartões e contas para renderizar miniaturas sem avisos de proporção
|
||||||
|
- Scripts: `install-deps.sh` — spinner travava o script por `wait` retornar código não-zero com `set -e` ativo; corrigido com `|| true`
|
||||||
|
- Scripts: `install-deps.sh` — prompt interativo do corepack suprimido com `COREPACK_ENABLE_DOWNLOAD_PROMPT=0`
|
||||||
|
- Scripts: `install-deps.sh` — PATH do Homebrew não estava configurado na seção de resumo
|
||||||
|
|
||||||
|
### Removido
|
||||||
|
|
||||||
|
- Scripts: removidos arquivos órfãos `scripts/dev.ts` e `scripts/setup-env.sh` (substituídos pelo `setup.mjs`)
|
||||||
|
- Docker: `docker-compose.yml` agora funciona sem arquivo `.env` — `DATABASE_URL` tem valor padrão com credenciais de desenvolvimento
|
||||||
|
- Docker: `docker-entrypoint.sh` converte automaticamente `@localhost:` para `@db:` na `DATABASE_URL` ao iniciar o container, eliminando a necessidade de usar hosts diferentes no `.env` para desenvolvimento local e Docker
|
||||||
|
|
||||||
|
## [2.3.6] - 2026-04-09
|
||||||
|
|
||||||
|
### Corrigido
|
||||||
|
|
||||||
|
- Docker: adicionado `NODE_PATH=/app/migrate/node_modules` no entrypoint para que o `drizzle-kit` consiga resolver `drizzle-orm` ao executar as migrations no container
|
||||||
|
|
||||||
|
## [2.3.5] - 2026-04-07
|
||||||
|
|
||||||
|
### Corrigido
|
||||||
|
|
||||||
|
- CSP: movido `Content-Security-Policy` do `next.config.ts` (build time) para `proxy.ts` (runtime), corrigindo bloqueio de upload de anexos quando `S3_ENDPOINT` não estava disponível durante o build do Docker
|
||||||
|
|
||||||
## [2.3.4] - 2026-04-05
|
## [2.3.4] - 2026-04-05
|
||||||
|
|
||||||
### Corrigido
|
### Corrigido
|
||||||
|
|||||||
42
CLAUDE.md
@@ -16,9 +16,10 @@
|
|||||||
3. **Periods** usam formato `YYYY-MM` (ex: `"2025-11"`). Utils em `src/shared/utils/period/`.
|
3. **Periods** usam formato `YYYY-MM` (ex: `"2025-11"`). Utils em `src/shared/utils/period/`.
|
||||||
4. **Moeda**: R$ com 2 decimais. DB: `numeric(12, 2)`. Utils em `src/shared/utils/currency.ts`.
|
4. **Moeda**: R$ com 2 decimais. DB: `numeric(12, 2)`. Utils em `src/shared/utils/currency.ts`.
|
||||||
5. **Revalidation**: usar `revalidateForEntity("entity")` de `src/shared/lib/actions/helpers.ts` apos mutations.
|
5. **Revalidation**: usar `revalidateForEntity("entity")` de `src/shared/lib/actions/helpers.ts` apos mutations.
|
||||||
6. **Versionamento**: registrar mudancas no `CHANGELOG.md` seguindo Keep a Changelog, também altere o `package.json`.
|
6. **Versionamento**: registrar mudancas no `CHANGELOG.md` seguindo Keep a Changelog, também altere o `package.json` e `readme.md` (Badges do README.md). Cada versão deve ter um parágrafo introdutório em linguagem humana logo abaixo do cabeçalho `## [x.y.z]`, antes das seções `### Adicionado/Alterado/Removido` — descrevendo em prosa o que a versão representa (ex: "Esta versão foca em polimento visual e reorganização interna...").
|
||||||
7. **Comunicacao**: responder em portugues clara e direta com o time.
|
7. **Comunicacao**: responder em portugues clara e direta com o time.
|
||||||
8. **Commit messages**: agrupar por natureza. em pt-br. seguindo o padrao do sistema.
|
8. **Commit messages**: agrupar por natureza. em pt-br. seguindo o padrao do sistema.
|
||||||
|
9. **README.md**: sempre que fizer alteracoes significativas, atualize o README.md.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -84,6 +85,7 @@ src/
|
|||||||
│ │ ├── insights/
|
│ │ ├── insights/
|
||||||
│ │ ├── calendar/
|
│ │ ├── calendar/
|
||||||
│ │ ├── inbox/
|
│ │ ├── inbox/
|
||||||
|
│ │ ├── attachments/
|
||||||
│ │ ├── changelog/
|
│ │ ├── changelog/
|
||||||
│ │ ├── reports/
|
│ │ ├── reports/
|
||||||
│ │ │ ├── category-trends/
|
│ │ │ ├── category-trends/
|
||||||
@@ -110,6 +112,7 @@ src/
|
|||||||
│ ├── insights/
|
│ ├── insights/
|
||||||
│ ├── calendar/
|
│ ├── calendar/
|
||||||
│ ├── inbox/
|
│ ├── inbox/
|
||||||
|
│ ├── attachments/
|
||||||
│ ├── reports/
|
│ ├── reports/
|
||||||
│ └── settings/
|
│ └── settings/
|
||||||
├── shared/
|
├── shared/
|
||||||
@@ -214,7 +217,9 @@ Layouts, `loading.tsx` e metadata continuam em `src/app/`.
|
|||||||
| `contas` | `accounts` |
|
| `contas` | `accounts` |
|
||||||
| `categorias` | `categories` |
|
| `categorias` | `categories` |
|
||||||
| `orcamentos` | `budgets` |
|
| `orcamentos` | `budgets` |
|
||||||
| `pagadores` | `payers` |
|
| `pessoas` | `payers` |
|
||||||
|
|
||||||
|
> **Nota:** o conceito de "pagador" foi renomeado para **"pessoa"** na UI (labels, toasts, textos visíveis ao usuário). O código, rotas e schema continuam usando o termo original em inglês (`payer`, `payerId`, `adminPayerId`) e em português interno (`pagador` como variável). Não renomear esses identificadores — a divergência entre UI e código é intencional e documentada.
|
||||||
| `anotacoes` | `notes` |
|
| `anotacoes` | `notes` |
|
||||||
| `calendario` | `calendar` |
|
| `calendario` | `calendar` |
|
||||||
| `ajustes` | `settings` |
|
| `ajustes` | `settings` |
|
||||||
@@ -306,18 +311,29 @@ export async function fetchData(userId: string, period: string) {
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Response Style
|
## Security Rules
|
||||||
|
|
||||||
Quando o time pedir avaliacao de plano ou feature:
|
Regras aplicadas automaticamente ao gerar codigo.
|
||||||
|
|
||||||
1. Responder em portugues simples.
|
### Secrets
|
||||||
2. Listar 3-5 problemas principais.
|
Nunca colocar API keys, credenciais de banco ou tokens em codigo frontend. Evitar variaveis prefixadas com `NEXT_PUBLIC_` para dados sensiveis — estas sao bundladas no cliente. Usar variaveis server-side apenas. `.env` deve estar no `.gitignore` antes do primeiro commit. `.env.example` deve ter apenas placeholders.
|
||||||
3. Fechar com decisao pratica:
|
|
||||||
- aprova agora
|
|
||||||
- nao aprova agora
|
|
||||||
- o que ajustar antes de comecar codigo
|
|
||||||
|
|
||||||
Exemplo:
|
### Autenticacao & Autorizacao
|
||||||
|
Toda rota protegida em `src/app/api/` requer `getUser()` ou `getOptionalUserSession()` antes de qualquer logica, retornando 401 para nao autenticados. Rotas com IDs de recursos devem verificar ownership: `eq(table.userId, userId)`. Rotas admin devem checar role e retornar 403 para nao-admins. Session cookies em Better Auth ja tem `httpOnly`, `secure` e `sameSite` configurados — nao alterar.
|
||||||
|
|
||||||
- "Nao aprovaria para comecar codigo imediatamente."
|
### Input & Output
|
||||||
- "Primeiro ajustaria o doc com estes 5 pontos."
|
Usar Drizzle ORM (parametrizado por padrao) — nunca concatenar input de usuario em SQL. Validar todo input com Zod antes de usar. Upload de arquivos: usar whitelist de MIME types (`ALLOWED_MIME_TYPES`), presigned URLs para S3, token de upload assinado com verificacao pos-upload. Nunca usar `dangerouslySetInnerHTML` com conteudo de usuario.
|
||||||
|
|
||||||
|
### Headers & CSP
|
||||||
|
CSP definida em `src/proxy.ts` via middleware — alterar la, nao em `next.config.ts`. Headers de seguranca (HSTS, X-Frame-Options, etc.) definidos em `next.config.ts`. Nao remover nem enfraquecer essas configuracoes.
|
||||||
|
|
||||||
|
### Rate Limiting
|
||||||
|
Login: 5 tentativas/min. Signup: 3 tentativas/min. API tokens: 100 req/min (inbox), 20 req/min (batch). Configurado em `src/shared/lib/auth/config.ts` e nas rotas de inbox. Nao remover.
|
||||||
|
|
||||||
|
### Tratamento de Erros
|
||||||
|
Erros nao devem expor stack traces, paths ou nomes de bibliotecas ao cliente. Usar mensagens genericas: `"Algo deu errado"`. Logar detalhes apenas no servidor com `console.error()`.
|
||||||
|
|
||||||
|
### Dependencias
|
||||||
|
Verificar pacotes novos sugeridos pela IA em npmjs.com antes de instalar. Red flags: menos de 1.000 downloads/semana, publicado nos ultimos 30 dias, nome muito parecido com pacote popular. Rodar `pnpm audit` periodicamente.
|
||||||
|
|
||||||
|
---
|
||||||
|
|||||||
10
Dockerfile
@@ -40,6 +40,10 @@ COPY --from=deps /app/public/pdf.worker.min.mjs ./public/pdf.worker.min.mjs
|
|||||||
ENV NEXT_TELEMETRY_DISABLED=1 \
|
ENV NEXT_TELEMETRY_DISABLED=1 \
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
|
# Nota: a integração Logo.dev não precisa mais de build args. O token
|
||||||
|
# `LOGO_DEV_TOKEN` é lido em runtime no servidor — basta configurá-lo no
|
||||||
|
# host (Coolify, Railway, etc.) junto com `LOGO_DEV_SECRET_KEY`.
|
||||||
|
|
||||||
# Build da aplicação Next.js
|
# Build da aplicação Next.js
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
@@ -87,7 +91,9 @@ COPY --from=builder --chown=nextjs:nodejs /app/src/db ./src/db
|
|||||||
|
|
||||||
# Copiar entrypoint de migrations
|
# Copiar entrypoint de migrations
|
||||||
COPY docker-entrypoint.sh ./
|
COPY docker-entrypoint.sh ./
|
||||||
RUN chmod +x /app/docker-entrypoint.sh && chown nextjs:nodejs /app/docker-entrypoint.sh
|
RUN sed -i 's/\r$//' /app/docker-entrypoint.sh && \
|
||||||
|
chmod +x /app/docker-entrypoint.sh && \
|
||||||
|
chown nextjs:nodejs /app/docker-entrypoint.sh
|
||||||
|
|
||||||
# Definir variáveis de ambiente de produção
|
# Definir variáveis de ambiente de produção
|
||||||
ENV NODE_ENV=production \
|
ENV NODE_ENV=production \
|
||||||
@@ -103,7 +109,7 @@ USER nextjs
|
|||||||
|
|
||||||
# Health check
|
# Health check
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||||
CMD wget --quiet --tries=1 --spider http://localhost:3000/api/health || exit 1
|
CMD wget --quiet --tries=1 --spider http://127.0.0.1:3000/api/health || exit 1
|
||||||
|
|
||||||
# Entrypoint: roda migrations e depois executa o CMD
|
# Entrypoint: roda migrations e depois executa o CMD
|
||||||
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
||||||
|
|||||||
322
README.md
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
> **⚠️ Não há versão online hospedada.** Você precisa clonar o repositório e rodar localmente ou no seu próprio servidor.
|
> **⚠️ Não há versão online hospedada.** Você precisa clonar o repositório e rodar localmente ou no seu próprio servidor.
|
||||||
|
|
||||||
[](CHANGELOG.md)
|
[](CHANGELOG.md)
|
||||||
[](https://nextjs.org/)
|
[](https://nextjs.org/)
|
||||||
[](https://www.typescriptlang.org/)
|
[](https://www.typescriptlang.org/)
|
||||||
[](https://www.postgresql.org/)
|
[](https://www.postgresql.org/)
|
||||||
@@ -23,15 +23,21 @@
|
|||||||
<img src="./public/images/dashboard-preview-light.webp" alt="Dashboard Preview" width="800" />
|
<img src="./public/images/dashboard-preview-light.webp" alt="Dashboard Preview" width="800" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="./public/images/preview-lancamentos-light.webp" alt="Lançamentos" width="800" />
|
||||||
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📖 Índice
|
## 📖 Índice
|
||||||
|
|
||||||
- [Sobre o Projeto](#-sobre-o-projeto)
|
- [Sobre o Projeto](#-sobre-o-projeto)
|
||||||
- [Instalação via Script](#-instalação-via-script)
|
- [Como rodar o OpenMonetis](#-como-rodar-o-openmonetis)
|
||||||
- [Início Rápido (manual)](#-início-rápido)
|
- [Perfil 1 — Usar](#perfil-1--usar-self-hosting)
|
||||||
|
- [Perfil 2 — Desenvolver](#perfil-2--desenvolver)
|
||||||
- [Scripts Disponíveis](#-scripts-disponíveis)
|
- [Scripts Disponíveis](#-scripts-disponíveis)
|
||||||
- [Docker](#-docker)
|
- [Docker](#-docker)
|
||||||
|
- [Backup](#-backup)
|
||||||
- [Storage S3 Compatível](#-storage-s3-compatível)
|
- [Storage S3 Compatível](#-storage-s3-compatível)
|
||||||
- [Variáveis de Ambiente](#-variáveis-de-ambiente)
|
- [Variáveis de Ambiente](#-variáveis-de-ambiente)
|
||||||
- [Arquitetura](#-arquitetura)
|
- [Arquitetura](#-arquitetura)
|
||||||
@@ -53,7 +59,7 @@ A ideia é simples: ter um lugar onde consigo ver todas as minhas contas, cartõ
|
|||||||
|
|
||||||
**1. Não há versão hospedada online** — Este projeto é self-hosted. Você precisa rodar no seu próprio computador ou servidor.
|
**1. Não há versão hospedada online** — Este projeto é self-hosted. Você precisa rodar no seu próprio computador ou servidor.
|
||||||
|
|
||||||
**2. Não há Open Finance** — Não há conexão automática com bancos. Você pode registrar transações manualmente ou importar extratos nos formatos OFX e XLS/XLSX.
|
**2. Não há Open Finance** — Não há conexão automática com bancos. Você pode registrar transações manualmente, usar o app companion para capturar notificações bancárias ou importar extratos nos formatos OFX e XLS/XLSX.
|
||||||
|
|
||||||
**3. Requer disciplina** — O OpenMonetis funciona melhor para quem tem disciplina de registrar os gastos regularmente, quer controle total sobre seus dados e gosta de entender exatamente onde o dinheiro está indo.
|
**3. Requer disciplina** — O OpenMonetis funciona melhor para quem tem disciplina de registrar os gastos regularmente, quer controle total sobre seus dados e gosta de entender exatamente onde o dinheiro está indo.
|
||||||
|
|
||||||
@@ -77,7 +83,11 @@ A ideia é simples: ter um lugar onde consigo ver todas as minhas contas, cartõ
|
|||||||
|
|
||||||
📅 **Calendário financeiro** — Visualize todos os lançamentos em um calendário mensal.
|
📅 **Calendário financeiro** — Visualize todos os lançamentos em um calendário mensal.
|
||||||
|
|
||||||
📲 **OpenMonetis Companion** — App Android que captura notificações bancárias (Nubank, Itaú, Bradesco, Inter, C6 e outros) e envia como pré-lançamentos para revisão. [Repositório](https://github.com/felipegcoutinho/openmonetis-companion).
|
📲 **OpenMonetis Companion** — App Android que captura notificações bancárias (Nubank, Itaú, Bradesco, Inter, C6 e outros) e envia automaticamente como pré-lançamentos para revisão — sem digitar nada. [Repositório](https://github.com/felipegcoutinho/openmonetis-companion).
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="./public/images/companion-preview-light.webp" alt="OpenMonetis Companion" width="300" height="600" />
|
||||||
|
</p>
|
||||||
|
|
||||||
⚙️ **Personalização** — Tema dark/light e modo privacidade.
|
⚙️ **Personalização** — Tema dark/light e modo privacidade.
|
||||||
|
|
||||||
@@ -93,82 +103,122 @@ A ideia é simples: ter um lugar onde consigo ver todas as minhas contas, cartõ
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## ⚡ Instalação via Script
|
## 🚀 Como rodar o OpenMonetis
|
||||||
|
|
||||||
A forma mais rápida de instalar. O script verifica dependências, configura o `.env` interativamente e sobe o banco automaticamente.
|
Escolha o perfil que corresponde ao seu objetivo:
|
||||||
|
|
||||||
**Pré-requisito:** Node.js 22+
|
| | Perfil 1 — Usar | Perfil 2 — Desenvolver |
|
||||||
|
|---|---|---|
|
||||||
```bash
|
| **Objetivo** | Rodar o app pronto | Modificar o código |
|
||||||
# Mac / Linux / WSL
|
| **Clonar repositório** | Não | Sim |
|
||||||
curl -fsSL https://raw.githubusercontent.com/felipegcoutinho/openmonetis/main/setup.mjs -o setup.mjs && node setup.mjs
|
| **Node.js / pnpm** | Não | Sim (Node 22+) |
|
||||||
|
| **Docker** | Sim | Sim |
|
||||||
# Windows (PowerShell)
|
| **Como iniciar** | `docker compose up -d` | `pnpm docker:db` + `pnpm dev` |
|
||||||
curl -o setup.mjs https://raw.githubusercontent.com/felipegcoutinho/openmonetis/main/setup.mjs ; node setup.mjs
|
| **App roda em** | Container Docker | Host local (hot-reload) |
|
||||||
```
|
| **Banco roda em** | Container Docker | Container Docker |
|
||||||
|
| **`DATABASE_URL` (host)** | `db` (automático pelo compose) | `localhost` |
|
||||||
O script irá:
|
| **Banco remoto (Supabase, Neon...)** | Sim (`docker compose up -d app`) | Sim (ajustar `DATABASE_URL`) |
|
||||||
- Verificar Node, pnpm, Git e Docker
|
| **Como atualizar** | `pnpm docker:update` | `git pull` + `pnpm install` + `pnpm db:push` |
|
||||||
- Perguntar se quer banco local (Docker) ou remoto (Supabase, Neon, etc.)
|
| **Indicado para** | Self-hosting, VPS, servidor | Contribuidores, customizações |
|
||||||
- Gerar o `BETTER_AUTH_SECRET` automaticamente
|
|
||||||
- Configurar opcionais: Google OAuth, e-mail, IA, domínio público
|
|
||||||
- Clonar o repositório, instalar dependências e aplicar o schema
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🚀 Início Rápido (manual)
|
### Perfil 1 — Usar (self-hosting)
|
||||||
|
|
||||||
### Pré-requisitos
|
Só quer rodar o OpenMonetis. **Não precisa clonar o repositório nem instalar Node.js** — apenas Docker.
|
||||||
|
|
||||||
- Node.js 22+ e pnpm
|
```bash
|
||||||
- Docker e Docker Compose
|
# 1. Baixe o compose
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/felipegcoutinho/openmonetis/main/docker-compose.yml -o docker-compose.yml
|
||||||
|
|
||||||
### Passo a Passo
|
# 2. Suba tudo
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
1. **Clone e instale**
|
Acesse em: `http://localhost:3000`
|
||||||
|
|
||||||
```bash
|
O banco sobe com credenciais padrão. Para personalizar (senha, Google OAuth, e-mail, IA...), crie um `.env` na mesma pasta **antes** de subir:
|
||||||
git clone https://github.com/felipegcoutinho/openmonetis.git
|
|
||||||
cd openmonetis
|
|
||||||
pnpm install
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Configure o `.env`**
|
```bash
|
||||||
|
# .env mínimo recomendado para produção
|
||||||
|
BETTER_AUTH_SECRET=gere-um-valor-com-openssl-rand-base64-32
|
||||||
|
BETTER_AUTH_URL=https://seu-dominio.com
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
Veja todas as variáveis disponíveis em [Variáveis de Ambiente](#-variáveis-de-ambiente).
|
||||||
cp .env.example .env
|
|
||||||
```
|
|
||||||
|
|
||||||
Edite o `.env` com suas credenciais. O principal é o `DATABASE_URL` e o `BETTER_AUTH_SECRET`:
|
**Banco remoto (Supabase, Neon, Railway...):** defina `DATABASE_URL` no `.env` e suba só o app:
|
||||||
|
|
||||||
```env
|
```bash
|
||||||
# Banco local (Docker): use host "localhost"
|
docker compose up -d app
|
||||||
DATABASE_URL=postgresql://openmonetis:openmonetis_dev_password@localhost:5432/openmonetis_db
|
```
|
||||||
|
|
||||||
# Banco remoto (Supabase, Neon, etc): use a URL completa do provider
|
**Não tem Docker instalado?** Em servidores Ubuntu 24.04 limpos, use o script de instalação:
|
||||||
# DATABASE_URL=postgresql://user:password@host:5432/database?sslmode=require
|
|
||||||
|
|
||||||
BETTER_AUTH_SECRET=seu-secret-aqui # gere com: openssl rand -base64 32
|
```bash
|
||||||
BETTER_AUTH_URL=http://localhost:3000
|
curl -fsSL https://raw.githubusercontent.com/felipegcoutinho/openmonetis/main/scripts/install-deps.sh -o install-deps.sh
|
||||||
```
|
sudo sh install-deps.sh
|
||||||
|
```
|
||||||
|
|
||||||
3. **Suba o banco de dados** (pule se estiver usando banco remoto)
|
> Ao final, faça **logout e login** para as permissões do grupo `docker` terem efeito.
|
||||||
|
|
||||||
```bash
|
#### Atualizando (Perfil 1)
|
||||||
docker compose up db -d
|
|
||||||
pnpm db:extensions
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **Execute as migrations e inicie**
|
```bash
|
||||||
|
pnpm docker:update
|
||||||
|
# ou equivalente:
|
||||||
|
docker compose pull && docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
O schema do banco é aplicado automaticamente no startup — nenhum passo extra necessário.
|
||||||
pnpm db:push
|
|
||||||
pnpm dev
|
|
||||||
```
|
|
||||||
|
|
||||||
5. Acesse `http://localhost:3000`
|
---
|
||||||
|
|
||||||
> **Docker completo** (app + banco em containers): use `pnpm docker:up` ao invés dos passos 3-4.
|
### Perfil 2 — Desenvolver
|
||||||
|
|
||||||
|
Quer modificar o código com hot-reload. O banco roda no Docker, o app roda direto no seu servidor.
|
||||||
|
|
||||||
|
**Requisitos:** Docker + Node.js 22+ + pnpm
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Clone o repositório
|
||||||
|
git clone https://github.com/felipegcoutinho/openmonetis.git
|
||||||
|
cd openmonetis
|
||||||
|
|
||||||
|
# 2. Instale as dependências
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
# 3. Configure o ambiente
|
||||||
|
cp .env.example .env
|
||||||
|
# O DATABASE_URL já vem com host "localhost" (correto para dev local).
|
||||||
|
# Edite o .env com suas configurações (BETTER_AUTH_SECRET, etc.)
|
||||||
|
|
||||||
|
# 4. Suba o banco
|
||||||
|
pnpm docker:db
|
||||||
|
|
||||||
|
# 5. Habilite extensões do PostgreSQL (apenas no primeiro setup)
|
||||||
|
pnpm db:extensions
|
||||||
|
|
||||||
|
# 6. Aplique o schema no banco (apenas no primeiro setup)
|
||||||
|
pnpm db:push
|
||||||
|
|
||||||
|
# 7. Inicie o app com hot-reload
|
||||||
|
pnpm dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Acesse em: `http://localhost:3000`
|
||||||
|
|
||||||
|
Toda vez que salvar um arquivo, o app atualiza automaticamente sem precisar reiniciar.
|
||||||
|
|
||||||
|
#### Atualizando (Perfil 2)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git pull
|
||||||
|
pnpm install # instala dependências novas, se houver
|
||||||
|
pnpm db:push # aplica mudanças de schema, se houver
|
||||||
|
```
|
||||||
|
|
||||||
|
O `pnpm dev` já em execução detecta as mudanças de código automaticamente — não precisa reiniciar.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -190,47 +240,62 @@ pnpm lint:fix # Biome auto-fix
|
|||||||
pnpm db:generate # Gerar migrations
|
pnpm db:generate # Gerar migrations
|
||||||
pnpm db:migrate # Executar migrations
|
pnpm db:migrate # Executar migrations
|
||||||
pnpm db:push # Push schema direto (dev)
|
pnpm db:push # Push schema direto (dev)
|
||||||
|
pnpm db:extensions # Habilitar extensões PostgreSQL (rodar uma vez)
|
||||||
pnpm db:studio # Drizzle Studio (UI visual)
|
pnpm db:studio # Drizzle Studio (UI visual)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Utilitários
|
### Utilitários
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm backup # Backup do banco (requer scripts/backup.sh configurado)
|
pnpm backup # Backup completo do banco (ver seção Backup)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm docker:up # Subir app + banco
|
pnpm docker:up # Sobe app (Docker Hub) + banco em background
|
||||||
pnpm docker:up:d # Subir em background
|
pnpm docker:db # Sobe apenas o banco em background (usar com pnpm dev)
|
||||||
pnpm docker:up:db # Subir apenas o banco
|
pnpm docker:down # Para e remove os containers
|
||||||
pnpm docker:down # Parar containers
|
pnpm docker:logs # Logs em tempo real (todos os containers)
|
||||||
pnpm docker:down:volumes # Parar e remover volumes (⚠️ apaga dados!)
|
pnpm docker:update # Atualiza para a imagem mais recente do Hub e reinicia
|
||||||
pnpm docker:logs # Logs em tempo real
|
|
||||||
pnpm docker:restart # Reiniciar
|
|
||||||
pnpm docker:rebuild # Rebuild completo
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🐳 Docker
|
## 🐳 Docker
|
||||||
|
|
||||||
O `Dockerfile` usa multi-stage build (deps → builder → runner) com imagem final ~200MB rodando como usuário não-root.
|
O `Dockerfile` usa multi-stage build (deps → builder → runner) com imagem final ~200MB rodando como usuário não-root. Health checks configurados para ambos os serviços (PostgreSQL via `pg_isready`, app via `GET /api/health`).
|
||||||
|
|
||||||
Health checks configurados para ambos os serviços (PostgreSQL via `pg_isready`, app via `GET /api/health`).
|
### Self-hosting (recomendado)
|
||||||
|
|
||||||
|
Baixe apenas o `docker-compose.yml` e suba tudo — sem clonar o repositório, sem instalar dependências:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/felipegcoutinho/openmonetis/main/docker-compose.yml -o docker-compose.yml
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
As credenciais padrão do banco já estão configuradas. Para personalizar (senhas, opcionais), crie um `.env` na mesma pasta antes de subir — veja [Variáveis de Ambiente](#-variáveis-de-ambiente).
|
||||||
|
|
||||||
|
### Banco remoto (Supabase, Neon, Railway...)
|
||||||
|
|
||||||
|
Suba apenas o app e aponte para o banco externo via `DATABASE_URL` no `.env`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d app
|
||||||
|
```
|
||||||
|
|
||||||
### Comandos úteis
|
### Comandos úteis
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker compose exec app sh # Shell da aplicação
|
docker compose exec app sh # Shell da aplicação
|
||||||
docker compose exec db psql -U openmonetis -d openmonetis_db # Shell do banco
|
docker compose exec db psql -U openmonetis -d openmonetis_db # Shell do banco
|
||||||
docker compose ps # Status
|
docker compose ps # Status
|
||||||
docker compose exec db pg_dump -U openmonetis openmonetis_db > backup.sql # Backup
|
docker compose exec db pg_dump -U openmonetis openmonetis_db > backup.sql # Backup
|
||||||
docker compose exec -T db psql -U openmonetis -d openmonetis_db < backup.sql # Restore
|
docker compose exec -T db psql -U openmonetis -d openmonetis_db < backup.sql # Restore
|
||||||
```
|
```
|
||||||
|
|
||||||
### Customizando Portas
|
### Customizando portas
|
||||||
|
|
||||||
```env
|
```env
|
||||||
APP_PORT=3001 # Padrão: 3000
|
APP_PORT=3001 # Padrão: 3000
|
||||||
@@ -239,6 +304,68 @@ DB_PORT=5433 # Padrão: 5432
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 💾 Backup
|
||||||
|
|
||||||
|
O backup é uma rotina de infraestrutura — não é uma tela no app. Ele opera diretamente sobre o banco PostgreSQL e é executado via linha de comando.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm backup
|
||||||
|
```
|
||||||
|
|
||||||
|
### O que é salvo
|
||||||
|
|
||||||
|
Cada execução gera **3 arquivos** em `backup/`:
|
||||||
|
|
||||||
|
| Arquivo | Conteúdo | Uso |
|
||||||
|
|---|---|---|
|
||||||
|
| `openmonetis_YYYY-MM-DD_HH-MM.dump` | Dump custom do PostgreSQL (binário) | Restore completo via `pg_restore` |
|
||||||
|
| `openmonetis_YYYY-MM-DD_HH-MM.sql.gz` | Dump SQL completo compactado | Inspeção manual, portabilidade |
|
||||||
|
| `openmonetis_YYYY-MM-DD_HH-MM.data.sql.gz` | Apenas os dados da schema `public` | Migração parcial, seed de outro ambiente |
|
||||||
|
|
||||||
|
### Modos de conexão
|
||||||
|
|
||||||
|
Configure `DB_MODE` no topo de `scripts/backup.sh`:
|
||||||
|
|
||||||
|
| Modo | Quando usar | Fonte de dados |
|
||||||
|
|---|---|---|
|
||||||
|
| `remote` (padrão) | Banco em Supabase, Neon, Railway, etc. | `DATABASE_URL` do `.env` |
|
||||||
|
| `docker` | Banco no container local | Container `openmonetis_postgres` |
|
||||||
|
|
||||||
|
### Upload para Google Drive (opcional)
|
||||||
|
|
||||||
|
Se o [rclone](https://rclone.org/) estiver instalado e configurado com um remote chamado `gdrive`, os arquivos são enviados automaticamente para `gdrive:BACKUP OPENMONETIS`. Sem o rclone, o backup funciona normalmente e fica apenas local.
|
||||||
|
|
||||||
|
**Retenção:**
|
||||||
|
- Local: 7 dias
|
||||||
|
- Google Drive: 30 dias
|
||||||
|
|
||||||
|
### Automatizar com cron
|
||||||
|
|
||||||
|
Para rodar o backup automaticamente todo dia às 3h:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
crontab -e
|
||||||
|
```
|
||||||
|
|
||||||
|
```cron
|
||||||
|
0 3 * * * cd /caminho/para/openmonetis && pnpm backup >> /var/log/openmonetis-backup.log 2>&1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Restore
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# A partir do .dump (recomendado — mais rápido)
|
||||||
|
pg_restore --clean --no-owner --no-privileges \
|
||||||
|
-d "postgresql://user:senha@host:5432/openmonetis_db" \
|
||||||
|
backup/openmonetis_YYYY-MM-DD_HH-MM.dump
|
||||||
|
|
||||||
|
# A partir do .sql.gz (banco local via Docker)
|
||||||
|
gunzip -c backup/openmonetis_YYYY-MM-DD_HH-MM.sql.gz | \
|
||||||
|
docker compose exec -T db psql -U openmonetis -d openmonetis_db
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## ☁️ Storage S3 Compatível
|
## ☁️ Storage S3 Compatível
|
||||||
|
|
||||||
O suporte a anexos de lançamentos usa upload direto com URL pré-assinada. Essa configuração é opcional, mas passa a ser necessária se você quiser habilitar anexos no app.
|
O suporte a anexos de lançamentos usa upload direto com URL pré-assinada. Essa configuração é opcional, mas passa a ser necessária se você quiser habilitar anexos no app.
|
||||||
@@ -256,20 +383,60 @@ S3_BUCKET=
|
|||||||
### Compatibilidade
|
### Compatibilidade
|
||||||
|
|
||||||
- O código atual espera um provider com API compatível com S3 e suporte a `PutObject`, `GetObject`, `HeadObject`, `DeleteObject` e URLs pré-assinadas.
|
- O código atual espera um provider com API compatível com S3 e suporte a `PutObject`, `GetObject`, `HeadObject`, `DeleteObject` e URLs pré-assinadas.
|
||||||
- A implementação usa `endpoint` customizado e `forcePathStyle: true` em [`src/shared/lib/storage/s3-client.ts`](/home/ubuntu/github/openmonetis/src/shared/lib/storage/s3-client.ts).
|
- A implementação usa `endpoint` customizado e `forcePathStyle: true` em [`src/shared/lib/storage/s3-client.ts`](./src/shared/lib/storage/s3-client.ts).
|
||||||
- Em geral isso cobre MinIO, Cloudflare R2, Backblaze B2 S3-Compatible, DigitalOcean Spaces e AWS S3. Mas foi testado apenas no Supabase Storage.
|
- Em geral isso cobre MinIO, Cloudflare R2, Backblaze B2 S3-Compatible, DigitalOcean Spaces e AWS S3. Mas foi testado apenas no Supabase Storage.
|
||||||
- Se o seu provider exigir `virtual-hosted-style` em vez de `path-style`, você vai precisar ajustar essa configuração antes de usar anexos.
|
- Se o seu provider exigir `virtual-hosted-style` em vez de `path-style`, você vai precisar ajustar essa configuração antes de usar anexos.
|
||||||
- Se as variáveis de S3 não forem configuradas, mantenha os anexos desabilitados no seu fluxo de uso.
|
- Se as variáveis de S3 não forem configuradas, mantenha os anexos desabilitados no seu fluxo de uso.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 🏷️ Logos de Estabelecimentos (Logo.dev)
|
||||||
|
|
||||||
|
O app exibe logos automáticos de marcas na coluna de estabelecimentos nos lançamentos. A integração usa a [Logo.dev](https://www.logo.dev) e é opcional — sem ela, o app exibe as iniciais coloridas normalmente.
|
||||||
|
|
||||||
|
### Variáveis
|
||||||
|
|
||||||
|
```env
|
||||||
|
LOGO_DEV_TOKEN=pk_... # token público (obrigatório para exibir logos)
|
||||||
|
LOGO_DEV_SECRET_KEY=sk_... # chave secreta (obrigatório para o picker de busca)
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Atualizando da v2.4.1 ou anterior:** a variável foi renomeada de `NEXT_PUBLIC_LOGO_DEV_TOKEN` para `LOGO_DEV_TOKEN`. Renomeie no seu `.env` (ou nas variáveis do Coolify/host) e remova o secret homônimo do GitHub Actions — ele não é mais usado. Não há outra etapa de migração.
|
||||||
|
|
||||||
|
### Como configurar
|
||||||
|
|
||||||
|
Ambas as variáveis são lidas em **runtime** pelo servidor Next.js. Não há mais nenhuma etapa no CI nem `--build-arg` no Docker.
|
||||||
|
|
||||||
|
**Self-hosted via Docker Hub (Coolify, Railway, etc.):**
|
||||||
|
|
||||||
|
1. Adicione `LOGO_DEV_TOKEN` e `LOGO_DEV_SECRET_KEY` nas variáveis de ambiente do host
|
||||||
|
2. Reinicie o container — pronto
|
||||||
|
|
||||||
|
**Desenvolvimento local:**
|
||||||
|
|
||||||
|
Adicione as duas no `.env` e rode `pnpm dev`.
|
||||||
|
|
||||||
|
### Como usar
|
||||||
|
|
||||||
|
Após configurado, passe o mouse sobre o avatar de qualquer estabelecimento nos lançamentos — um ícone de lápis aparece. Clique para abrir o picker, busque pelo nome da marca e selecione o logo desejado. O mapeamento fica salvo por usuário no banco.
|
||||||
|
|
||||||
|
### Arquitetura
|
||||||
|
|
||||||
|
O token **nunca chega ao cliente**. O servidor constrói a URL `https://img.logo.dev/{domain}?token=...` nos endpoints `/api/logo/mapping` e `/api/logo/search`, e o cliente apenas consome a URL pronta. Um Context Provider (`LogoDevProvider`) propaga a flag `enabled` para os componentes que decidem se renderizam o picker.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 🔐 Variáveis de Ambiente
|
## 🔐 Variáveis de Ambiente
|
||||||
|
|
||||||
Copie `.env.example` para `.env` e configure:
|
**Perfil 2 (dev):** copie `.env.example` para `.env` — o `DATABASE_URL` já vem com `localhost`, pronto para uso com `pnpm dev`.
|
||||||
|
|
||||||
|
**Perfil 1 (Docker):** não precisa definir `DATABASE_URL` — o compose já configura automaticamente com host `db`. Só defina se usar banco remoto (Supabase, Neon, etc.).
|
||||||
|
|
||||||
### Obrigatórias
|
### Obrigatórias
|
||||||
|
|
||||||
```env
|
```env
|
||||||
|
# Perfil 2 (dev): host "localhost" — o banco roda em container, o app no host
|
||||||
|
# Perfil 1 (Docker): não precisa definir — o compose usa "db" automaticamente
|
||||||
DATABASE_URL=postgresql://openmonetis:openmonetis_dev_password@localhost:5432/openmonetis_db
|
DATABASE_URL=postgresql://openmonetis:openmonetis_dev_password@localhost:5432/openmonetis_db
|
||||||
BETTER_AUTH_SECRET=seu-secret-aqui # openssl rand -base64 32
|
BETTER_AUTH_SECRET=seu-secret-aqui # openssl rand -base64 32
|
||||||
BETTER_AUTH_URL=http://localhost:3000
|
BETTER_AUTH_URL=http://localhost:3000
|
||||||
@@ -306,6 +473,11 @@ ANTHROPIC_API_KEY=
|
|||||||
OPENAI_API_KEY=
|
OPENAI_API_KEY=
|
||||||
GOOGLE_GENERATIVE_AI_API_KEY=
|
GOOGLE_GENERATIVE_AI_API_KEY=
|
||||||
OPENROUTER_API_KEY=
|
OPENROUTER_API_KEY=
|
||||||
|
|
||||||
|
# Logo.dev (opcional, necessário para logos automáticos de estabelecimentos)
|
||||||
|
# Ambas as variáveis são runtime — basta definir no host; nenhum build arg necessário.
|
||||||
|
LOGO_DEV_TOKEN=
|
||||||
|
LOGO_DEV_SECRET_KEY=
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/2.4.10/schema.json",
|
"$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
|
||||||
"vcs": {
|
"vcs": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"clientKind": "git",
|
"clientKind": "git",
|
||||||
|
|||||||
@@ -1,138 +1,52 @@
|
|||||||
# Docker Compose para Next.js + PostgreSQL
|
|
||||||
name: openmonetis
|
name: openmonetis
|
||||||
|
|
||||||
# MODOS DE USO:
|
|
||||||
# 1. Banco LOCAL (PostgreSQL em container):
|
|
||||||
# - Configure DATABASE_URL com host "db" no .env
|
|
||||||
# - Execute: docker compose --profile local up
|
|
||||||
#
|
|
||||||
# 2. Banco REMOTO (ex: Supabase, Neon, etc):
|
|
||||||
# - Configure DATABASE_URL com a URL do banco remoto no .env
|
|
||||||
# - Execute: docker compose up
|
|
||||||
#
|
|
||||||
# 3. Build local (desenvolvimento):
|
|
||||||
# - Execute: docker compose --profile local up --build
|
|
||||||
#
|
|
||||||
# 4. Para parar todos os serviços:
|
|
||||||
# - Execute: docker compose down
|
|
||||||
#
|
|
||||||
# 5. Para remover volumes (CUIDADO: apaga dados do banco local):
|
|
||||||
# - Execute: docker compose down -v
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# ============================================
|
|
||||||
# Serviço: PostgreSQL (Banco de dados local)
|
|
||||||
# Ativado apenas com: --profile local
|
|
||||||
# ============================================
|
|
||||||
db:
|
db:
|
||||||
profiles: ["local"]
|
|
||||||
image: postgres:18-alpine
|
image: postgres:18-alpine
|
||||||
container_name: openmonetis_postgres
|
container_name: openmonetis_postgres
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-openmonetis}
|
POSTGRES_USER: ${POSTGRES_USER:-openmonetis}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-openmonetis_dev_password}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-openmonetis_dev_password}
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-openmonetis_db}
|
POSTGRES_DB: ${POSTGRES_DB:-openmonetis_db}
|
||||||
PGDATA: /var/lib/postgresql/data
|
|
||||||
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
|
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
|
||||||
|
PGDATA: /var/lib/postgresql/data
|
||||||
ports:
|
ports:
|
||||||
- "${DB_PORT:-5432}:5432"
|
- "${DB_PORT:-5432}:5432"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
|
||||||
# Cria extensão pgcrypto inline (necessária para gen_random_bytes no schema)
|
|
||||||
entrypoint: ["/bin/sh", "-c"]
|
|
||||||
command:
|
|
||||||
- |
|
|
||||||
echo 'CREATE EXTENSION IF NOT EXISTS pgcrypto;' > /docker-entrypoint-initdb.d/init.sql
|
|
||||||
exec docker-entrypoint.sh postgres
|
|
||||||
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-openmonetis} -d ${POSTGRES_DB:-openmonetis_db}"]
|
||||||
[
|
|
||||||
"CMD-SHELL",
|
|
||||||
"pg_isready -U ${POSTGRES_USER:-openmonetis} -d ${POSTGRES_DB:-openmonetis_db}",
|
|
||||||
]
|
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 10s
|
start_period: 10s
|
||||||
|
|
||||||
# Para ativar logs de queries (debug), adicione ao command acima:
|
|
||||||
# exec docker-entrypoint.sh postgres -c log_statement=all
|
|
||||||
|
|
||||||
# ============================================
|
|
||||||
# Serviço: Aplicação Next.js
|
|
||||||
# ============================================
|
|
||||||
app:
|
app:
|
||||||
build: .
|
|
||||||
image: felipegcoutinho/openmonetis:latest
|
image: felipegcoutinho/openmonetis:latest
|
||||||
|
|
||||||
container_name: openmonetis_app
|
container_name: openmonetis_app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "${APP_PORT:-3000}:3000"
|
- "${APP_PORT:-3000}:3000"
|
||||||
|
env_file:
|
||||||
|
- path: .env
|
||||||
|
required: false
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
|
DATABASE_URL: ${DATABASE_URL:-postgresql://openmonetis:openmonetis_dev_password@db:5432/openmonetis_db}
|
||||||
# Banco local: use host "db" | Banco remoto: URL completa do provider
|
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:-}
|
||||||
DATABASE_URL: ${DATABASE_URL}
|
|
||||||
|
|
||||||
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET}
|
|
||||||
BETTER_AUTH_URL: ${BETTER_AUTH_URL:-http://localhost:3000}
|
BETTER_AUTH_URL: ${BETTER_AUTH_URL:-http://localhost:3000}
|
||||||
|
|
||||||
# S3 (opcional)
|
|
||||||
S3_ENDPOINT: ${S3_ENDPOINT:-}
|
|
||||||
S3_REGION: ${S3_REGION:-}
|
|
||||||
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-}
|
|
||||||
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-}
|
|
||||||
S3_BUCKET: ${S3_BUCKET:-}
|
|
||||||
|
|
||||||
# Email (opcional)
|
|
||||||
RESEND_API_KEY: ${RESEND_API_KEY:-}
|
|
||||||
RESEND_FROM_EMAIL: ${RESEND_FROM_EMAIL:-}
|
|
||||||
|
|
||||||
# OAuth (opcional)
|
|
||||||
GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID:-}
|
|
||||||
GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET:-}
|
|
||||||
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID:-}
|
|
||||||
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET:-}
|
|
||||||
|
|
||||||
# AI providers (opcional)
|
|
||||||
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
|
|
||||||
OPENAI_API_KEY: ${OPENAI_API_KEY:-}
|
|
||||||
GOOGLE_GENERATIVE_AI_API_KEY: ${GOOGLE_GENERATIVE_AI_API_KEY:-}
|
|
||||||
OPENROUTER_API_KEY: ${OPENROUTER_API_KEY:-}
|
|
||||||
|
|
||||||
# required: false permite subir sem banco local (banco remoto via DATABASE_URL)
|
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://127.0.0.1:3000/api/health"]
|
||||||
[
|
|
||||||
"CMD",
|
|
||||||
"wget",
|
|
||||||
"--quiet",
|
|
||||||
"--tries=1",
|
|
||||||
"--spider",
|
|
||||||
"http://localhost:3000/api/health",
|
|
||||||
]
|
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 40s
|
start_period: 40s
|
||||||
|
|
||||||
# ============================================
|
|
||||||
# Volumes
|
|
||||||
# ============================================
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
driver: local
|
driver: local
|
||||||
|
|||||||
@@ -1,15 +1,26 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "Habilitando extensão pgcrypto..."
|
||||||
|
node -e "
|
||||||
|
const { Client } = require('/app/migrate/node_modules/pg');
|
||||||
|
const c = new Client({ connectionString: process.env.DATABASE_URL });
|
||||||
|
c.connect()
|
||||||
|
.then(() => c.query('CREATE EXTENSION IF NOT EXISTS pgcrypto'))
|
||||||
|
.then(() => c.end())
|
||||||
|
.catch((e) => { console.error('Aviso pgcrypto:', e.message); process.exit(0); });
|
||||||
|
"
|
||||||
|
|
||||||
echo "Rodando migrations..."
|
echo "Rodando migrations..."
|
||||||
RETRIES=5
|
MIGRATED=0
|
||||||
until /app/migrate/node_modules/.bin/drizzle-kit push || [ "$RETRIES" -eq 0 ]; do
|
for i in 1 2 3 4 5; do
|
||||||
RETRIES=$((RETRIES - 1))
|
if NODE_PATH=/app/migrate/node_modules /app/migrate/node_modules/.bin/drizzle-kit push; then
|
||||||
echo "Migration falhou, aguardando banco... ($RETRIES tentativas restantes)"
|
MIGRATED=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Tentativa $i/5 falhou. Aguardando 5s..."
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$RETRIES" -eq 0 ]; then
|
[ "$MIGRATED" -eq 0 ] && echo "Aviso: migrations não foram aplicadas."
|
||||||
echo "Aviso: migrations nao foram aplicadas"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|||||||
24
drizzle/0025_burly_colonel_america.sql
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
DROP INDEX "tokens_api_user_id_idx";--> statement-breakpoint
|
||||||
|
DROP INDEX "cartoes_user_id_status_idx";--> statement-breakpoint
|
||||||
|
DROP INDEX "dashboard_notification_states_user_id_archived_idx";--> statement-breakpoint
|
||||||
|
DROP INDEX "contas_user_id_status_idx";--> statement-breakpoint
|
||||||
|
DROP INDEX "antecipacoes_parcelas_series_id_idx";--> statement-breakpoint
|
||||||
|
DROP INDEX "pagadores_user_id_status_idx";--> statement-breakpoint
|
||||||
|
DROP INDEX "pagadores_user_id_role_idx";--> statement-breakpoint
|
||||||
|
CREATE INDEX "account_user_id_idx" ON "account" USING btree ("userId");--> statement-breakpoint
|
||||||
|
CREATE INDEX "anexos_user_id_idx" ON "anexos" USING btree ("user_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "orcamentos_categoria_id_idx" ON "orcamentos" USING btree ("categoria_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "cartoes_conta_id_idx" ON "cartoes" USING btree ("conta_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "import_category_mappings_category_id_idx" ON "import_category_mappings" USING btree ("category_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "pre_lancamentos_lancamento_id_idx" ON "pre_lancamentos" USING btree ("lancamento_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "antecipacoes_parcelas_lancamento_id_idx" ON "antecipacoes_parcelas" USING btree ("lancamento_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "antecipacoes_parcelas_pagador_id_idx" ON "antecipacoes_parcelas" USING btree ("pagador_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "antecipacoes_parcelas_categoria_id_idx" ON "antecipacoes_parcelas" USING btree ("categoria_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "anotacoes_user_id_idx" ON "anotacoes" USING btree ("user_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "passkey_user_id_idx" ON "passkey" USING btree ("userId");--> statement-breakpoint
|
||||||
|
CREATE INDEX "compartilhamentos_pagador_shared_with_user_id_idx" ON "compartilhamentos_pagador" USING btree ("shared_with_user_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "compartilhamentos_pagador_created_by_user_id_idx" ON "compartilhamentos_pagador" USING btree ("created_by_user_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "session_user_id_idx" ON "session" USING btree ("userId");--> statement-breakpoint
|
||||||
|
CREATE INDEX "lancamentos_conta_id_idx" ON "lancamentos" USING btree ("conta_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "lancamentos_categoria_id_idx" ON "lancamentos" USING btree ("categoria_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "lancamentos_antecipacao_id_idx" ON "lancamentos" USING btree ("antecipacao_id");
|
||||||
2
drizzle/0026_bored_eternity.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE "lancamentos" ADD COLUMN "split_group_id" uuid;--> statement-breakpoint
|
||||||
|
CREATE INDEX "lancamentos_user_id_split_group_id_idx" ON "lancamentos" USING btree ("user_id","split_group_id");
|
||||||
2889
drizzle/meta/0025_snapshot.json
Normal file
2916
drizzle/meta/0026_snapshot.json
Normal file
@@ -176,6 +176,20 @@
|
|||||||
"when": 1774891206703,
|
"when": 1774891206703,
|
||||||
"tag": "0024_petite_lucky_pierre",
|
"tag": "0024_petite_lucky_pierre",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 25,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1776351838548,
|
||||||
|
"tag": "0025_burly_colonel_america",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 26,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1777042423451,
|
||||||
|
"tag": "0026_bored_eternity",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,17 @@ import type { NextConfig } from "next";
|
|||||||
// Carregar variáveis de ambiente explicitamente
|
// Carregar variáveis de ambiente explicitamente
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === "development";
|
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
cacheComponents: true,
|
cacheComponents: true,
|
||||||
reactCompiler: true,
|
reactCompiler: true,
|
||||||
|
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [new URL("https://lh3.googleusercontent.com/**")],
|
remotePatterns: [
|
||||||
|
new URL("https://lh3.googleusercontent.com/**"),
|
||||||
|
{ protocol: "https", hostname: "**" },
|
||||||
|
{ protocol: "http", hostname: "**" },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
devIndicators: {
|
devIndicators: {
|
||||||
position: "bottom-right",
|
position: "bottom-right",
|
||||||
@@ -44,18 +46,6 @@ const nextConfig: NextConfig = {
|
|||||||
key: "X-Frame-Options",
|
key: "X-Frame-Options",
|
||||||
value: "DENY",
|
value: "DENY",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: "Content-Security-Policy",
|
|
||||||
value: [
|
|
||||||
"default-src 'self'",
|
|
||||||
`script-src 'self' 'unsafe-inline'${isDev ? " 'unsafe-eval'" : ""} https://umami.felipecoutinho.com`,
|
|
||||||
"style-src 'self' 'unsafe-inline'",
|
|
||||||
"img-src 'self' https://lh3.googleusercontent.com data: blob:",
|
|
||||||
"font-src 'self'",
|
|
||||||
`connect-src 'self' https://umami.felipecoutinho.com ${process.env.S3_ENDPOINT ? new URL(process.env.S3_ENDPOINT).origin : ""}`.trim(),
|
|
||||||
"frame-ancestors 'none'",
|
|
||||||
].join("; "),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: "Referrer-Policy",
|
key: "Referrer-Policy",
|
||||||
value: "strict-origin-when-cross-origin",
|
value: "strict-origin-when-cross-origin",
|
||||||
|
|||||||
75
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "openmonetis",
|
"name": "openmonetis",
|
||||||
"version": "2.3.4",
|
"version": "2.4.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "pnpm@10.33.0",
|
"packageManager": "pnpm@10.33.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -11,36 +11,37 @@
|
|||||||
"lint": "biome check .",
|
"lint": "biome check .",
|
||||||
"lint:deadcode": "knip --reporter compact",
|
"lint:deadcode": "knip --reporter compact",
|
||||||
"lint:fix": "biome check --write .",
|
"lint:fix": "biome check --write .",
|
||||||
"env:setup": "bash scripts/setup-env.sh",
|
"env:setup": "node setup.mjs",
|
||||||
"db:generate": "drizzle-kit generate",
|
"db:generate": "drizzle-kit generate",
|
||||||
"db:migrate": "drizzle-kit migrate",
|
"db:migrate": "drizzle-kit migrate",
|
||||||
"db:push": "drizzle-kit push",
|
"db:push": "drizzle-kit push",
|
||||||
"db:extensions": "tsx scripts/postgres/enable-extensions.ts",
|
"db:extensions": "tsx scripts/postgres/enable-extensions.ts",
|
||||||
"db:studio": "drizzle-kit studio",
|
"db:studio": "drizzle-kit studio",
|
||||||
"docker:up": "docker compose up --build",
|
|
||||||
"postinstall": "cp node_modules/pdfjs-dist/build/pdf.worker.min.mjs public/pdf.worker.min.mjs",
|
"postinstall": "cp node_modules/pdfjs-dist/build/pdf.worker.min.mjs public/pdf.worker.min.mjs",
|
||||||
"docker:up:db": "docker compose up -d db",
|
"docker:up": "docker compose up -d",
|
||||||
"docker:up:d": "docker compose up --build -d",
|
"//docker:up": "Sobe app (Docker Hub) + banco PostgreSQL em background",
|
||||||
|
"docker:db": "docker compose up -d db",
|
||||||
|
"//docker:db": "Sobe apenas o banco em background (para usar com pnpm dev)",
|
||||||
"docker:down": "docker compose down",
|
"docker:down": "docker compose down",
|
||||||
"docker:down:volumes": "docker compose down -v",
|
"//docker:down": "Para e remove os containers",
|
||||||
"docker:logs": "docker compose logs -f",
|
"docker:logs": "docker compose logs -f",
|
||||||
"docker:logs:app": "docker compose logs -f app",
|
"//docker:logs": "Acompanha logs de todos os containers em tempo real",
|
||||||
"docker:logs:db": "docker compose logs -f db",
|
"docker:update": "docker compose pull && docker compose up -d",
|
||||||
"docker:restart": "docker compose restart",
|
"//docker:update": "Atualiza para a imagem mais recente do Docker Hub e reinicia",
|
||||||
"docker:rebuild": "docker compose up --build --force-recreate",
|
"backup": "bash scripts/backup.sh",
|
||||||
"backup": "bash scripts/backup.sh"
|
"mockup": "tsx scripts/mock-data.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ai-sdk/anthropic": "^3.0.65",
|
"@ai-sdk/anthropic": "^3.0.71",
|
||||||
"@ai-sdk/google": "^3.0.55",
|
"@ai-sdk/google": "^3.0.64",
|
||||||
"@ai-sdk/openai": "^3.0.49",
|
"@ai-sdk/openai": "^3.0.53",
|
||||||
"@aws-sdk/client-s3": "^3.1022.0",
|
"@aws-sdk/client-s3": "^3.1037.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.1022.0",
|
"@aws-sdk/s3-request-presigner": "^3.1037.0",
|
||||||
"@better-auth/passkey": "^1.5.6",
|
"@better-auth/passkey": "^1.6.9",
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@openrouter/ai-sdk-provider": "^2.3.3",
|
"@openrouter/ai-sdk-provider": "^2.8.0",
|
||||||
"@radix-ui/react-alert-dialog": "1.1.15",
|
"@radix-ui/react-alert-dialog": "1.1.15",
|
||||||
"@radix-ui/react-avatar": "1.1.11",
|
"@radix-ui/react-avatar": "1.1.11",
|
||||||
"@radix-ui/react-checkbox": "1.3.3",
|
"@radix-ui/react-checkbox": "1.3.3",
|
||||||
@@ -49,11 +50,13 @@
|
|||||||
"@radix-ui/react-dropdown-menu": "2.1.16",
|
"@radix-ui/react-dropdown-menu": "2.1.16",
|
||||||
"@radix-ui/react-hover-card": "^1.1.15",
|
"@radix-ui/react-hover-card": "^1.1.15",
|
||||||
"@radix-ui/react-label": "2.1.8",
|
"@radix-ui/react-label": "2.1.8",
|
||||||
|
"@radix-ui/react-navigation-menu": "^1.2.14",
|
||||||
"@radix-ui/react-popover": "^1.1.15",
|
"@radix-ui/react-popover": "^1.1.15",
|
||||||
"@radix-ui/react-progress": "1.1.8",
|
"@radix-ui/react-progress": "1.1.8",
|
||||||
"@radix-ui/react-radio-group": "^1.3.8",
|
"@radix-ui/react-radio-group": "^1.3.8",
|
||||||
"@radix-ui/react-select": "2.2.6",
|
"@radix-ui/react-select": "2.2.6",
|
||||||
"@radix-ui/react-separator": "1.1.8",
|
"@radix-ui/react-separator": "1.1.8",
|
||||||
|
"@radix-ui/react-slider": "^1.3.6",
|
||||||
"@radix-ui/react-slot": "1.2.4",
|
"@radix-ui/react-slot": "1.2.4",
|
||||||
"@radix-ui/react-switch": "1.2.6",
|
"@radix-ui/react-switch": "1.2.6",
|
||||||
"@radix-ui/react-tabs": "1.1.13",
|
"@radix-ui/react-tabs": "1.1.13",
|
||||||
@@ -61,11 +64,11 @@
|
|||||||
"@radix-ui/react-toggle-group": "1.1.11",
|
"@radix-ui/react-toggle-group": "1.1.11",
|
||||||
"@radix-ui/react-tooltip": "1.2.8",
|
"@radix-ui/react-tooltip": "1.2.8",
|
||||||
"@remixicon/react": "4.9.0",
|
"@remixicon/react": "4.9.0",
|
||||||
"@tanstack/react-query": "^5.96.2",
|
"@tanstack/react-query": "^5.100.3",
|
||||||
"@tanstack/react-table": "8.21.3",
|
"@tanstack/react-table": "8.21.3",
|
||||||
"@tanstack/react-virtual": "^3.13.23",
|
"@tanstack/react-virtual": "^3.13.24",
|
||||||
"ai": "^6.0.143",
|
"ai": "^6.0.168",
|
||||||
"better-auth": "1.5.6",
|
"better-auth": "1.6.9",
|
||||||
"canvas-confetti": "^1.9.4",
|
"canvas-confetti": "^1.9.4",
|
||||||
"class-variance-authority": "0.7.1",
|
"class-variance-authority": "0.7.1",
|
||||||
"clsx": "2.1.1",
|
"clsx": "2.1.1",
|
||||||
@@ -75,34 +78,38 @@
|
|||||||
"exceljs": "^4.4.0",
|
"exceljs": "^4.4.0",
|
||||||
"jspdf": "^4.2.1",
|
"jspdf": "^4.2.1",
|
||||||
"jspdf-autotable": "^5.0.7",
|
"jspdf-autotable": "^5.0.7",
|
||||||
"next": "16.2.2",
|
"next": "16.2.4",
|
||||||
"next-themes": "0.4.6",
|
"next-themes": "0.4.6",
|
||||||
"pdfjs-dist": "^5.6.205",
|
"pdfjs-dist": "^5.6.205",
|
||||||
"pg": "8.20.0",
|
"pg": "8.20.0",
|
||||||
"radix-ui": "^1.4.3",
|
"react": "19.2.5",
|
||||||
"react": "19.2.4",
|
|
||||||
"react-day-picker": "^9.14.0",
|
"react-day-picker": "^9.14.0",
|
||||||
"react-dom": "19.2.4",
|
"react-dom": "19.2.5",
|
||||||
"recharts": "3.8.1",
|
"recharts": "3.8.1",
|
||||||
"resend": "^6.10.0",
|
"resend": "^6.12.2",
|
||||||
"sonner": "2.0.7",
|
"sonner": "2.0.7",
|
||||||
"tailwind-merge": "3.5.0",
|
"tailwind-merge": "3.5.0",
|
||||||
"vaul": "1.1.2",
|
"vaul": "1.1.2",
|
||||||
"zod": "4.3.6"
|
"zod": "4.3.6"
|
||||||
},
|
},
|
||||||
|
"pnpm": {
|
||||||
|
"overrides": {
|
||||||
|
"defu": "6.1.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "2.4.10",
|
"@biomejs/biome": "2.4.13",
|
||||||
"@tailwindcss/postcss": "4.2.2",
|
"@tailwindcss/postcss": "4.2.4",
|
||||||
"@types/canvas-confetti": "^1.9.0",
|
"@types/canvas-confetti": "^1.9.0",
|
||||||
"@types/node": "25.5.0",
|
"@types/node": "25.6.0",
|
||||||
"@types/pg": "^8.20.0",
|
"@types/pg": "^8.20.0",
|
||||||
"@types/react": "19.2.14",
|
"@types/react": "19.2.14",
|
||||||
"@types/react-dom": "19.2.3",
|
"@types/react-dom": "19.2.3",
|
||||||
"dotenv": "^17.4.0",
|
"dotenv": "^17.4.2",
|
||||||
"drizzle-kit": "0.31.10",
|
"drizzle-kit": "0.31.10",
|
||||||
"knip": "^6.3.0",
|
"knip": "^6.7.0",
|
||||||
"tailwindcss": "4.2.2",
|
"tailwindcss": "4.2.4",
|
||||||
"tsx": "4.21.0",
|
"tsx": "4.21.0",
|
||||||
"typescript": "6.0.2"
|
"typescript": "6.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3737
pnpm-lock.yaml
generated
@@ -1,18 +1,10 @@
|
|||||||
import localFont from "next/font/local";
|
import { Inter } from "next/font/google";
|
||||||
|
|
||||||
export const america = localFont({
|
export const inter = Inter({
|
||||||
src: [
|
subsets: ["latin"],
|
||||||
{
|
display: "swap",
|
||||||
path: "./america-regular.woff2",
|
variable: "--font-inter",
|
||||||
weight: "400",
|
fallback: ["ui-sans-serif", "system-ui"],
|
||||||
style: "normal",
|
weight: ["500", "600", "700"],
|
||||||
},
|
preload: true,
|
||||||
{
|
|
||||||
path: "./america-medium.woff2",
|
|
||||||
weight: "500",
|
|
||||||
style: "normal",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
display: "fallback",
|
|
||||||
variable: "--font-america",
|
|
||||||
});
|
});
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 165 KiB After Width: | Height: | Size: 183 KiB |
|
Before Width: | Height: | Size: 165 KiB After Width: | Height: | Size: 193 KiB |
|
Before Width: | Height: | Size: 382 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 134 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 195 KiB After Width: | Height: | Size: 180 KiB |
|
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 127 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 138 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 149 KiB |
|
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 170 KiB |
|
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 176 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 92 KiB |
@@ -1,17 +0,0 @@
|
|||||||
#!/usr/bin/env tsx
|
|
||||||
|
|
||||||
import { execSync } from "node:child_process";
|
|
||||||
import { config } from "dotenv";
|
|
||||||
|
|
||||||
// Carregar variáveis de ambiente
|
|
||||||
config();
|
|
||||||
|
|
||||||
const port = process.env.PORT || "3000";
|
|
||||||
|
|
||||||
console.log(`Starting Next.js development server on port ${port}...`);
|
|
||||||
|
|
||||||
// Executar next dev com a porta especificada
|
|
||||||
execSync(`npx next dev --turbopack --port ${port}`, {
|
|
||||||
stdio: "inherit",
|
|
||||||
env: { ...process.env, PORT: port },
|
|
||||||
});
|
|
||||||
245
scripts/install-deps.sh
Executable file
@@ -0,0 +1,245 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# install-deps.sh — Instala pré-requisitos do OpenMonetis
|
||||||
|
# Testado apenas em Ubuntu Server 24.04 LTS
|
||||||
|
# Uso: curl -fsSL https://raw.githubusercontent.com/felipegcoutinho/openmonetis/main/scripts/install-deps.sh -o install-deps.sh
|
||||||
|
# sudo sh install-deps.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
LOG_FILE="/tmp/openmonetis-install.log"
|
||||||
|
> "$LOG_FILE"
|
||||||
|
|
||||||
|
# Suprimir prompt interativo do corepack ao chamar pnpm/node versioning
|
||||||
|
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
||||||
|
|
||||||
|
# ── Cores ──────────────────────────────────────────────────────────────────────
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
RED='\033[0;31m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
BOLD='\033[1m'
|
||||||
|
RESET='\033[0m'
|
||||||
|
|
||||||
|
ok() { printf "${GREEN}✔${RESET} %s\n" "$1"; }
|
||||||
|
warn() { printf "${YELLOW}!${RESET} %s\n" "$1"; }
|
||||||
|
info() { printf "${CYAN}→${RESET} %s\n" "$1"; }
|
||||||
|
fail() { printf "${RED}✗${RESET} %s\n" "$1"; exit 1; }
|
||||||
|
|
||||||
|
# ── Contador de etapas ─────────────────────────────────────────────────────────
|
||||||
|
_STEP=0
|
||||||
|
_TOTAL=5
|
||||||
|
|
||||||
|
section() {
|
||||||
|
_STEP=$((_STEP + 1))
|
||||||
|
printf "\n${BOLD}[%d/%d] %s${RESET}\n" "$_STEP" "$_TOTAL" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ── Spinner ────────────────────────────────────────────────────────────────────
|
||||||
|
_spin_pid=""
|
||||||
|
|
||||||
|
spinner_start() {
|
||||||
|
_spin_label="$1"
|
||||||
|
( i=0
|
||||||
|
while true; do
|
||||||
|
case $((i % 4)) in
|
||||||
|
0) d=" " ;; 1) d=". " ;; 2) d=".. " ;; *) d="..." ;;
|
||||||
|
esac
|
||||||
|
printf "\r${CYAN}→${RESET} %s%s" "$_spin_label" "$d"
|
||||||
|
i=$((i + 1))
|
||||||
|
sleep 0.4
|
||||||
|
done
|
||||||
|
) &
|
||||||
|
_spin_pid=$!
|
||||||
|
}
|
||||||
|
|
||||||
|
spinner_stop() {
|
||||||
|
if [ -n "$_spin_pid" ]; then
|
||||||
|
kill "$_spin_pid" 2>/dev/null || true
|
||||||
|
wait "$_spin_pid" 2>/dev/null || true
|
||||||
|
_spin_pid=""
|
||||||
|
printf "\r\033[2K"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ── Executores silenciosos com spinner ─────────────────────────────────────────
|
||||||
|
|
||||||
|
# run_quiet "label" cmd [args...] — roda comando com spinner, falha mostra log
|
||||||
|
run_quiet() {
|
||||||
|
_rq_label="$1"; shift
|
||||||
|
spinner_start "$_rq_label"
|
||||||
|
if ! "$@" >> "$LOG_FILE" 2>&1; then
|
||||||
|
spinner_stop
|
||||||
|
printf "${RED}✗ Falha em: %s${RESET}\n" "$_rq_label"
|
||||||
|
printf " Log completo: %s\n\n" "$LOG_FILE"
|
||||||
|
tail -20 "$LOG_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
spinner_stop
|
||||||
|
}
|
||||||
|
|
||||||
|
# run_as_user "label" "comando_shell" — roda comando como $CURRENT_USER com spinner
|
||||||
|
run_as_user() {
|
||||||
|
_ru_label="$1"; shift
|
||||||
|
spinner_start "$_ru_label"
|
||||||
|
if ! su - "$CURRENT_USER" -c "$*" >> "$LOG_FILE" 2>&1; then
|
||||||
|
spinner_stop
|
||||||
|
printf "${RED}✗ Falha em: %s${RESET}\n" "$_ru_label"
|
||||||
|
printf " Log completo: %s\n\n" "$LOG_FILE"
|
||||||
|
tail -20 "$LOG_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
spinner_stop
|
||||||
|
}
|
||||||
|
|
||||||
|
# ── Cleanup no Ctrl+C ──────────────────────────────────────────────────────────
|
||||||
|
cleanup() {
|
||||||
|
spinner_stop
|
||||||
|
printf "\n${YELLOW}Instalação interrompida.${RESET} Log em: %s\n" "$LOG_FILE"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
trap cleanup INT TERM
|
||||||
|
|
||||||
|
# ── Tempo total ────────────────────────────────────────────────────────────────
|
||||||
|
_START=$(date +%s)
|
||||||
|
elapsed() {
|
||||||
|
_secs=$(( $(date +%s) - _START ))
|
||||||
|
printf "%dm%ds" $((_secs / 60)) $((_secs % 60))
|
||||||
|
}
|
||||||
|
|
||||||
|
# ── Root check ─────────────────────────────────────────────────────────────────
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
fail "Execute como root ou com sudo: sudo sh install-deps.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
CURRENT_USER="${SUDO_USER:-$(whoami)}"
|
||||||
|
|
||||||
|
printf "\n${BOLD}OpenMonetis — Instalação de Dependências${RESET}\n"
|
||||||
|
printf "Usuário: ${CYAN}%s${RESET} | Log: %s\n" "$CURRENT_USER" "$LOG_FILE"
|
||||||
|
|
||||||
|
# ── [1/5] Dependências base ────────────────────────────────────────────────────
|
||||||
|
section "Dependências base"
|
||||||
|
run_quiet "Atualizando lista de pacotes" apt-get update -qq
|
||||||
|
run_quiet "Instalando git, curl, ca-certificates" apt-get install -y -qq ca-certificates curl git
|
||||||
|
ok "git $(git --version | cut -d' ' -f3) · curl · ca-certificates"
|
||||||
|
|
||||||
|
# ── [2/5] Docker ───────────────────────────────────────────────────────────────
|
||||||
|
section "Docker"
|
||||||
|
|
||||||
|
if command -v docker > /dev/null 2>&1; then
|
||||||
|
ok "Docker já instalado: $(docker --version | cut -d',' -f1)"
|
||||||
|
else
|
||||||
|
info "Adicionando repositório oficial do Docker..."
|
||||||
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
|
run_quiet "Baixando chave GPG do Docker" \
|
||||||
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
||||||
|
chmod a+r /etc/apt/keyrings/docker.asc
|
||||||
|
|
||||||
|
. /etc/os-release
|
||||||
|
mkdir -p /etc/apt/sources.list.d
|
||||||
|
printf 'deb [arch=%s signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu %s stable\n' \
|
||||||
|
"$(dpkg --print-architecture)" "$VERSION_CODENAME" \
|
||||||
|
> /etc/apt/sources.list.d/docker.list
|
||||||
|
|
||||||
|
run_quiet "Atualizando lista de pacotes" apt-get update -qq
|
||||||
|
run_quiet "Instalando Docker Engine (pode levar alguns minutos)" \
|
||||||
|
apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||||
|
|
||||||
|
systemctl enable docker > /dev/null 2>&1 || true
|
||||||
|
systemctl start docker > /dev/null 2>&1 || true
|
||||||
|
ok "Docker $(docker --version | cut -d',' -f1 | cut -d' ' -f3) instalado"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if docker compose version > /dev/null 2>&1; then
|
||||||
|
ok "Docker Compose $(docker compose version | cut -d' ' -f4)"
|
||||||
|
else
|
||||||
|
run_quiet "Instalando Docker Compose plugin" \
|
||||||
|
sh -c 'mkdir -p /usr/local/lib/docker/cli-plugins && curl -fsSL "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o /usr/local/lib/docker/cli-plugins/docker-compose && chmod +x /usr/local/lib/docker/cli-plugins/docker-compose'
|
||||||
|
ok "Docker Compose $(docker compose version | cut -d' ' -f4) instalado"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$CURRENT_USER" ] && [ "$CURRENT_USER" != "root" ]; then
|
||||||
|
if ! groups "$CURRENT_USER" | grep -q docker; then
|
||||||
|
usermod -aG docker "$CURRENT_USER"
|
||||||
|
warn "Usuário '$CURRENT_USER' adicionado ao grupo docker — faça logout/login para aplicar"
|
||||||
|
else
|
||||||
|
ok "Usuário '$CURRENT_USER' já está no grupo docker"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── [3/5] Homebrew ─────────────────────────────────────────────────────────────
|
||||||
|
section "Homebrew"
|
||||||
|
|
||||||
|
if command -v brew > /dev/null 2>&1; then
|
||||||
|
ok "Homebrew já instalado: $(brew --version | head -1)"
|
||||||
|
else
|
||||||
|
warn "Esta etapa pode levar de 5 a 10 minutos."
|
||||||
|
run_quiet "Instalando dependências de compilação" \
|
||||||
|
apt-get install -y -qq build-essential procps file
|
||||||
|
|
||||||
|
if [ -n "$CURRENT_USER" ] && [ "$CURRENT_USER" != "root" ]; then
|
||||||
|
run_as_user "Instalando Homebrew" \
|
||||||
|
'NONINTERACTIVE=1 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
|
||||||
|
|
||||||
|
BREW_PROFILE="/home/$CURRENT_USER/.bashrc"
|
||||||
|
BREW_EVAL='eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'
|
||||||
|
grep -qxF "$BREW_EVAL" "$BREW_PROFILE" 2>/dev/null || echo "$BREW_EVAL" >> "$BREW_PROFILE"
|
||||||
|
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
|
||||||
|
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 2>/dev/null || true
|
||||||
|
else
|
||||||
|
fail "Homebrew não pode ser instalado como root. Use sudo com um usuário normal."
|
||||||
|
fi
|
||||||
|
|
||||||
|
ok "Homebrew instalado"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── [4/5] Node.js 22 ───────────────────────────────────────────────────────────
|
||||||
|
section "Node.js 22"
|
||||||
|
|
||||||
|
NODE_MAJOR=0
|
||||||
|
if command -v node > /dev/null 2>&1; then
|
||||||
|
NODE_MAJOR=$(node -e "process.stdout.write(String(parseInt(process.versions.node)))")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$NODE_MAJOR" -ge 22 ] 2>/dev/null; then
|
||||||
|
ok "Node.js já instalado: $(node --version)"
|
||||||
|
else
|
||||||
|
warn "Node.js via Homebrew pode levar alguns minutos."
|
||||||
|
if [ -n "$CURRENT_USER" ] && [ "$CURRENT_USER" != "root" ]; then
|
||||||
|
run_as_user "Instalando Node.js 22" \
|
||||||
|
'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" && brew install node@22 && brew link node@22 --force --overwrite'
|
||||||
|
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
|
||||||
|
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 2>/dev/null || true
|
||||||
|
else
|
||||||
|
fail "Node.js via Homebrew não pode ser instalado como root."
|
||||||
|
fi
|
||||||
|
ok "Node.js $(node --version) instalado"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── [5/5] pnpm ─────────────────────────────────────────────────────────────────
|
||||||
|
section "pnpm"
|
||||||
|
|
||||||
|
if command -v pnpm > /dev/null 2>&1; then
|
||||||
|
ok "pnpm já instalado: $(pnpm --version)"
|
||||||
|
else
|
||||||
|
if [ -n "$CURRENT_USER" ] && [ "$CURRENT_USER" != "root" ]; then
|
||||||
|
run_as_user "Instalando pnpm via corepack" \
|
||||||
|
'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" && corepack enable && COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack prepare pnpm@latest --activate'
|
||||||
|
else
|
||||||
|
run_quiet "Instalando pnpm via corepack" \
|
||||||
|
sh -c 'corepack enable && COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack prepare pnpm@latest --activate'
|
||||||
|
fi
|
||||||
|
ok "pnpm instalado"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── Resumo ─────────────────────────────────────────────────────────────────────
|
||||||
|
# Garantir que node/pnpm do brew estejam no PATH para o resumo
|
||||||
|
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
|
||||||
|
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" 2>/dev/null || true
|
||||||
|
|
||||||
|
printf "\n${BOLD}Concluído em $(elapsed)${RESET}\n"
|
||||||
|
|
||||||
|
ok "git: $(git --version | cut -d' ' -f3)"
|
||||||
|
ok "docker: $(docker --version | cut -d',' -f1 | cut -d' ' -f3)"
|
||||||
|
ok "docker compose: $(docker compose version | cut -d' ' -f4)"
|
||||||
|
ok "node: $(node --version)"
|
||||||
|
ok "pnpm: $(pnpm --version)"
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Script para configurar ambiente de forma segura
|
|
||||||
# Cria backup do .env atual antes de sobrescrever
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "🔧 Configurando ambiente..."
|
|
||||||
|
|
||||||
# Se .env já existe, criar backup
|
|
||||||
if [ -f .env ]; then
|
|
||||||
BACKUP_FILE=".env.backup.$(date +%Y%m%d_%H%M%S)"
|
|
||||||
echo "⚠️ Arquivo .env existente detectado!"
|
|
||||||
echo "📦 Criando backup em: $BACKUP_FILE"
|
|
||||||
cp .env "$BACKUP_FILE"
|
|
||||||
echo "✅ Backup criado com sucesso!"
|
|
||||||
echo ""
|
|
||||||
read -p "Deseja sobrescrever o .env atual com .env.example? (s/N) " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Ss]$ ]]; then
|
|
||||||
echo "❌ Operação cancelada. Seu .env não foi modificado."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Copiar .env.example para .env
|
|
||||||
if [ -f .env.example ]; then
|
|
||||||
cp .env.example .env
|
|
||||||
echo "✅ Arquivo .env criado a partir de .env.example"
|
|
||||||
else
|
|
||||||
echo "❌ Erro: .env.example não encontrado!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Gerar BETTER_AUTH_SECRET automaticamente
|
|
||||||
if command -v openssl &> /dev/null; then
|
|
||||||
SECRET=$(openssl rand -base64 32)
|
|
||||||
sed -i.bak "s|BETTER_AUTH_SECRET=.*|BETTER_AUTH_SECRET=$SECRET|" .env && rm -f .env.bak
|
|
||||||
echo "✅ BETTER_AUTH_SECRET gerado automaticamente"
|
|
||||||
else
|
|
||||||
echo "⚠️ openssl não encontrado — configure BETTER_AUTH_SECRET manualmente:"
|
|
||||||
echo " openssl rand -base64 32"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "⚠️ IMPORTANTE: Edite o arquivo .env e configure:"
|
|
||||||
echo " - DATABASE_URL"
|
|
||||||
echo " - BETTER_AUTH_URL"
|
|
||||||
echo " - Demais variáveis opcionais (OAuth, e-mail, IA)"
|
|
||||||
23
src/app/(auth)/layout.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Logo } from "@/shared/components/logo";
|
||||||
|
|
||||||
|
export default function AuthLayout({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="relative flex min-h-svh flex-col items-center justify-center overflow-hidden bg-linear-to-b from-background via-background to-muted/20 px-5 py-8 md:px-8 md:py-10">
|
||||||
|
<div className="pointer-events-none absolute inset-0 overflow-hidden flex items-center justify-center">
|
||||||
|
<div className="absolute -right-32 top-0 h-96 w-96 rounded-full bg-primary/10 blur-3xl animate-blob mix-blend-multiply" />
|
||||||
|
<div className="absolute -left-32 bottom-0 h-96 w-96 rounded-full bg-primary/7 blur-3xl animate-blob animation-delay-2000 mix-blend-multiply" />
|
||||||
|
<div className="absolute -bottom-32 left-1/2 h-80 w-80 rounded-full bg-secondary/30 blur-3xl animate-blob animation-delay-4000 mix-blend-multiply" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="relative mb-6 flex md:hidden z-20">
|
||||||
|
<Logo variant="compact" colorIcon />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="relative w-full max-w-sm md:max-w-5xl">{children}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,21 +1,5 @@
|
|||||||
import { LoginForm } from "@/features/auth/components/login-form";
|
import { LoginForm } from "@/features/auth/components/login-form";
|
||||||
import { Logo } from "@/shared/components/logo";
|
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
return (
|
return <LoginForm />;
|
||||||
<div className="relative flex min-h-svh flex-col items-center justify-center overflow-hidden bg-linear-to-b from-background via-background to-muted/20 px-5 py-8 md:px-8 md:py-10">
|
|
||||||
<div className="pointer-events-none absolute inset-0">
|
|
||||||
<div className="absolute -right-32 -top-32 h-72 w-72 rounded-full bg-primary/10 blur-3xl" />
|
|
||||||
<div className="absolute -bottom-32 -left-32 h-72 w-72 rounded-full bg-primary/7 blur-3xl" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="relative mb-6 flex md:hidden">
|
|
||||||
<Logo variant="compact" colorIcon />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="relative w-full max-w-sm md:max-w-5xl">
|
|
||||||
<LoginForm />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,5 @@
|
|||||||
import { SignupForm } from "@/features/auth/components/signup-form";
|
import { SignupForm } from "@/features/auth/components/signup-form";
|
||||||
import { Logo } from "@/shared/components/logo";
|
|
||||||
|
|
||||||
export default function SignupPage() {
|
export default function SignupPage() {
|
||||||
return (
|
return <SignupForm />;
|
||||||
<div className="relative flex min-h-svh flex-col items-center justify-center overflow-hidden bg-linear-to-b from-background via-background to-muted/20 px-5 py-8 md:px-8 md:py-10">
|
|
||||||
<div className="pointer-events-none absolute inset-0">
|
|
||||||
<div className="absolute -right-32 -top-32 h-72 w-72 rounded-full bg-primary/10 blur-3xl" />
|
|
||||||
<div className="absolute -bottom-32 -left-32 h-72 w-72 rounded-full bg-primary/7 blur-3xl" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="relative mb-6 flex md:hidden">
|
|
||||||
<Logo variant="compact" colorIcon />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="relative w-full max-w-sm md:max-w-5xl">
|
|
||||||
<SignupForm />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiBankLine />}
|
icon={<RiBankLine />}
|
||||||
title="Contas"
|
title="Contas"
|
||||||
|
|||||||
26
src/app/(dashboard)/attachments/layout.tsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { RiAttachmentLine } from "@remixicon/react";
|
||||||
|
import MonthNavigation from "@/shared/components/month-picker/month-navigation";
|
||||||
|
import PageDescription from "@/shared/components/page-description";
|
||||||
|
|
||||||
|
export const metadata = {
|
||||||
|
title: "Anexos",
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function RootLayout({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<section className="space-y-6">
|
||||||
|
<PageDescription
|
||||||
|
icon={<RiAttachmentLine />}
|
||||||
|
title="Anexos"
|
||||||
|
subtitle="Gerencie os anexos das suas transações"
|
||||||
|
/>
|
||||||
|
<MonthNavigation />
|
||||||
|
|
||||||
|
{children}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiBarChart2Line />}
|
icon={<RiBarChart2Line />}
|
||||||
title="Orçamentos"
|
title="Orçamentos"
|
||||||
|
|||||||
@@ -20,22 +20,13 @@ const getSingleParam = (
|
|||||||
return Array.isArray(value) ? (value[0] ?? null) : value;
|
return Array.isArray(value) ? (value[0] ?? null) : value;
|
||||||
};
|
};
|
||||||
|
|
||||||
const capitalize = (value: string) =>
|
|
||||||
value.length === 0 ? value : value[0]?.toUpperCase() + value.slice(1);
|
|
||||||
|
|
||||||
export default async function Page({ searchParams }: PageProps) {
|
export default async function Page({ searchParams }: PageProps) {
|
||||||
await connection();
|
await connection();
|
||||||
const userId = await getUserId();
|
const userId = await getUserId();
|
||||||
const resolvedSearchParams = searchParams ? await searchParams : undefined;
|
const resolvedSearchParams = searchParams ? await searchParams : undefined;
|
||||||
const periodoParam = getSingleParam(resolvedSearchParams, "periodo");
|
const periodoParam = getSingleParam(resolvedSearchParams, "periodo");
|
||||||
|
|
||||||
const {
|
const { period: selectedPeriod } = parsePeriodParam(periodoParam);
|
||||||
period: selectedPeriod,
|
|
||||||
monthName: rawMonthName,
|
|
||||||
year,
|
|
||||||
} = parsePeriodParam(periodoParam);
|
|
||||||
|
|
||||||
const periodLabel = `${capitalize(rawMonthName)} ${year}`;
|
|
||||||
|
|
||||||
const { budgets, categoriesOptions } = await fetchBudgetsForUser(
|
const { budgets, categoriesOptions } = await fetchBudgetsForUser(
|
||||||
userId,
|
userId,
|
||||||
@@ -49,7 +40,6 @@ export default async function Page({ searchParams }: PageProps) {
|
|||||||
budgets={budgets}
|
budgets={budgets}
|
||||||
categories={categoriesOptions}
|
categories={categoriesOptions}
|
||||||
selectedPeriod={selectedPeriod}
|
selectedPeriod={selectedPeriod}
|
||||||
periodLabel={periodLabel}
|
|
||||||
/>
|
/>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiCalendarEventLine />}
|
icon={<RiCalendarEventLine />}
|
||||||
title="Calendário"
|
title="Calendário"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiBankCard2Line />}
|
icon={<RiBankCard2Line />}
|
||||||
title="Cartões"
|
title="Cartões"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { connection } from "next/server";
|
import { connection } from "next/server";
|
||||||
import { fetchCategoryHistory } from "@/features/dashboard/categories/category-history-queries";
|
import { fetchCategoryHistory } from "@/features/dashboard/categories/category-history-queries";
|
||||||
import { CategoryHistoryWidget } from "@/features/dashboard/components/category-history-widget";
|
import { CategoryHistoryWidget } from "@/features/dashboard/components/widgets/category-history-widget";
|
||||||
import { getUser } from "@/shared/lib/auth/server";
|
import { getUser } from "@/shared/lib/auth/server";
|
||||||
import { getCurrentPeriod } from "@/shared/utils/period";
|
import { getCurrentPeriod } from "@/shared/utils/period";
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiPriceTag3Line />}
|
icon={<RiPriceTag3Line />}
|
||||||
title="Categorias"
|
title="Categorias"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiHistoryLine />}
|
icon={<RiHistoryLine />}
|
||||||
title="Changelog"
|
title="Changelog"
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ import { connection } from "next/server";
|
|||||||
import { DashboardGridEditable } from "@/features/dashboard/components/dashboard-grid-editable";
|
import { DashboardGridEditable } from "@/features/dashboard/components/dashboard-grid-editable";
|
||||||
import { DashboardMetricsCards } from "@/features/dashboard/components/dashboard-metrics-cards";
|
import { DashboardMetricsCards } from "@/features/dashboard/components/dashboard-metrics-cards";
|
||||||
import { DashboardWelcome } from "@/features/dashboard/components/dashboard-welcome";
|
import { DashboardWelcome } from "@/features/dashboard/components/dashboard-welcome";
|
||||||
|
import { extractDashboardLogoNames } from "@/features/dashboard/extract-logo-names";
|
||||||
import { fetchDashboardPageData } from "@/features/dashboard/page-data-queries";
|
import { fetchDashboardPageData } from "@/features/dashboard/page-data-queries";
|
||||||
import { getSingleParam } from "@/features/transactions/page-helpers";
|
import { getSingleParam } from "@/features/transactions/page-helpers";
|
||||||
|
import { LogoPrefetchProvider } from "@/shared/components/entity-avatar";
|
||||||
import MonthNavigation from "@/shared/components/month-picker/month-navigation";
|
import MonthNavigation from "@/shared/components/month-picker/month-navigation";
|
||||||
import { getUser } from "@/shared/lib/auth/server";
|
import { getUser } from "@/shared/lib/auth/server";
|
||||||
|
import { prefetchLogoMappings } from "@/shared/lib/logo/prefetch-server";
|
||||||
import { parsePeriodParam } from "@/shared/utils/period";
|
import { parsePeriodParam } from "@/shared/utils/period";
|
||||||
|
|
||||||
type PageSearchParams = Promise<Record<string, string | string[] | undefined>>;
|
type PageSearchParams = Promise<Record<string, string | string[] | undefined>>;
|
||||||
@@ -25,17 +28,24 @@ export default async function Page({ searchParams }: PageProps) {
|
|||||||
await fetchDashboardPageData(user.id, selectedPeriod);
|
await fetchDashboardPageData(user.id, selectedPeriod);
|
||||||
const { dashboardWidgets } = preferences;
|
const { dashboardWidgets } = preferences;
|
||||||
|
|
||||||
|
const logoMappings = await prefetchLogoMappings(
|
||||||
|
user.id,
|
||||||
|
extractDashboardLogoNames(dashboardData),
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="flex flex-col gap-4">
|
<main className="flex flex-col gap-4">
|
||||||
<DashboardWelcome name={user.name} />
|
<DashboardWelcome name={user.name} />
|
||||||
<MonthNavigation />
|
<MonthNavigation />
|
||||||
<DashboardMetricsCards metrics={dashboardData.metrics} />
|
<DashboardMetricsCards metrics={dashboardData.metrics} />
|
||||||
<DashboardGridEditable
|
<LogoPrefetchProvider mappings={logoMappings}>
|
||||||
data={dashboardData}
|
<DashboardGridEditable
|
||||||
period={selectedPeriod}
|
data={dashboardData}
|
||||||
initialPreferences={dashboardWidgets}
|
period={selectedPeriod}
|
||||||
quickActionOptions={quickActionOptions}
|
initialPreferences={dashboardWidgets}
|
||||||
/>
|
quickActionOptions={quickActionOptions}
|
||||||
|
/>
|
||||||
|
</LogoPrefetchProvider>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiAtLine />}
|
icon={<RiAtLine />}
|
||||||
title="Pré-Lançamentos"
|
title="Pré-Lançamentos"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiSparklingLine />}
|
icon={<RiSparklingLine />}
|
||||||
title="Insights"
|
title="Insights"
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { connection } from "next/server";
|
import { connection } from "next/server";
|
||||||
import { fetchDashboardNavbarData } from "@/features/dashboard/navbar-queries";
|
import { fetchDashboardNavbarData } from "@/features/dashboard/navbar-queries";
|
||||||
import { AppNavbar } from "@/shared/components/navigation/navbar/app-navbar";
|
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";
|
import { PrivacyProvider } from "@/shared/components/providers/privacy-provider";
|
||||||
import { DotPattern } from "@/shared/components/ui/dot-pattern";
|
|
||||||
import { getUserSession } from "@/shared/lib/auth/server";
|
import { getUserSession } from "@/shared/lib/auth/server";
|
||||||
|
import { isLogoDevEnabled } from "@/shared/lib/logo/server";
|
||||||
|
|
||||||
export default async function DashboardLayout({
|
export default async function DashboardLayout({
|
||||||
children,
|
children,
|
||||||
@@ -13,33 +14,25 @@ export default async function DashboardLayout({
|
|||||||
await connection();
|
await connection();
|
||||||
const session = await getUserSession();
|
const session = await getUserSession();
|
||||||
const navbarData = await fetchDashboardNavbarData(session.user.id);
|
const navbarData = await fetchDashboardNavbarData(session.user.id);
|
||||||
|
const logoDevEnabled = isLogoDevEnabled();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PrivacyProvider>
|
<LogoDevProvider enabled={logoDevEnabled}>
|
||||||
<AppNavbar
|
<PrivacyProvider>
|
||||||
user={{ ...session.user, image: session.user.image ?? null }}
|
<AppNavbar
|
||||||
pagadorAvatarUrl={navbarData.pagadorAvatarUrl}
|
user={{ ...session.user, image: session.user.image ?? null }}
|
||||||
preLancamentosCount={navbarData.preLancamentosCount}
|
pagadorAvatarUrl={navbarData.pagadorAvatarUrl}
|
||||||
notificationsSnapshot={navbarData.notificationsSnapshot}
|
preLancamentosCount={navbarData.preLancamentosCount}
|
||||||
/>
|
notificationsSnapshot={navbarData.notificationsSnapshot}
|
||||||
<div className="relative flex flex-1 flex-col pt-16">
|
/>
|
||||||
<div className="pointer-events-none absolute inset-x-0 top-0 h-32 overflow-hidden md:h-36">
|
<div className="relative flex flex-1 flex-col pt-16">
|
||||||
<DotPattern
|
<div className="@container/main flex flex-1 flex-col gap-2">
|
||||||
width={20}
|
<div className="flex flex-col gap-4 py-5 md:gap-6 w-full max-w-8xl mx-auto px-4 ">
|
||||||
height={20}
|
{children}
|
||||||
cx={1.25}
|
</div>
|
||||||
cy={1.25}
|
|
||||||
cr={1.25}
|
|
||||||
className="text-primary/10 mask-[linear-gradient(to_bottom,black_0%,transparent_100%)]"
|
|
||||||
/>
|
|
||||||
<div className="absolute inset-0 bg-linear-to-b from-primary/6 to-transparent" />
|
|
||||||
</div>
|
|
||||||
<div className="@container/main flex flex-1 flex-col gap-2">
|
|
||||||
<div className="flex flex-col gap-4 py-5 md:gap-6 w-full max-w-8xl mx-auto px-4 ">
|
|
||||||
{children}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</PrivacyProvider>
|
||||||
</PrivacyProvider>
|
</LogoDevProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiTodoLine />}
|
icon={<RiTodoLine />}
|
||||||
title="Anotações"
|
title="Anotações"
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import {
|
|||||||
fetchRecentEstablishments,
|
fetchRecentEstablishments,
|
||||||
fetchTransactionFilterSources,
|
fetchTransactionFilterSources,
|
||||||
} from "@/features/transactions/queries";
|
} from "@/features/transactions/queries";
|
||||||
|
import { LogoPrefetchProvider } from "@/shared/components/entity-avatar";
|
||||||
import { ExpandableWidgetCard } from "@/shared/components/expandable-widget-card";
|
import { ExpandableWidgetCard } from "@/shared/components/expandable-widget-card";
|
||||||
import MonthNavigation from "@/shared/components/month-picker/month-navigation";
|
import MonthNavigation from "@/shared/components/month-picker/month-navigation";
|
||||||
import {
|
import {
|
||||||
@@ -50,6 +51,7 @@ import {
|
|||||||
TabsTrigger,
|
TabsTrigger,
|
||||||
} from "@/shared/components/ui/tabs";
|
} from "@/shared/components/ui/tabs";
|
||||||
import { getUserId } from "@/shared/lib/auth/server";
|
import { getUserId } from "@/shared/lib/auth/server";
|
||||||
|
import { prefetchLogoMappings } from "@/shared/lib/logo/prefetch-server";
|
||||||
import { getPayerAccess } from "@/shared/lib/payers/access";
|
import { getPayerAccess } from "@/shared/lib/payers/access";
|
||||||
import {
|
import {
|
||||||
fetchPagadorBoletoItems,
|
fetchPagadorBoletoItems,
|
||||||
@@ -80,6 +82,9 @@ const EMPTY_FILTERS: TransactionSearchFilters = {
|
|||||||
categoryFilter: null,
|
categoryFilter: null,
|
||||||
accountCardFilter: null,
|
accountCardFilter: null,
|
||||||
searchFilter: null,
|
searchFilter: null,
|
||||||
|
settledFilter: null,
|
||||||
|
attachmentFilter: null,
|
||||||
|
dividedFilter: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const createEmptySlugMaps = (): SlugMaps => ({
|
const createEmptySlugMaps = (): SlugMaps => ({
|
||||||
@@ -305,104 +310,113 @@ export default async function Page({ params, searchParams }: PageProps) {
|
|||||||
lancamentoCount: transactionData.length,
|
lancamentoCount: transactionData.length,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const logoMappings = await prefetchLogoMappings(dataOwnerId, [
|
||||||
|
...transactionData.map((t) => t.name),
|
||||||
|
...boletoItems.map((b) => b.name),
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="flex flex-col gap-6">
|
<main className="flex flex-col gap-6">
|
||||||
<MonthNavigation />
|
<MonthNavigation />
|
||||||
|
|
||||||
<Tabs defaultValue="profile" className="w-full">
|
<LogoPrefetchProvider mappings={logoMappings}>
|
||||||
<TabsList className="mb-2">
|
<Tabs defaultValue="profile" className="w-full">
|
||||||
<TabsTrigger value="profile">Perfil</TabsTrigger>
|
<TabsList className="mb-2">
|
||||||
<TabsTrigger value="painel">Painel</TabsTrigger>
|
<TabsTrigger value="profile">Perfil</TabsTrigger>
|
||||||
<TabsTrigger value="lancamentos">Lançamentos</TabsTrigger>
|
<TabsTrigger value="painel">Painel</TabsTrigger>
|
||||||
</TabsList>
|
<TabsTrigger value="lancamentos">Lançamentos</TabsTrigger>
|
||||||
<PayerHeaderCard
|
</TabsList>
|
||||||
payer={payerData}
|
<PayerHeaderCard
|
||||||
selectedPeriod={selectedPeriod}
|
payer={payerData}
|
||||||
summary={summaryPreview}
|
selectedPeriod={selectedPeriod}
|
||||||
/>
|
summary={summaryPreview}
|
||||||
|
/>
|
||||||
|
|
||||||
<TabsContent value="profile" className="space-y-4">
|
<TabsContent value="profile" className="space-y-4">
|
||||||
<PagadorInfoCard payer={payerData} />
|
<PagadorInfoCard payer={payerData} />
|
||||||
{canEdit && payerData.shareCode ? (
|
{canEdit && payerData.shareCode ? (
|
||||||
<PayerSharingCard
|
<PayerSharingCard
|
||||||
payerId={pagador.id}
|
payerId={pagador.id}
|
||||||
shareCode={payerData.shareCode}
|
shareCode={payerData.shareCode}
|
||||||
shares={payerSharesData}
|
shares={payerSharesData}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{!canEdit && currentUserShare ? (
|
{!canEdit && currentUserShare ? (
|
||||||
<PayerLeaveShareCard
|
<PayerLeaveShareCard
|
||||||
shareId={currentUserShare.id}
|
shareId={currentUserShare.id}
|
||||||
pagadorName={payerData.name}
|
pagadorName={payerData.name}
|
||||||
createdAt={currentUserShare.createdAt}
|
createdAt={currentUserShare.createdAt}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="painel" className="space-y-4">
|
<TabsContent value="painel" className="space-y-4">
|
||||||
<section className="grid gap-3 lg:grid-cols-2">
|
<section className="grid gap-3 lg:grid-cols-2">
|
||||||
<PayerMonthlySummaryCard
|
<PayerMonthlySummaryCard
|
||||||
periodLabel={periodLabel}
|
periodLabel={periodLabel}
|
||||||
breakdown={monthlyBreakdown}
|
breakdown={monthlyBreakdown}
|
||||||
/>
|
/>
|
||||||
<PayerHistoryCard data={historyData} />
|
<PayerHistoryCard data={historyData} />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="grid gap-3 lg:grid-cols-3">
|
<section className="grid gap-3 lg:grid-cols-3">
|
||||||
<ExpandableWidgetCard
|
<ExpandableWidgetCard
|
||||||
title="Minhas Faturas"
|
title="Minhas Faturas"
|
||||||
subtitle="Valores por cartão neste período"
|
subtitle="Valores por cartão neste período"
|
||||||
icon={<RiBankCard2Line className="size-4" />}
|
icon={<RiBankCard2Line className="size-4" />}
|
||||||
>
|
>
|
||||||
<PayerCardUsageCard items={cardUsage} />
|
<PayerCardUsageCard items={cardUsage} />
|
||||||
</ExpandableWidgetCard>
|
</ExpandableWidgetCard>
|
||||||
<ExpandableWidgetCard
|
<ExpandableWidgetCard
|
||||||
title="Boletos"
|
title="Boletos"
|
||||||
subtitle="Boletos registrados neste período"
|
subtitle="Boletos registrados neste período"
|
||||||
icon={<RiBarcodeLine className="size-4" />}
|
icon={<RiBarcodeLine className="size-4" />}
|
||||||
>
|
>
|
||||||
<PayerBoletoCard items={boletoItems} />
|
<PayerBoletoCard items={boletoItems} />
|
||||||
</ExpandableWidgetCard>
|
</ExpandableWidgetCard>
|
||||||
<ExpandableWidgetCard
|
<ExpandableWidgetCard
|
||||||
title="Status de Pagamento"
|
title="Status de Pagamento"
|
||||||
subtitle="Situação das despesas no período"
|
subtitle="Situação das despesas no período"
|
||||||
icon={<RiWallet3Line className="size-4" />}
|
icon={<RiWallet3Line className="size-4" />}
|
||||||
>
|
>
|
||||||
<PayerPaymentStatusCard data={paymentStatus} />
|
<PayerPaymentStatusCard data={paymentStatus} />
|
||||||
</ExpandableWidgetCard>
|
</ExpandableWidgetCard>
|
||||||
</section>
|
</section>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="lancamentos">
|
<TabsContent value="lancamentos">
|
||||||
<section className="flex flex-col gap-4">
|
<section className="flex flex-col gap-4">
|
||||||
<LancamentosSection
|
<LancamentosSection
|
||||||
currentUserId={userId}
|
currentUserId={userId}
|
||||||
transactions={transactionData}
|
transactions={transactionData}
|
||||||
payerOptions={optionSets.payerOptions}
|
payerOptions={optionSets.payerOptions}
|
||||||
splitPayerOptions={optionSets.splitPayerOptions}
|
splitPayerOptions={optionSets.splitPayerOptions}
|
||||||
defaultPayerId={pagador.id}
|
defaultPayerId={pagador.id}
|
||||||
accountOptions={optionSets.accountOptions}
|
accountOptions={optionSets.accountOptions}
|
||||||
cardOptions={optionSets.cardOptions}
|
cardOptions={optionSets.cardOptions}
|
||||||
categoryOptions={optionSets.categoryOptions}
|
categoryOptions={optionSets.categoryOptions}
|
||||||
payerFilterOptions={payerFilterOptions}
|
payerFilterOptions={payerFilterOptions}
|
||||||
categoryFilterOptions={optionSets.categoryFilterOptions}
|
categoryFilterOptions={optionSets.categoryFilterOptions}
|
||||||
accountCardFilterOptions={optionSets.accountCardFilterOptions}
|
accountCardFilterOptions={optionSets.accountCardFilterOptions}
|
||||||
selectedPeriod={selectedPeriod}
|
selectedPeriod={selectedPeriod}
|
||||||
estabelecimentos={estabelecimentos}
|
estabelecimentos={estabelecimentos}
|
||||||
allowCreate={canEdit}
|
allowCreate={canEdit}
|
||||||
noteAsColumn={userPreferences?.statementNoteAsColumn ?? false}
|
noteAsColumn={userPreferences?.statementNoteAsColumn ?? false}
|
||||||
columnOrder={userPreferences?.transactionsColumnOrder ?? null}
|
columnOrder={userPreferences?.transactionsColumnOrder ?? null}
|
||||||
attachmentMaxSizeMb={userPreferences?.attachmentMaxSizeMb ?? 50}
|
attachmentMaxSizeMb={userPreferences?.attachmentMaxSizeMb ?? 50}
|
||||||
importPayerOptions={loggedUserOptionSets?.payerOptions}
|
importPayerOptions={loggedUserOptionSets?.payerOptions}
|
||||||
importSplitPayerOptions={loggedUserOptionSets?.splitPayerOptions}
|
importSplitPayerOptions={
|
||||||
importDefaultPayerId={loggedUserOptionSets?.defaultPayerId}
|
loggedUserOptionSets?.splitPayerOptions
|
||||||
importAccountOptions={loggedUserOptionSets?.accountOptions}
|
}
|
||||||
importCardOptions={loggedUserOptionSets?.cardOptions}
|
importDefaultPayerId={loggedUserOptionSets?.defaultPayerId}
|
||||||
importCategoryOptions={loggedUserOptionSets?.categoryOptions}
|
importAccountOptions={loggedUserOptionSets?.accountOptions}
|
||||||
/>
|
importCardOptions={loggedUserOptionSets?.cardOptions}
|
||||||
</section>
|
importCategoryOptions={loggedUserOptionSets?.categoryOptions}
|
||||||
</TabsContent>
|
/>
|
||||||
</Tabs>
|
</section>
|
||||||
|
</TabsContent>
|
||||||
|
</Tabs>
|
||||||
|
</LogoPrefetchProvider>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { RiGroupLine } from "@remixicon/react";
|
|||||||
import PageDescription from "@/shared/components/page-description";
|
import PageDescription from "@/shared/components/page-description";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "Pagadores",
|
title: "Pessoas",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({
|
export default function RootLayout({
|
||||||
@@ -11,10 +11,10 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiGroupLine />}
|
icon={<RiGroupLine />}
|
||||||
title="Pagadores"
|
title="Pessoas"
|
||||||
subtitle="Gerencie as pessoas ou entidades responsáveis pelos pagamentos."
|
subtitle="Gerencie as pessoas ou entidades responsáveis pelos pagamentos."
|
||||||
/>
|
/>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Skeleton } from "@/shared/components/ui/skeleton";
|
import { Skeleton } from "@/shared/components/ui/skeleton";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loading state para a página de pagadores
|
* Loading state para a página de pessoas
|
||||||
* Layout: Header + Input de compartilhamento + Grid de cards
|
* Layout: Header + Input de compartilhamento + Grid de cards
|
||||||
*/
|
*/
|
||||||
export default function PagadoresLoading() {
|
export default function PagadoresLoading() {
|
||||||
@@ -17,7 +17,7 @@ export default function PagadoresLoading() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Grid de cards de pagadores */}
|
{/* Grid de cards de pessoas */}
|
||||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||||
{Array.from({ length: 6 }).map((_, i) => (
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
<div key={i} className="rounded-md border p-6 space-y-4">
|
<div key={i} className="rounded-md border p-6 space-y-4">
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiBankCard2Line />}
|
icon={<RiBankCard2Line />}
|
||||||
title="Uso de Cartões"
|
title="Uso de Cartões"
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export default async function RelatorioCartoesPage({
|
|||||||
<div className="flex size-14 items-center justify-center rounded-full bg-muted mb-4">
|
<div className="flex size-14 items-center justify-center rounded-full bg-muted mb-4">
|
||||||
<RiBankCard2Line className="size-7 text-muted-foreground" />
|
<RiBankCard2Line className="size-7 text-muted-foreground" />
|
||||||
</div>
|
</div>
|
||||||
<p className="text-base font-medium">Nenhum cartão selecionado</p>
|
<p className="text-base font-semibold">Nenhum cartão selecionado</p>
|
||||||
<p className="text-sm text-muted-foreground mt-1">
|
<p className="text-sm text-muted-foreground mt-1">
|
||||||
Selecione um cartão para ver os detalhes de uso.
|
Selecione um cartão para ver os detalhes de uso.
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiFileChartLine />}
|
icon={<RiFileChartLine />}
|
||||||
title="Tendências"
|
title="Tendências"
|
||||||
|
|||||||
@@ -40,7 +40,9 @@ export default async function Page({ searchParams }: PageProps) {
|
|||||||
// Extract query params
|
// Extract query params
|
||||||
const inicioParam = getSingleParam(resolvedSearchParams, "inicio");
|
const inicioParam = getSingleParam(resolvedSearchParams, "inicio");
|
||||||
const fimParam = getSingleParam(resolvedSearchParams, "fim");
|
const fimParam = getSingleParam(resolvedSearchParams, "fim");
|
||||||
const categoriasParam = getSingleParam(resolvedSearchParams, "categories");
|
const categoriasParam =
|
||||||
|
getSingleParam(resolvedSearchParams, "categorias") ??
|
||||||
|
getSingleParam(resolvedSearchParams, "categories");
|
||||||
|
|
||||||
// Calculate default period (last 6 months)
|
// Calculate default period (last 6 months)
|
||||||
const currentPeriod = getCurrentPeriod();
|
const currentPeriod = getCurrentPeriod();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiStore2Line />}
|
icon={<RiStore2Line />}
|
||||||
title="Top Estabelecimentos"
|
title="Top Estabelecimentos"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiSecurePaymentLine />}
|
icon={<RiSecurePaymentLine />}
|
||||||
title="Análise de Parcelas"
|
title="Análise de Parcelas"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiSettings2Line />}
|
icon={<RiSettings2Line />}
|
||||||
title="Ajustes"
|
title="Ajustes"
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export default async function Page() {
|
|||||||
<Card className="p-6">
|
<Card className="p-6">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-xl font-medium mb-1">Preferências</h2>
|
<h2 className="text-xl font-semibold mb-1">Preferências</h2>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Personalize sua experiência no OpenMonetis ajustando as
|
Personalize sua experiência no OpenMonetis ajustando as
|
||||||
configurações de acordo com suas necessidades.
|
configurações de acordo com suas necessidades.
|
||||||
@@ -92,7 +92,9 @@ export default async function Page() {
|
|||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center gap-2 mb-1">
|
<div className="flex items-center gap-2 mb-1">
|
||||||
<h2 className="text-xl font-medium">OpenMonetis Companion</h2>
|
<h2 className="text-xl font-semibold">
|
||||||
|
OpenMonetis Companion
|
||||||
|
</h2>
|
||||||
<span className="inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-xs font-medium text-success dark:bg-success/10">
|
<span className="inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-xs font-medium text-success dark:bg-success/10">
|
||||||
<RiAndroidLine className="h-3 w-3" />
|
<RiAndroidLine className="h-3 w-3" />
|
||||||
Android
|
Android
|
||||||
@@ -114,7 +116,7 @@ export default async function Page() {
|
|||||||
<Card className="p-6">
|
<Card className="p-6">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-xl font-medium mb-1">Alterar nome</h2>
|
<h2 className="text-xl font-semibold mb-1">Alterar nome</h2>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Atualize como seu nome aparece no OpenMonetis. Esse nome pode
|
Atualize como seu nome aparece no OpenMonetis. Esse nome pode
|
||||||
ser exibido em diferentes seções do app e em comunicações.
|
ser exibido em diferentes seções do app e em comunicações.
|
||||||
@@ -130,7 +132,7 @@ export default async function Page() {
|
|||||||
<Card className="p-6">
|
<Card className="p-6">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-xl font-medium mb-1">Alterar senha</h2>
|
<h2 className="text-xl font-semibold mb-1">Alterar senha</h2>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Defina uma nova senha para sua conta. Guarde-a em local
|
Defina uma nova senha para sua conta. Guarde-a em local
|
||||||
seguro.
|
seguro.
|
||||||
@@ -146,7 +148,7 @@ export default async function Page() {
|
|||||||
<Card className="p-6">
|
<Card className="p-6">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-xl font-medium mb-1">Passkeys</h2>
|
<h2 className="text-xl font-semibold mb-1">Passkeys</h2>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Passkeys permitem login sem senha, usando biometria (Face ID,
|
Passkeys permitem login sem senha, usando biometria (Face ID,
|
||||||
Touch ID, Windows Hello) ou chaves de segurança.
|
Touch ID, Windows Hello) ou chaves de segurança.
|
||||||
@@ -162,7 +164,7 @@ export default async function Page() {
|
|||||||
<Card className="p-6">
|
<Card className="p-6">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-xl font-medium mb-1">Alterar e-mail</h2>
|
<h2 className="text-xl font-semibold mb-1">Alterar e-mail</h2>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Atualize o e-mail associado à sua conta. Você precisará
|
Atualize o e-mail associado à sua conta. Você precisará
|
||||||
confirmar os links enviados para o novo e também para o e-mail
|
confirmar os links enviados para o novo e também para o e-mail
|
||||||
@@ -182,9 +184,7 @@ export default async function Page() {
|
|||||||
<Card className="p-6">
|
<Card className="p-6">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-xl font-medium mb-1 text-destructive">
|
<h2 className="text-xl font-semibold mb-1">Ações perigosas</h2>
|
||||||
Ações perigosas
|
|
||||||
</h2>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Você pode zerar os dados do OpenMonetis e manter seu acesso,
|
Você pode zerar os dados do OpenMonetis e manter seu acesso,
|
||||||
ou excluir sua conta inteira de forma irreversível.
|
ou excluir sua conta inteira de forma irreversível.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-4">
|
<section className="space-y-6">
|
||||||
<PageDescription
|
<PageDescription
|
||||||
icon={<RiArrowLeftRightLine />}
|
icon={<RiArrowLeftRightLine />}
|
||||||
title="Lançamentos"
|
title="Lançamentos"
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ import {
|
|||||||
fetchTransactionFilterSources,
|
fetchTransactionFilterSources,
|
||||||
fetchTransactionsPage,
|
fetchTransactionsPage,
|
||||||
} from "@/features/transactions/queries";
|
} from "@/features/transactions/queries";
|
||||||
|
import { LogoPrefetchProvider } from "@/shared/components/entity-avatar";
|
||||||
import MonthNavigation from "@/shared/components/month-picker/month-navigation";
|
import MonthNavigation from "@/shared/components/month-picker/month-navigation";
|
||||||
import { getUserId } from "@/shared/lib/auth/server";
|
import { getUserId } from "@/shared/lib/auth/server";
|
||||||
|
import { prefetchLogoMappings } from "@/shared/lib/logo/prefetch-server";
|
||||||
import { parsePeriodParam } from "@/shared/utils/period";
|
import { parsePeriodParam } from "@/shared/utils/period";
|
||||||
|
|
||||||
type PageSearchParams = Promise<ResolvedSearchParams>;
|
type PageSearchParams = Promise<ResolvedSearchParams>;
|
||||||
@@ -74,38 +76,45 @@ export default async function Page({ searchParams }: PageProps) {
|
|||||||
payerRows: filterSources.payerRows,
|
payerRows: filterSources.payerRows,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const logoMappings = await prefetchLogoMappings(
|
||||||
|
userId,
|
||||||
|
transactionData.map((t) => t.name),
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="flex flex-col gap-6">
|
<main className="flex flex-col gap-6">
|
||||||
<MonthNavigation />
|
<MonthNavigation />
|
||||||
<TransactionsPage
|
<LogoPrefetchProvider mappings={logoMappings}>
|
||||||
currentUserId={userId}
|
<TransactionsPage
|
||||||
transactions={transactionData}
|
currentUserId={userId}
|
||||||
payerOptions={payerOptions}
|
transactions={transactionData}
|
||||||
splitPayerOptions={splitPayerOptions}
|
payerOptions={payerOptions}
|
||||||
defaultPayerId={defaultPayerId}
|
splitPayerOptions={splitPayerOptions}
|
||||||
accountOptions={accountOptions}
|
defaultPayerId={defaultPayerId}
|
||||||
cardOptions={cardOptions}
|
accountOptions={accountOptions}
|
||||||
categoryOptions={categoryOptions}
|
cardOptions={cardOptions}
|
||||||
payerFilterOptions={payerFilterOptions}
|
categoryOptions={categoryOptions}
|
||||||
categoryFilterOptions={categoryFilterOptions}
|
payerFilterOptions={payerFilterOptions}
|
||||||
accountCardFilterOptions={accountCardFilterOptions}
|
categoryFilterOptions={categoryFilterOptions}
|
||||||
selectedPeriod={selectedPeriod}
|
accountCardFilterOptions={accountCardFilterOptions}
|
||||||
estabelecimentos={estabelecimentos}
|
selectedPeriod={selectedPeriod}
|
||||||
pagination={{
|
estabelecimentos={estabelecimentos}
|
||||||
page: transactionsPage.page,
|
pagination={{
|
||||||
pageSize: transactionsPage.pageSize,
|
page: transactionsPage.page,
|
||||||
totalItems: transactionsPage.totalItems,
|
pageSize: transactionsPage.pageSize,
|
||||||
totalPages: transactionsPage.totalPages,
|
totalItems: transactionsPage.totalItems,
|
||||||
}}
|
totalPages: transactionsPage.totalPages,
|
||||||
exportContext={{
|
}}
|
||||||
source: "transactions",
|
exportContext={{
|
||||||
period: selectedPeriod,
|
source: "transactions",
|
||||||
filters: searchFilters,
|
period: selectedPeriod,
|
||||||
}}
|
filters: searchFilters,
|
||||||
noteAsColumn={userPreferences?.statementNoteAsColumn ?? false}
|
}}
|
||||||
columnOrder={userPreferences?.transactionsColumnOrder ?? null}
|
noteAsColumn={userPreferences?.statementNoteAsColumn ?? false}
|
||||||
attachmentMaxSizeMb={userPreferences?.attachmentMaxSizeMb ?? 50}
|
columnOrder={userPreferences?.transactionsColumnOrder ?? null}
|
||||||
/>
|
attachmentMaxSizeMb={userPreferences?.attachmentMaxSizeMb ?? 50}
|
||||||
|
/>
|
||||||
|
</LogoPrefetchProvider>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import { NavbarShell } from "@/shared/components/navigation/navbar/navbar-shell"
|
|||||||
import { Badge } from "@/shared/components/ui/badge";
|
import { Badge } from "@/shared/components/ui/badge";
|
||||||
import { Button } from "@/shared/components/ui/button";
|
import { Button } from "@/shared/components/ui/button";
|
||||||
import { Card, CardContent } from "@/shared/components/ui/card";
|
import { Card, CardContent } from "@/shared/components/ui/card";
|
||||||
import { DotPattern } from "@/shared/components/ui/dot-pattern";
|
|
||||||
import { getOptionalUserSession } from "@/shared/lib/auth/server";
|
import { getOptionalUserSession } from "@/shared/lib/auth/server";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
@@ -57,7 +56,7 @@ export default async function Page() {
|
|||||||
<a
|
<a
|
||||||
key={href}
|
key={href}
|
||||||
href={href}
|
href={href}
|
||||||
className="rounded-md px-2 py-1.5 text-sm font-medium text-black/75 hover:text-black hover:bg-black/10 transition-colors"
|
className="rounded-md px-2 py-1.5 text-sm font-medium text-black/75 hover:text-black hover:bg-black/10 transition-colors dark:text-white/75 dark:hover:text-white dark:hover:bg-white/10"
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</a>
|
</a>
|
||||||
@@ -70,9 +69,9 @@ export default async function Page() {
|
|||||||
(session?.user ? (
|
(session?.user ? (
|
||||||
<Link prefetch href="/dashboard" className="hidden md:block">
|
<Link prefetch href="/dashboard" className="hidden md:block">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="navbar"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="border-black/20 text-black/80 bg-transparent hover:bg-black/10 hover:text-black shadow-none"
|
className="border border-black/20 dark:border-white/20"
|
||||||
>
|
>
|
||||||
Dashboard
|
Dashboard
|
||||||
</Button>
|
</Button>
|
||||||
@@ -83,7 +82,7 @@ export default async function Page() {
|
|||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="text-black/75 hover:bg-black/10 hover:text-black shadow-none"
|
className="text-black/75 hover:bg-black/10 hover:text-black shadow-none dark:text-white/75 dark:hover:bg-white/10 dark:hover:text-white"
|
||||||
>
|
>
|
||||||
Entrar
|
Entrar
|
||||||
</Button>
|
</Button>
|
||||||
@@ -91,7 +90,7 @@ export default async function Page() {
|
|||||||
<Link href="/signup">
|
<Link href="/signup">
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
className="bg-black/10 border border-black/20 text-black shadow-none hover:bg-black/20 gap-2"
|
className="bg-black/10 border border-black/20 text-black shadow-none hover:bg-black/20 gap-2 dark:bg-white/10 dark:border-white/20 dark:text-white dark:hover:bg-white/20"
|
||||||
>
|
>
|
||||||
Começar
|
Começar
|
||||||
</Button>
|
</Button>
|
||||||
@@ -107,26 +106,14 @@ export default async function Page() {
|
|||||||
|
|
||||||
{/* Hero Section */}
|
{/* Hero Section */}
|
||||||
<section className="relative overflow-hidden pt-14 md:pt-20 lg:pt-24 pb-0">
|
<section className="relative overflow-hidden pt-14 md:pt-20 lg:pt-24 pb-0">
|
||||||
<div className="pointer-events-none absolute inset-x-0 top-0 h-80 overflow-hidden">
|
|
||||||
<DotPattern
|
|
||||||
width={20}
|
|
||||||
height={20}
|
|
||||||
cx={1.25}
|
|
||||||
cy={1.25}
|
|
||||||
cr={1.25}
|
|
||||||
className="text-primary/10 mask-[linear-gradient(to_bottom,black_0%,transparent_100%)]"
|
|
||||||
/>
|
|
||||||
<div className="absolute inset-0 bg-linear-to-b from-primary/6 to-transparent" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="max-w-8xl mx-auto px-4 relative">
|
<div className="max-w-8xl mx-auto px-4 relative">
|
||||||
<div className="mx-auto flex max-w-3xl flex-col items-center text-center gap-5 md:gap-6 pb-10 md:pb-14">
|
<div className="mx-auto flex max-w-4xl flex-col items-center text-center gap-5 md:gap-6 pb-10 md:pb-14">
|
||||||
<Badge variant="outline">
|
<Badge variant="outline">
|
||||||
<RiGithubFill className="size-4 mr-1" />
|
<RiGithubFill className="size-4 mr-1" />
|
||||||
Projeto Open Source
|
Projeto Open Source
|
||||||
</Badge>
|
</Badge>
|
||||||
|
|
||||||
<h1 className="text-3xl sm:text-4xl md:text-5xl lg:text-6xl font-medium tracking-tight">
|
<h1 className="text-3xl sm:text-4xl md:text-5xl lg:text-6xl font-semibold">
|
||||||
Suas finanças,
|
Suas finanças,
|
||||||
<span className="text-primary"> do seu jeito</span>
|
<span className="text-primary"> do seu jeito</span>
|
||||||
</h1>
|
</h1>
|
||||||
@@ -207,7 +194,7 @@ export default async function Page() {
|
|||||||
className="flex flex-col items-center text-center gap-1.5"
|
className="flex flex-col items-center text-center gap-1.5"
|
||||||
>
|
>
|
||||||
<Icon className="size-5" style={{ color: colorVar }} />
|
<Icon className="size-5" style={{ color: colorVar }} />
|
||||||
<span className="text-2xl md:text-3xl font-medium">
|
<span className="text-2xl md:text-3xl font-semibold">
|
||||||
{value}
|
{value}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs md:text-sm text-muted-foreground">
|
<span className="text-xs md:text-sm text-muted-foreground">
|
||||||
@@ -229,7 +216,7 @@ export default async function Page() {
|
|||||||
<Badge variant="outline" className="mb-4">
|
<Badge variant="outline" className="mb-4">
|
||||||
Conheça as telas
|
Conheça as telas
|
||||||
</Badge>
|
</Badge>
|
||||||
<h2 className="text-2xl sm:text-3xl md:text-4xl font-medium tracking-tight mb-3 md:mb-4">
|
<h2 className="text-2xl sm:text-3xl md:text-4xl mb-3 md:mb-4 font-semibold">
|
||||||
Veja o que você pode fazer
|
Veja o que você pode fazer
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-base md:text-lg text-muted-foreground max-w-2xl mx-auto px-4 sm:px-0">
|
<p className="text-base md:text-lg text-muted-foreground max-w-2xl mx-auto px-4 sm:px-0">
|
||||||
@@ -254,7 +241,7 @@ export default async function Page() {
|
|||||||
<Badge variant="outline" className="mb-4">
|
<Badge variant="outline" className="mb-4">
|
||||||
O que tem aqui
|
O que tem aqui
|
||||||
</Badge>
|
</Badge>
|
||||||
<h2 className="text-2xl sm:text-3xl md:text-4xl font-medium tracking-tight mb-3 md:mb-4">
|
<h2 className="text-2xl sm:text-3xl md:text-4xl mb-3 md:mb-4 font-semibold">
|
||||||
Funcionalidades que importam
|
Funcionalidades que importam
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-base md:text-lg text-muted-foreground max-w-2xl mx-auto px-4 sm:px-0">
|
<p className="text-base md:text-lg text-muted-foreground max-w-2xl mx-auto px-4 sm:px-0">
|
||||||
@@ -265,72 +252,34 @@ export default async function Page() {
|
|||||||
</AnimateOnScroll>
|
</AnimateOnScroll>
|
||||||
|
|
||||||
<AnimateOnScroll>
|
<AnimateOnScroll>
|
||||||
<div className="grid gap-4 md:gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
<div className="grid gap-4 md:gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||||
{mainFeatures.map((feature) => (
|
{[...mainFeatures, ...extraFeatures].map((feature) => (
|
||||||
<Card key={feature.title}>
|
<Card key={feature.title}>
|
||||||
<CardContent className="pt-5 pb-5 md:pt-6">
|
<CardContent>
|
||||||
<div className="flex flex-col gap-3 md:gap-4">
|
<div className="flex items-center gap-3 mb-3">
|
||||||
<div
|
<div
|
||||||
className="flex h-11 w-11 md:h-12 md:w-12 items-center justify-center rounded-lg"
|
className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: `color-mix(in oklch, ${feature.colorVar} 14%, transparent)`,
|
backgroundColor: `color-mix(in oklch, ${feature.colorVar} 20%, transparent)`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<feature.icon
|
<feature.icon
|
||||||
className="size-[22px] md:size-6"
|
className="size-5"
|
||||||
style={{ color: feature.colorVar }}
|
style={{ color: "var(--foreground)" }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<h3 className="font-semibold text-base leading-tight">
|
||||||
<h3 className="font-medium text-base md:text-lg mb-1.5 md:mb-2">
|
{feature.title}
|
||||||
{feature.title}
|
</h3>
|
||||||
</h3>
|
|
||||||
<p className="text-sm text-muted-foreground leading-relaxed">
|
|
||||||
{feature.description}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<p className="text-sm text-muted-foreground leading-relaxed">
|
||||||
|
{feature.description}
|
||||||
|
</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</AnimateOnScroll>
|
</AnimateOnScroll>
|
||||||
|
|
||||||
<AnimateOnScroll>
|
|
||||||
<div className="mt-8 md:mt-12">
|
|
||||||
<h3 className="text-sm font-medium text-center mb-4 md:mb-6 text-muted-foreground">
|
|
||||||
Também inclui
|
|
||||||
</h3>
|
|
||||||
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
|
||||||
{extraFeatures.map((feature) => (
|
|
||||||
<div
|
|
||||||
key={feature.title}
|
|
||||||
className="flex items-start gap-3 rounded-lg border bg-card p-3 md:p-4"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="flex h-9 w-9 shrink-0 items-center justify-center rounded-md"
|
|
||||||
style={{
|
|
||||||
backgroundColor: `color-mix(in oklch, ${feature.colorVar} 14%, transparent)`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<feature.icon
|
|
||||||
className="size-[18px]"
|
|
||||||
style={{ color: feature.colorVar }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="min-w-0">
|
|
||||||
<h4 className="font-medium text-sm mb-0.5">
|
|
||||||
{feature.title}
|
|
||||||
</h4>
|
|
||||||
<p className="text-xs text-muted-foreground leading-relaxed">
|
|
||||||
{feature.description}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</AnimateOnScroll>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -346,7 +295,7 @@ export default async function Page() {
|
|||||||
<RiSmartphoneLine className="size-3.5 mr-1" />
|
<RiSmartphoneLine className="size-3.5 mr-1" />
|
||||||
Mobile
|
Mobile
|
||||||
</Badge>
|
</Badge>
|
||||||
<h2 className="text-2xl sm:text-3xl md:text-4xl font-medium tracking-tight mb-3 md:mb-4">
|
<h2 className="text-2xl sm:text-3xl md:text-4xl mb-3 md:mb-4 font-semibold">
|
||||||
Use o OpenMonetis no celular sem perder o fluxo
|
Use o OpenMonetis no celular sem perder o fluxo
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-base md:text-lg text-muted-foreground max-w-2xl mx-auto px-4 sm:px-0">
|
<p className="text-base md:text-lg text-muted-foreground max-w-2xl mx-auto px-4 sm:px-0">
|
||||||
@@ -396,14 +345,14 @@ export default async function Page() {
|
|||||||
{pwaHighlights.map((item) => (
|
{pwaHighlights.map((item) => (
|
||||||
<li key={item.title} className="flex items-start gap-3">
|
<li key={item.title} className="flex items-start gap-3">
|
||||||
<div
|
<div
|
||||||
className="mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md"
|
className="mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: `color-mix(in oklch, ${item.colorVar} 14%, transparent)`,
|
backgroundColor: `color-mix(in oklch, ${item.colorVar} 20%, transparent)`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<item.icon
|
<item.icon
|
||||||
className="size-[15px]"
|
className="size-[15px]"
|
||||||
style={{ color: item.colorVar }}
|
style={{ color: "var(--foreground)" }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm">
|
<p className="text-sm">
|
||||||
@@ -438,17 +387,19 @@ export default async function Page() {
|
|||||||
pré-lançamentos automaticamente para você revisar na inbox.
|
pré-lançamentos automaticamente para você revisar na inbox.
|
||||||
</p>
|
</p>
|
||||||
<ol className="space-y-3 mb-6">
|
<ol className="space-y-3 mb-6">
|
||||||
{companionSteps.map((step, index) => (
|
{companionSteps.map((step) => (
|
||||||
<li key={step.title} className="flex items-start gap-3">
|
<li key={step.title} className="flex items-start gap-3">
|
||||||
<span
|
<div
|
||||||
className="mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-medium"
|
className="mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: `color-mix(in oklch, ${step.colorVar} 14%, transparent)`,
|
backgroundColor: `color-mix(in oklch, ${step.colorVar} 20%, transparent)`,
|
||||||
color: step.colorVar,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{index + 1}
|
<step.icon
|
||||||
</span>
|
className="size-3.5"
|
||||||
|
style={{ color: "var(--foreground)" }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<p className="text-sm">
|
<p className="text-sm">
|
||||||
<span className="font-medium">{step.title}</span>
|
<span className="font-medium">{step.title}</span>
|
||||||
<span className="text-muted-foreground">
|
<span className="text-muted-foreground">
|
||||||
@@ -529,7 +480,7 @@ export default async function Page() {
|
|||||||
<Badge variant="outline" className="mb-4">
|
<Badge variant="outline" className="mb-4">
|
||||||
Stack técnica
|
Stack técnica
|
||||||
</Badge>
|
</Badge>
|
||||||
<h2 className="text-2xl sm:text-3xl md:text-4xl font-medium tracking-tight mb-3 md:mb-4">
|
<h2 className="text-2xl sm:text-3xl md:text-4xl mb-3 md:mb-4 font-semibold">
|
||||||
O que roda por baixo
|
O que roda por baixo
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-base md:text-lg text-muted-foreground max-w-2xl mx-auto px-4 sm:px-0">
|
<p className="text-base md:text-lg text-muted-foreground max-w-2xl mx-auto px-4 sm:px-0">
|
||||||
@@ -545,18 +496,18 @@ export default async function Page() {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="flex items-start gap-4">
|
<div className="flex items-start gap-4">
|
||||||
<div
|
<div
|
||||||
className="flex h-11 w-11 shrink-0 items-center justify-center rounded-lg"
|
className="flex h-11 w-11 shrink-0 items-center justify-center rounded-full"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: `color-mix(in oklch, ${item.colorVar} 14%, transparent)`,
|
backgroundColor: `color-mix(in oklch, ${item.colorVar} 20%, transparent)`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<item.icon
|
<item.icon
|
||||||
className="size-6"
|
className="size-6"
|
||||||
style={{ color: item.colorVar }}
|
style={{ color: "var(--foreground)" }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 className="font-medium text-base md:text-lg mb-1.5 md:mb-2">
|
<h3 className="font-semibold text-base md:text-lg mb-1.5 md:mb-2">
|
||||||
{item.title}
|
{item.title}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-sm text-muted-foreground mb-2 md:mb-3">
|
<p className="text-sm text-muted-foreground mb-2 md:mb-3">
|
||||||
@@ -582,7 +533,7 @@ export default async function Page() {
|
|||||||
<Badge variant="outline" className="mb-4">
|
<Badge variant="outline" className="mb-4">
|
||||||
Como usar
|
Como usar
|
||||||
</Badge>
|
</Badge>
|
||||||
<h2 className="text-2xl sm:text-3xl md:text-4xl font-medium tracking-tight mb-3 md:mb-4">
|
<h2 className="text-2xl sm:text-3xl md:text-4xl mb-3 md:mb-4 font-semibold">
|
||||||
Rode no seu computador
|
Rode no seu computador
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-base md:text-lg text-muted-foreground px-4 sm:px-0">
|
<p className="text-base md:text-lg text-muted-foreground px-4 sm:px-0">
|
||||||
@@ -617,7 +568,7 @@ export default async function Page() {
|
|||||||
<Badge variant="outline" className="mb-4">
|
<Badge variant="outline" className="mb-4">
|
||||||
Para quem é?
|
Para quem é?
|
||||||
</Badge>
|
</Badge>
|
||||||
<h2 className="text-2xl sm:text-3xl md:text-4xl font-medium tracking-tight mb-3 md:mb-4">
|
<h2 className="text-2xl sm:text-3xl md:text-4xl mb-3 md:mb-4 font-semibold">
|
||||||
Feito para quem gosta de controle
|
Feito para quem gosta de controle
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-base md:text-lg text-muted-foreground px-4 sm:px-0">
|
<p className="text-base md:text-lg text-muted-foreground px-4 sm:px-0">
|
||||||
@@ -633,18 +584,18 @@ export default async function Page() {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="flex gap-3 md:gap-4">
|
<div className="flex gap-3 md:gap-4">
|
||||||
<div
|
<div
|
||||||
className="flex h-9 w-9 md:h-10 md:w-10 shrink-0 items-center justify-center rounded-lg"
|
className="flex h-9 w-9 md:h-10 md:w-10 shrink-0 items-center justify-center rounded-full"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: `color-mix(in oklch, ${item.colorVar} 14%, transparent)`,
|
backgroundColor: `color-mix(in oklch, ${item.colorVar} 20%, transparent)`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<item.icon
|
<item.icon
|
||||||
className="size-[18px] md:size-5"
|
className="size-[18px] md:size-5"
|
||||||
style={{ color: item.colorVar }}
|
style={{ color: "var(--foreground)" }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 className="font-medium mb-1">{item.title}</h3>
|
<h3 className="font-semibold mb-1">{item.title}</h3>
|
||||||
<p className="text-xs sm:text-sm text-muted-foreground">
|
<p className="text-xs sm:text-sm text-muted-foreground">
|
||||||
{item.description}
|
{item.description}
|
||||||
</p>
|
</p>
|
||||||
@@ -664,7 +615,7 @@ export default async function Page() {
|
|||||||
<div className="max-w-8xl mx-auto px-4">
|
<div className="max-w-8xl mx-auto px-4">
|
||||||
<AnimateOnScroll>
|
<AnimateOnScroll>
|
||||||
<div className="mx-auto max-w-4xl rounded-2xl border bg-card px-8 py-12 md:py-16 text-center">
|
<div className="mx-auto max-w-4xl rounded-2xl border bg-card px-8 py-12 md:py-16 text-center">
|
||||||
<h2 className="text-2xl sm:text-3xl md:text-4xl font-medium tracking-tight mb-3 md:mb-4">
|
<h2 className="text-2xl sm:text-3xl md:text-4xl mb-3 md:mb-4 font-semibold">
|
||||||
Pronto para testar?
|
Pronto para testar?
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-base md:text-lg text-muted-foreground mb-6 md:mb-8">
|
<p className="text-base md:text-lg text-muted-foreground mb-6 md:mb-8">
|
||||||
@@ -715,7 +666,7 @@ export default async function Page() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h3 className="font-medium mb-3 md:mb-4">Projeto</h3>
|
<h3 className="font-semibold mb-3 md:mb-4">Projeto</h3>
|
||||||
<ul className="space-y-2.5 md:space-y-3 text-sm text-muted-foreground">
|
<ul className="space-y-2.5 md:space-y-3 text-sm text-muted-foreground">
|
||||||
<li>
|
<li>
|
||||||
<Link
|
<Link
|
||||||
@@ -749,7 +700,7 @@ export default async function Page() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h3 className="font-medium mb-3 md:mb-4">Companion</h3>
|
<h3 className="font-semibold mb-3 md:mb-4">Companion</h3>
|
||||||
<ul className="space-y-2.5 md:space-y-3 text-sm text-muted-foreground">
|
<ul className="space-y-2.5 md:space-y-3 text-sm text-muted-foreground">
|
||||||
<li>
|
<li>
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
29
src/app/api/logo/mapping/route.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import { getOptionalUserSession } from "@/shared/lib/auth/server";
|
||||||
|
import { fetchEstablishmentLogoDomain } from "@/shared/lib/logo/establishment-logo-queries";
|
||||||
|
import { buildLogoDevUrl } from "@/shared/lib/logo/server";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/logo/mapping?name={name}
|
||||||
|
*
|
||||||
|
* Retorna o domínio Logo.dev salvo pelo usuário para um estabelecimento,
|
||||||
|
* junto com a `logoUrl` final (construída server-side com o token). O
|
||||||
|
* cliente usa `logoUrl` diretamente — sem precisar conhecer o token.
|
||||||
|
*/
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
const session = await getOptionalUserSession();
|
||||||
|
if (!session) {
|
||||||
|
return NextResponse.json({ domain: null, logoUrl: null }, { status: 200 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const name = searchParams.get("name")?.trim();
|
||||||
|
|
||||||
|
if (!name) {
|
||||||
|
return NextResponse.json({ domain: null, logoUrl: null }, { status: 200 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const domain = await fetchEstablishmentLogoDomain(session.user.id, name);
|
||||||
|
const logoUrl = buildLogoDevUrl(domain);
|
||||||
|
return NextResponse.json({ domain, logoUrl });
|
||||||
|
}
|
||||||
87
src/app/api/logo/search/route.ts
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import { getOptionalUserSession } from "@/shared/lib/auth/server";
|
||||||
|
import { buildLogoDevUrl } from "@/shared/lib/logo/server";
|
||||||
|
|
||||||
|
const LOGO_DEV_SEARCH_URL = "https://api.logo.dev/search";
|
||||||
|
|
||||||
|
interface LogoResult {
|
||||||
|
name: string;
|
||||||
|
domain: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LogoResultWithUrl extends LogoResult {
|
||||||
|
logoUrl: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function searchByStrategy(
|
||||||
|
q: string,
|
||||||
|
strategy: "match" | "typeahead",
|
||||||
|
secretKey: string,
|
||||||
|
): Promise<LogoResult[]> {
|
||||||
|
try {
|
||||||
|
const url = `${LOGO_DEV_SEARCH_URL}?q=${encodeURIComponent(q)}&strategy=${strategy}`;
|
||||||
|
const res = await fetch(url, {
|
||||||
|
headers: { Authorization: `Bearer ${secretKey}` },
|
||||||
|
next: { revalidate: 3600 },
|
||||||
|
});
|
||||||
|
if (!res.ok) return [];
|
||||||
|
const data = await res.json();
|
||||||
|
return Array.isArray(data) ? data : [];
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/logo/search?q={name}
|
||||||
|
*
|
||||||
|
* Proxy seguro para a Logo.dev Brand Search API.
|
||||||
|
* Faz duas buscas paralelas (match + typeahead) e retorna até 20 resultados únicos.
|
||||||
|
* Usa LOGO_DEV_SECRET_KEY server-side — nunca exposta ao cliente.
|
||||||
|
*/
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
const session = await getOptionalUserSession();
|
||||||
|
if (!session) {
|
||||||
|
return NextResponse.json({ error: "Não autorizado." }, { status: 401 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const q = searchParams.get("q")?.trim();
|
||||||
|
|
||||||
|
if (!q) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Parâmetro q obrigatório." },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const secretKey = process.env.LOGO_DEV_SECRET_KEY;
|
||||||
|
if (!secretKey) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Logo.dev não configurado." },
|
||||||
|
{ status: 503 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Duas buscas paralelas para maximizar resultados (cada uma retorna até 10)
|
||||||
|
const [matchResults, typeaheadResults] = await Promise.all([
|
||||||
|
searchByStrategy(q, "match", secretKey),
|
||||||
|
searchByStrategy(q, "typeahead", secretKey),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Mescla e deduplica por domain, mantendo ordem (match tem prioridade)
|
||||||
|
const seen = new Set<string>();
|
||||||
|
const merged: LogoResultWithUrl[] = [];
|
||||||
|
|
||||||
|
for (const result of [...matchResults, ...typeaheadResults]) {
|
||||||
|
if (!seen.has(result.domain)) {
|
||||||
|
seen.add(result.domain);
|
||||||
|
// logoUrl é construída server-side com o token — o cliente nunca
|
||||||
|
// precisa conhecer LOGO_DEV_TOKEN para renderizar a imagem.
|
||||||
|
merged.push({ ...result, logoUrl: buildLogoDevUrl(result.domain) });
|
||||||
|
if (merged.length >= 20) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(merged);
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
:root {
|
:root {
|
||||||
--background: oklch(97.412% 0.00332 67.032);
|
--background: oklch(97.412% 0.00332 67.032);
|
||||||
--foreground: oklch(27% 0.008 45);
|
--foreground: oklch(27% 0.008 45);
|
||||||
--card: oklch(99% 0.002 67);
|
--card: oklch(100% 0 0);
|
||||||
--card-foreground: var(--foreground);
|
--card-foreground: var(--foreground);
|
||||||
--popover: oklch(100% 0 0);
|
--popover: oklch(100% 0 0);
|
||||||
--popover-foreground: var(--foreground);
|
--popover-foreground: var(--foreground);
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
--destructive: oklch(55% 0.22 27);
|
--destructive: oklch(55% 0.22 27);
|
||||||
--destructive-foreground: oklch(98% 0.005 30);
|
--destructive-foreground: oklch(98% 0.005 30);
|
||||||
|
|
||||||
--border: oklch(90.274% 0.01362 60.342);
|
--border: oklch(92.323% 0.01276 63.703);
|
||||||
--input: var(--border);
|
--input: var(--border);
|
||||||
--ring: var(--primary);
|
--ring: var(--primary);
|
||||||
|
|
||||||
@@ -57,10 +57,6 @@
|
|||||||
--data-4: oklch(74% 0.18 55); /* âmbar */
|
--data-4: oklch(74% 0.18 55); /* âmbar */
|
||||||
--data-5: oklch(78% 0.16 68); /* âmbar-dourado */
|
--data-5: oklch(78% 0.16 68); /* âmbar-dourado */
|
||||||
--data-6: oklch(76% 0.15 82); /* amarelo-quente */
|
--data-6: oklch(76% 0.15 82); /* amarelo-quente */
|
||||||
--data-7: oklch(70% 0.17 95); /* amarelo-lima */
|
|
||||||
--data-8: oklch(65% 0.18 108); /* lima-verde */
|
|
||||||
--data-9: oklch(62% 0.17 120); /* verde-oliva claro */
|
|
||||||
--data-10: oklch(56% 0.15 10); /* terracota escuro */
|
|
||||||
|
|
||||||
--sidebar: oklch(99.3% 0.0015 75);
|
--sidebar: oklch(99.3% 0.0015 75);
|
||||||
--sidebar-foreground: var(--foreground);
|
--sidebar-foreground: var(--foreground);
|
||||||
@@ -71,7 +67,7 @@
|
|||||||
--sidebar-border: oklch(91% 0.004 70);
|
--sidebar-border: oklch(91% 0.004 70);
|
||||||
--sidebar-ring: var(--primary);
|
--sidebar-ring: var(--primary);
|
||||||
|
|
||||||
--radius: 0.625rem;
|
--radius: 0.7rem;
|
||||||
|
|
||||||
--shadow-2xs: 0 1px 2px 0px oklch(35% 0.02 45 / 0.04);
|
--shadow-2xs: 0 1px 2px 0px oklch(35% 0.02 45 / 0.04);
|
||||||
--shadow-xs: 0 1px 3px 0px oklch(35% 0.02 45 / 0.06);
|
--shadow-xs: 0 1px 3px 0px oklch(35% 0.02 45 / 0.06);
|
||||||
@@ -94,7 +90,7 @@
|
|||||||
.dark {
|
.dark {
|
||||||
--background: oklch(18% 0.004 55);
|
--background: oklch(18% 0.004 55);
|
||||||
--foreground: oklch(93% 0.008 80);
|
--foreground: oklch(93% 0.008 80);
|
||||||
--card: oklch(21.5% 0.004 55);
|
--card: oklch(21.531% 0.00369 48.293);
|
||||||
--card-foreground: var(--foreground);
|
--card-foreground: var(--foreground);
|
||||||
--popover: oklch(24% 0.004 55);
|
--popover: oklch(24% 0.004 55);
|
||||||
--popover-foreground: var(--foreground);
|
--popover-foreground: var(--foreground);
|
||||||
@@ -120,7 +116,7 @@
|
|||||||
--destructive: oklch(62% 0.2 28);
|
--destructive: oklch(62% 0.2 28);
|
||||||
--destructive-foreground: oklch(98% 0.005 30);
|
--destructive-foreground: oklch(98% 0.005 30);
|
||||||
|
|
||||||
--border: oklch(31% 0.004 55);
|
--border: oklch(28% 0.0035 55);
|
||||||
--input: var(--border);
|
--input: var(--border);
|
||||||
--ring: var(--primary);
|
--ring: var(--primary);
|
||||||
|
|
||||||
@@ -141,10 +137,6 @@
|
|||||||
--data-4: oklch(81% 0.18 55);
|
--data-4: oklch(81% 0.18 55);
|
||||||
--data-5: oklch(84% 0.16 68);
|
--data-5: oklch(84% 0.16 68);
|
||||||
--data-6: oklch(82% 0.15 82);
|
--data-6: oklch(82% 0.15 82);
|
||||||
--data-7: oklch(77% 0.17 95);
|
|
||||||
--data-8: oklch(72% 0.18 108);
|
|
||||||
--data-9: oklch(69% 0.17 120);
|
|
||||||
--data-10: oklch(63% 0.15 10);
|
|
||||||
|
|
||||||
--sidebar: oklch(15.5% 0.004 55);
|
--sidebar: oklch(15.5% 0.004 55);
|
||||||
--sidebar-foreground: var(--foreground);
|
--sidebar-foreground: var(--foreground);
|
||||||
@@ -155,7 +147,7 @@
|
|||||||
--sidebar-border: oklch(30% 0.004 55);
|
--sidebar-border: oklch(30% 0.004 55);
|
||||||
--sidebar-ring: var(--primary);
|
--sidebar-ring: var(--primary);
|
||||||
|
|
||||||
--radius: 0.625rem;
|
--radius: 0.7rem;
|
||||||
|
|
||||||
--shadow-2xs: 0 1px 2px 0px oklch(0% 0 0 / 0.3);
|
--shadow-2xs: 0 1px 2px 0px oklch(0% 0 0 / 0.3);
|
||||||
--shadow-xs: 0 1px 3px 0px oklch(0% 0 0 / 0.4);
|
--shadow-xs: 0 1px 3px 0px oklch(0% 0 0 / 0.4);
|
||||||
@@ -177,7 +169,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
--default-font-family: var(--font-america);
|
--default-font-family: var(--font-inter);
|
||||||
--color-background: var(--background);
|
--color-background: var(--background);
|
||||||
--color-foreground: var(--foreground);
|
--color-foreground: var(--foreground);
|
||||||
--color-card: var(--card);
|
--color-card: var(--card);
|
||||||
@@ -354,3 +346,22 @@
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
animation: blink-out 6s ease-in-out infinite;
|
animation: blink-out 6s ease-in-out infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes blob {
|
||||||
|
0% { transform: translate(0px, 0px) scale(1); }
|
||||||
|
33% { transform: translate(30px, -50px) scale(1.1); }
|
||||||
|
66% { transform: translate(-20px, 20px) scale(0.9); }
|
||||||
|
100% { transform: translate(0px, 0px) scale(1); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.animate-blob {
|
||||||
|
animation: blob 10s infinite alternate ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.animation-delay-2000 {
|
||||||
|
animation-delay: 2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.animation-delay-4000 {
|
||||||
|
animation-delay: 4s;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { QueryProvider } from "@/shared/components/providers/query-provider";
|
|||||||
import { ThemeProvider } from "@/shared/components/providers/theme-provider";
|
import { ThemeProvider } from "@/shared/components/providers/theme-provider";
|
||||||
import { Toaster } from "@/shared/components/ui/sonner";
|
import { Toaster } from "@/shared/components/ui/sonner";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
import { america } from "@/public/fonts/font_index";
|
import { inter } from "@/public/fonts/font_index";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: {
|
title: {
|
||||||
@@ -24,19 +24,23 @@ export default function RootLayout({
|
|||||||
<html
|
<html
|
||||||
data-scroll-behavior="smooth"
|
data-scroll-behavior="smooth"
|
||||||
lang="pt-BR"
|
lang="pt-BR"
|
||||||
className={`${america.variable} ${america.className} `}
|
className={`${inter.variable}`}
|
||||||
suppressHydrationWarning
|
suppressHydrationWarning
|
||||||
>
|
>
|
||||||
<head>
|
<head>
|
||||||
<meta name="apple-mobile-web-app-title" content="OpenMonetis" />
|
<meta name="apple-mobile-web-app-title" content="OpenMonetis" />
|
||||||
<script
|
{process.env.UMAMI_URL && process.env.UMAMI_WEBSITE_ID && (
|
||||||
defer
|
<script
|
||||||
src="https://umami.felipecoutinho.com/script.js"
|
defer
|
||||||
data-website-id="ea438854-a014-42ea-b416-0a8321471f0f"
|
src={`${process.env.UMAMI_URL}/script.js`}
|
||||||
data-domains="openmonetis.com"
|
data-website-id={process.env.UMAMI_WEBSITE_ID}
|
||||||
/>
|
{...(process.env.UMAMI_DOMAINS
|
||||||
|
? { "data-domains": process.env.UMAMI_DOMAINS }
|
||||||
|
: {})}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</head>
|
</head>
|
||||||
<body className="antialiased" suppressHydrationWarning>
|
<body className="subpixel-antialiased" suppressHydrationWarning>
|
||||||
<ThemeProvider attribute="class" defaultTheme="light">
|
<ThemeProvider attribute="class" defaultTheme="light">
|
||||||
<QueryProvider>
|
<QueryProvider>
|
||||||
<Suspense>{children}</Suspense>
|
<Suspense>{children}</Suspense>
|
||||||
|
|||||||
361
src/db/schema.ts
@@ -32,57 +32,69 @@ export const user = pgTable("user", {
|
|||||||
}).notNull(),
|
}).notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const account = pgTable("account", {
|
export const account = pgTable(
|
||||||
id: text("id").primaryKey(),
|
"account",
|
||||||
accountId: text("accountId").notNull(),
|
{
|
||||||
providerId: text("providerId").notNull(),
|
id: text("id").primaryKey(),
|
||||||
userId: text("userId")
|
accountId: text("accountId").notNull(),
|
||||||
.notNull()
|
providerId: text("providerId").notNull(),
|
||||||
.references(() => user.id, { onDelete: "cascade" }),
|
userId: text("userId")
|
||||||
accessToken: text("accessToken"),
|
.notNull()
|
||||||
refreshToken: text("refreshToken"),
|
.references(() => user.id, { onDelete: "cascade" }),
|
||||||
idToken: text("idToken"),
|
accessToken: text("accessToken"),
|
||||||
accessTokenExpiresAt: timestamp("accessTokenExpiresAt", {
|
refreshToken: text("refreshToken"),
|
||||||
mode: "date",
|
idToken: text("idToken"),
|
||||||
withTimezone: true,
|
accessTokenExpiresAt: timestamp("accessTokenExpiresAt", {
|
||||||
|
mode: "date",
|
||||||
|
withTimezone: true,
|
||||||
|
}),
|
||||||
|
refreshTokenExpiresAt: timestamp("refreshTokenExpiresAt", {
|
||||||
|
mode: "date",
|
||||||
|
withTimezone: true,
|
||||||
|
}),
|
||||||
|
scope: text("scope"),
|
||||||
|
password: text("password"),
|
||||||
|
createdAt: timestamp("createdAt", {
|
||||||
|
mode: "date",
|
||||||
|
withTimezone: true,
|
||||||
|
}).notNull(),
|
||||||
|
updatedAt: timestamp("updatedAt", {
|
||||||
|
mode: "date",
|
||||||
|
withTimezone: true,
|
||||||
|
}).notNull(),
|
||||||
|
},
|
||||||
|
(table) => ({
|
||||||
|
userIdIdx: index("account_user_id_idx").on(table.userId),
|
||||||
}),
|
}),
|
||||||
refreshTokenExpiresAt: timestamp("refreshTokenExpiresAt", {
|
);
|
||||||
mode: "date",
|
|
||||||
withTimezone: true,
|
|
||||||
}),
|
|
||||||
scope: text("scope"),
|
|
||||||
password: text("password"),
|
|
||||||
createdAt: timestamp("createdAt", {
|
|
||||||
mode: "date",
|
|
||||||
withTimezone: true,
|
|
||||||
}).notNull(),
|
|
||||||
updatedAt: timestamp("updatedAt", {
|
|
||||||
mode: "date",
|
|
||||||
withTimezone: true,
|
|
||||||
}).notNull(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const session = pgTable("session", {
|
export const session = pgTable(
|
||||||
id: text("id").primaryKey(),
|
"session",
|
||||||
expiresAt: timestamp("expiresAt", {
|
{
|
||||||
mode: "date",
|
id: text("id").primaryKey(),
|
||||||
withTimezone: true,
|
expiresAt: timestamp("expiresAt", {
|
||||||
}).notNull(),
|
mode: "date",
|
||||||
token: text("token").notNull().unique(),
|
withTimezone: true,
|
||||||
createdAt: timestamp("createdAt", {
|
}).notNull(),
|
||||||
mode: "date",
|
token: text("token").notNull().unique(),
|
||||||
withTimezone: true,
|
createdAt: timestamp("createdAt", {
|
||||||
}).notNull(),
|
mode: "date",
|
||||||
updatedAt: timestamp("updatedAt", {
|
withTimezone: true,
|
||||||
mode: "date",
|
}).notNull(),
|
||||||
withTimezone: true,
|
updatedAt: timestamp("updatedAt", {
|
||||||
}).notNull(),
|
mode: "date",
|
||||||
ipAddress: text("ipAddress"),
|
withTimezone: true,
|
||||||
userAgent: text("userAgent"),
|
}).notNull(),
|
||||||
userId: text("userId")
|
ipAddress: text("ipAddress"),
|
||||||
.notNull()
|
userAgent: text("userAgent"),
|
||||||
.references(() => user.id, { onDelete: "cascade" }),
|
userId: text("userId")
|
||||||
});
|
.notNull()
|
||||||
|
.references(() => user.id, { onDelete: "cascade" }),
|
||||||
|
},
|
||||||
|
(table) => ({
|
||||||
|
userIdIdx: index("session_user_id_idx").on(table.userId),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
export const verification = pgTable("verification", {
|
export const verification = pgTable("verification", {
|
||||||
id: text("id").primaryKey(),
|
id: text("id").primaryKey(),
|
||||||
@@ -104,24 +116,30 @@ export const verification = pgTable("verification", {
|
|||||||
|
|
||||||
// ===================== PASSKEY (WebAuthn) =====================
|
// ===================== PASSKEY (WebAuthn) =====================
|
||||||
|
|
||||||
export const passkey = pgTable("passkey", {
|
export const passkey = pgTable(
|
||||||
id: text("id").primaryKey(),
|
"passkey",
|
||||||
name: text("name"),
|
{
|
||||||
publicKey: text("publicKey").notNull(),
|
id: text("id").primaryKey(),
|
||||||
userId: text("userId")
|
name: text("name"),
|
||||||
.notNull()
|
publicKey: text("publicKey").notNull(),
|
||||||
.references(() => user.id, { onDelete: "cascade" }),
|
userId: text("userId")
|
||||||
credentialID: text("credentialID").notNull(),
|
.notNull()
|
||||||
counter: integer("counter").notNull(),
|
.references(() => user.id, { onDelete: "cascade" }),
|
||||||
deviceType: text("deviceType").notNull(),
|
credentialID: text("credentialID").notNull(),
|
||||||
backedUp: boolean("backedUp").notNull(),
|
counter: integer("counter").notNull(),
|
||||||
transports: text("transports"),
|
deviceType: text("deviceType").notNull(),
|
||||||
aaguid: text("aaguid"),
|
backedUp: boolean("backedUp").notNull(),
|
||||||
createdAt: timestamp("createdAt", {
|
transports: text("transports"),
|
||||||
mode: "date",
|
aaguid: text("aaguid"),
|
||||||
withTimezone: true,
|
createdAt: timestamp("createdAt", {
|
||||||
|
mode: "date",
|
||||||
|
withTimezone: true,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
(table) => ({
|
||||||
|
userIdIdx: index("passkey_user_id_idx").on(table.userId),
|
||||||
}),
|
}),
|
||||||
});
|
);
|
||||||
|
|
||||||
export const userPreferences = pgTable("preferencias_usuario", {
|
export const userPreferences = pgTable("preferencias_usuario", {
|
||||||
id: uuid("id").primaryKey().default(sql`gen_random_uuid()`),
|
id: uuid("id").primaryKey().default(sql`gen_random_uuid()`),
|
||||||
@@ -157,39 +175,30 @@ export const userPreferences = pgTable("preferencias_usuario", {
|
|||||||
|
|
||||||
// ===================== PUBLIC TABLES =====================
|
// ===================== PUBLIC TABLES =====================
|
||||||
|
|
||||||
export const financialAccounts = pgTable(
|
export const financialAccounts = pgTable("contas", {
|
||||||
"contas",
|
id: uuid("id").primaryKey().default(sql`gen_random_uuid()`),
|
||||||
{
|
name: text("nome").notNull(),
|
||||||
id: uuid("id").primaryKey().default(sql`gen_random_uuid()`),
|
accountType: text("tipo_conta").notNull(),
|
||||||
name: text("nome").notNull(),
|
note: text("anotacao"),
|
||||||
accountType: text("tipo_conta").notNull(),
|
status: text("status").notNull(),
|
||||||
note: text("anotacao"),
|
logo: text("logo").notNull(),
|
||||||
status: text("status").notNull(),
|
initialBalance: numeric("saldo_inicial", { precision: 12, scale: 2 })
|
||||||
logo: text("logo").notNull(),
|
.notNull()
|
||||||
initialBalance: numeric("saldo_inicial", { precision: 12, scale: 2 })
|
.default("0"),
|
||||||
.notNull()
|
excludeFromBalance: boolean("excluir_do_saldo").notNull().default(false),
|
||||||
.default("0"),
|
excludeInitialBalanceFromIncome: boolean("excluir_saldo_inicial_receitas")
|
||||||
excludeFromBalance: boolean("excluir_do_saldo").notNull().default(false),
|
.notNull()
|
||||||
excludeInitialBalanceFromIncome: boolean("excluir_saldo_inicial_receitas")
|
.default(false),
|
||||||
.notNull()
|
userId: text("user_id")
|
||||||
.default(false),
|
.notNull()
|
||||||
userId: text("user_id")
|
.references(() => user.id, { onDelete: "cascade" }),
|
||||||
.notNull()
|
createdAt: timestamp("created_at", {
|
||||||
.references(() => user.id, { onDelete: "cascade" }),
|
mode: "date",
|
||||||
createdAt: timestamp("created_at", {
|
withTimezone: true,
|
||||||
mode: "date",
|
})
|
||||||
withTimezone: true,
|
.notNull()
|
||||||
})
|
.defaultNow(),
|
||||||
.notNull()
|
});
|
||||||
.defaultNow(),
|
|
||||||
},
|
|
||||||
(table) => ({
|
|
||||||
userIdStatusIdx: index("contas_user_id_status_idx").on(
|
|
||||||
table.userId,
|
|
||||||
table.status,
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
export const categories = pgTable(
|
export const categories = pgTable(
|
||||||
"categorias",
|
"categorias",
|
||||||
@@ -248,14 +257,6 @@ export const payers = pgTable(
|
|||||||
uniqueShareCode: uniqueIndex("pagadores_share_code_key").on(
|
uniqueShareCode: uniqueIndex("pagadores_share_code_key").on(
|
||||||
table.shareCode,
|
table.shareCode,
|
||||||
),
|
),
|
||||||
userIdStatusIdx: index("pagadores_user_id_status_idx").on(
|
|
||||||
table.userId,
|
|
||||||
table.status,
|
|
||||||
),
|
|
||||||
userIdRoleIdx: index("pagadores_user_id_role_idx").on(
|
|
||||||
table.userId,
|
|
||||||
table.role,
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -285,6 +286,12 @@ export const payerShares = pgTable(
|
|||||||
table.payerId,
|
table.payerId,
|
||||||
table.sharedWithUserId,
|
table.sharedWithUserId,
|
||||||
),
|
),
|
||||||
|
sharedWithUserIdIdx: index(
|
||||||
|
"compartilhamentos_pagador_shared_with_user_id_idx",
|
||||||
|
).on(table.sharedWithUserId),
|
||||||
|
createdByUserIdIdx: index(
|
||||||
|
"compartilhamentos_pagador_created_by_user_id_idx",
|
||||||
|
).on(table.createdByUserId),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -317,10 +324,7 @@ export const cards = pgTable(
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
userIdStatusIdx: index("cartoes_user_id_status_idx").on(
|
accountIdIdx: index("cartoes_conta_id_idx").on(table.accountId),
|
||||||
table.userId,
|
|
||||||
table.status,
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -387,26 +391,33 @@ export const budgets = pgTable(
|
|||||||
userIdCategoryIdPeriodUnique: uniqueIndex(
|
userIdCategoryIdPeriodUnique: uniqueIndex(
|
||||||
"orcamentos_user_id_categoria_id_periodo_key",
|
"orcamentos_user_id_categoria_id_periodo_key",
|
||||||
).on(table.userId, table.categoryId, table.period),
|
).on(table.userId, table.categoryId, table.period),
|
||||||
|
categoryIdIdx: index("orcamentos_categoria_id_idx").on(table.categoryId),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
export const notes = pgTable("anotacoes", {
|
export const notes = pgTable(
|
||||||
id: uuid("id").primaryKey().default(sql`gen_random_uuid()`),
|
"anotacoes",
|
||||||
title: text("titulo"),
|
{
|
||||||
description: text("descricao"),
|
id: uuid("id").primaryKey().default(sql`gen_random_uuid()`),
|
||||||
type: text("tipo").notNull().default("nota"), // "nota" ou "tarefa"
|
title: text("titulo"),
|
||||||
tasks: text("tasks"), // JSON stringificado com array de tarefas
|
description: text("descricao"),
|
||||||
archived: boolean("arquivada").notNull().default(false),
|
type: text("tipo").notNull().default("nota"), // "nota" ou "tarefa"
|
||||||
createdAt: timestamp("created_at", {
|
tasks: text("tasks"), // JSON stringificado com array de tarefas
|
||||||
mode: "date",
|
archived: boolean("arquivada").notNull().default(false),
|
||||||
withTimezone: true,
|
createdAt: timestamp("created_at", {
|
||||||
})
|
mode: "date",
|
||||||
.notNull()
|
withTimezone: true,
|
||||||
.defaultNow(),
|
})
|
||||||
userId: text("user_id")
|
.notNull()
|
||||||
.notNull()
|
.defaultNow(),
|
||||||
.references(() => user.id, { onDelete: "cascade" }),
|
userId: text("user_id")
|
||||||
});
|
.notNull()
|
||||||
|
.references(() => user.id, { onDelete: "cascade" }),
|
||||||
|
},
|
||||||
|
(table) => ({
|
||||||
|
userIdIdx: index("anotacoes_user_id_idx").on(table.userId),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
export const savedInsights = pgTable(
|
export const savedInsights = pgTable(
|
||||||
"insights_salvos",
|
"insights_salvos",
|
||||||
@@ -460,7 +471,6 @@ export const apiTokens = pgTable(
|
|||||||
.defaultNow(),
|
.defaultNow(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
userIdIdx: index("tokens_api_user_id_idx").on(table.userId),
|
|
||||||
tokenHashIdx: uniqueIndex("tokens_api_token_hash_idx").on(table.tokenHash),
|
tokenHashIdx: uniqueIndex("tokens_api_token_hash_idx").on(table.tokenHash),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -524,6 +534,9 @@ export const inboxItems = pgTable(
|
|||||||
table.userId,
|
table.userId,
|
||||||
table.createdAt,
|
table.createdAt,
|
||||||
),
|
),
|
||||||
|
transactionIdIdx: index("pre_lancamentos_lancamento_id_idx").on(
|
||||||
|
table.transactionId,
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -555,9 +568,6 @@ export const dashboardNotificationStates = pgTable(
|
|||||||
userIdNotificationKeyUnique: uniqueIndex(
|
userIdNotificationKeyUnique: uniqueIndex(
|
||||||
"dashboard_notification_states_user_id_key_unique",
|
"dashboard_notification_states_user_id_key_unique",
|
||||||
).on(table.userId, table.notificationKey),
|
).on(table.userId, table.notificationKey),
|
||||||
userIdArchivedAtIdx: index(
|
|
||||||
"dashboard_notification_states_user_id_archived_idx",
|
|
||||||
).on(table.userId, table.archivedAt),
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -597,10 +607,14 @@ export const installmentAnticipations = pgTable(
|
|||||||
.defaultNow(),
|
.defaultNow(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
seriesIdIdx: index("antecipacoes_parcelas_series_id_idx").on(
|
|
||||||
table.seriesId,
|
|
||||||
),
|
|
||||||
userIdIdx: index("antecipacoes_parcelas_user_id_idx").on(table.userId),
|
userIdIdx: index("antecipacoes_parcelas_user_id_idx").on(table.userId),
|
||||||
|
transactionIdIdx: index("antecipacoes_parcelas_lancamento_id_idx").on(
|
||||||
|
table.transactionId,
|
||||||
|
),
|
||||||
|
payerIdIdx: index("antecipacoes_parcelas_pagador_id_idx").on(table.payerId),
|
||||||
|
categoryIdIdx: index("antecipacoes_parcelas_categoria_id_idx").on(
|
||||||
|
table.categoryId,
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -656,6 +670,7 @@ export const transactions = pgTable(
|
|||||||
onUpdate: "cascade",
|
onUpdate: "cascade",
|
||||||
}),
|
}),
|
||||||
seriesId: uuid("series_id"),
|
seriesId: uuid("series_id"),
|
||||||
|
splitGroupId: uuid("split_group_id"),
|
||||||
transferId: uuid("transfer_id"),
|
transferId: uuid("transfer_id"),
|
||||||
ofxFitId: text("ofx_fit_id"),
|
ofxFitId: text("ofx_fit_id"),
|
||||||
importBatchId: text("import_batch_id"),
|
importBatchId: text("import_batch_id"),
|
||||||
@@ -688,6 +703,11 @@ export const transactions = pgTable(
|
|||||||
),
|
),
|
||||||
// Índice para buscar parcelas de uma série
|
// Índice para buscar parcelas de uma série
|
||||||
seriesIdIdx: index("lancamentos_series_id_idx").on(table.seriesId),
|
seriesIdIdx: index("lancamentos_series_id_idx").on(table.seriesId),
|
||||||
|
// Índice para buscar shares de um split (userId + splitGroupId)
|
||||||
|
userIdSplitGroupIdIdx: index("lancamentos_user_id_split_group_id_idx").on(
|
||||||
|
table.userId,
|
||||||
|
table.splitGroupId,
|
||||||
|
),
|
||||||
// Índice para buscar transferências relacionadas
|
// Índice para buscar transferências relacionadas
|
||||||
transferIdIdx: index("lancamentos_transfer_id_idx").on(table.transferId),
|
transferIdIdx: index("lancamentos_transfer_id_idx").on(table.transferId),
|
||||||
// Índice para filtrar por condição (aberto, realizado, cancelado)
|
// Índice para filtrar por condição (aberto, realizado, cancelado)
|
||||||
@@ -700,6 +720,12 @@ export const transactions = pgTable(
|
|||||||
table.cardId,
|
table.cardId,
|
||||||
table.period,
|
table.period,
|
||||||
),
|
),
|
||||||
|
// FK indexes: evitam seq scan em deletes/updates nas tabelas pai
|
||||||
|
accountIdIdx: index("lancamentos_conta_id_idx").on(table.accountId),
|
||||||
|
categoryIdIdx: index("lancamentos_categoria_id_idx").on(table.categoryId),
|
||||||
|
anticipationIdIdx: index("lancamentos_antecipacao_id_idx").on(
|
||||||
|
table.anticipationId,
|
||||||
|
),
|
||||||
// Dedup OFX: garante FITID único por usuário
|
// Dedup OFX: garante FITID único por usuário
|
||||||
ofxFitIdUserIdIdx: uniqueIndex("lancamentos_ofx_fit_id_user_id_idx")
|
ofxFitIdUserIdIdx: uniqueIndex("lancamentos_ofx_fit_id_user_id_idx")
|
||||||
.on(table.userId, table.ofxFitId)
|
.on(table.userId, table.ofxFitId)
|
||||||
@@ -721,6 +747,7 @@ export const userRelations = relations(user, ({ many, one }) => ({
|
|||||||
installmentAnticipations: many(installmentAnticipations),
|
installmentAnticipations: many(installmentAnticipations),
|
||||||
apiTokens: many(apiTokens),
|
apiTokens: many(apiTokens),
|
||||||
inboxItems: many(inboxItems),
|
inboxItems: many(inboxItems),
|
||||||
|
establishmentLogos: many(establishmentLogos),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const accountRelations = relations(account, ({ one }) => ({
|
export const accountRelations = relations(account, ({ one }) => ({
|
||||||
@@ -904,19 +931,25 @@ export const installmentAnticipationsRelations = relations(
|
|||||||
|
|
||||||
// ===================== ATTACHMENTS =====================
|
// ===================== ATTACHMENTS =====================
|
||||||
|
|
||||||
export const attachments = pgTable("anexos", {
|
export const attachments = pgTable(
|
||||||
id: uuid("id").primaryKey().default(sql`gen_random_uuid()`),
|
"anexos",
|
||||||
userId: text("user_id")
|
{
|
||||||
.notNull()
|
id: uuid("id").primaryKey().default(sql`gen_random_uuid()`),
|
||||||
.references(() => user.id, { onDelete: "cascade" }),
|
userId: text("user_id")
|
||||||
fileKey: text("chave_arquivo").notNull().unique(),
|
.notNull()
|
||||||
fileName: text("nome_arquivo").notNull(),
|
.references(() => user.id, { onDelete: "cascade" }),
|
||||||
fileSize: integer("tamanho_bytes").notNull(),
|
fileKey: text("chave_arquivo").notNull().unique(),
|
||||||
mimeType: text("mime_type").notNull(),
|
fileName: text("nome_arquivo").notNull(),
|
||||||
createdAt: timestamp("created_at", { mode: "date", withTimezone: true })
|
fileSize: integer("tamanho_bytes").notNull(),
|
||||||
.notNull()
|
mimeType: text("mime_type").notNull(),
|
||||||
.defaultNow(),
|
createdAt: timestamp("created_at", { mode: "date", withTimezone: true })
|
||||||
});
|
.notNull()
|
||||||
|
.defaultNow(),
|
||||||
|
},
|
||||||
|
(table) => ({
|
||||||
|
userIdIdx: index("anexos_user_id_idx").on(table.userId),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
export const transactionAttachments = pgTable(
|
export const transactionAttachments = pgTable(
|
||||||
"lancamento_anexos",
|
"lancamento_anexos",
|
||||||
@@ -952,9 +985,31 @@ export const importCategoryMappings = pgTable(
|
|||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
pk: primaryKey({ columns: [table.userId, table.descriptionKey] }),
|
pk: primaryKey({ columns: [table.userId, table.descriptionKey] }),
|
||||||
|
categoryIdIdx: index("import_category_mappings_category_id_idx").on(
|
||||||
|
table.categoryId,
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const establishmentLogos = pgTable(
|
||||||
|
"establishment_logos",
|
||||||
|
{
|
||||||
|
userId: text("user_id")
|
||||||
|
.notNull()
|
||||||
|
.references(() => user.id, { onDelete: "cascade" }),
|
||||||
|
nameKey: text("name_key").notNull(),
|
||||||
|
domain: text("domain").notNull(),
|
||||||
|
updatedAt: timestamp("updated_at", { mode: "date", withTimezone: true })
|
||||||
|
.notNull()
|
||||||
|
.defaultNow(),
|
||||||
|
},
|
||||||
|
(table) => ({
|
||||||
|
pk: primaryKey({ columns: [table.userId, table.nameKey] }),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
export type EstablishmentLogo = typeof establishmentLogos.$inferSelect;
|
||||||
|
|
||||||
export type User = typeof user.$inferSelect;
|
export type User = typeof user.$inferSelect;
|
||||||
export type NewUser = typeof user.$inferInsert;
|
export type NewUser = typeof user.$inferInsert;
|
||||||
export type Account = typeof account.$inferSelect;
|
export type Account = typeof account.$inferSelect;
|
||||||
@@ -1004,3 +1059,13 @@ export const transactionAttachmentsRelations = relations(
|
|||||||
|
|
||||||
export type Attachment = typeof attachments.$inferSelect;
|
export type Attachment = typeof attachments.$inferSelect;
|
||||||
export type TransactionAttachment = typeof transactionAttachments.$inferSelect;
|
export type TransactionAttachment = typeof transactionAttachments.$inferSelect;
|
||||||
|
|
||||||
|
export const establishmentLogosRelations = relations(
|
||||||
|
establishmentLogos,
|
||||||
|
({ one }) => ({
|
||||||
|
user: one(user, {
|
||||||
|
fields: [establishmentLogos.userId],
|
||||||
|
references: [user.id],
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ export async function createAccountAction(
|
|||||||
|
|
||||||
if (hasInitialBalance && !adminPayerId) {
|
if (hasInitialBalance && !adminPayerId) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Payer com papel administrador não encontrado. Crie um pagador admin antes de definir um saldo inicial.",
|
"Pessoa com papel administrador não encontrado. Crie um pessoa admin antes de definir um saldo inicial.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ export async function transferBetweenAccountsAction(
|
|||||||
|
|
||||||
if (!adminPayerId) {
|
if (!adminPayerId) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Payer administrador não encontrado. Por favor, crie um pagador admin.",
|
"Pessoa administrador não encontrado. Por favor, crie um pessoa admin.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
RiArrowLeftRightLine,
|
RiArrowLeftRightLine,
|
||||||
RiDeleteBin5Line,
|
RiDeleteBin5Line,
|
||||||
@@ -47,6 +48,13 @@ export function AccountCard({
|
|||||||
}: AccountCardProps) {
|
}: AccountCardProps) {
|
||||||
const isInactive = status?.toLowerCase() === "inativa";
|
const isInactive = status?.toLowerCase() === "inativa";
|
||||||
|
|
||||||
|
const balanceColor =
|
||||||
|
balance > 0
|
||||||
|
? "text-success"
|
||||||
|
: balance < 0
|
||||||
|
? "text-destructive"
|
||||||
|
: "text-foreground";
|
||||||
|
|
||||||
const actions = [
|
const actions = [
|
||||||
{
|
{
|
||||||
label: "editar",
|
label: "editar",
|
||||||
@@ -75,76 +83,90 @@ export function AccountCard({
|
|||||||
].filter((action) => typeof action.onClick === "function");
|
].filter((action) => typeof action.onClick === "function");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className={cn("h-full w-full gap-0", className)}>
|
<Card className={cn("flex w-full flex-col p-6", className)}>
|
||||||
<CardContent className="flex flex-1 flex-col gap-4">
|
<div className="flex items-start justify-between gap-2">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex min-w-0 items-center gap-2">
|
||||||
{icon ? (
|
<div
|
||||||
<div
|
className={cn(
|
||||||
className={cn(
|
"flex shrink-0 items-center justify-center",
|
||||||
"flex items-center justify-center",
|
isInactive && "grayscale opacity-40",
|
||||||
isInactive && "[&_img]:grayscale [&_img]:opacity-40",
|
)}
|
||||||
)}
|
>
|
||||||
>
|
{icon}
|
||||||
{icon}
|
</div>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<h3 className="truncate font-semibold text-foreground">
|
||||||
|
{accountName}
|
||||||
|
</h3>
|
||||||
|
{excludeFromBalance || excludeInitialBalanceFromIncome ? (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="shrink-0 text-muted-foreground/70 transition-colors hover:text-foreground"
|
||||||
|
aria-label="Informações da conta"
|
||||||
|
>
|
||||||
|
<RiInformationLine className="size-3.5" />
|
||||||
|
</button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent side="top" align="start" className="max-w-xs">
|
||||||
|
<div className="space-y-1">
|
||||||
|
{excludeFromBalance && (
|
||||||
|
<p className="text-xs">
|
||||||
|
<strong>Desconsiderado do saldo total:</strong> Esta
|
||||||
|
conta não é incluída no cálculo do saldo total geral.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{excludeInitialBalanceFromIncome && (
|
||||||
|
<p className="text-xs">
|
||||||
|
<strong>
|
||||||
|
Saldo inicial desconsiderado das receitas:
|
||||||
|
</strong>{" "}
|
||||||
|
O saldo inicial desta conta não é contabilizado como
|
||||||
|
receita nas métricas.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
|
||||||
<h2 className="text-lg font-medium text-foreground">{accountName}</h2>
|
|
||||||
|
|
||||||
{(excludeFromBalance || excludeInitialBalanceFromIncome) && (
|
<p className="text-xs text-muted-foreground">{status}</p>
|
||||||
<Tooltip>
|
</div>
|
||||||
<TooltipTrigger asChild>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<RiInformationLine className="size-5 text-muted-foreground hover:text-foreground transition-colors cursor-help" />
|
|
||||||
</div>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent side="right" className="max-w-xs">
|
|
||||||
<div className="space-y-1">
|
|
||||||
{excludeFromBalance && (
|
|
||||||
<p className="text-xs">
|
|
||||||
<strong>Desconsiderado do saldo total:</strong> Esta conta
|
|
||||||
não é incluída no cálculo do saldo total geral.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
{excludeInitialBalanceFromIncome && (
|
|
||||||
<p className="text-xs">
|
|
||||||
<strong>
|
|
||||||
Saldo inicial desconsiderado das receitas:
|
|
||||||
</strong>{" "}
|
|
||||||
O saldo inicial desta conta não é contabilizado como
|
|
||||||
receita nas métricas.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-2">
|
<p className="text-xs text-muted-foreground">{accountType}</p>
|
||||||
<MoneyValues amount={balance} className="text-3xl" />
|
</div>
|
||||||
<p className="text-sm text-muted-foreground">{accountType}</p>
|
|
||||||
|
<CardContent className="flex flex-1 flex-col gap-2 px-0 pb-2">
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
|
<span className="text-xs text-muted-foreground">Saldo</span>
|
||||||
|
<MoneyValues
|
||||||
|
amount={balance}
|
||||||
|
className={cn("text-2xl font-semibold", balanceColor)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|
||||||
{actions.length > 0 ? (
|
<CardFooter className="flex flex-wrap gap-4 p-0 text-sm">
|
||||||
<CardFooter className="flex flex-wrap gap-3 px-6 pt-6 text-sm">
|
{actions.map(({ label, icon, onClick, variant }) => (
|
||||||
{actions.map(({ label, icon, onClick, variant }) => (
|
<button
|
||||||
<button
|
key={label}
|
||||||
key={label}
|
type="button"
|
||||||
type="button"
|
onClick={onClick}
|
||||||
onClick={onClick}
|
className={cn(
|
||||||
className={cn(
|
"flex items-center gap-1 font-medium transition-opacity hover:opacity-80",
|
||||||
"flex items-center gap-1 font-medium transition-opacity hover:opacity-80",
|
variant === "destructive" ? "text-destructive" : "text-primary",
|
||||||
variant === "destructive" ? "text-destructive" : "text-primary",
|
)}
|
||||||
)}
|
aria-label={`${label} conta`}
|
||||||
aria-label={`${label} conta`}
|
>
|
||||||
>
|
{icon}
|
||||||
{icon}
|
{label}
|
||||||
{label}
|
</button>
|
||||||
</button>
|
))}
|
||||||
))}
|
</CardFooter>
|
||||||
</CardFooter>
|
|
||||||
) : null}
|
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,12 +227,12 @@ export function AccountDialog({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const title = mode === "create" ? "Nova conta" : "Editar conta";
|
const title = mode === "create" ? "Nova conta" : "Atualizar conta";
|
||||||
const description =
|
const description =
|
||||||
mode === "create"
|
mode === "create"
|
||||||
? "Cadastre uma nova conta para organizar seus lançamentos."
|
? "Cadastre uma nova conta para organizar seus lançamentos."
|
||||||
: "Atualize as informações da conta selecionada.";
|
: "Atualize as informações da conta selecionada.";
|
||||||
const submitLabel = mode === "create" ? "Salvar conta" : "Atualizar conta";
|
const submitLabel = mode === "create" ? "Salvar" : "Atualizar";
|
||||||
|
|
||||||
const handleMainDialogOpenChange = (open: boolean) => {
|
const handleMainDialogOpenChange = (open: boolean) => {
|
||||||
if (!open && logoDialogOpen) {
|
if (!open && logoDialogOpen) {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export function AccountStatementCard({
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<h2 className="truncate text-sm font-medium text-foreground">
|
<h2 className="truncate text-sm font-semibold text-foreground">
|
||||||
{accountName}
|
{accountName}
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
@@ -81,12 +81,12 @@ export function AccountStatementCard({
|
|||||||
|
|
||||||
{/* Linha 2 — saldo final (hero) */}
|
{/* Linha 2 — saldo final (hero) */}
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<p className="text-sm font-medium text-muted-foreground ">
|
<p className="text-sm text-muted-foreground ">
|
||||||
Saldo ao final do período
|
Saldo ao final do período
|
||||||
</p>
|
</p>
|
||||||
<MoneyValues
|
<MoneyValues
|
||||||
amount={currentBalance}
|
amount={currentBalance}
|
||||||
className="text-3xl leading-none font-medium tracking-tight sm:text-[2rem]"
|
className="text-3xl leading-none tracking-tighter sm:text-2xl"
|
||||||
/>
|
/>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Badge
|
<Badge
|
||||||
@@ -123,7 +123,7 @@ export function AccountStatementCard({
|
|||||||
|
|
||||||
<MetaItem
|
<MetaItem
|
||||||
label="Saídas"
|
label="Saídas"
|
||||||
tooltip="Total de despesas pagas neste mês (considerando divisão entre pagadores)."
|
tooltip="Total de despesas pagas neste mês (considerando divisão entre pessoas)."
|
||||||
>
|
>
|
||||||
<span className="text-sm font-medium text-destructive">
|
<span className="text-sm font-medium text-destructive">
|
||||||
{formatCurrency(totalExpenses)}
|
{formatCurrency(totalExpenses)}
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ export function AccountsPage({
|
|||||||
onOpenChange={handleRemoveOpenChange}
|
onOpenChange={handleRemoveOpenChange}
|
||||||
title={removeTitle}
|
title={removeTitle}
|
||||||
description="Ao remover esta conta, todos os dados relacionados a ela serão perdidos."
|
description="Ao remover esta conta, todos os dados relacionados a ela serão perdidos."
|
||||||
confirmLabel="Remover conta"
|
confirmLabel="Remover"
|
||||||
pendingLabel="Removendo..."
|
pendingLabel="Removendo..."
|
||||||
confirmVariant="destructive"
|
confirmVariant="destructive"
|
||||||
onConfirm={handleRemoveConfirm}
|
onConfirm={handleRemoveConfirm}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { INITIAL_BALANCE_NOTE } from "@/shared/lib/accounts/constants";
|
|||||||
import { db } from "@/shared/lib/db";
|
import { db } from "@/shared/lib/db";
|
||||||
import { getAdminPayerId } from "@/shared/lib/payers/get-admin-id";
|
import { getAdminPayerId } from "@/shared/lib/payers/get-admin-id";
|
||||||
|
|
||||||
export type AccountSummaryData = {
|
type AccountSummaryData = {
|
||||||
openingBalance: number;
|
openingBalance: number;
|
||||||
currentBalance: number;
|
currentBalance: number;
|
||||||
totalIncomes: number;
|
totalIncomes: number;
|
||||||
|
|||||||
@@ -69,9 +69,7 @@ function PdfCanvas({ url }: PdfCanvasProps) {
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full flex-col items-center justify-center gap-2 bg-muted/50">
|
<div className="flex h-full w-full flex-col items-center justify-center gap-2 bg-muted/50">
|
||||||
<RiFilePdf2Line className="size-12 text-muted-foreground/40" />
|
<RiFilePdf2Line className="size-12 text-muted-foreground/40" />
|
||||||
<span className="text-xs font-medium text-muted-foreground/60">
|
<span className="text-xs text-muted-foreground/60">PDF Protegido</span>
|
||||||
PDF Protegido
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -153,7 +151,7 @@ export function AttachmentGridItem({
|
|||||||
|
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<p className="truncate text-sm font-medium leading-tight text-foreground">
|
<p className="truncate text-sm font-semibold leading-tight text-foreground">
|
||||||
{attachment.fileName}
|
{attachment.fileName}
|
||||||
</p>
|
</p>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
@@ -180,25 +178,21 @@ export function AttachmentGridItem({
|
|||||||
{attachment.transactionName}
|
{attachment.transactionName}
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<span
|
<span className={cn("shrink-0 text-sm font-medium tracking-tighter")}>
|
||||||
className={cn(
|
|
||||||
"shrink-0 text-sm font-medium tracking-tighter tabular-nums",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{formatCurrency(amount)}
|
{formatCurrency(amount)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Footer: Tamanho + Botão Detalhes */}
|
{/* Footer: Tamanho + Botão Detalhes */}
|
||||||
<div className="mt-auto flex items-center justify-between border-t pt-3">
|
<div className="mt-auto flex items-center justify-between border-t pt-3">
|
||||||
<span className="text-xs font-medium text-muted-foreground/70">
|
<span className="text-xs text-muted-foreground/70">
|
||||||
{formatBytes(attachment.fileSize)}
|
{formatBytes(attachment.fileSize)}
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onDetails}
|
onClick={onDetails}
|
||||||
disabled={isLoadingDetails}
|
disabled={isLoadingDetails}
|
||||||
className="text-xs font-medium text-muted-foreground/70 underline-offset-2 hover:underline focus-visible:outline-none disabled:opacity-50"
|
className="text-xs text-muted-foreground/70 underline-offset-2 hover:underline focus-visible:outline-none disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{isLoadingDetails ? "Carregando..." : "Detalhes"}
|
{isLoadingDetails ? "Carregando..." : "Detalhes"}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export function AttachmentPreview({
|
|||||||
>
|
>
|
||||||
<RiArrowLeftSLine className="size-4" />
|
<RiArrowLeftSLine className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<span className="select-none text-xs text-muted-foreground tabular-nums">
|
<span className="select-none text-xs text-muted-foreground">
|
||||||
{currentIndex + 1} / {attachments.length}
|
{currentIndex + 1} / {attachments.length}
|
||||||
</span>
|
</span>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import { TransactionDetailsDialog } from "@/features/transactions/components/dia
|
|||||||
import { TransactionDialog } from "@/features/transactions/components/dialogs/transaction-dialog/transaction-dialog";
|
import { TransactionDialog } from "@/features/transactions/components/dialogs/transaction-dialog/transaction-dialog";
|
||||||
import type { TransactionItem } from "@/features/transactions/components/types";
|
import type { TransactionItem } from "@/features/transactions/components/types";
|
||||||
import { EmptyState } from "@/shared/components/empty-state";
|
import { EmptyState } from "@/shared/components/empty-state";
|
||||||
import MonthNavigation from "@/shared/components/month-picker/month-navigation";
|
|
||||||
import PageDescription from "@/shared/components/page-description";
|
|
||||||
import { Card, CardContent } from "@/shared/components/ui/card";
|
import { Card, CardContent } from "@/shared/components/ui/card";
|
||||||
import { cn } from "@/shared/utils/ui";
|
import { cn } from "@/shared/utils/ui";
|
||||||
|
|
||||||
@@ -143,14 +141,6 @@ export function AttachmentsPage({ attachments }: AttachmentsPageProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full space-y-6">
|
<div className="w-full space-y-6">
|
||||||
<PageDescription
|
|
||||||
icon={<RiAttachmentLine className="size-5" />}
|
|
||||||
title="Anexos"
|
|
||||||
subtitle="Comprovantes e documentos dos seus lançamentos no mês."
|
|
||||||
/>
|
|
||||||
|
|
||||||
<MonthNavigation />
|
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{attachments.length === 0 ? (
|
{attachments.length === 0 ? (
|
||||||
|
|||||||
@@ -1,25 +1,12 @@
|
|||||||
import type { PropsWithChildren } from "react";
|
import type { PropsWithChildren } from "react";
|
||||||
import { Card, CardContent } from "@/shared/components/ui/card";
|
import { Card, CardContent } from "@/shared/components/ui/card";
|
||||||
import { DotPattern } from "@/shared/components/ui/dot-pattern";
|
|
||||||
import AuthSidebar from "./auth-sidebar";
|
import AuthSidebar from "./auth-sidebar";
|
||||||
|
|
||||||
export function AuthCardShell({ children }: PropsWithChildren) {
|
export function AuthCardShell({ children }: PropsWithChildren) {
|
||||||
return (
|
return (
|
||||||
<Card className="relative overflow-hidden p-0">
|
<Card className="overflow-hidden border-primary/10 p-0 shadow-lg">
|
||||||
<div className="pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]">
|
<CardContent className="grid p-0 md:min-h-[640px] md:grid-cols-[1.05fr_0.95fr]">
|
||||||
<DotPattern
|
<div className="flex md:rounded-l-4xl">{children}</div>
|
||||||
width={17}
|
|
||||||
height={17}
|
|
||||||
cx={1.3}
|
|
||||||
cy={1.3}
|
|
||||||
cr={1.3}
|
|
||||||
className="text-primary/8 mask-[linear-gradient(to_bottom,black,transparent_84%)]"
|
|
||||||
/>
|
|
||||||
<div className="absolute inset-0 bg-linear-to-br from-primary/6 via-transparent to-transparent" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<CardContent className="relative z-10 grid gap-0 p-0 md:min-h-[640px] md:grid-cols-[1.05fr_0.95fr]">
|
|
||||||
<div className="flex bg-card/92 backdrop-blur-[1px]">{children}</div>
|
|
||||||
<AuthSidebar />
|
<AuthSidebar />
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ interface AuthHeaderProps {
|
|||||||
export function AuthHeader({ title, description }: AuthHeaderProps) {
|
export function AuthHeader({ title, description }: AuthHeaderProps) {
|
||||||
return (
|
return (
|
||||||
<div className={cn("flex flex-col gap-2.5")}>
|
<div className={cn("flex flex-col gap-2.5")}>
|
||||||
<h1 className="text-2xl font-medium tracking-tight text-card-foreground">
|
<h1 className="text-2xl font-semibold tracking-tight text-card-foreground">
|
||||||
{title}
|
{title}
|
||||||
</h1>
|
</h1>
|
||||||
{description ? (
|
{description ? (
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import type { Budget } from "./types";
|
|||||||
|
|
||||||
interface BudgetCardProps {
|
interface BudgetCardProps {
|
||||||
budget: Budget;
|
budget: Budget;
|
||||||
periodLabel: string;
|
|
||||||
onEdit: (budget: Budget) => void;
|
onEdit: (budget: Budget) => void;
|
||||||
onRemove: (budget: Budget) => void;
|
onRemove: (budget: Budget) => void;
|
||||||
}
|
}
|
||||||
@@ -29,81 +28,88 @@ const buildUsagePercent = (spent: number, limit: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const formatCategoryName = (budget: Budget) =>
|
const formatCategoryName = (budget: Budget) =>
|
||||||
budget.category?.name ?? "Category removida";
|
budget.category?.name ?? "Categoria removida";
|
||||||
|
|
||||||
export function BudgetCard({
|
export function BudgetCard({ budget, onEdit, onRemove }: BudgetCardProps) {
|
||||||
budget,
|
|
||||||
periodLabel,
|
|
||||||
onEdit,
|
|
||||||
onRemove,
|
|
||||||
}: BudgetCardProps) {
|
|
||||||
const { amount: limit, spent } = budget;
|
const { amount: limit, spent } = budget;
|
||||||
const exceeded = spent > limit && limit >= 0;
|
const exceeded = spent > limit && limit >= 0;
|
||||||
const difference = Math.abs(spent - limit);
|
const difference = Math.abs(spent - limit);
|
||||||
const usagePercent = buildUsagePercent(spent, limit);
|
const usagePercent = buildUsagePercent(spent, limit);
|
||||||
|
const remaining = Math.max(limit - spent, 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="flex h-full flex-col">
|
<Card className="flex w-full flex-col p-6">
|
||||||
<CardContent className="flex h-full flex-col gap-4">
|
<div className="flex items-center gap-2">
|
||||||
<div className="flex items-start gap-3">
|
<CategoryIconBadge
|
||||||
<CategoryIconBadge
|
icon={budget.category?.icon ?? undefined}
|
||||||
icon={budget.category?.icon ?? undefined}
|
name={formatCategoryName(budget)}
|
||||||
name={formatCategoryName(budget)}
|
size="lg"
|
||||||
size="lg"
|
/>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<h3 className="truncate font-semibold text-foreground">
|
||||||
|
{formatCategoryName(budget)}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<CardContent className="flex flex-1 flex-col gap-4 p-0">
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
|
<span className="text-xs text-muted-foreground">
|
||||||
|
{exceeded ? "Excedido em" : "Disponível"}
|
||||||
|
</span>
|
||||||
|
<MoneyValues
|
||||||
|
amount={exceeded ? difference : remaining}
|
||||||
|
className={cn(
|
||||||
|
"text-xl font-semibold",
|
||||||
|
exceeded ? "text-destructive" : "text-success",
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
<div className="space-y-1">
|
|
||||||
<h3 className="text-base font-medium leading-tight">
|
|
||||||
{formatCategoryName(budget)}
|
|
||||||
</h3>
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
Orçamento de {periodLabel}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-1 flex-col gap-2">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<div className="flex items-baseline justify-between text-sm">
|
<div className="flex flex-col gap-0.5">
|
||||||
<span className="text-muted-foreground">Gasto até agora</span>
|
<span className="text-xs text-muted-foreground">Orçamento</span>
|
||||||
<MoneyValues
|
<MoneyValues
|
||||||
amount={spent}
|
amount={limit}
|
||||||
className={cn(exceeded && "text-destructive")}
|
className="text-sm font-semibold text-foreground"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Progress
|
<div className="flex flex-col gap-0.5">
|
||||||
value={usagePercent}
|
<span className="text-xs text-muted-foreground">Gasto</span>
|
||||||
className={cn("h-2", exceeded && "bg-destructive/20!")}
|
<MoneyValues
|
||||||
/>
|
amount={spent}
|
||||||
<div className="flex flex-wrap items-baseline justify-between gap-1 text-sm">
|
className={cn(
|
||||||
<span className="text-muted-foreground">Limite</span>
|
"text-sm font-semibold",
|
||||||
<MoneyValues amount={limit} className="text-foreground" />
|
exceeded ? "text-destructive" : "text-primary",
|
||||||
</div>
|
)}
|
||||||
|
/>
|
||||||
<div>
|
|
||||||
{exceeded ? (
|
|
||||||
<div className="text-xs text-destructive">
|
|
||||||
Excedeu em <MoneyValues amount={difference} />
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="text-xs text-success">
|
|
||||||
Restam <MoneyValues amount={Math.max(limit - spent, 0)} />{" "}
|
|
||||||
disponíveis.
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<Progress
|
||||||
|
value={usagePercent}
|
||||||
|
className={cn("h-2.5", exceeded && "bg-destructive/20!")}
|
||||||
|
aria-label={`${usagePercent.toFixed(1)}% do orçamento utilizado`}
|
||||||
|
/>
|
||||||
|
<span className="text-xs text-muted-foreground">
|
||||||
|
{usagePercent.toFixed(1)}% utilizado
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardFooter className="flex flex-wrap gap-3 px-5 text-sm">
|
|
||||||
|
<CardFooter className="mt-auto flex flex-wrap gap-4 px-0 pt-2 text-sm">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => onEdit(budget)}
|
onClick={() => onEdit(budget)}
|
||||||
className="flex items-center gap-1 text-primary font-medium transition-opacity hover:opacity-80"
|
className="flex items-center gap-1 font-medium text-primary transition-opacity hover:opacity-80"
|
||||||
>
|
>
|
||||||
<RiPencilLine className="size-4" aria-hidden /> editar
|
<RiPencilLine className="size-4" aria-hidden /> editar
|
||||||
</button>
|
</button>
|
||||||
{budget.category && (
|
{budget.category && (
|
||||||
<Link
|
<Link
|
||||||
href={`/categories/${budget.category.id}`}
|
href={`/categories/${budget.category.id}`}
|
||||||
className="flex items-center gap-1 text-primary font-medium transition-opacity hover:opacity-80"
|
className="flex items-center gap-1 font-medium text-primary transition-opacity hover:opacity-80"
|
||||||
>
|
>
|
||||||
<RiFileList2Line className="size-4" aria-hidden /> detalhes
|
<RiFileList2Line className="size-4" aria-hidden /> detalhes
|
||||||
</Link>
|
</Link>
|
||||||
@@ -111,7 +117,7 @@ export function BudgetCard({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => onRemove(budget)}
|
onClick={() => onRemove(budget)}
|
||||||
className="flex items-center gap-1 text-destructive font-medium transition-opacity hover:opacity-80"
|
className="flex items-center gap-1 font-medium text-destructive transition-opacity hover:opacity-80"
|
||||||
>
|
>
|
||||||
<RiDeleteBin5Line className="size-4" aria-hidden /> remover
|
<RiDeleteBin5Line className="size-4" aria-hidden /> remover
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -161,13 +161,12 @@ export function BudgetDialog({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const title = mode === "create" ? "Novo orçamento" : "Editar orçamento";
|
const title = mode === "create" ? "Novo orçamento" : "Atualizar orçamento";
|
||||||
const description =
|
const description =
|
||||||
mode === "create"
|
mode === "create"
|
||||||
? "Defina um limite de gastos para acompanhar suas despesas."
|
? "Defina um limite de gastos para acompanhar suas despesas."
|
||||||
: "Atualize os detalhes do orçamento selecionado.";
|
: "Atualize os detalhes do orçamento selecionado.";
|
||||||
const submitLabel =
|
const submitLabel = mode === "create" ? "Salvar" : "Atualizar";
|
||||||
mode === "create" ? "Salvar orçamento" : "Atualizar orçamento";
|
|
||||||
const disabled = categories.length === 0;
|
const disabled = categories.length === 0;
|
||||||
const parsedAmount = Number.parseFloat(formState.amount);
|
const parsedAmount = Number.parseFloat(formState.amount);
|
||||||
const sliderValue = Number.isFinite(parsedAmount)
|
const sliderValue = Number.isFinite(parsedAmount)
|
||||||
|
|||||||
@@ -19,14 +19,12 @@ interface BudgetsPageProps {
|
|||||||
budgets: Budget[];
|
budgets: Budget[];
|
||||||
categories: BudgetCategory[];
|
categories: BudgetCategory[];
|
||||||
selectedPeriod: string;
|
selectedPeriod: string;
|
||||||
periodLabel: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BudgetsPage({
|
export function BudgetsPage({
|
||||||
budgets,
|
budgets,
|
||||||
categories,
|
categories,
|
||||||
selectedPeriod,
|
selectedPeriod,
|
||||||
periodLabel,
|
|
||||||
}: BudgetsPageProps) {
|
}: BudgetsPageProps) {
|
||||||
const [editOpen, setEditOpen] = useState(false);
|
const [editOpen, setEditOpen] = useState(false);
|
||||||
const [selectedBudget, setSelectedBudget] = useState<Budget | null>(null);
|
const [selectedBudget, setSelectedBudget] = useState<Budget | null>(null);
|
||||||
@@ -137,7 +135,6 @@ export function BudgetsPage({
|
|||||||
<BudgetCard
|
<BudgetCard
|
||||||
key={budget.id}
|
key={budget.id}
|
||||||
budget={budget}
|
budget={budget}
|
||||||
periodLabel={periodLabel}
|
|
||||||
onEdit={handleEdit}
|
onEdit={handleEdit}
|
||||||
onRemove={handleRemoveRequest}
|
onRemove={handleRemoveRequest}
|
||||||
/>
|
/>
|
||||||
@@ -168,7 +165,7 @@ export function BudgetsPage({
|
|||||||
onOpenChange={handleRemoveOpenChange}
|
onOpenChange={handleRemoveOpenChange}
|
||||||
title={removeTitle}
|
title={removeTitle}
|
||||||
description="Esta ação remove o limite configurado para a categoria selecionada."
|
description="Esta ação remove o limite configurado para a categoria selecionada."
|
||||||
confirmLabel="Remover orçamento"
|
confirmLabel="Remover"
|
||||||
pendingLabel="Removendo..."
|
pendingLabel="Removendo..."
|
||||||
confirmVariant="destructive"
|
confirmVariant="destructive"
|
||||||
onConfirm={handleRemoveConfirm}
|
onConfirm={handleRemoveConfirm}
|
||||||
@@ -179,7 +176,7 @@ export function BudgetsPage({
|
|||||||
onOpenChange={setDuplicateOpen}
|
onOpenChange={setDuplicateOpen}
|
||||||
title="Copiar orçamentos do último mês?"
|
title="Copiar orçamentos do último mês?"
|
||||||
description="Isso copiará os limites definidos no mês anterior para as categorias que ainda não possuem orçamento neste mês."
|
description="Isso copiará os limites definidos no mês anterior para as categorias que ainda não possuem orçamento neste mês."
|
||||||
confirmLabel="Copiar orçamentos"
|
confirmLabel="Copiar"
|
||||||
pendingLabel="Copiando..."
|
pendingLabel="Copiando..."
|
||||||
onConfirm={handleDuplicateConfirm}
|
onConfirm={handleDuplicateConfirm}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const toNumber = (value: string | number | null | undefined) => {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BudgetData = {
|
type BudgetData = {
|
||||||
id: string;
|
id: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
spent: number;
|
spent: number;
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { DayCell } from "@/features/calendar/components/day-cell";
|
import { DayCell } from "@/features/calendar/components/day-cell";
|
||||||
|
|
||||||
import type { CalendarDay } from "@/shared/lib/types/calendar";
|
import type { CalendarDay } from "@/shared/lib/types/calendar";
|
||||||
import { WEEK_DAYS_SHORT } from "@/shared/utils/calendar";
|
import { WEEK_DAYS_SHORT } from "@/shared/utils/calendar";
|
||||||
import { cn } from "@/shared/utils/ui";
|
|
||||||
|
|
||||||
type CalendarGridProps = {
|
type CalendarGridProps = {
|
||||||
days: CalendarDay[];
|
days: CalendarDay[];
|
||||||
@@ -18,21 +16,18 @@ export function CalendarGrid({
|
|||||||
onCreateDay,
|
onCreateDay,
|
||||||
}: CalendarGridProps) {
|
}: CalendarGridProps) {
|
||||||
return (
|
return (
|
||||||
<div className="overflow-hidden rounded-lg bg-card drop-shadow-xs border-none">
|
<div className="overflow-hidden rounded-lg border p-2">
|
||||||
<div className="grid grid-cols-7 text-sm font-medium uppercase tracking-wide text-muted-foreground">
|
<div className="grid grid-cols-7 text-sm font-semibold uppercase tracking-wide text-muted-foreground">
|
||||||
{WEEK_DAYS_SHORT.map((dayName) => (
|
{WEEK_DAYS_SHORT.map((dayName) => (
|
||||||
<span key={dayName} className="px-3 py-2 text-center text-primary">
|
<span key={dayName} className="text-center">
|
||||||
{dayName}
|
{dayName}
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-7 gap-px bg-border/60 px-px pb-px pt-px">
|
<div className="grid grid-cols-7 gap-px px-px pb-px pt-px">
|
||||||
{days.map((day) => (
|
{days.map((day) => (
|
||||||
<div
|
<div key={day.date} className="h-[150px] p-0.5">
|
||||||
key={day.date}
|
|
||||||
className={cn("h-[150px] bg-card p-0.5", !day.isCurrentMonth && "")}
|
|
||||||
>
|
|
||||||
<DayCell day={day} onSelect={onSelectDay} onCreate={onCreateDay} />
|
<DayCell day={day} onSelect={onSelectDay} onCreate={onCreateDay} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,34 +1,33 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { EVENT_TYPE_STYLES } from "@/features/calendar/components/day-cell";
|
import { EVENT_TYPE_STYLES } from "@/features/calendar/components/day-cell";
|
||||||
import StatusDot from "@/shared/components/status-dot";
|
import { cn } from "@/shared/utils/ui";
|
||||||
import { Card } from "@/shared/components/ui/card";
|
|
||||||
import type { CalendarEvent } from "@/shared/lib/types/calendar";
|
|
||||||
|
|
||||||
const LEGEND_ITEMS: Array<{
|
const LEGEND_ITEMS = [
|
||||||
type?: CalendarEvent["type"];
|
{ label: "Lançamentos", ...EVENT_TYPE_STYLES.transaction },
|
||||||
label: string;
|
{ label: "Parcelas", ...EVENT_TYPE_STYLES.installment },
|
||||||
dotColor?: string;
|
{ label: "Boletos", ...EVENT_TYPE_STYLES.boleto },
|
||||||
}> = [
|
{ label: "Fatura de Cartão", ...EVENT_TYPE_STYLES.card },
|
||||||
{ type: "transaction", label: "Lançamentos" },
|
|
||||||
{ type: "boleto", label: "Boleto com vencimento" },
|
|
||||||
{ type: "card", label: "Vencimento de cartão" },
|
|
||||||
{ label: "Pagamento fatura", dotColor: "bg-success" },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export function CalendarLegend() {
|
export function CalendarLegend() {
|
||||||
return (
|
return (
|
||||||
<Card className="flex flex-row gap-2 p-2 text-sm">
|
<ul className="flex items-center justify-start gap-2 px-1">
|
||||||
{LEGEND_ITEMS.map((item, index) => {
|
{LEGEND_ITEMS.map((item) => (
|
||||||
const dotColor =
|
<li
|
||||||
item.dotColor || (item.type ? EVENT_TYPE_STYLES[item.type].dot : "");
|
key={item.label}
|
||||||
return (
|
className={cn(
|
||||||
<span key={item.type || index} className="flex items-center gap-2">
|
"flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium",
|
||||||
<StatusDot color={dotColor} />
|
item.wrapper,
|
||||||
{item.label}
|
)}
|
||||||
</span>
|
>
|
||||||
);
|
<span
|
||||||
})}
|
className={cn("size-1.5 shrink-0 rounded-full", item.dot)}
|
||||||
</Card>
|
aria-hidden
|
||||||
|
/>
|
||||||
|
{item.label}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RiAddLine } from "@remixicon/react";
|
import { RiAddLine, RiCheckboxCircleFill } from "@remixicon/react";
|
||||||
import type { KeyboardEvent, MouseEvent } from "react";
|
import type { KeyboardEvent, MouseEvent } from "react";
|
||||||
import type { CalendarDay, CalendarEvent } from "@/shared/lib/types/calendar";
|
import type { CalendarDay, CalendarEvent } from "@/shared/lib/types/calendar";
|
||||||
import { currencyFormatter } from "@/shared/utils/currency";
|
import { currencyFormatter } from "@/shared/utils/currency";
|
||||||
@@ -14,44 +14,40 @@ type DayCellProps = {
|
|||||||
|
|
||||||
export const EVENT_TYPE_STYLES: Record<
|
export const EVENT_TYPE_STYLES: Record<
|
||||||
CalendarEvent["type"],
|
CalendarEvent["type"],
|
||||||
{ wrapper: string; dot: string; accent?: string }
|
{ wrapper: string; dot: string }
|
||||||
> = {
|
> = {
|
||||||
transaction: {
|
transaction: {
|
||||||
|
wrapper: "bg-primary/10 text-primary dark:bg-primary/5 dark:text-primary",
|
||||||
|
dot: "bg-primary",
|
||||||
|
},
|
||||||
|
installment: {
|
||||||
wrapper:
|
wrapper:
|
||||||
"bg-warning/10 text-warning dark:bg-warning/5 dark:text-warning border-l-4 border-warning",
|
"bg-amber-100 text-amber-600 dark:bg-amber-900/10 dark:text-amber-500",
|
||||||
dot: "bg-warning",
|
dot: "bg-amber-500",
|
||||||
},
|
},
|
||||||
boleto: {
|
boleto: {
|
||||||
wrapper:
|
wrapper: "bg-info/10 text-info dark:bg-info/5 dark:text-info",
|
||||||
"bg-info/10 text-info dark:bg-info/5 dark:text-info border-l-4 border-info",
|
|
||||||
dot: "bg-info",
|
dot: "bg-info",
|
||||||
},
|
},
|
||||||
card: {
|
card: {
|
||||||
wrapper:
|
wrapper:
|
||||||
"bg-violet-100 text-violet-600 dark:bg-violet-900/10 dark:text-violet-50 border-l-4 border-violet-500",
|
"bg-violet-100 text-violet-600 dark:bg-violet-900/10 dark:text-violet-500",
|
||||||
dot: "bg-violet-600",
|
dot: "bg-violet-600 dark:bg-violet-500",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const eventStyles = EVENT_TYPE_STYLES;
|
|
||||||
|
|
||||||
const formatCurrencyValue = (value: number | null | undefined) =>
|
const formatCurrencyValue = (value: number | null | undefined) =>
|
||||||
currencyFormatter.format(Math.abs(value ?? 0));
|
currencyFormatter.format(Math.abs(value ?? 0));
|
||||||
|
|
||||||
const formatAmount = (event: Extract<CalendarEvent, { type: "transaction" }>) =>
|
|
||||||
formatCurrencyValue(event.transaction.amount);
|
|
||||||
|
|
||||||
const buildEventLabel = (event: CalendarEvent) => {
|
const buildEventLabel = (event: CalendarEvent) => {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "transaction": {
|
case "transaction":
|
||||||
|
case "boleto":
|
||||||
return event.transaction.name;
|
return event.transaction.name;
|
||||||
}
|
case "installment":
|
||||||
case "boleto": {
|
|
||||||
return event.transaction.name;
|
return event.transaction.name;
|
||||||
}
|
case "card":
|
||||||
case "card": {
|
|
||||||
return event.card.name;
|
return event.card.name;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -59,60 +55,50 @@ const buildEventLabel = (event: CalendarEvent) => {
|
|||||||
|
|
||||||
const buildEventComplement = (event: CalendarEvent) => {
|
const buildEventComplement = (event: CalendarEvent) => {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "transaction": {
|
case "transaction":
|
||||||
return formatAmount(event);
|
case "boleto":
|
||||||
}
|
|
||||||
case "boleto": {
|
|
||||||
return formatCurrencyValue(event.transaction.amount);
|
return formatCurrencyValue(event.transaction.amount);
|
||||||
}
|
case "installment":
|
||||||
case "card": {
|
return `${event.installmentCount}x de ${formatCurrencyValue(event.installmentValue)}`;
|
||||||
if (event.card.totalDue !== null) {
|
case "card":
|
||||||
return formatCurrencyValue(event.card.totalDue);
|
return event.card.totalDue !== null
|
||||||
}
|
? formatCurrencyValue(event.card.totalDue)
|
||||||
return null;
|
: null;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isPagamentoFatura = (event: CalendarEvent) => {
|
const isPaid = (event: CalendarEvent) => {
|
||||||
return (
|
if (event.type === "boleto") return Boolean(event.transaction.isSettled);
|
||||||
event.type === "transaction" &&
|
if (event.type === "card") return event.card.isPaid;
|
||||||
event.transaction.name.startsWith("Pagamento fatura -")
|
return false;
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const getEventStyle = (event: CalendarEvent) => {
|
|
||||||
if (isPagamentoFatura(event)) {
|
|
||||||
return {
|
|
||||||
wrapper:
|
|
||||||
"bg-success/10 text-success dark:bg-success/5 dark:text-success border-l-4 border-success",
|
|
||||||
dot: "bg-success",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return eventStyles[event.type];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const DayEventPreview = ({ event }: { event: CalendarEvent }) => {
|
const DayEventPreview = ({ event }: { event: CalendarEvent }) => {
|
||||||
const complement = buildEventComplement(event);
|
const complement = buildEventComplement(event);
|
||||||
const label = buildEventLabel(event);
|
const label = buildEventLabel(event);
|
||||||
const style = getEventStyle(event);
|
const style = EVENT_TYPE_STYLES[event.type];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex w-full items-center justify-between gap-2 rounded p-1 text-xs",
|
"flex w-full items-center justify-between gap-2 rounded-md px-2 py-1 text-xs",
|
||||||
style.wrapper,
|
style.wrapper,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="flex min-w-0 items-center gap-1">
|
<div className="flex min-w-0 items-center gap-1">
|
||||||
|
<span
|
||||||
|
className={cn("size-1.5 shrink-0 rounded-full", style.dot)}
|
||||||
|
aria-hidden
|
||||||
|
/>
|
||||||
<span className="truncate">{label}</span>
|
<span className="truncate">{label}</span>
|
||||||
|
{isPaid(event) && (
|
||||||
|
<RiCheckboxCircleFill className="size-3.5 shrink-0 text-success" />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{complement ? (
|
{complement ? (
|
||||||
<span className={cn("shrink-0 font-medium", style.accent ?? "text-xs")}>
|
<span className="shrink-0 font-medium">{complement}</span>
|
||||||
{complement}
|
|
||||||
</span>
|
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -143,8 +129,8 @@ export function DayCell({ day, onSelect, onCreate }: DayCellProps) {
|
|||||||
onClick={() => onSelect(day)}
|
onClick={() => onSelect(day)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
className={cn(
|
className={cn(
|
||||||
"group flex h-full cursor-pointer flex-col gap-1.5 rounded-lg border border-transparent bg-card/80 p-2 text-left transition-all duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 hover:border-primary/40 hover:bg-primary/5 dark:hover:bg-accent",
|
"group flex h-full cursor-pointer flex-col gap-1.5 rounded-lg border bg-card/80 p-2 text-left transition-all duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 hover:border-primary/40 hover:bg-primary/5 dark:hover:bg-accent",
|
||||||
!day.isCurrentMonth && "opacity-60",
|
!day.isCurrentMonth && "bg-muted/20 opacity-60",
|
||||||
day.isToday && "border-primary/70 bg-primary/5 hover:border-primary",
|
day.isToday && "border-primary/70 bg-primary/5 hover:border-primary",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -159,14 +145,16 @@ export function DayCell({ day, onSelect, onCreate }: DayCellProps) {
|
|||||||
>
|
>
|
||||||
{day.label}
|
{day.label}
|
||||||
</span>
|
</span>
|
||||||
<button
|
{day.isCurrentMonth && (
|
||||||
type="button"
|
<button
|
||||||
onClick={handleCreateClick}
|
type="button"
|
||||||
className="flex size-6 items-center justify-center rounded-full bg-muted text-muted-foreground opacity-0 transition-all group-hover:opacity-100 hover:bg-primary/20 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1"
|
onClick={handleCreateClick}
|
||||||
aria-label={`Criar lançamento em ${day.date}`}
|
className="flex size-6 items-center justify-center rounded-full bg-muted text-muted-foreground opacity-0 transition-all group-hover:opacity-100 hover:bg-primary/20 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1"
|
||||||
>
|
aria-label={`Criar lançamento em ${day.date}`}
|
||||||
<RiAddLine className="size-3.5" />
|
>
|
||||||
</button>
|
<RiAddLine className="size-3.5" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-1 flex-col gap-1.5">
|
<div className="flex flex-1 flex-col gap-1.5">
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { RiCalendarEventLine } from "@remixicon/react";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import { EVENT_TYPE_STYLES } from "@/features/calendar/components/day-cell";
|
import { EVENT_TYPE_STYLES } from "@/features/calendar/components/day-cell";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
@@ -29,17 +30,13 @@ type EventModalProps = {
|
|||||||
const EventCard = ({
|
const EventCard = ({
|
||||||
children,
|
children,
|
||||||
type,
|
type,
|
||||||
isPagamentoFatura = false,
|
|
||||||
}: {
|
}: {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
type: CalendarEvent["type"];
|
type: CalendarEvent["type"];
|
||||||
isPagamentoFatura?: boolean;
|
|
||||||
}) => {
|
}) => {
|
||||||
const style = isPagamentoFatura
|
const style = EVENT_TYPE_STYLES[type];
|
||||||
? { dot: "bg-success" }
|
|
||||||
: EVENT_TYPE_STYLES[type];
|
|
||||||
return (
|
return (
|
||||||
<Card className="flex flex-row gap-2 p-3 mb-1">
|
<Card className="flex flex-row gap-2 p-3">
|
||||||
<span
|
<span
|
||||||
className={cn("mt-1 size-3 shrink-0 rounded-full", style.dot)}
|
className={cn("mt-1 size-3 shrink-0 rounded-full", style.dot)}
|
||||||
aria-hidden
|
aria-hidden
|
||||||
@@ -49,41 +46,34 @@ const EventCard = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const DATE_FORMAT: Intl.DateTimeFormatOptions = {
|
||||||
|
day: "2-digit",
|
||||||
|
month: "2-digit",
|
||||||
|
year: "numeric",
|
||||||
|
};
|
||||||
|
|
||||||
const renderLancamento = (
|
const renderLancamento = (
|
||||||
event: Extract<CalendarEvent, { type: "transaction" }>,
|
event: Extract<CalendarEvent, { type: "transaction" }>,
|
||||||
) => {
|
) => {
|
||||||
const isReceita = event.transaction.transactionType === "Receita";
|
const isReceita = event.transaction.transactionType === "Receita";
|
||||||
const isPagamentoFatura =
|
|
||||||
event.transaction.name.startsWith("Pagamento fatura -");
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EventCard type="transaction" isPagamentoFatura={isPagamentoFatura}>
|
<EventCard type="transaction">
|
||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<span
|
<span className="text-sm font-medium leading-tight">
|
||||||
className={`text-sm font-medium leading-tight ${
|
|
||||||
isPagamentoFatura && "text-success"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{event.transaction.name}
|
{event.transaction.name}
|
||||||
</span>
|
</span>
|
||||||
|
<Badge variant="outline">{event.transaction.categoriaName}</Badge>
|
||||||
<div className="flex gap-1">
|
|
||||||
<Badge variant={"outline"}>{event.transaction.categoriaName}</Badge>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<span
|
<MoneyValues
|
||||||
|
showPositiveSign
|
||||||
className={cn(
|
className={cn(
|
||||||
"text-sm font-medium whitespace-nowrap",
|
"text-base whitespace-nowrap font-medium",
|
||||||
isReceita ? "text-success" : "text-foreground",
|
isReceita ? "text-success" : "text-foreground",
|
||||||
)}
|
)}
|
||||||
>
|
amount={event.transaction.amount}
|
||||||
<MoneyValues
|
/>
|
||||||
showPositiveSign
|
|
||||||
className="text-base"
|
|
||||||
amount={event.transaction.amount}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</EventCard>
|
</EventCard>
|
||||||
);
|
);
|
||||||
@@ -91,64 +81,118 @@ const renderLancamento = (
|
|||||||
|
|
||||||
const renderBoleto = (event: Extract<CalendarEvent, { type: "boleto" }>) => {
|
const renderBoleto = (event: Extract<CalendarEvent, { type: "boleto" }>) => {
|
||||||
const isPaid = Boolean(event.transaction.isSettled);
|
const isPaid = Boolean(event.transaction.isSettled);
|
||||||
const dueDate = event.transaction.dueDate;
|
const dueDateLabel = formatFinancialDateLabel(
|
||||||
const dueDateLabel = formatFinancialDateLabel(dueDate, "Vence em", {
|
event.transaction.dueDate,
|
||||||
day: "2-digit",
|
"Vence em",
|
||||||
month: "2-digit",
|
DATE_FORMAT,
|
||||||
year: "numeric",
|
);
|
||||||
});
|
const paymentDateLabel = isPaid
|
||||||
|
? formatFinancialDateLabel(
|
||||||
|
event.transaction.boletoPaymentDate,
|
||||||
|
"Pago em",
|
||||||
|
DATE_FORMAT,
|
||||||
|
)
|
||||||
|
: null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EventCard type="boleto">
|
<EventCard type="boleto">
|
||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<div className="flex gap-1 items-center">
|
<span className="text-sm font-medium leading-tight">
|
||||||
<span className="text-sm font-medium leading-tight">
|
{event.transaction.name}
|
||||||
{event.transaction.name}
|
</span>
|
||||||
</span>
|
<div className="flex flex-wrap gap-x-3 gap-y-0.5 text-xs">
|
||||||
|
|
||||||
{dueDateLabel && (
|
{dueDateLabel && (
|
||||||
<span className="text-xs text-muted-foreground leading-tight">
|
<span className="text-muted-foreground">{dueDateLabel}</span>
|
||||||
{dueDateLabel}
|
)}
|
||||||
</span>
|
{paymentDateLabel && (
|
||||||
|
<span className="text-success">{paymentDateLabel}</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<Badge variant="outline">{isPaid ? "Pago" : "Pendente"}</Badge>
|
||||||
<Badge variant={"outline"}>{isPaid ? "Pago" : "Pendente"}</Badge>
|
|
||||||
</div>
|
</div>
|
||||||
<span className="font-medium">
|
<MoneyValues
|
||||||
<MoneyValues amount={event.transaction.amount} />
|
className="font-medium whitespace-nowrap"
|
||||||
</span>
|
amount={event.transaction.amount}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</EventCard>
|
</EventCard>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderCard = (event: Extract<CalendarEvent, { type: "card" }>) => (
|
const renderCard = (event: Extract<CalendarEvent, { type: "card" }>) => {
|
||||||
<EventCard type="card">
|
const paymentDateLabel = event.card.isPaid
|
||||||
<div className="flex items-start justify-between gap-3">
|
? formatFinancialDateLabel(event.card.paymentDate, "Pago em", DATE_FORMAT)
|
||||||
<div className="flex flex-col gap-1">
|
: null;
|
||||||
<div className="flex gap-1 items-center">
|
|
||||||
<span className="text-sm font-medium leading-tight">
|
|
||||||
Vencimento Invoice - {event.card.name}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Badge variant={"outline"}>{event.card.status ?? "Invoice"}</Badge>
|
return (
|
||||||
|
<EventCard type="card">
|
||||||
|
<div className="flex items-start justify-between gap-3">
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<span className="text-sm font-medium leading-tight">
|
||||||
|
Vencimento Fatura — {event.card.name}
|
||||||
|
</span>
|
||||||
|
{paymentDateLabel && (
|
||||||
|
<span className="text-xs text-success">{paymentDateLabel}</span>
|
||||||
|
)}
|
||||||
|
<Badge variant="outline">
|
||||||
|
{event.card.isPaid ? "Pago" : (event.card.status ?? "Fatura")}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
{event.card.totalDue !== null ? (
|
||||||
|
<MoneyValues
|
||||||
|
className="font-medium whitespace-nowrap"
|
||||||
|
amount={event.card.totalDue}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
{event.card.totalDue !== null ? (
|
</EventCard>
|
||||||
<span className="font-medium">
|
);
|
||||||
<MoneyValues amount={event.card.totalDue} />
|
};
|
||||||
</span>
|
|
||||||
) : null}
|
const renderInstallment = (
|
||||||
</div>
|
event: Extract<CalendarEvent, { type: "installment" }>,
|
||||||
</EventCard>
|
) => {
|
||||||
);
|
const isReceita = event.transaction.transactionType === "Receita";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<EventCard type="installment">
|
||||||
|
<div className="flex items-start justify-between gap-3">
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<span className="text-sm font-medium leading-tight">
|
||||||
|
{event.transaction.name}
|
||||||
|
</span>
|
||||||
|
<Badge variant="outline">{event.installmentCount}x parcelas</Badge>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col items-end gap-0.5">
|
||||||
|
<MoneyValues
|
||||||
|
showPositiveSign
|
||||||
|
className={cn(
|
||||||
|
"text-base whitespace-nowrap font-medium",
|
||||||
|
isReceita ? "text-success" : "text-foreground",
|
||||||
|
)}
|
||||||
|
amount={event.installmentValue}
|
||||||
|
/>
|
||||||
|
<span className="text-xs text-muted-foreground">por parcela</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</EventCard>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const SECTION_LABELS: Record<CalendarEvent["type"], string> = {
|
||||||
|
transaction: "Lançamentos",
|
||||||
|
installment: "Parcelas",
|
||||||
|
boleto: "Boletos",
|
||||||
|
card: "Faturas",
|
||||||
|
};
|
||||||
|
|
||||||
const renderEvent = (event: CalendarEvent) => {
|
const renderEvent = (event: CalendarEvent) => {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "transaction":
|
case "transaction":
|
||||||
return renderLancamento(event);
|
return renderLancamento(event);
|
||||||
|
case "installment":
|
||||||
|
return renderInstallment(event);
|
||||||
case "boleto":
|
case "boleto":
|
||||||
return renderBoleto(event);
|
return renderBoleto(event);
|
||||||
case "card":
|
case "card":
|
||||||
@@ -169,28 +213,51 @@ export function EventModal({ open, day, onClose, onCreate }: EventModalProps) {
|
|||||||
onCreate(day.date);
|
onCreate(day.date);
|
||||||
};
|
};
|
||||||
|
|
||||||
const description = day?.events.length
|
const hasEvents = Boolean(day?.events.length);
|
||||||
? "Confira os lançamentos e vencimentos cadastrados para este dia."
|
|
||||||
: "Nenhum lançamento encontrado para este dia. Você pode criar um novo lançamento agora.";
|
const grouped = day
|
||||||
|
? {
|
||||||
|
transaction: day.events.filter((e) => e.type === "transaction"),
|
||||||
|
installment: day.events.filter((e) => e.type === "installment"),
|
||||||
|
boleto: day.events.filter((e) => e.type === "boleto"),
|
||||||
|
card: day.events.filter((e) => e.type === "card"),
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={(value) => (!value ? onClose() : null)}>
|
<Dialog open={open} onOpenChange={(value) => (!value ? onClose() : null)}>
|
||||||
<DialogContent className="max-w-xl">
|
<DialogContent className="max-w-xl">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>{formattedDate}</DialogTitle>
|
<DialogTitle>{formattedDate}</DialogTitle>
|
||||||
<DialogDescription>{description}</DialogDescription>
|
<DialogDescription>
|
||||||
|
{hasEvents
|
||||||
|
? "Lançamentos e vencimentos cadastrados para este dia."
|
||||||
|
: "Nenhum lançamento encontrado para este dia."}
|
||||||
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<div className="max-h-[380px] space-y-2 overflow-y-auto pr-2">
|
<div className="max-h-[380px] space-y-3 overflow-y-auto pr-2">
|
||||||
{day?.events.length ? (
|
{hasEvents && grouped ? (
|
||||||
day.events.map((event) => (
|
(["transaction", "installment", "boleto", "card"] as const)
|
||||||
<div key={event.id}>{renderEvent(event)}</div>
|
.filter((type) => grouped[type].length > 0)
|
||||||
))
|
.map((type) => (
|
||||||
|
<div key={type} className="space-y-1.5">
|
||||||
|
<p className="px-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground">
|
||||||
|
{SECTION_LABELS[type]}
|
||||||
|
</p>
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
{grouped[type].map((event) => (
|
||||||
|
<div key={event.id}>{renderEvent(event)}</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
) : (
|
) : (
|
||||||
<div className="rounded-xl border border-dashed border-border/60 bg-muted/30 p-6 text-center text-sm text-muted-foreground">
|
<div className="flex flex-col items-center gap-3 rounded-xl border border-dashed border-border/60 bg-muted/30 p-8 text-center">
|
||||||
Nenhum lançamento ou vencimento registrado. Clique em{" "}
|
<RiCalendarEventLine className="size-8 text-muted-foreground/50" />
|
||||||
<span className="font-medium text-primary">Novo lançamento</span>{" "}
|
<p className="text-sm text-muted-foreground">
|
||||||
para começar.
|
Nenhum lançamento registrado para este dia.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { parsePeriod } from "@/shared/utils/period";
|
|||||||
|
|
||||||
const PAYMENT_METHOD_BOLETO = "Boleto";
|
const PAYMENT_METHOD_BOLETO = "Boleto";
|
||||||
const TRANSACTION_TYPE_TRANSFERENCIA = "Transferência";
|
const TRANSACTION_TYPE_TRANSFERENCIA = "Transferência";
|
||||||
|
const PAYMENT_PREFIX = "Pagamento fatura - ";
|
||||||
|
|
||||||
const clampDayInMonth = (year: number, monthIndex: number, day: number) => {
|
const clampDayInMonth = (year: number, monthIndex: number, day: number) => {
|
||||||
const lastDay = new Date(Date.UTC(year, monthIndex + 1, 0)).getUTCDate();
|
const lastDay = new Date(Date.UTC(year, monthIndex + 1, 0)).getUTCDate();
|
||||||
@@ -88,19 +89,28 @@ export const fetchCalendarData = async ({
|
|||||||
const transactionData = mapTransactionsData(transactionRows);
|
const transactionData = mapTransactionsData(transactionRows);
|
||||||
const events: CalendarEvent[] = [];
|
const events: CalendarEvent[] = [];
|
||||||
|
|
||||||
|
// Totais por cartão para exibir no vencimento
|
||||||
const cardTotals = new Map<string, number>();
|
const cardTotals = new Map<string, number>();
|
||||||
for (const item of transactionData) {
|
for (const item of transactionData) {
|
||||||
if (!item.cardId || item.period !== period) {
|
if (!item.cardId || item.period !== period) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const amount = Math.abs(item.amount ?? 0);
|
const amount = Math.abs(item.amount ?? 0);
|
||||||
cardTotals.set(item.cardId, (cardTotals.get(item.cardId) ?? 0) + amount);
|
cardTotals.set(item.cardId, (cardTotals.get(item.cardId) ?? 0) + amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pagamentos de fatura por nome do cartão → data de pagamento
|
||||||
|
const paymentByCardName = new Map<string, string | null>();
|
||||||
for (const item of transactionData) {
|
for (const item of transactionData) {
|
||||||
|
if (!item.name.startsWith(PAYMENT_PREFIX)) continue;
|
||||||
|
const cardName = item.name.slice(PAYMENT_PREFIX.length);
|
||||||
|
paymentByCardName.set(cardName, item.purchaseDate?.slice(0, 10) ?? null);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const item of transactionData) {
|
||||||
|
// Pagamentos de fatura são consumidos pelos eventos de cartão
|
||||||
|
if (item.name.startsWith(PAYMENT_PREFIX)) continue;
|
||||||
|
|
||||||
const isBoleto = item.paymentMethod === PAYMENT_METHOD_BOLETO;
|
const isBoleto = item.paymentMethod === PAYMENT_METHOD_BOLETO;
|
||||||
|
|
||||||
// Para boletos, exibir apenas na data de vencimento
|
|
||||||
if (isBoleto) {
|
if (isBoleto) {
|
||||||
if (
|
if (
|
||||||
item.dueDate &&
|
item.dueDate &&
|
||||||
@@ -114,7 +124,6 @@ export const fetchCalendarData = async ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Para outros tipos de lançamento, exibir na data de compra
|
|
||||||
const purchaseDateKey = item.purchaseDate.slice(0, 10);
|
const purchaseDateKey = item.purchaseDate.slice(0, 10);
|
||||||
if (isWithinRange(purchaseDateKey, rangeStartKey, rangeEndKey)) {
|
if (isWithinRange(purchaseDateKey, rangeStartKey, rangeEndKey)) {
|
||||||
events.push({
|
events.push({
|
||||||
@@ -127,23 +136,60 @@ export const fetchCalendarData = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exibir vencimentos apenas de cartões com lançamentos do período
|
// Agrupar parcelas da mesma série em um único evento
|
||||||
|
const installmentGroups = new Map<
|
||||||
|
string,
|
||||||
|
Array<Extract<CalendarEvent, { type: "transaction" }>>
|
||||||
|
>();
|
||||||
|
for (const event of events) {
|
||||||
|
if (event.type !== "transaction") continue;
|
||||||
|
const { seriesId, installmentCount } = event.transaction;
|
||||||
|
if (!seriesId || !installmentCount || installmentCount <= 1) continue;
|
||||||
|
const group = installmentGroups.get(seriesId) ?? [];
|
||||||
|
group.push(event as Extract<CalendarEvent, { type: "transaction" }>);
|
||||||
|
installmentGroups.set(seriesId, group);
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupedSeriesIds = new Set<string>();
|
||||||
|
const installmentEvents: CalendarEvent[] = [];
|
||||||
|
for (const [seriesId, group] of installmentGroups) {
|
||||||
|
if (group.length < 2) continue;
|
||||||
|
groupedSeriesIds.add(seriesId);
|
||||||
|
const rep = group[0];
|
||||||
|
installmentEvents.push({
|
||||||
|
id: `${seriesId}:installment`,
|
||||||
|
type: "installment",
|
||||||
|
date: rep.date,
|
||||||
|
transaction: rep.transaction,
|
||||||
|
installmentCount: rep.transaction.installmentCount ?? group.length,
|
||||||
|
installmentValue: rep.transaction.amount ?? 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseEvents = events.filter((e) => {
|
||||||
|
if (e.type !== "transaction") return true;
|
||||||
|
const { seriesId } = e.transaction;
|
||||||
|
return !seriesId || !groupedSeriesIds.has(seriesId);
|
||||||
|
});
|
||||||
|
|
||||||
|
const allEvents = [...baseEvents, ...installmentEvents];
|
||||||
|
|
||||||
|
// Vencimentos de cartões com lançamentos no período
|
||||||
for (const card of cardRows) {
|
for (const card of cardRows) {
|
||||||
if (!cardTotals.has(card.id)) {
|
if (!cardTotals.has(card.id)) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const dueDayNumber = Number.parseInt(card.dueDay ?? "", 10);
|
const dueDayNumber = Number.parseInt(card.dueDay ?? "", 10);
|
||||||
if (Number.isNaN(dueDayNumber)) {
|
if (Number.isNaN(dueDayNumber)) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalizedDay = clampDayInMonth(year, monthIndex, dueDayNumber);
|
const normalizedDay = clampDayInMonth(year, monthIndex, dueDayNumber);
|
||||||
const dueDateKey = formatDateKey(
|
const dueDateKey = formatDateKey(
|
||||||
new Date(Date.UTC(year, monthIndex, normalizedDay)),
|
new Date(Date.UTC(year, monthIndex, normalizedDay)),
|
||||||
);
|
);
|
||||||
|
|
||||||
events.push({
|
const isPaid = paymentByCardName.has(card.name);
|
||||||
|
const paymentDate = paymentByCardName.get(card.name) ?? null;
|
||||||
|
|
||||||
|
allEvents.push({
|
||||||
id: `${card.id}:cartao`,
|
id: `${card.id}:cartao`,
|
||||||
type: "card",
|
type: "card",
|
||||||
date: dueDateKey,
|
date: dueDateKey,
|
||||||
@@ -156,17 +202,20 @@ export const fetchCalendarData = async ({
|
|||||||
status: card.status,
|
status: card.status,
|
||||||
logo: card.logo ?? null,
|
logo: card.logo ?? null,
|
||||||
totalDue: cardTotals.get(card.id) ?? null,
|
totalDue: cardTotals.get(card.id) ?? null,
|
||||||
|
isPaid,
|
||||||
|
paymentDate,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const typePriority: Record<CalendarEvent["type"], number> = {
|
const typePriority: Record<CalendarEvent["type"], number> = {
|
||||||
transaction: 0,
|
transaction: 0,
|
||||||
|
installment: 0,
|
||||||
boleto: 1,
|
boleto: 1,
|
||||||
card: 2,
|
card: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
events.sort((a, b) => {
|
allEvents.sort((a, b) => {
|
||||||
if (a.date === b.date) {
|
if (a.date === b.date) {
|
||||||
return typePriority[a.type] - typePriority[b.type];
|
return typePriority[a.type] - typePriority[b.type];
|
||||||
}
|
}
|
||||||
@@ -182,7 +231,7 @@ export const fetchCalendarData = async ({
|
|||||||
const estabelecimentos = await fetchRecentEstablishments(userId);
|
const estabelecimentos = await fetchRecentEstablishments(userId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
events,
|
events: allEvents,
|
||||||
formOptions: {
|
formOptions: {
|
||||||
payerOptions: optionSets.payerOptions,
|
payerOptions: optionSets.payerOptions,
|
||||||
splitPayerOptions: optionSets.splitPayerOptions,
|
splitPayerOptions: optionSets.splitPayerOptions,
|
||||||
|
|||||||
@@ -194,12 +194,12 @@ export function CardDialog({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const title = mode === "create" ? "Novo cartão" : "Editar cartão";
|
const title = mode === "create" ? "Novo cartão" : "Atualizar cartão";
|
||||||
const description =
|
const description =
|
||||||
mode === "create"
|
mode === "create"
|
||||||
? "Inclua um novo cartão de crédito para acompanhar seus gastos."
|
? "Inclua um novo cartão de crédito para acompanhar seus gastos."
|
||||||
: "Atualize as informações do cartão selecionado.";
|
: "Atualize as informações do cartão selecionado.";
|
||||||
const submitLabel = mode === "create" ? "Salvar cartão" : "Atualizar cartão";
|
const submitLabel = mode === "create" ? "Salvar" : "Atualizar";
|
||||||
|
|
||||||
const handleMainDialogOpenChange = (open: boolean) => {
|
const handleMainDialogOpenChange = (open: boolean) => {
|
||||||
if (!open && logoDialogOpen) {
|
if (!open && logoDialogOpen) {
|
||||||
|
|||||||
@@ -84,39 +84,11 @@ export function CardItem({
|
|||||||
const logoPath = resolveLogoSrc(logo);
|
const logoPath = resolveLogoSrc(logo);
|
||||||
const brandAsset = resolveCardBrandAsset(brand);
|
const brandAsset = resolveCardBrandAsset(brand);
|
||||||
const isInactive = status?.toLowerCase() === "inativo";
|
const isInactive = status?.toLowerCase() === "inativo";
|
||||||
const metrics =
|
const hasMetrics = limitTotal !== null && used !== null && available !== null;
|
||||||
limitTotal === null || used === null || available === null
|
|
||||||
? null
|
|
||||||
: [
|
|
||||||
{ label: "Limite Total", value: limitTotal },
|
|
||||||
{ label: "Em uso", value: used },
|
|
||||||
{ label: "Disponível", value: available },
|
|
||||||
];
|
|
||||||
|
|
||||||
const actions = [
|
|
||||||
{
|
|
||||||
label: "editar",
|
|
||||||
icon: <RiPencilLine className="size-4" aria-hidden />,
|
|
||||||
onClick: onEdit,
|
|
||||||
className: "text-primary",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "ver fatura",
|
|
||||||
icon: <RiFileList2Line className="size-4" aria-hidden />,
|
|
||||||
onClick: onInvoice,
|
|
||||||
className: "text-primary",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "remover",
|
|
||||||
icon: <RiDeleteBin5Line className="size-4" aria-hidden />,
|
|
||||||
onClick: onRemove,
|
|
||||||
className: "text-destructive",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="flex flex-col p-6 w-full">
|
<Card className="flex flex-col p-6 w-full">
|
||||||
<CardHeader className="space-y-2 px-0 pb-0">
|
<CardHeader className="space-y-2 p-0">
|
||||||
<div className="flex items-start justify-between gap-2">
|
<div className="flex items-start justify-between gap-2">
|
||||||
<div className="flex flex-1 items-center gap-2">
|
<div className="flex flex-1 items-center gap-2">
|
||||||
{logoPath ? (
|
{logoPath ? (
|
||||||
@@ -135,8 +107,8 @@ export function CardItem({
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-2">
|
||||||
<h3 className="truncate text-sm font-medium text-foreground sm:text-base">
|
<h3 className="truncate font-semibold text-foreground">
|
||||||
{name}
|
{name}
|
||||||
</h3>
|
</h3>
|
||||||
{note ? (
|
{note ? (
|
||||||
@@ -166,14 +138,14 @@ export function CardItem({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{brandAsset ? (
|
{brandAsset ? (
|
||||||
<div className="flex items-center justify-center py-1">
|
<div className="flex items-center justify-center py-2">
|
||||||
<Image
|
<Image
|
||||||
src={brandAsset}
|
src={brandAsset}
|
||||||
alt={`Bandeira ${brand}`}
|
alt={`Bandeira ${brand}`}
|
||||||
width={36}
|
width={36}
|
||||||
height={36}
|
height={36}
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-5 w-auto rounded",
|
"h-4 w-auto rounded",
|
||||||
isInactive && "grayscale opacity-40",
|
isInactive && "grayscale opacity-40",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@@ -185,56 +157,65 @@ export function CardItem({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between border-y py-3 text-xs font-medium text-muted-foreground sm:text-sm">
|
<div className="flex items-center justify-between border-y py-3 text-sm text-muted-foreground">
|
||||||
<span>
|
<span>
|
||||||
Fecha dia{" "}
|
Fecha em{" "}
|
||||||
<span className="font-medium text-foreground">
|
<span className="font-semibold text-foreground">
|
||||||
{formatDay(closingDay)}
|
dia {formatDay(closingDay)}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
Vence dia{" "}
|
Vence em{" "}
|
||||||
<span className="font-medium text-foreground">
|
<span className="font-semibold text-foreground">
|
||||||
{formatDay(dueDay)}
|
dia {formatDay(dueDay)}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
<CardContent className="flex flex-1 flex-col gap-5 px-0">
|
<CardContent className="flex flex-1 flex-col gap-4 px-0">
|
||||||
{metrics ? (
|
{hasMetrics &&
|
||||||
|
available !== null &&
|
||||||
|
used !== null &&
|
||||||
|
limitTotal !== null ? (
|
||||||
<>
|
<>
|
||||||
<div className="grid grid-cols-3 gap-4">
|
<div className="flex flex-col gap-0.5">
|
||||||
<div className="flex flex-col items-start gap-1">
|
<span className="text-xs text-muted-foreground">Disponível</span>
|
||||||
<p className="text-sm font-medium text-foreground">
|
<MoneyValues
|
||||||
<MoneyValues amount={metrics[0].value} />
|
amount={available}
|
||||||
</p>
|
className="text-xl font-semibold text-success"
|
||||||
<span className="text-xs font-medium text-muted-foreground">
|
/>
|
||||||
{metrics[0].label}
|
</div>
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex flex-col items-center gap-1">
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<p className="flex items-center gap-1.5 text-sm font-medium text-foreground">
|
<div className="flex flex-col gap-0.5">
|
||||||
<span className="size-2 rounded-full bg-primary" />
|
<span className="text-xs text-muted-foreground">
|
||||||
<MoneyValues amount={metrics[1].value} />
|
Limite total
|
||||||
</p>
|
|
||||||
<span className="text-xs font-medium text-muted-foreground">
|
|
||||||
{metrics[1].label}
|
|
||||||
</span>
|
</span>
|
||||||
|
<MoneyValues
|
||||||
|
amount={limitTotal}
|
||||||
|
className="text-sm font-semibold text-foreground"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
<div className="flex flex-col items-end gap-1">
|
<span className="text-xs text-muted-foreground">Em uso</span>
|
||||||
<p className="text-sm font-medium text-foreground">
|
<MoneyValues
|
||||||
<MoneyValues amount={metrics[2].value} />
|
amount={used}
|
||||||
</p>
|
className="text-sm font-semibold text-primary"
|
||||||
<span className="text-xs font-medium text-muted-foreground">
|
/>
|
||||||
{metrics[2].label}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Progress value={usagePercent} className="h-3" />
|
<div className="flex flex-col gap-2">
|
||||||
|
<Progress
|
||||||
|
value={usagePercent}
|
||||||
|
className="h-2.5"
|
||||||
|
aria-label={`${usagePercent.toFixed(0)}% do limite utilizado`}
|
||||||
|
/>
|
||||||
|
<span className="text-xs text-muted-foreground">
|
||||||
|
{usagePercent.toFixed(1)}% utilizado
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
@@ -243,21 +224,31 @@ export function CardItem({
|
|||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|
||||||
<CardFooter className="mt-auto flex flex-wrap gap-4 px-0 text-sm">
|
<CardFooter className="mt-auto flex flex-wrap gap-4 px-0 pt-2 text-sm">
|
||||||
{actions.map(({ label, icon, onClick, className }) => (
|
<button
|
||||||
<button
|
type="button"
|
||||||
key={label}
|
onClick={onEdit}
|
||||||
type="button"
|
className="flex items-center gap-1 font-medium text-primary transition-opacity hover:opacity-80"
|
||||||
onClick={onClick}
|
>
|
||||||
className={cn(
|
<RiPencilLine className="size-4" aria-hidden />
|
||||||
"flex items-center gap-1 font-medium transition-opacity hover:opacity-80",
|
editar
|
||||||
className,
|
</button>
|
||||||
)}
|
<button
|
||||||
>
|
type="button"
|
||||||
{icon}
|
onClick={onInvoice}
|
||||||
{label}
|
className="flex items-center gap-1 font-medium text-primary transition-opacity hover:opacity-80"
|
||||||
</button>
|
>
|
||||||
))}
|
<RiFileList2Line className="size-4" aria-hidden />
|
||||||
|
ver fatura
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onRemove}
|
||||||
|
className="flex items-center gap-1 font-medium text-destructive transition-opacity hover:opacity-80"
|
||||||
|
>
|
||||||
|
<RiDeleteBin5Line className="size-4" aria-hidden />
|
||||||
|
remover
|
||||||
|
</button>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||