251211:1314 Frontend: reeactor Admin panel
This commit is contained in:
@@ -49,8 +49,9 @@ backend/
|
||||
│ │ ├── master/
|
||||
│ │ ├── monitoring/
|
||||
│ │ ├── notification/
|
||||
│ │ ├── organizations/
|
||||
│ │ ├── project/
|
||||
│ │ ├── organization/
|
||||
│ │ ├── contract/
|
||||
│ │ ├── rfa/
|
||||
│ │ ├── search/
|
||||
│ │ ├── transmittal/
|
||||
|
||||
2569
specs/07-database/lcbp3-v1.5.1-seed-contractdrawing.sql
Normal file
2569
specs/07-database/lcbp3-v1.5.1-seed-contractdrawing.sql
Normal file
File diff suppressed because it is too large
Load Diff
48
specs/09-history/2025-12-11-admin-console-fixes.md
Normal file
48
specs/09-history/2025-12-11-admin-console-fixes.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# Session Log: Admin Console Fixes
|
||||
Date: 2025-12-11
|
||||
|
||||
## Overview
|
||||
This session focused on debugging and resolving critical display and functionality issues in the Admin Console. Major fixes included Data integration for Document Numbering, RBAC Matrix functionality, and resolving data unwrapping issues for Active Sessions and Logs.
|
||||
|
||||
## Resolved Issues
|
||||
|
||||
### 1. Tag Management
|
||||
- **Issue:** 404 Error when accessing system tags.
|
||||
- **Cause:** Incorrect API endpoint (`/tags` vs `/master/tags`).
|
||||
- **Resolution:** Updated frontend service to use the correct `/master` prefix.
|
||||
|
||||
### 2. Document Numbering
|
||||
- **Issue:** Project Selection dropdown used hardcoded mock data.
|
||||
- **Cause:** `PROJECTS` constant in component.
|
||||
- **Resolution:** Implemented `useProjects` hook to fetch dynamic project list from backend.
|
||||
|
||||
### 3. RBAC Matrix
|
||||
- **Issue:** Permission checkboxes were all empty.
|
||||
- **Cause:** `UserService.findAllRoles` did not load the `permissions` relation.
|
||||
- **Resolution:**
|
||||
- Updated `UserService` to eager load relations.
|
||||
- Implemented `updateRolePermissions` in backend.
|
||||
- Added `PATCH` endpoint for saving changes.
|
||||
|
||||
### 4. Active Sessions
|
||||
- **Issue:** List "No results" and missing user names.
|
||||
- **Cause:**
|
||||
- Property mismatch (`first_name` vs `firstName`).
|
||||
- Frontend failed to unwrap `response.data.data` (Interceptor behavior).
|
||||
- **Resolution:**
|
||||
- Aligned backend/frontend naming convention.
|
||||
- Updated `sessionService` to handle wrapped response data.
|
||||
- Improved backend date comparison robustness.
|
||||
|
||||
### 5. Numbering Logs
|
||||
- **Issue:** Logs table empty.
|
||||
- **Cause:** Same data unwrapping issue as Active Sessions.
|
||||
- **Resolution:** Updated `logService` in `system-logs/numbering/page.tsx`.
|
||||
|
||||
### 6. Missing Permissions (Advisory)
|
||||
- **Issue:** 403 Forbidden on Logs page.
|
||||
- **Cause:** `system.view_logs` permission missing from user role.
|
||||
- **Resolution:** Advised user to use the newly fixed RBAC Matrix to assign the permission.
|
||||
|
||||
## Verification
|
||||
All issues were verified by manual testing and confirming correct data display in the Admin Console. Backend logs were used to debug the Active Sessions data flow.
|
||||
108
specs/09-history/2025-12-11-frontend-tests.md
Normal file
108
specs/09-history/2025-12-11-frontend-tests.md
Normal file
@@ -0,0 +1,108 @@
|
||||
# Session Summary: Frontend Unit Tests Implementation
|
||||
|
||||
**Date:** 2025-12-11
|
||||
**Session ID:** 1339bffa-8d99-4bf5-a5c0-5458630ed9fc
|
||||
|
||||
---
|
||||
|
||||
## Objective
|
||||
|
||||
Implement frontend testing infrastructure and unit tests per `specs/03-implementation/testing-strategy.md`.
|
||||
|
||||
---
|
||||
|
||||
## Changes Made
|
||||
|
||||
### 1. Test Infrastructure Setup
|
||||
|
||||
| File | Description |
|
||||
| ----------------------------- | --------------------------------------------------------- |
|
||||
| `frontend/vitest.config.ts` | Vitest config with jsdom, path aliases, coverage settings |
|
||||
| `frontend/vitest.setup.ts` | Global mocks for sonner, next/navigation, apiClient |
|
||||
| `frontend/lib/test-utils.tsx` | QueryClient wrapper for React Query hook testing |
|
||||
| `frontend/package.json` | Added test scripts: `test`, `test:watch`, `test:coverage` |
|
||||
|
||||
**Dependencies Installed:**
|
||||
- `vitest`
|
||||
- `@vitejs/plugin-react`
|
||||
- `@testing-library/react`
|
||||
- `@testing-library/jest-dom`
|
||||
- `@testing-library/user-event`
|
||||
- `jsdom`
|
||||
|
||||
---
|
||||
|
||||
### 2. Unit Tests - Hooks (52 tests)
|
||||
|
||||
| Test File | Tests |
|
||||
| -------------------------------------------- | ----- |
|
||||
| `hooks/__tests__/use-correspondence.test.ts` | 12 |
|
||||
| `hooks/__tests__/use-drawing.test.ts` | 10 |
|
||||
| `hooks/__tests__/use-rfa.test.ts` | 10 |
|
||||
| `hooks/__tests__/use-projects.test.ts` | 10 |
|
||||
| `hooks/__tests__/use-users.test.ts` | 10 |
|
||||
|
||||
---
|
||||
|
||||
### 3. Unit Tests - Services (49 tests)
|
||||
|
||||
| Test File | Tests |
|
||||
| ------------------------------------------------------- | ----- |
|
||||
| `lib/services/__tests__/correspondence.service.test.ts` | 11 |
|
||||
| `lib/services/__tests__/project.service.test.ts` | 12 |
|
||||
| `lib/services/__tests__/master-data.service.test.ts` | 26 |
|
||||
|
||||
---
|
||||
|
||||
### 4. Component Tests (17 tests)
|
||||
|
||||
| Test File | Tests |
|
||||
| ----------------------------------------- | ----- |
|
||||
| `components/ui/__tests__/button.test.tsx` | 17 |
|
||||
|
||||
---
|
||||
|
||||
## Final Results
|
||||
|
||||
```
|
||||
Test Files 9 passed (9)
|
||||
Tests 118 passed (118)
|
||||
Duration 9.06s
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Test Coverage Areas
|
||||
|
||||
- ✅ Query Hooks (list and detail fetching)
|
||||
- ✅ Mutation Hooks (create, update, delete, workflow)
|
||||
- ✅ Service Layer (API client calls)
|
||||
- ✅ Cache Keys (query cache key generation)
|
||||
- ✅ Toast Notifications (success and error toasts)
|
||||
- ✅ Error Handling (API error states)
|
||||
- ✅ Component Variants, Sizes, States
|
||||
|
||||
---
|
||||
|
||||
## How to Run Tests
|
||||
|
||||
```bash
|
||||
cd frontend
|
||||
|
||||
# Run all tests once
|
||||
pnpm test --run
|
||||
|
||||
# Run tests in watch mode
|
||||
pnpm test:watch
|
||||
|
||||
# Run with coverage
|
||||
pnpm test:coverage
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Remaining Optional Work
|
||||
|
||||
- [ ] E2E tests with Playwright
|
||||
- [ ] Additional component tests (Form, Table, Dialog)
|
||||
- [ ] Integration tests for page components
|
||||
78
specs/09-history/2025-12-11_frontend-integration-review.md
Normal file
78
specs/09-history/2025-12-11_frontend-integration-review.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# Session Summary: Frontend Integration Review & Fixes
|
||||
|
||||
**Date:** 2025-12-11
|
||||
**Session ID:** ae7069dd-6475-48f9-8c85-21694e014975
|
||||
|
||||
---
|
||||
|
||||
## Objective
|
||||
|
||||
Review frontend integration status and fix minor issues in Correspondences, RFAs, and Drawings modules.
|
||||
|
||||
## Work Completed
|
||||
|
||||
### 1. Integration Review ✅
|
||||
|
||||
Verified that all 3 core modules are properly integrated with Backend APIs:
|
||||
|
||||
| Module | Service | Hook | API Endpoint | Status |
|
||||
| ----------------- | ----------------------------- | ----------------------- | -------------------- | ---------- |
|
||||
| Correspondences | `correspondence.service.ts` | `use-correspondence.ts` | `/correspondences` | ✅ Real API |
|
||||
| RFAs | `rfa.service.ts` | `use-rfa.ts` | `/rfas` | ✅ Real API |
|
||||
| Contract Drawings | `contract-drawing.service.ts` | `use-drawing.ts` | `/drawings/contract` | ✅ Real API |
|
||||
| Shop Drawings | `shop-drawing.service.ts` | `use-drawing.ts` | `/drawings/shop` | ✅ Real API |
|
||||
|
||||
### 2. Minor Issues Fixed ✅
|
||||
|
||||
#### 2.1 `components/drawings/list.tsx`
|
||||
- **Issue:** Hardcoded `projectId: 1`
|
||||
- **Fix:** Added optional `projectId` prop to `DrawingListProps` interface
|
||||
|
||||
```diff
|
||||
interface DrawingListProps {
|
||||
type: "CONTRACT" | "SHOP";
|
||||
+ projectId?: number;
|
||||
}
|
||||
|
||||
-export function DrawingList({ type }: DrawingListProps) {
|
||||
- const { data: drawings, isLoading, isError } = useDrawings(type, { projectId: 1 });
|
||||
+export function DrawingList({ type, projectId }: DrawingListProps) {
|
||||
+ const { data: drawings, isLoading, isError } = useDrawings(type, { projectId: projectId ?? 1 });
|
||||
```
|
||||
|
||||
#### 2.2 `hooks/use-drawing.ts`
|
||||
- **Issue:** `any` types in multiple places
|
||||
- **Fix:** Added proper types
|
||||
|
||||
```diff
|
||||
+type DrawingSearchParams = SearchContractDrawingDto | SearchShopDrawingDto;
|
||||
+type CreateDrawingData = CreateContractDrawingDto | CreateShopDrawingDto;
|
||||
|
||||
-export function useDrawings(type: DrawingType, params: any) {
|
||||
+export function useDrawings(type: DrawingType, params: DrawingSearchParams) {
|
||||
|
||||
-mutationFn: async (data: any) => {
|
||||
+mutationFn: async (data: CreateDrawingData) => {
|
||||
|
||||
-onError: (error: any) => {
|
||||
+onError: (error: Error & { response?: { data?: { message?: string } } }) => {
|
||||
```
|
||||
|
||||
#### 2.3 `hooks/use-correspondence.ts`
|
||||
- **Issue:** `any` types and missing mutations
|
||||
- **Fix:**
|
||||
- Added `ApiError` type for error handling
|
||||
- Imported `WorkflowActionDto` for proper typing
|
||||
- Added `useUpdateCorrespondence()` mutation
|
||||
- Added `useDeleteCorrespondence()` mutation
|
||||
- Replaced all `any` types with proper types
|
||||
|
||||
## Files Modified
|
||||
|
||||
1. `frontend/components/drawings/list.tsx`
|
||||
2. `frontend/hooks/use-drawing.ts`
|
||||
3. `frontend/hooks/use-correspondence.ts`
|
||||
|
||||
## Conclusion
|
||||
|
||||
All frontend business modules (Correspondences, RFAs, Drawings) are confirmed to be properly integrated with Backend APIs using TanStack Query. The security features (Idempotency-Key, JWT injection) are correctly implemented in the API client. Minor type safety issues have been resolved.
|
||||
Reference in New Issue
Block a user