Commit graph

123 commits

Author SHA1 Message Date
Tiago Yamamoto
b52f780e26 feat: consolidate architecture, remove bff dependency and update backend/frontend modules 2026-03-07 06:40:42 -06:00
Tiago Yamamoto
cab74b9879 fix(api): add empresas aliases for get/delete/verify by id 2026-03-04 19:29:24 -06:00
Tiago Yamamoto
b99f4427ae fix: normalize auth me payload for perfil 2026-03-04 13:20:50 -06:00
Tiago Yamamoto
e701b57f6a fix: accept legacy login payload 2026-03-04 12:33:49 -06:00
Tiago Yamamoto
b00d0fe99c fix: align dev auth and bootstrap superadmin 2026-03-04 10:41:40 -06:00
Tiago Yamamoto
3ca9f50d0c Merge branch 'main' into dev 2026-03-04 09:43:50 -06:00
joaoaodt
915a49967e fix: correcao de login e configuracoes de ambiente local
Alteracoes:
- Configura .env do backend-old com DATABASE_URL e porta 8214
- Atualiza server.go com correcoes de servidor
- Adiciona package-lock.json e atualiza package.json do backend Medusa
- Adiciona docker-compose.yml para servicos locais
- Corrige authUtils.ts e CadastroProdutoWizard.tsx no frontend
2026-03-04 12:26:22 -03:00
joaoaodt
eb9dc8be1d fix: correcoes de acesso e marketplace
- Corrige algoritmo de validacao CNPJ (pesos completos 12/13 digitos)
- Auto-login apos cadastro de usuario redirecionando para /seller
- Registro: role padrao Seller quando campo vazio, mapeamento company_name/cnpj
- Adiciona role Seller ao middleware productManagers (fix 403 em criacao de produto)
- Inventario: usa campos corretos da API (nome, ean_code, sale_price_cents, stock_quantity)
- Marketplace: raio padrao nacional (5000km), empresas sem coordenadas sempre visiveis
- dto.go: adiciona CompanyName e CNPJ ao registerAuthRequest
2026-02-27 15:46:35 -03:00
joaoaodt
d8073629a6 feat(cli): adiciona comando para reset de senha de usuários
Implementa comando CLI que permite resetar a senha de usuários diretamente no banco de dados para casos de recuperação de acesso.

Funcionalidades:
- Conecta com PostgreSQL usando pgx
- Gera hash bcrypt da nova senha com pepper
- Atualiza senha do usuário por email
- Valida existência do usuário

Uso: go run cmd/reset_password/main.go
Email padrão: usuario@saveinmed.com
Senha padrão: senha123
2026-02-26 18:43:40 -03:00
joaoaodt
dca3725864 Merge branch 'dev' of https://github.com/rede5/saveinmed into dev 2026-02-26 18:39:05 -03:00
caio-machado-dev
3aea36e594 feat: resolve react-icons dependency, add frontend e2e and backend tests 2026-02-26 18:27:02 -03:00
joaoaodt
5900241df6 Merge: mudanças locais + remotas do branch dev 2026-02-26 16:30:59 -03:00
eycksilva
3559afc1f7 feat(ui): padronizar paleta #0F4C81 e estrutura em múltiplas telas
- SellerDashboard: migrado para Shell (header topo), removida sidebar lateral,
  cards KPI brancos com react-icons pretos (FaChartLine, FaBoxOpen, FaReceipt)
- Shell: adicionados todos os links de nav para owner/seller no header
  (Estoque, Buscar Produtos, Pedidos, Carteira, Equipe, Config. Entrega)
- Wallet: ícone FaMoneyCheck no botão Solicitar Saque, card saldo com #0F4C81,
  thead da tabela com #0F4C81, fix R$ NaN (formatCurrency null-safe)
- Team: botões e thead com #0F4C81, emojis removidos dos roleLabels
- ShippingSettings: wrapped com Shell (mantém header), emojis substituídos por
  react-icons pretos (FaTruck, FaLocationDot, FaStore, FaCircleInfo, FaFloppyDisk),
  botão Salvar com #0F4C81
- Orders: removido box cinza de fundo dos ícones nas abas e estado vazio
- LocationPicker: fallback seguro para OpenStreetMap quando VITE_MAP_TILE_LAYER
  não está definido (corrige tela branca em /search)
