Commit graph

153 commits

Author SHA1 Message Date
Tiago Yamamoto
4f6c96daf0 feat: improve admin products with store column and seeder with orders/cart
- Add Loja (store) column to ProductsPage showing which company owns product
- Optimize ProductsPage to update local state instead of reloading list
- Add orders (5-10 random) and cart items to lean seeder for testing
- Fix expires_at date format to ISO 8601 for backend compatibility
- Improve delete error message for products with related orders
2025-12-22 08:29:22 -03:00
Tiago Yamamoto
6c0b4c4cd6 fix(marketplace): fix product date format and improve UX
- Convert expires_at to ISO 8601 format for backend compatibility
- Update local state instead of reloading list on edit/create/delete
- Improve delete error message for products with related orders
2025-12-22 08:21:42 -03:00
Tiago Yamamoto
00685f7b26 fix(marketplace): fix duplicate /api in URLs and add adminService tests
- Fix adminService URLs from /api/v1 to /v1 (base URL already includes /api)
- Add adminService.test.ts with 17 unit tests for all CRUD operations
- Update productService.test.ts and auth.test.ts for new apiClient format
- All 31 frontend tests passing
2025-12-22 08:04:27 -03:00
Tiago Yamamoto
460303e90e feat(marketplace): add console logging to adminService for debugging 2025-12-22 07:51:42 -03:00
Tiago Yamamoto
59919cb875 feat(marketplace): implement admin dashboard with full CRUD operations
- Add Header component with top navigation menu
- Create DashboardLayout with nested routing under /dashboard
- Implement Users, Companies, Products, Orders CRUD pages
- Add adminService with all API operations
- Update apiClient to return data directly with patch support
- Fix TypeScript errors in existing pages
- Update seeder README with detailed user credentials table
- Fix fmt.Sprintf format verb in seeder.go
2025-12-22 07:22:01 -03:00
Tiago Yamamoto
ebfc72969c feat(seeder): implemented 4 pharmacies with staff in lean mode 2025-12-22 01:42:21 -03:00
Tiago Yamamoto
d44a8873b9 docs(seeder): update documentation, fix go.mod and ignore binary 2025-12-22 01:38:41 -03:00
Tiago Yamamoto
e624d642aa feat: RBAC implementation and Seeder refactor 2025-12-22 01:30:55 -03:00
Tiago Yamamoto
6e2b6a8e89 debug(marketplace): add component mount log to trigger deploy 2025-12-22 01:17:19 -03:00
Tiago Yamamoto
9740ba2e9b chore(marketplace): configure env vars for API and Map 2025-12-22 01:15:37 -03:00
Tiago Yamamoto
c0903f06ab debug(marketplace): add console.log to authService 2025-12-22 01:09:26 -03:00
Tiago Yamamoto
77c93346e5 debug(marketplace): add console.log to login for debugging 2025-12-22 01:05:31 -03:00
Tiago Yamamoto
9ad6d87590 fix(backend): add missing Username field to admin seeding 2025-12-22 00:45:30 -03:00
Tiago Yamamoto
a160321ca2 chore(backend): remove unused go dependencies 2025-12-22 00:38:55 -03:00
Tiago Yamamoto
a2f305be3f fix(marketplace): exclude test files from production build 2025-12-22 00:35:28 -03:00
Tiago Yamamoto
c9a08c8621 test: add automated tests for admin login
Backend:
- TestAdminLogin_Success: verify admin login with username
- TestAdminLogin_WrongPassword: verify 401 for wrong password

