Commit graph

51 commits

Author SHA1 Message Date
Tiago Yamamoto
091e8093c0 feat: apply logo, document database schema, update docs
- Move logo to marketplace/src/assets/
- Apply logo in Shell.tsx header
- Add favicon and meta tags to index.html
- Create docs/database-schema.md with ER diagram
- Update README.md with database section
- Update marketplace/README.md with assets section
- Update seeder-api/README.md with new fields
2025-12-23 17:01:16 -03:00
Tiago Yamamoto
8d4731268e feat(marketplace): add company management and user editing features
Backend:
- Add phone, operating_hours, is_24_hours fields to Tenant model
- Create migration 0005_tenants_operating_hours.sql for new columns
- Update postgres repository queries for new fields

Frontend Company.tsx:
- Expand company edit form with phone, city, state
- Add operating hours section with 24h toggle
- Add user edit/delete buttons with Actions column
- Add user edit modal with name, email, role fields
- Add handleDeleteUser and handleSaveUser functions
2025-12-23 16:44:51 -03:00
Tiago Yamamoto
352ef86617 fix(marketplace): filter own products by company_id from JWT
- Add companyId field to AuthUser interface in AuthContext
- Extract company_id from JWT payload in Login.tsx
- Use user.companyId to filter products where seller_id matches
- This properly excludes own store products using UUID comparison
2025-12-23 16:31:46 -03:00
Tiago Yamamoto
2bbb715ebb fix(marketplace): filter out own store products by 0km distance
- For owners/sellers, exclude products at exactly 0km (own pharmacy)
- This correctly hides own products without needing company_id in JWT
2025-12-23 16:29:08 -03:00
Tiago Yamamoto
e7b02f24e7 fix(marketplace): fix modal z-index and button colors
- Change modal z-index from z-50 to z-[1000] to appear above Leaflet map
- Replace bg-primary with bg-blue-600 for visible button styling
- Fix 'Adicionar' button in ProductOffersModal
- Fix 'Ver ofertas' button in GroupedProductCard
2025-12-23 16:23:59 -03:00
Tiago Yamamoto
8ec820c383 feat(marketplace): add cart hover dropdown preview
- Add CartDropdownContent component showing cart items on hover
- Show 'carrinho vazio' message when empty
- Display up to 4 items with name, quantity, price
- Add remove button for each item in dropdown
- Show total and 'Ver carrinho completo' link
- Badge only shows when cart has items (already implemented)
2025-12-23 16:21:48 -03:00
Tiago Yamamoto
299001d8bc feat(marketplace): add functional sort dropdown to ProductSearch
- Add sortBy state with options: price, distance, expiry
- Replace static text with interactive select dropdown
- Implement sorting logic for each option in groupedProducts memo
2025-12-23 16:19:47 -03:00
Tiago Yamamoto
1600591f86 feat(marketplace): improve ProductSearch with grouping, modal, and filters
- Add Shell layout to restore header navigation
- Filter out products from logged-in user's own pharmacy
- Group medications by name (e.g., Losartana 50mg shows as 1 card with '3 offers')
- Create GroupedProductCard component with offer count badge
- Create ProductOffersModal with sorted offers and add-to-cart
- Implement advanced filters (price range, minimum expiry days)
- Add GroupedProduct interface to types
- Sort grouped products by lowest price
2025-12-23 16:13:19 -03:00
Tiago Yamamoto
3a618fa466 chore(marketplace): remove Checkout page and route
- Remove CheckoutPage import from App.tsx
- Remove /checkout route from routing configuration
2025-12-23 16:04:46 -03:00
Tiago Yamamoto
cad6010965 feat(marketplace): replace cart text with icon + badge counter
- Remove Checkout link from header navigation
- Replace 'Carrinho' text with cart SVG icon
- Add red badge showing cart item count (max 99+)
- Import and use cartStore for real-time count updates
2025-12-23 16:01:54 -03:00
Tiago Yamamoto
77d23dac7e feat(marketplace): enable ProductSearch page for pharmacy owners and employees
- Add ProductSearch route at /search with access for owner, seller, employee roles
- Add 'Comprar Medicamentos' button to SellerDashboard header
- Add 'Comprar Medicamentos' button and card to EmployeeDashboard
- Remove redirect that was blocking access to the product search page
2025-12-23 15:59:51 -03:00
Tiago Yamamoto
32f6fde529 Fix shipping settings validation 2025-12-23 15:08:46 -03:00
Tiago Yamamoto
36c0742735 Add company tabs for users and shipping settings 2025-12-23 14:30:55 -03:00
Tiago Yamamoto
51b6165f09 Add cart empty state 2025-12-23 12:03:47 -03:00
Tiago Yamamoto
6a66503b48 Update profile dropdown in marketplace shell 2025-12-23 11:48:54 -03:00
Tiago Yamamoto
49d8878706 Add owner profile link and page 2025-12-23 09:21:38 -03:00
Tiago Yamamoto
20980d8a80 Add profile dropdown to marketplace header 2025-12-23 08:12:54 -03:00
Tiago Yamamoto
95913578e9 Add profile dropdown to marketplace header 2025-12-23 08:05:51 -03:00
Tiago Yamamoto
54d0de2844 Gate marketplace logs behind logger 2025-12-22 17:52:05 -03:00
Tiago Yamamoto
6477eeb756 fix(marketplace): handle paginated API response in Orders and Inventory pages 2025-12-22 16:39:30 -03:00
Tiago Yamamoto
965cedca05 fix(marketplace): add centralized formatCurrency/formatCents utilities to prevent toFixed errors 2025-12-22 16:31:39 -03:00
Tiago Yamamoto
5c004422f2 feat(marketplace): fix R$ NaN and add owner navigation links 2025-12-22 15:42:58 -03:00
Tiago Yamamoto
940e6561f4 feat(marketplace): add password visibility toggle with eye icon on login page 2025-12-22 15:10:29 -03:00
Tiago Yamamoto
9e0601179e fix(marketplace): install dependencies and resolve vite/client type error 2025-12-22 14:55:12 -03:00
Tiago Yamamoto
c288767057 Fix admin dashboard stats loading 2025-12-22 11:21:56 -03:00
Tiago Yamamoto
03a14b628b fix: seeder tables and marketplace api proxy configuration 2025-12-22 11:14:14 -03:00
Tiago Yamamoto
b0b96d469c Add review and shipment admin listing endpoints 2025-12-22 10:15:27 -03:00
Tiago Yamamoto
4ccfa629cc feat: add admin reviews, logistics, profile pages and update seeder 2025-12-22 09:08:42 -03:00
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
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
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
f0b9d27cee Fix login token guard 2025-12-22 00:06:06 -03:00
Tiago Yamamoto
c11652d386 Block marketplace search route 2025-12-22 00:00:27 -03:00
Tiago Yamamoto
a87459455d Guard against missing marketplace arrays 2025-12-21 23:55:06 -03:00
Tiago Yamamoto
b710383733 Implement marketplace auth login integration 2025-12-21 23:40:34 -03:00
Tiago Yamamoto
e73d423b16 refactor: move seeder to api, improve coverage and security 2025-12-20 11:13:53 -03:00
Tiago Yamamoto
25cee3911c chore: refactor backend config, unignore .env, update config loading 2025-12-20 10:10:55 -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
e40517aac4 refactor(handler): extract company handlers + update READMEs
Backend:
- Extract 8 company handlers to company_handler.go (228 lines)
- handler.go reduced from 1254 to ~1026 lines
- Total refactoring: ~35% of original handler.go

READMEs updated:
- Backend: new architecture, test coverage table
- Marketplace: new pages (Orders, Inventory, Company, SellerDashboard), Vitest info
2025-12-20 07:58:37 -03:00
Tiago Yamamoto
b8973739ab feat(backend): add comprehensive test suite for 80% coverage
- Add config_test.go (5 tests for env parsing)
- Add middleware_test.go (16 tests for CORS, Auth, Gzip, Logger)
- Add usecase_test.go (30+ tests for business logic)
- Add payments_test.go (6 tests for MercadoPago gateway)

Coverage: config 100%, middleware 95.9%, payments 100%, usecase 64.7%

feat(marketplace): add test framework and new pages

- Setup Vitest with jsdom environment
- Add cartStore.test.ts (15 tests for Zustand store)
- Add usePersistentFilters.test.ts (5 tests for hook)
- Add apiClient.test.ts (7 tests for axios client)
- Add Orders page with status transitions
- Add Inventory page with stock adjustments
- Add Company page with edit functionality
- Add SellerDashboard page with KPIs

Total marketplace tests: 27 passing
2025-12-20 07:43:56 -03:00
Tiago Yamamoto
c83079e4c9 chore(marketplace): update package-lock.json 2025-12-20 07:27:37 -03:00