- Inventory/Cart: cores dos botões e thead atualizadas para #0F4C81
2026-02-26 15:56:03 -03:00
caio-machado-dev
bf85072bff chore: remove legacy services and restructure monorepo
- remove backend-old (Medusa), saveinmed-frontend (Next.js/Appwrite) and marketplace dirs
- split Go usecases by domain and move notifications/payments to infrastructure
- reorganize frontend pages into auth, dashboard and marketplace modules
- add Makefile, docker-compose.yml and architecture docs
2026-02-25 16:51:34 -03:00
caio-machado-dev
ea22729994 feat(company): adiciona melhorias de geolocalização e documentos
- implementa busca automática de CEP e coordenadas
- adiciona upload e visualização de licença sanitária
- corrige listagem de pedidos vinculados à empresa
- ajusta interceptador Axios para envio correto de multipart/form-data
2026-02-20 19:31:24 -03:00
Gabbriiel
90467db1ec refactor: substitui backend Medusa por backend Go e corrige testes do marketplace
- Remove backend Medusa.js (TypeScript) e substitui pelo backend Go (saveinmed-performance-core)
- Corrige testes auth.test.ts: alinha paths de API (v1/ sem barra inicial) e campo access_token
- Corrige GroupedProductCard.test.tsx: ajusta distância formatada (toFixed) e troca userEvent por fireEvent com fakeTimers
- Corrige AuthContext.test.tsx: usa vi.hoisted() para mocks e corrige parênteses no waitFor

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 04:56:37 -06:00
Tiago Yamamoto
9a8ba8fca8 Add Medusa backend starter 2026-01-16 11:14:36 -03:00
Tiago Yamamoto
668156fb48 Rename backend folder to backend-old 2026-01-16 10:51:52 -03:00
Tiago Yamamoto
78c7839e60 docs: add status sections to markdown files 2026-01-08 14:28:34 -03:00
Tiago Yamamoto
bb8b10b26b Expandir cobertura de handlers financeiros e admin 2026-01-02 11:27:36 -03:00
Tiago Yamamoto
3f69cade21 test: expand backend coverage 2026-01-02 11:01:56 -03:00
Tiago Yamamoto
4a18f76bd1 test: cover product import 2026-01-02 09:23:18 -03:00
Tiago Yamamoto
8eb9126bcc Add financial service unit tests 2026-01-02 09:17:17 -03:00
Tiago Yamamoto
9fb4f3e12e test: expand backend coverage 2026-01-01 16:01:45 -03:00
Tiago Yamamoto
f913f6b3d4 Add backend middleware and frontend card tests 2026-01-01 15:49:17 -03:00
Tiago Yamamoto
8588d07388 Add config helper tests 2026-01-01 15:43:33 -03:00
Tiago Yamamoto
d3f1d0e36d docs: add b2b gaps roadmap and test matrix 2026-01-01 15:20:48 -03:00
Tiago Yamamoto
c48666bf60 Add backend and frontend test coverage 2026-01-01 15:06:55 -03:00
Tiago Yamamoto
f7967490e7 test: expand config coverage 2026-01-01 11:46:06 -03:00
Tiago Yamamoto
eb5c59c1e2 fix(backoffice): repair build errors, update prisma schema and services 2025-12-29 19:07:31 -03:00
Tiago Yamamoto
5c59e7b5a1 docs: add DEVOPS guide and optimize Dockerfiles
- Add DEVOPS.md with complete deployment guide for apolo server
- Add DATABASE.md (unified schema documentation)
- Fix backend Dockerfile: Go 1.24 -> 1.23 (current stable)
- Add marketplace Dockerfile with pnpm + static-web-server
- Migrate marketplace from npm to pnpm
- Remove duplicate database-schema.md and DATABASE_SCHEMA.md
2025-12-29 17:00:42 -03:00
Tiago Yamamoto
36d6fa4ae0 feat: Implement Phase 4 features
Backend (Go):
- FCM Push Notifications (fcm.go, push_handler.go)
- Credit Lines (credit_line.go, credit_handler.go)
- Payment Config (admin_handler.go, seller_payment_handler.go)
- Team Management (team_handler.go)