Frontend (Marketplace):
- auth.test.ts: mocked tests for login/logout (5 tests)
- auth.integration.test.ts: real API tests (3 tests, skipped in CI)
2025-12-22 00:31:26 -03:00
Tiago Yamamoto
fa726e5864
Merge pull request #28 from rede5/codex/verificar-erro-de-login
Corrige login do marketplace quando token JWT ausente
2025-12-22 00:06:16 -03:00
Tiago Yamamoto
f0b9d27cee Fix login token guard 2025-12-22 00:06:06 -03:00
Tiago Yamamoto
8b4304b910
Merge pull request #27 from rede5/codex/block-marketplace-search-route
Block marketplace /search route by redirecting to /dashboard
2025-12-22 00:00:43 -03:00
Tiago Yamamoto
c11652d386 Block marketplace search route 2025-12-22 00:00:27 -03:00
Tiago Yamamoto
d79e2ffee0
Merge pull request #26 from rede5/codex/fix-typeerror-for-undefined-properties
Handle missing arrays in marketplace API responses
2025-12-21 23:55:26 -03:00
Tiago Yamamoto
a87459455d Guard against missing marketplace arrays 2025-12-21 23:55:06 -03:00
Tiago Yamamoto
55342c5375
Merge pull request #25 from rede5/codex/implementar-no-marketplace
Implement marketplace authentication login integration
2025-12-21 23:40:47 -03:00
Tiago Yamamoto
b710383733 Implement marketplace auth login integration 2025-12-21 23:40:34 -03:00
Tiago Yamamoto
9997aed18a fix(backend): fix build errors, update tests, and improve documentation
- Add GetUserByEmail to Repository interface for password reset flow
- Add username to UpdateUser query
- Fix config_test.go: remove references to deleted DB pool fields
- Fix handler_test.go: add GetUserByUsername to MockRepository
- Fix usecase_test.go: add GetUserByUsername and update auth tests
- Update backend README with auth and admin seeding info
- Create seeder-api README with usage and warnings
2025-12-21 23:11:33 -03:00
Tiago Yamamoto
4612172b3c feat(backend): switch auth to username and cleanup db config 2025-12-21 23:04:47 -03:00
Tiago Yamamoto
c1f32d0165
Merge pull request #24 from rede5/codex/verify-and-implement-authentication-routes-in-swagger
Add complete auth endpoints, password reset/verify and update swagger
2025-12-21 22:39:01 -03:00
Tiago Yamamoto
b72f8f3099 Add full auth endpoints and swagger updates 2025-12-21 22:37:54 -03:00
Tiago Yamamoto
276b6bb923 refactor(backend): rename SWAGGER_HOST to BACKEND_HOST
Renames SWAGGER_HOST to BACKEND_HOST in .env.example and config. Updates main.go to use the new configuration variable.
2025-12-21 22:21:37 -03:00
Tiago Yamamoto
e162ef04a5
Merge pull request #23 from rede5/codex/add-url-selection-from-env-file
Add Swagger host and schemes env config
2025-12-21 22:16:25 -03:00
Tiago Yamamoto
73ebe3ec6d Add swagger host/scheme env config 2025-12-21 22:16:11 -03:00
Tiago Yamamoto
f71a3a320a
Merge pull request #22 from rede5/codex/fix-content-security-policy-violations
Relax Content-Security-Policy for Swagger UI under /docs
2025-12-21 22:10:19 -03:00
Tiago Yamamoto
8ab398723d Relax CSP for Swagger docs 2025-12-21 22:10:03 -03:00
Tiago Yamamoto
fd237cd9c4 fix(backend): resolving hardcoded values and test failures
Updates .env.example with missing variables. Adds missing security headers in middleware. Fixes repository tests including timezone issues and sqlmock expectations.
2025-12-21 21:43:50 -03:00
Tiago Yamamoto
d63fb0da2d
Merge pull request #21 from rede5/codex/implement-advanced-search-repository-layer
Add marketplace advanced record search with windowed pagination and updated_at trigger
2025-12-21 17:36:28 -03:00
Tiago Yamamoto
4ad6a0aae5 Add marketplace record search and audit trigger 2025-12-21 17:36:17 -03:00
Tiago Yamamoto
ab138b6436 chore(deps): update go modules 2025-12-20 11:13:53 -03:00
Tiago Yamamoto
bad6d15a60 refactor: move seeder to api, improve coverage and security 2025-12-20 11:13:53 -03:00
Tiago Yamamoto
e73d423b16 refactor: move seeder to api, improve coverage and security 2025-12-20 11:13:53 -03:00
Tiago Yamamoto
51ad574d72
Merge pull request #20 from rede5/codex/implement-logistics-and-delivery-module
Add shipping settings, calculation logic and API endpoints
2025-12-20 10:47:56 -03:00
Tiago Yamamoto
fd60888706 Add shipping settings and calculation 2025-12-20 10:47:37 -03:00
Tiago Yamamoto
d9886fae62
Merge pull request #19 from rede5/codex/implement-backend-migrations-and-test
Add SQL migrations runner for backend schema
2025-12-20 10:33:46 -03:00
Tiago Yamamoto
77f414bf02 Add database migrations runner 2025-12-20 10:32:54 -03:00
Tiago Yamamoto
c3006064f7 chore: update backend .env.example 2025-12-20 10:12:02 -03:00
Tiago Yamamoto
25cee3911c chore: refactor backend config, unignore .env, update config loading 2025-12-20 10:10:55 -03:00
Tiago Yamamoto
4bb848788f feat: tenant model, seeder, and product search with distance
Tenant Model:
- Renamed Company→Tenant (Company alias for compatibility)
- Added: lat/lng, city, state, category
- Updated: postgres, handlers, DTOs, schema SQL