Backoffice (NestJS):
- Dashboard module (KPIs, revenue charts)
- Audit module (tracking changes)
- Disputes module (CRUD, resolution)
- Reports module (CSV export)
- Performance module (seller scores)
- Fraud module (detection, alerts)

Frontend (Marketplace):
- ThemeContext for Dark Mode
- HelpCenter page with FAQ
- OrderDetails with timeline
- Team management page
- Persistent cart (Zustand)
2025-12-27 10:07:05 -03:00
Tiago Yamamoto
b41f1f6a52 feat(phase2): implement Trust, Safety & Financials
- Backend: Add Financial logic (Ledger, Withdrawals) and KYC Endpoints
- Backoffice: Update Prisma Schema and add KYC Review Module
- Frontend: Add Company Profile, Wallet View, and Reviews/Ratings UI
- Frontend: Enhance Admin Companies Page for KYC Review Queue
2025-12-27 01:56:32 -03:00
Tiago Yamamoto
bbe6ec447e feat(backend): implement financial features (KYC, ledger, withdrawals) 2025-12-27 01:34:29 -03:00
Tiago Yamamoto
6de471ce3e feat(backend): implement notification system (logger mock) 2025-12-27 01:24:43 -03:00
Tiago Yamamoto
b63242b8fd feat(backend): implement stripe and asaas webhook handlers 2025-12-27 01:21:25 -03:00
Tiago Yamamoto
132fef816c feat(backend): implement order state machine with validation 2025-12-27 01:18:00 -03:00
Tiago Yamamoto
89036d7b39 docs: add detailed mermaid diagrams for db, backend and marketplace 2025-12-27 01:13:11 -03:00
Tiago Yamamoto
53385670a3 feat: consolidate admin/seller dashboard, remove bff, fix backoffice docker, update docs 2025-12-27 00:58:06 -03:00
Tiago Yamamoto
d1d2f3f338 chore: remove unused parseShippingMethodType function 2025-12-27 00:31:54 -03:00
Tiago Yamamoto
7105549faf test: add handler tests (+9.6% coverage: 36.9% → 46.5%)
Added 26 new handler tests:
- SearchProducts: MissingLatLng, InvalidLat/Lng, Success, WithFilters
- Auth: RegisterCustomer, RegisterTenant, ForgotPassword, ResetPassword, VerifyEmail, Logout
- Pagination: ListProducts, ListCompanies, ListOrders
- Shipping: CalculateShipping, GetShippingSettings
- Reviews: CreateReview, GetCompanyRating
- Dashboard: GetSellerDashboard
- Payments: CreatePaymentPreference, HandlePaymentWebhook
- Shipments: CreateShipment, GetShipmentByOrderID

Handler coverage: 36.9% → 46.5% (+9.6%)
Seeder already has 'Aparecida de Goiânia' (verified)
2025-12-27 00:29:03 -03:00
Tiago Yamamoto
ebd6d903ec test: add comprehensive Asaas gateway tests (+45% payments coverage)
Added 17 new tests for Asaas payment gateway:
- TestNewAsaasGateway, TestAsaasBaseURL_Sandbox/Production
- TestAsaasCreatePreference, TestAsaasCreatePixPayment
- TestAsaasCreateBoletoPayment, TestAsaasConfirmPayment
- TestAsaasRefundPayment, TestAsaasCreateSubaccount
- Context cancellation tests for all methods

Coverage results:
- Payments: 50% → 95.3% (+45%)
- Middleware: 90.8%
- Config: 85.7%
- Server: 69.1%
- Handler: 36.9%
2025-12-27 00:22:52 -03:00
Tiago Yamamoto
3c49df55e4 feat: complete payment gateway implementation (Asaas, Stripe, MercadoPago)
Payment Gateways:
- asaas.go: Pix (QR code), Boleto, Credit Card with split
- Seller subaccount creation for split payments
- 6 new domain types: PixPaymentResult, BoletoPaymentResult, SellerPaymentAccount, Customer, PaymentGatewayConfig

Documentation:
- docs/PAYMENT_GATEWAYS.md: Complete comparison (MercadoPago vs Stripe vs Asaas)
- Admin routes for gateway config
- Seller onboarding routes
- Environment variables reference