Seeder (cmd/seeder):
- Generates 400 pharmacies in Anápolis/GO
- 20-500 products per tenant
- Haversine distance variation ±5km from center

Product Search:
- GET /products/search with advanced filters
- Filters: price (min/max), expiration, distance
- Haversine distance calculation (approx km)
- Anonymous seller (only city/state shown until checkout)
- Ordered by expiration date (nearest first)

New domain types:
- ProductWithDistance, ProductSearchFilter, ProductSearchPage
- HaversineDistance function

Updated tests for Category instead of Role
2025-12-20 09:03:13 -03:00
Tiago Yamamoto
beffeb8268 feat(security): add rate limiting and security headers middleware
Rate Limiting (ratelimit.go):
- Token bucket algorithm per IP
- Default: 100 requests/minute
- X-Forwarded-For support
- Cleanup for stale buckets
- 7 tests (ratelimit_test.go)

Security Headers (security.go):
- X-Content-Type-Options: nosniff
- X-Frame-Options: DENY
- X-XSS-Protection: 1; mode=block
- Content-Security-Policy: default-src 'none'
- Referrer-Policy: strict-origin-when-cross-origin
- Cache-Control: no-store, max-age=0

Middleware coverage: 97.3% -> 95.8% (new code added)
2025-12-20 08:41:36 -03:00
Tiago Yamamoto
45d34f36c8 feat(pagination): add pagination to all list endpoints
Added pagination support to:
- ListCompanies: filter by role, search
- ListProducts: filter by seller, search
- ListOrders: filter by buyer, seller, status
- ListInventory: filter by expiring date, seller

New domain types:
- ProductFilter, ProductPage
- CompanyFilter, CompanyPage
- OrderFilter, OrderPage
- InventoryPage

All endpoints now return paginated responses with:
- items array
- total count
- current page
- page size

Updated MockRepository in both test files to match new signatures
2025-12-20 08:37:59 -03:00
Tiago Yamamoto
b713d8fbed test(middleware): expand coverage 95.9% -> 97.3%
Added tests for:
- Expired token handling
- Wrong signing method rejection (None type attack)
2025-12-20 08:24:03 -03:00
Tiago Yamamoto
16a9ff7ffe test(handler): expand handler test coverage 6.6% -> 44.9%
Added 40+ new handler tests covering:
- Auth: Register, Login (invalid JSON, missing company)
- Company: Get, Update, Delete, Verify, Rating, MyCompany
- Product: Get, Update, Delete (not found, invalid UUID)
- Inventory: List, Adjust (invalid params)
- Order: Create, Get, Update, Delete (validation)
- Payment: Preference, Webhook, Shipment
- Dashboard: Seller, Admin (authorization)
- User: CRUD operations (admin/seller scoping)
- Cart: Add, Get, Delete (context validation)
- Review: Create (validation)

Fixed MockRepository to return errors for not found entities
2025-12-20 08:21:25 -03:00