Coverage: 50% payments
2025-12-27 00:11:48 -03:00
Tiago Yamamoto
c53cd5a4dd test: add Stripe and Mock gateway tests (+79% payments coverage)
Added 12 new tests for payment gateways:
- TestNewStripeGateway, TestStripeCreatePreference, TestStripeCreatePaymentIntent
- TestNewMockGateway, TestMockCreatePreference, TestMockConfirmPayment, TestMockRefundPayment
- Context cancellation tests for all gateways

Coverage increases:
- Payments: 11.8% → 91.4% (+79.6%)
- Handler: 32.6% → 36.9%
- Middleware: 90.8%
- Config: 85.7%
- Server: 69.1%

Frontend: 95 tests passing
2025-12-26 23:42:38 -03:00
Tiago Yamamoto
8f1e893142 feat: major implementation - seeder, payments, docs
Seeder API:
- 110 pharmacies across 5 cities (Goiânia 72, Anápolis 22, Nerópolis 10, Senador Canedo 5, Aparecida 1)
- 3-300 products per pharmacy
- Dynamic city/state in company records

Payment Gateways:
- stripe.go: Stripe integration with PaymentIntent
- mock.go: Mock gateway with auto-approve for testing
- PaymentResult and RefundResult domain types

Documentation:
- docs/BACKEND.md: Architecture, invisible fee, endpoints
- docs/SEEDER_API.md: City distribution, product counts
- docs/MARKETPLACE.md: Frontend structure, stores, utils
- docs/BACKOFFICE.md: Admin features, encrypted settings
2025-12-26 23:39:49 -03:00
Tiago Yamamoto
12e2503244 feat: implement invisible 12% buyer fee
Business model:
- Seller registers R$10,00 → Seller sees R$10,00 → Seller receives R$10,00
- Buyer searches → sees R$11,20 (+12%) → pays R$11,20
- Marketplace keeps R$1,20 (12%)

Changes:
- config.go: Add BuyerFeeRate (default 0.12)
- handler.go: Add buyerFeeRate field to Handler struct
- product_handler.go: SearchProducts inflates prices for buyers
- server.go: Pass cfg.BuyerFeeRate to handler.New()
- handler_test.go: Fix 3 New() calls with fee rate

Env var: BUYER_FEE_RATE (default: 0.12)
2025-12-26 23:23:18 -03:00
Tiago Yamamoto
670af4ea67 test: increase test coverage +10% frontend, +2% backend
Backend (+1.8%):
- Add shipping handler tests (GetShippingSettings, UpsertShippingSettings, CalculateShipping)
- Add ListOrders with role filters tests
- Handler coverage: 32.6% → 37.2%

Frontend (+16 tests, 72 → 88):
- Add jwt.test.ts (6 tests)
- Add logger.test.ts (8 tests)
- Add useDebounce.test.ts (5 tests)
2025-12-26 23:02:18 -03:00
Tiago Yamamoto
114e8dc5bc fix: add payment_method column to orders table
Migration 0008: adds payment_method column with default 'pix'
Fixes 500 error: column "payment_method" does not exist
2025-12-26 22:56:46 -03:00
Tiago Yamamoto
f0d64d1801 fix(tests): fix failing tests and increase coverage
Backend:
- Fix TestCreateCompany (added Phone, OperatingHours, Is24Hours)
- Fix TestCreateProduct (added EANCode, Manufacturer, Category, etc)
- Add TestCreateUser, TestListUsers, TestListOrders, TestGetShippingSettings
- All 9 repository tests now pass

Frontend:
- Add shippingService.test.ts (4 tests)
- Add ordersService.test.ts (5 tests)
- Add format.test.ts (9 tests)
- Total tests increased from 54 to 72
2025-12-26 22:54:51 -03:00
Tiago Yamamoto
630bcc9da5 debug: add detailed logging with emojis for orders endpoint
Backend (order_handler.go):
- Log URL, method, pagination
- Log requester role and company ID
- Log role query param and filter values
- Log service call results and errors

Frontend (Orders.tsx):
- Styled console logs with colors
- Log tab, endpoint, response data
- Detailed error logging with response data
2025-12-26 22:44:34 -03:00