From 61ba649ac481326744c1d774a1a3fbdc0ea1d283 Mon Sep 17 00:00:00 2001 From: laxmanhalaki Date: Mon, 10 Nov 2025 16:13:38 +0530 Subject: [PATCH] reported bugs fixed --- CLAIM_MANAGEMENT_FLOW.md | 248 ------------- CUSTOM_REQUEST_FIX.md | 337 ----------------- ERROR_FIX.md | 188 ---------- MIGRATION_GUIDE.md | 306 ---------------- SEPARATION_IMPLEMENTATION.md | 217 ----------- SETUP_INSTRUCTIONS.md | 283 --------------- SLA_TRACKING_GUIDE.md | 183 ---------- START_HERE.md | 342 ------------------ SYSTEM_CONFIGURATION.md | 308 ---------------- .../SkipApproverModal/SkipApproverModal.tsx | 172 +++++++++ .../approval/SkipApproverModal/index.ts | 2 + .../ActionStatusModal/ActionStatusModal.tsx | 70 ++++ .../common/ActionStatusModal/index.ts | 2 + .../AddApproverModal/AddApproverModal.tsx | 10 +- .../AddSpectatorModal/AddSpectatorModal.tsx | 10 +- .../NotificationStatusModal.tsx | 75 ++++ .../settings/NotificationStatusModal/index.ts | 2 + .../workNote/WorkNoteChat/WorkNoteChat.tsx | 89 ++++- src/pages/CreateRequest/CreateRequest.tsx | 97 ++++- src/pages/Dashboard/Dashboard.tsx | 30 +- src/pages/MyRequests/MyRequests.tsx | 4 +- src/pages/OpenRequests/OpenRequests.tsx | 109 +++--- src/pages/RequestDetail/RequestDetail.tsx | 240 ++++++++++-- src/pages/Settings/Settings.tsx | 43 ++- 24 files changed, 834 insertions(+), 2533 deletions(-) delete mode 100644 CLAIM_MANAGEMENT_FLOW.md delete mode 100644 CUSTOM_REQUEST_FIX.md delete mode 100644 ERROR_FIX.md delete mode 100644 MIGRATION_GUIDE.md delete mode 100644 SEPARATION_IMPLEMENTATION.md delete mode 100644 SETUP_INSTRUCTIONS.md delete mode 100644 SLA_TRACKING_GUIDE.md delete mode 100644 START_HERE.md delete mode 100644 SYSTEM_CONFIGURATION.md create mode 100644 src/components/approval/SkipApproverModal/SkipApproverModal.tsx create mode 100644 src/components/approval/SkipApproverModal/index.ts create mode 100644 src/components/common/ActionStatusModal/ActionStatusModal.tsx create mode 100644 src/components/common/ActionStatusModal/index.ts create mode 100644 src/components/settings/NotificationStatusModal/NotificationStatusModal.tsx create mode 100644 src/components/settings/NotificationStatusModal/index.ts diff --git a/CLAIM_MANAGEMENT_FLOW.md b/CLAIM_MANAGEMENT_FLOW.md deleted file mode 100644 index 93101ae..0000000 --- a/CLAIM_MANAGEMENT_FLOW.md +++ /dev/null @@ -1,248 +0,0 @@ -# Claim Management System - Complete Data Flow - -## 🎯 Overview - -The claim management system now has complete integration with automatic dealer lookup and proper workflow management. - -## πŸ“Š Data Flow Diagram - -``` -β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” -β”‚ 1. User Creates Claim β”‚ -β”‚ (ClaimManagementWizard) β”‚ -β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ - β”‚ - β–Ό -β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” -β”‚ 2. Select Dealer Code (e.g., RE-MH-001) β”‚ -β”‚ β”‚ -β”‚ Triggers: getDealerInfo(dealerCode) β”‚ -β”‚ Returns from dealerDatabase.ts: β”‚ -β”‚ β€’ Dealer Name: "Royal Motors Mumbai" β”‚ -β”‚ β€’ Email: "dealer@royalmotorsmumbai.com" β”‚ -β”‚ β€’ Phone: "+91 98765 12345" β”‚ -β”‚ β€’ Address: "Shop No. 12-15, Central Avenue..." β”‚ -β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ - β”‚ - β–Ό -β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” -β”‚ 3. Complete Form & Submit (formData) β”‚ -β”‚ β”‚ -β”‚ Captured Fields: β”‚ -β”‚ β€’ activityName β”‚ -β”‚ β€’ activityType β”‚ -β”‚ β€’ activityDate β”‚ -β”‚ β€’ location β”‚ -β”‚ β€’ dealerCode β”‚ -β”‚ β€’ dealerName ┐ β”‚ -β”‚ β€’ dealerEmail β”œβ”€ Auto-populated from database β”‚ -β”‚ β€’ dealerPhone β”‚ β”‚ -β”‚ β€’ dealerAddress β”˜ β”‚ -β”‚ β€’ estimatedBudget β”‚ -β”‚ β€’ requestDescription β”‚ -β”‚ β€’ periodStart, periodEnd β”‚ -β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ - β”‚ - β–Ό -β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” -β”‚ 4. App.tsx Creates Request Object β”‚ -β”‚ β”‚ -β”‚ REQUEST_DATABASE[requestId] = { β”‚ -β”‚ id: 'RE-REQ-2024-CM-XXX', β”‚ -β”‚ title: '...', β”‚ -β”‚ status: 'pending', β”‚ -β”‚ currentStep: 1, β”‚ -β”‚ totalSteps: 8, β”‚ -β”‚ templateType: 'claim-management', β”‚ -β”‚ claimDetails: { β”‚ -β”‚ activityName: formData.activityName, β”‚ -β”‚ dealerEmail: formData.dealerEmail, ← From DB β”‚ -β”‚ dealerPhone: formData.dealerPhone, ← From DB β”‚ -β”‚ dealerAddress: formData.dealerAddress, ← From DB β”‚ -β”‚ estimatedBudget: formData.estimatedBudget, β”‚ -β”‚ ...all other fields β”‚ -β”‚ }, β”‚ -β”‚ approvalFlow: [ 8 steps... ] β”‚ -β”‚ } β”‚ -β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ - β”‚ - β–Ό -β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” -β”‚ 5. MyRequests Shows Request in List β”‚ -β”‚ β”‚ -β”‚ RE-REQ-2024-CM-001 β”‚ -β”‚ Dealer Marketing Activity Claim β”‚ -β”‚ Status: Pending | Step 1 of 8 β”‚ -β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ - β”‚ - β–Ό -β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” -β”‚ 6. User Clicks Request β†’ RequestDetail.tsx β”‚ -β”‚ β”‚ -β”‚ Fetches from REQUEST_DATABASE[requestId] β”‚ -β”‚ Displays all information: β”‚ -β”‚ β”‚ -β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ -β”‚ β”‚ Overview Tab β”‚ β”‚ -β”‚ β”‚ β”‚ β”‚ -β”‚ β”‚ πŸ“‹ Activity Information β”‚ β”‚ -β”‚ β”‚ β€’ Activity Name: "..." β”‚ β”‚ -β”‚ β”‚ β€’ Activity Type: "..." β”‚ β”‚ -β”‚ β”‚ β€’ Date: "..." β”‚ β”‚ -β”‚ β”‚ β€’ Location: "..." β”‚ β”‚ -β”‚ β”‚ β”‚ β”‚ -β”‚ β”‚ 🏒 Dealer Information β”‚ β”‚ -β”‚ β”‚ β€’ Dealer Code: RE-MH-001 β”‚ β”‚ -β”‚ β”‚ β€’ Dealer Name: Royal Motors Mumbai β”‚ β”‚ -β”‚ β”‚ β€’ Email: dealer@royalmotorsmumbai.com βœ“ β”‚ β”‚ -β”‚ β”‚ β€’ Phone: +91 98765 12345 βœ“ β”‚ β”‚ -β”‚ β”‚ β€’ Address: Shop No. 12-15... βœ“ β”‚ β”‚ -β”‚ β”‚ β”‚ β”‚ -β”‚ β”‚ πŸ’° Claim Request Details β”‚ β”‚ -β”‚ β”‚ β€’ Description: "..." β”‚ β”‚ -β”‚ β”‚ β€’ Estimated Budget: β‚Ή2,45,000 βœ“ β”‚ β”‚ -β”‚ β”‚ β€’ Period: Oct 1 - Oct 10 β”‚ β”‚ -β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ -β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ - β”‚ - β–Ό -β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” -β”‚ 7. Workflow Tab Shows 8-Step Process β”‚ -β”‚ β”‚ -β”‚ Step 1: Dealer Document Upload [PENDING] β”‚ -β”‚ Action: [Upload Proposal Documents] ← Opens modal β”‚ -β”‚ β”‚ -β”‚ Step 2: Initiator Evaluation [WAITING] β”‚ -β”‚ Actions: [Approve] [Request Modifications] β”‚ -β”‚ β”‚ -β”‚ Step 3: IO Confirmation (Auto) [WAITING] β”‚ -β”‚ β”‚ -β”‚ Step 4: Department Lead Approval [WAITING] β”‚ -β”‚ Action: [Approve & Lock Budget] β”‚ -β”‚ β”‚ -β”‚ Step 5: Dealer Completion Documents [WAITING] β”‚ -β”‚ Action: [Upload Completion Documents] β”‚ -β”‚ β”‚ -β”‚ Step 6: Initiator Verification [WAITING] β”‚ -β”‚ Action: [Verify & Set Amount] ← Opens modal β”‚ -β”‚ β”‚ -β”‚ Step 7: E-Invoice Generation (Auto) [WAITING] β”‚ -β”‚ β”‚ -β”‚ Step 8: Credit Note Issuance [WAITING] β”‚ -β”‚ Action: [Issue Credit Note] β”‚ -β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ -``` - -## πŸ”„ Key Features Implemented - -### 1. Dealer Database Auto-Population -```typescript -// When dealer selected in wizard -handleDealerChange('RE-MH-001') - ↓ -getDealerInfo('RE-MH-001') - ↓ -Returns complete dealer object - ↓ -Auto-fills: name, email, phone, address -``` - -### 2. Complete Data Capture -- βœ… All activity details -- βœ… All dealer information (from database) -- βœ… Estimated budget -- βœ… Request description -- βœ… Period dates - -### 3. Step-Specific Actions -Each workflow step shows relevant action buttons: -- **Upload buttons** for document steps -- **Approve/Reject buttons** for approval steps -- **Set Amount button** for verification step -- **Automatic processing** for system steps - -### 4. Modal Integration -- **DealerDocumentModal**: For steps 1 & 5 - - Upload multiple documents - - Add dealer comments - - Validation before submit - -- **InitiatorVerificationModal**: For step 6 - - Review completion documents - - Set final approved amount - - Add verification comments - -## 🎨 UI Components - -### ClaimManagementWizard -``` -Step 1: Claim Details - β”œβ”€β”€ Activity Name & Type - β”œβ”€β”€ Dealer Selection β†’ Auto-fills email, phone, address - β”œβ”€β”€ Date & Location - β”œβ”€β”€ Estimated Budget (new!) - └── Request Description - -Step 2: Review & Submit - β”œβ”€β”€ Activity Information Card - β”œβ”€β”€ Dealer Information Card (with email, phone, address) - β”œβ”€β”€ Date & Location Card (with budget) - └── Request Details Card -``` - -### RequestDetail Overview Tab -``` -β”œβ”€β”€ Activity Information -β”‚ β”œβ”€β”€ Activity Name -β”‚ β”œβ”€β”€ Activity Type -β”‚ β”œβ”€β”€ Date -β”‚ └── Location -β”‚ -β”œβ”€β”€ Dealer Information -β”‚ β”œβ”€β”€ Dealer Code -β”‚ β”œβ”€β”€ Dealer Name -β”‚ β”œβ”€β”€ Email ← From dealer database -β”‚ β”œβ”€β”€ Phone ← From dealer database -β”‚ └── Address ← From dealer database -β”‚ -└── Claim Request Details - β”œβ”€β”€ Description - β”œβ”€β”€ Estimated Budget ← User input - └── Period -``` - -## πŸ“ Database Schema - -### dealerDatabase.ts Structure -```typescript -{ - 'RE-MH-001': { - code: 'RE-MH-001', - name: 'Royal Motors Mumbai', - email: 'dealer@royalmotorsmumbai.com', - phone: '+91 98765 12345', - address: 'Shop No. 12-15, Central Avenue, Andheri West', - city: 'Mumbai', - state: 'Maharashtra', - region: 'West', - managerName: 'Rahul Deshmukh' - }, - // ... 9 more dealers -} -``` - -## βœ… Verification Checklist - -- [x] Dealer database created with 10+ dealers -- [x] Auto-population works when dealer selected -- [x] All fields captured in claimDetails -- [x] RequestDetail displays all information -- [x] Step-specific action buttons appear -- [x] Modals integrate properly -- [x] 8-step workflow displays correctly -- [x] IDs synchronized across components -- [x] Data flows from wizard β†’ app β†’ detail - -## πŸš€ Ready for Testing! - -The system is now complete and ready for end-to-end testing. All dealer information is automatically fetched from the database, properly saved in the request, and correctly displayed in the detail view. diff --git a/CUSTOM_REQUEST_FIX.md b/CUSTOM_REQUEST_FIX.md deleted file mode 100644 index eebca3d..0000000 --- a/CUSTOM_REQUEST_FIX.md +++ /dev/null @@ -1,337 +0,0 @@ -# Custom Request Details Page Fix - -## Problem -Custom requests created through the NewRequestWizard were not displaying in the detail page. Instead, users only saw a "Go Back" button. - -## Root Cause -1. **Database Lookup Issue**: Dynamic requests created through wizards were only stored in `App.tsx` component state (`dynamicRequests`), not in the static `CUSTOM_REQUEST_DATABASE` -2. **Component Props**: `RequestDetail` and `ClaimManagementDetail` components weren't receiving the `dynamicRequests` prop -3. **Data Flow Gap**: No connection between newly created requests and the detail view components - -## Solution Implemented - -### 1. Enhanced Request Creation (`App.tsx`) - -Updated `handleNewRequestSubmit` to properly create custom request objects: - -```typescript -const newCustomRequest = { - id: requestId, - title: requestData.title, - description: requestData.description, - category: requestData.category, - subcategory: requestData.subcategory, - status: 'pending', - priority: requestData.priority, - amount: requestData.budget, - template: 'custom', - initiator: { ... }, - approvalFlow: [...], // Maps approvers from wizard - spectators: [...], // Maps spectators from wizard - documents: [], - auditTrail: [...], - // ... complete request object -}; - -setDynamicRequests([...dynamicRequests, newCustomRequest]); -``` - -**Features**: -- Generates unique request ID: `RE-REQ-2024-XXX` -- Maps wizard data to proper request structure -- Creates approval flow from selected approvers -- Adds spectators from wizard -- Initializes audit trail -- Sets proper SLA dates -- Navigates to My Requests page after creation - -### 2. Updated Component Props - -#### RequestDetail.tsx -```typescript -interface RequestDetailProps { - requestId: string; - onBack?: () => void; - onOpenModal?: (modal: string) => void; - dynamicRequests?: any[]; // NEW -} -``` - -#### ClaimManagementDetail.tsx -```typescript -interface ClaimManagementDetailProps { - requestId: string; - onBack?: () => void; - onOpenModal?: (modal: string) => void; - dynamicRequests?: any[]; // NEW -} -``` - -### 3. Enhanced Request Lookup Logic - -Both detail components now check both static databases AND dynamic requests: - -```typescript -const request = useMemo(() => { - // First check static database - const staticRequest = CUSTOM_REQUEST_DATABASE[requestId]; - if (staticRequest) return staticRequest; - - // Then check dynamic requests - const dynamicRequest = dynamicRequests.find((req: any) => req.id === requestId); - if (dynamicRequest) return dynamicRequest; - - return null; -}, [requestId, dynamicRequests]); -``` - -### 4. Intelligent Routing (`App.tsx`) - -Updated `renderCurrentPage` for `request-detail` case: - -```typescript -case 'request-detail': - // Check static databases - const isClaimRequest = CLAIM_MANAGEMENT_DATABASE[selectedRequestId]; - const isCustomRequest = CUSTOM_REQUEST_DATABASE[selectedRequestId]; - - // Check dynamic requests - const dynamicRequest = dynamicRequests.find(...); - const isDynamicClaim = dynamicRequest?.templateType === 'claim-management'; - const isDynamicCustom = dynamicRequest && !isDynamicClaim; - - // Route to appropriate component with dynamicRequests prop - if (isClaimRequest || isDynamicClaim) { - return ; - } else { - return ; - } -``` - -### 5. Updated handleViewRequest - -```typescript -const handleViewRequest = (requestId: string, requestTitle?: string) => { - setSelectedRequestId(requestId); - - // Check all sources - const isClaimRequest = CLAIM_MANAGEMENT_DATABASE[requestId]; - const isCustomRequest = CUSTOM_REQUEST_DATABASE[requestId]; - const dynamicRequest = dynamicRequests.find(...); - - const request = isClaimRequest || isCustomRequest || dynamicRequest; - setSelectedRequestTitle(requestTitle || request?.title || 'Unknown Request'); - setCurrentPage('request-detail'); -}; -``` - -## Data Flow - -### Creating a Custom Request - -1. User clicks "Raise New Request" β†’ "Custom Request" -2. Fills out NewRequestWizard form: - - Title - - Description - - Category/Subcategory - - Budget - - Priority - - Approvers (multiple) - - Spectators (multiple) - - Tagged Participants - -3. On Submit: - - `handleNewRequestSubmit` creates complete request object - - Adds to `dynamicRequests` state - - Navigates to My Requests page - - Shows success toast - -4. Viewing the Request: - - User clicks on request in My Requests - - `handleViewRequest` finds request in dynamicRequests - - Routes to `request-detail` page - - `RequestDetail` component receives `dynamicRequests` prop - - Component finds request in dynamicRequests array - - Displays complete request details - -## Custom Request Details Page Features - -### Header -- Back button -- Request ID with file icon -- Priority badge (urgent/standard) -- Status badge (pending/in-review/approved/rejected) -- Refresh button -- Title display - -### SLA Progress Bar -- Color-coded (green/orange/red based on progress) -- Time remaining -- Progress percentage -- Due date - -### Tabs -1. **Overview** - - Request Initiator (with avatar, role, email, phone) - - Request Details (description, category, subcategory, amount, dates) - - Quick Actions sidebar - - Spectators list - -2. **Workflow** - - Step-by-step approval flow - - Color-coded status indicators - - TAT and elapsed time - - Comments from approvers - -3. **Documents** - - List of uploaded documents - - Upload new document button - - View and download actions - -4. **Activity** - - Complete audit trail - - Action icons - - User and timestamp for each action - -### Quick Actions (Right Sidebar) -- Add Work Note (dark green button) -- Add Approver -- Add Spectator -- Modify SLA -- Approve Request (green) -- Reject Request (red) - -## Testing Checklist - -βœ… **Request Creation** -- [ ] Create custom request through wizard -- [ ] Verify request appears in My Requests -- [ ] Check request ID is properly generated -- [ ] Verify all wizard data is captured - -βœ… **Request Detail Display** -- [ ] Click on custom request from My Requests -- [ ] Verify detail page loads (not "Go Back" button) -- [ ] Check all fields are populated correctly -- [ ] Verify initiator information displays -- [ ] Check description and category fields - -βœ… **Workflow Display** -- [ ] Verify approvers from wizard appear in workflow -- [ ] Check first approver is marked as "pending" -- [ ] Verify other approvers are "waiting" -- [ ] Check TAT hours are set - -βœ… **Spectators** -- [ ] Verify spectators from wizard appear -- [ ] Check avatar generation works -- [ ] Verify role display - -βœ… **Audit Trail** -- [ ] Check "Request Created" entry -- [ ] Check "Assigned to Approver" entry -- [ ] Verify timestamps are correct - -βœ… **Quick Actions** -- [ ] Test all quick action buttons -- [ ] Verify modals/toasts appear -- [ ] Check button styling - -βœ… **Claim Management Independence** -- [ ] Create claim request through ClaimManagementWizard -- [ ] Verify it routes to ClaimManagementDetail (purple theme) -- [ ] Verify custom requests route to RequestDetail (blue theme) -- [ ] Confirm no cross-contamination - -## Sample Custom Request Data Structure - -```typescript -{ - id: 'RE-REQ-2024-004', - title: 'Marketing Campaign Budget Approval', - description: 'Q4 marketing campaign budget request...', - category: 'Marketing & Campaigns', - subcategory: 'Digital Marketing', - status: 'pending', - priority: 'express', - amount: 'β‚Ή5,00,000', - slaProgress: 0, - slaRemaining: '5 days', - slaEndDate: 'Oct 20, 2024 5:00 PM', - currentStep: 1, - totalSteps: 3, - template: 'custom', - initiator: { - name: 'Current User', - role: 'Employee', - department: 'Marketing', - email: 'current.user@royalenfield.com', - phone: '+91 98765 43290', - avatar: 'CU' - }, - approvalFlow: [ - { - step: 1, - approver: 'Rajesh Kumar', - role: 'Marketing Director', - status: 'pending', - tatHours: 48, - elapsedHours: 0, - assignedAt: '2024-10-15T...', - comment: null, - timestamp: null - }, - // ... more approvers - ], - spectators: [ - { - name: 'Finance Team', - role: 'Budget Monitoring', - avatar: 'FT' - } - ], - documents: [], - auditTrail: [ - { - type: 'created', - action: 'Request Created', - details: 'Custom request "..." created', - user: 'Current User', - timestamp: 'Oct 15, 2024 10:30 AM' - } - ], - tags: ['custom-request'] -} -``` - -## Future Enhancements - -1. **Persistence**: Add backend API integration to persist dynamic requests -2. **Real-time Updates**: WebSocket for live status updates -3. **Document Upload**: Implement actual file upload functionality -4. **Notifications**: Email/push notifications for approvers -5. **Search**: Add search functionality in My Requests -6. **Filters**: Advanced filtering by status, priority, date -7. **Export**: Export request details to PDF -8. **Comments**: Thread-based commenting system -9. **Attachments**: Support for multiple file types -10. **Permissions**: Role-based access control - -## Known Limitations - -1. Dynamic requests are in-memory only (lost on refresh) -2. No actual file upload (UI only) -3. No real approval actions (mocked) -4. No email notifications -5. No database persistence - -## Next Steps - -1. Implement backend API for request persistence -2. Add authentication and authorization -3. Implement real approval workflows -4. Add document upload functionality -5. Create notification system -6. Add reporting and analytics -7. Mobile responsive improvements -8. Accessibility enhancements diff --git a/ERROR_FIX.md b/ERROR_FIX.md deleted file mode 100644 index a96f555..0000000 --- a/ERROR_FIX.md +++ /dev/null @@ -1,188 +0,0 @@ -# Error Fix: "Objects are not valid as a React child" - -## Problem -When creating a custom request through the NewRequestWizard, the application threw an error: -``` -Error: Objects are not valid as a React child (found: object with keys {email, name, level, tat, tatType}) -``` - -## Root Cause -The NewRequestWizard stores approvers, spectators, ccList, and invitedUsers as arrays of objects with the structure: -```typescript -{ - email: string, - name: string, - level: number, - tat: number, - tatType: 'hours' | 'days' -} -``` - -When these objects were passed to `handleNewRequestSubmit` in App.tsx, they were being mapped to the request structure, but the mapping wasn't properly extracting the string values from the objects. Instead, entire objects were being assigned to fields that should contain strings. - -## Solution - -### 1. Enhanced Approver Mapping -Updated the `approvalFlow` mapping in `handleNewRequestSubmit` to properly extract values: - -```typescript -approvalFlow: (requestData.approvers || []) - .filter((a: any) => a) // Filter out null/undefined - .map((approver: any, index: number) => { - // Extract name from email if name is not available - const approverName = approver?.name || approver?.email?.split('@')[0] || `Approver ${index + 1}`; - const approverEmail = approver?.email || ''; - - return { - step: index + 1, - approver: `${approverName}${approverEmail ? ` (${approverEmail})` : ''}`, // STRING, not object - role: approver?.role || `Level ${approver?.level || index + 1} Approver`, - status: index === 0 ? 'pending' : 'waiting', - tatHours: approver?.tat ? (typeof approver.tat === 'string' ? parseInt(approver.tat) : approver.tat) : 48, - elapsedHours: index === 0 ? 0 : 0, - assignedAt: index === 0 ? new Date().toISOString() : null, - comment: null, - timestamp: null - }; - }) -``` - -**Key changes:** -- Added `.filter((a: any) => a)` to remove null/undefined entries -- Properly extract `approverName` from `name` or `email` -- Build a display string combining name and email -- Convert TAT to number (handles both string and number inputs) - -### 2. Enhanced Spectator Mapping -Updated spectators mapping to properly extract values: - -```typescript -spectators: (requestData.spectators || []) - .filter((s: any) => s && (s.name || s.email)) // Filter invalid entries - .map((spectator: any) => { - const name = spectator?.name || spectator?.email?.split('@')[0] || 'Observer'; - return { - name: name, // STRING, not object - role: spectator?.role || spectator?.department || 'Observer', - avatar: name.split(' ').map((n: string) => n[0]).join('').toUpperCase().slice(0, 2) || 'OB' - }; - }) -``` - -**Key changes:** -- Filter out entries without name or email -- Extract name from email if needed -- Safe avatar generation with fallback - -### 3. Added Missing Fields -Added fields required by MyRequests component: - -```typescript -currentApprover: requestData.approvers?.[0]?.name || requestData.approvers?.[0]?.email?.split('@')[0] || 'Pending Assignment', -approverLevel: `1 of ${requestData.approvers?.length || 1}`, -submittedDate: new Date().toISOString(), -estimatedCompletion: new Date(Date.now() + 5 * 24 * 60 * 60 * 1000).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }) -``` - -### 4. Fixed Audit Trail Message -Updated audit trail to safely extract approver name: - -```typescript -details: `Request assigned to ${requestData.approvers?.[0]?.name || requestData.approvers?.[0]?.email || 'first approver'}` -``` - -## Testing Checklist - -βœ… **Create Custom Request** -- [ ] Fill out NewRequestWizard with title, description -- [ ] Add 2-3 approvers with emails -- [ ] Add spectators (optional) -- [ ] Submit request - -βœ… **Verify No Errors** -- [ ] No console errors about "Objects are not valid as React child" -- [ ] Request appears in My Requests -- [ ] Can click on request - -βœ… **Verify Detail Page** -- [ ] Request detail page loads -- [ ] Approver names display correctly (not [object Object]) -- [ ] Workflow tab shows all approvers -- [ ] Spectators display correctly (if added) - -βœ… **Verify My Requests Display** -- [ ] Request shows in list -- [ ] Current approver displays as string -- [ ] Approver level shows correctly (e.g., "1 of 3") - -## Common Patterns to Avoid - -### ❌ Bad: Rendering Objects Directly -```typescript -{approver} // If approver is {email: "...", name: "..."} -``` - -### βœ… Good: Extract String First -```typescript -{approver.name || approver.email} -``` - -### ❌ Bad: Assigning Object to String Field -```typescript -{ - approver: approverObject // {email: "...", name: "..."} -} -``` - -### βœ… Good: Extract String Value -```typescript -{ - approver: approverObject.name || approverObject.email -} -``` - -## Related Files Modified - -1. **App.tsx** - `handleNewRequestSubmit` function - - Enhanced approver mapping - - Enhanced spectator mapping - - Added missing fields for MyRequests compatibility - - Fixed audit trail messages - -## Data Flow - -``` -NewRequestWizard (formData) - β”œβ”€β”€ approvers: [{email, name, level, tat, tatType}, ...] - β”œβ”€β”€ spectators: [{email, name, role, department}, ...] - └── ...other fields - ↓ -handleNewRequestSubmit (App.tsx) - β”œβ”€β”€ Maps approvers β†’ approvalFlow with STRING values - β”œβ”€β”€ Maps spectators β†’ spectators with STRING values - └── Creates complete request object - ↓ -dynamicRequests state (App.tsx) - β”œβ”€β”€ Stored in memory - └── Passed to components - ↓ -RequestDetail / MyRequests - β”œβ”€β”€ Receives proper data structure - └── Renders strings (no object errors) -``` - -## Prevention Tips - -1. **Always validate data types** when mapping from wizard to database -2. **Extract primitive values** from objects before assigning to display fields -3. **Add TypeScript interfaces** to catch type mismatches early -4. **Test with console.log** before rendering to verify data structure -5. **Use optional chaining** (`?.`) to safely access nested properties - -## Future Improvements - -1. Add TypeScript interfaces for wizard form data -2. Add TypeScript interfaces for request objects -3. Create validation functions for data transformation -4. Add unit tests for data mapping functions -5. Create reusable mapping utilities diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md deleted file mode 100644 index b95f79c..0000000 --- a/MIGRATION_GUIDE.md +++ /dev/null @@ -1,306 +0,0 @@ -# πŸ”„ Migration Guide - Project Setup Complete - -## βœ… What Has Been Created - -### Configuration Files βœ“ -- βœ… `package.json` - Dependencies and scripts -- βœ… `tsconfig.json` - TypeScript configuration -- βœ… `tsconfig.node.json` - Node TypeScript config -- βœ… `vite.config.ts` - Vite build configuration -- βœ… `tailwind.config.ts` - Tailwind CSS configuration -- βœ… `postcss.config.js` - PostCSS configuration -- βœ… `eslint.config.js` - ESLint configuration -- βœ… `.prettierrc` - Prettier configuration -- βœ… `.gitignore` - Git ignore rules -- βœ… `.env.example` - Environment variables template -- βœ… `index.html` - HTML entry point - -### VS Code Configuration βœ“ -- βœ… `.vscode/settings.json` - Editor settings -- βœ… `.vscode/extensions.json` - Recommended extensions - -### Documentation βœ“ -- βœ… `README.md` - Comprehensive project documentation -- βœ… `MIGRATION_GUIDE.md` - This file - -### Source Files Created βœ“ -- βœ… `src/main.tsx` - Application entry point -- βœ… `src/vite-env.d.ts` - Vite environment types -- βœ… `src/types/index.ts` - TypeScript type definitions - ---- - -## πŸš€ Next Steps - File Migration - -### Step 1: Install Dependencies - -\`\`\`bash -npm install -\`\`\` - -This will install all required packages (~5 minutes). - -### Step 2: Migrate Files to src Directory - -You need to manually move the existing files to the `src` directory: - -#### A. Move App.tsx -\`\`\`bash -# Windows Command Prompt -move App.tsx src\\App.tsx - -# Or manually drag and drop in VS Code -\`\`\` - -#### B. Move Components Directory -\`\`\`bash -# Windows Command Prompt -move components src\\components - -# Or manually drag and drop in VS Code -\`\`\` - -#### C. Move Utils Directory -\`\`\`bash -# Windows Command Prompt -move utils src\\utils - -# Or manually drag and drop in VS Code -\`\`\` - -#### D. Move Styles Directory -\`\`\`bash -# Windows Command Prompt -move styles src\\styles - -# Or manually drag and drop in VS Code -\`\`\` - -### Step 3: Update Import Paths - -After moving files, you'll need to update import statements to use path aliases. - -#### Example Changes: - -**Before:** -\`\`\`typescript -import { Layout } from './components/Layout'; -import { Dashboard } from './components/Dashboard'; -\`\`\` - -**After:** -\`\`\`typescript -import { Layout } from '@/components/Layout'; -import { Dashboard } from '@/components/Dashboard'; -\`\`\` - -**Files that need updating:** -1. `src/App.tsx` - Update all component imports -2. All files in `src/components/` - Update relative imports -3. All modal files in `src/components/modals/` - -### Step 4: Fix Sonner Import - -In `src/App.tsx`, update the sonner import: - -**Before:** -\`\`\`typescript -import { toast } from 'sonner@2.0.3'; -\`\`\` - -**After:** -\`\`\`typescript -import { toast } from 'sonner'; -\`\`\` - -### Step 5: Start Development Server - -\`\`\`bash -npm run dev -\`\`\` - -The app should open at `http://localhost:3000` - ---- - -## πŸ” Common Issues & Solutions - -### Issue 1: Module not found errors - -**Problem:** TypeScript can't find modules after migration. - -**Solution:** -1. Restart VS Code TypeScript server: `Ctrl+Shift+P` β†’ "TypeScript: Restart TS Server" -2. Clear node_modules and reinstall: - \`\`\`bash - rm -rf node_modules package-lock.json - npm install - \`\`\` - -### Issue 2: Path alias not working - -**Problem:** `@/` imports show errors. - -**Solution:** -1. Check `tsconfig.json` paths configuration -2. Check `vite.config.ts` resolve.alias configuration -3. Restart VS Code - -### Issue 3: Tailwind classes not applying - -**Problem:** Styles not working after migration. - -**Solution:** -1. Ensure `globals.css` is imported in `src/main.tsx` -2. Check `tailwind.config.ts` content paths -3. Restart dev server: `Ctrl+C` then `npm run dev` - -### Issue 4: Build errors - -**Problem:** TypeScript compilation errors. - -**Solution:** -1. Run type check: `npm run type-check` -2. Fix any TypeScript errors shown -3. Run build again: `npm run build` - ---- - -## πŸ“‹ Migration Checklist - -Use this checklist to track your migration progress: - -### Files Migration -- [ ] Installed dependencies (`npm install`) -- [ ] Moved `App.tsx` to `src/` -- [ ] Moved `components/` to `src/components/` -- [ ] Moved `utils/` to `src/utils/` -- [ ] Moved `styles/` to `src/styles/` -- [ ] Created `src/main.tsx` (already done) - -### Import Updates -- [ ] Updated imports in `src/App.tsx` -- [ ] Updated imports in `src/components/Layout.tsx` -- [ ] Updated imports in `src/components/Dashboard.tsx` -- [ ] Updated imports in all other component files -- [ ] Fixed `sonner` import in `App.tsx` - -### Testing -- [ ] Dev server starts successfully (`npm run dev`) -- [ ] Application loads at `http://localhost:3000` -- [ ] No console errors -- [ ] Dashboard displays correctly -- [ ] Navigation works -- [ ] New request wizard works -- [ ] Claim management wizard works - -### Code Quality -- [ ] ESLint passes (`npm run lint`) -- [ ] TypeScript compiles (`npm run type-check`) -- [ ] Code formatted (`npm run format`) -- [ ] Build succeeds (`npm run build`) - -### Environment -- [ ] Created `.env` from `.env.example` -- [ ] Updated environment variables if needed -- [ ] VS Code extensions installed - ---- - -## 🎯 After Migration - -### 1. Clean Up Old Files - -After confirming everything works in `src/`: -\`\`\`bash -# Delete old documentation files from root (optional) -# Keep only if you want them at root level -\`\`\` - -### 2. Commit Changes - -\`\`\`bash -git add . -git commit -m "feat: migrate to standard React project structure with Vite" -\`\`\` - -### 3. Update Team - -Inform team members about: -- New project structure -- Updated npm scripts -- Path alias usage (`@/`) -- Required VS Code extensions - ---- - -## πŸ“š Additional Resources - -### Documentation -- [Vite Documentation](https://vitejs.dev/) -- [React TypeScript Cheatsheet](https://react-typescript-cheatsheet.netlify.app/) -- [Tailwind CSS Docs](https://tailwindcss.com/docs) -- [shadcn/ui Components](https://ui.shadcn.com/) - -### Scripts Reference -\`\`\`bash -npm run dev # Start development server -npm run build # Build for production -npm run preview # Preview production build -npm run lint # Check for linting errors -npm run lint:fix # Auto-fix linting errors -npm run format # Format code with Prettier -npm run type-check # Check TypeScript types -\`\`\` - ---- - -## πŸ’‘ Tips for Development - -### 1. Use Path Aliases -\`\`\`typescript -// Good βœ“ -import { Button } from '@/components/ui/button'; -import { getDealerInfo } from '@/utils/dealerDatabase'; - -// Avoid βœ— -import { Button } from '../../../components/ui/button'; -\`\`\` - -### 2. Type Safety -\`\`\`typescript -// Import types -import type { Request, DealerInfo } from '@/types'; - -// Use them in your components -const request: Request = { ... }; -\`\`\` - -### 3. Code Formatting -Set up auto-format on save in VS Code (already configured in `.vscode/settings.json`) - -### 4. Commit Conventions -Use conventional commits: -- `feat:` for new features -- `fix:` for bug fixes -- `docs:` for documentation -- `style:` for formatting changes -- `refactor:` for code refactoring - ---- - -## ❓ Need Help? - -If you encounter issues: -1. Check this migration guide -2. Check the main README.md -3. Review error messages carefully -4. Check VS Code Problems panel -5. Restart VS Code TypeScript server -6. Clear node_modules and reinstall - ---- - -**Migration prepared by the Development Team** -**Date: 2024** - diff --git a/SEPARATION_IMPLEMENTATION.md b/SEPARATION_IMPLEMENTATION.md deleted file mode 100644 index 252c583..0000000 --- a/SEPARATION_IMPLEMENTATION.md +++ /dev/null @@ -1,217 +0,0 @@ -# Request Type Separation Implementation - -## Overview -Successfully implemented complete separation between **Custom Requests** and **Claim Management Requests** to ensure independent processes, databases, and components. - -## Architecture - -### 1. Separate Databases - -#### Custom Request Database -- **Location**: `/utils/customRequestDatabase.ts` -- **Purpose**: Stores all custom requests created via NewRequestWizard -- **Export**: `CUSTOM_REQUEST_DATABASE` -- **API Endpoints**: `CUSTOM_REQUEST_API_ENDPOINTS` -- **Features**: - - User-defined workflow - - Custom approvers added during creation - - Spectators and tagged participants - - Category/subcategory fields - - Flexible approval steps - -#### Claim Management Database -- **Location**: `/utils/claimManagementDatabase.ts` -- **Purpose**: Stores all claim management requests created via ClaimManagementWizard -- **Export**: `CLAIM_MANAGEMENT_DATABASE` -- **API Endpoints**: `CLAIM_MANAGEMENT_API_ENDPOINTS` -- **Features**: - - Fixed 8-step workflow process - - Dealer information (code, name, contact, address) - - Activity details (name, type, location, date) - - Budget tracking - - Specialized modals (DealerDocumentModal, InitiatorVerificationModal) - -### 2. Separate Detail Components - -#### Request Detail Component -- **Location**: `/components/RequestDetail.tsx` -- **Purpose**: Display custom/standard requests only -- **Database**: Uses `CUSTOM_REQUEST_DATABASE` -- **Features**: - - Standard initiator information - - Category and subcategory display - - Approvers shown from request creation - - General description and specifications - - Flexible workflow steps - - Standard action buttons - -#### Claim Management Detail Component -- **Location**: `/components/ClaimManagementDetail.tsx` -- **Purpose**: Display claim management requests only -- **Database**: Uses `CLAIM_MANAGEMENT_DATABASE` -- **Features**: - - Dealer information prominently displayed - - Activity information section - - 8-step workflow with specific actions per step - - Budget/amount tracking - - Claim-specific modals (dealer docs, verification) - - Purple theme for claim management branding - - Step-specific action buttons (Upload Documents, Verify Amount, etc.) - -### 3. App.tsx Routing Logic - -The main App component now includes intelligent routing: - -```typescript -case 'request-detail': - const isClaimRequest = CLAIM_MANAGEMENT_DATABASE[selectedRequestId]; - const isCustomRequest = CUSTOM_REQUEST_DATABASE[selectedRequestId]; - - if (isClaimRequest) { - return ; - } else if (isCustomRequest) { - return ; - } -``` - -### 4. API Endpoint Separation - -Each database file includes its own API endpoint constants: - -#### Custom Request Endpoints -- `/api/v1/custom-request/*` -- Includes: create, update, get, list, approve, reject, add approver/spectator/tagged, documents, work notes, etc. - -#### Claim Management Endpoints -- `/api/v1/claim-management/*` -- Includes: create, update, get, list, dealer document upload, initiator evaluate, generate IO, department approval, completion docs, verify, e-invoice, credit note, etc. - -## Benefits - -### 1. Complete Independence -- Changes to claim management don't affect custom requests -- Changes to custom requests don't affect claim management -- Each process has its own data structure and business logic - -### 2. Future-Proof -- Easy to add new template types (e.g., Budget Approval, Travel Requests) -- Each new template gets its own database and detail component -- No cross-contamination between processes - -### 3. API Ready -- Separate endpoints allow different backend services -- Different authentication/authorization per process type -- Different data validation and business rules - -### 4. Maintainability -- Clear separation of concerns -- Easy to debug issues (know which system to check) -- Independent testing for each process type - -## Data Flow - -### Custom Request Flow -1. User clicks "Custom Request" in NewRequestWizard -2. Fills out form with custom approvers, spectators, etc. -3. Submitted to `CUSTOM_REQUEST_DATABASE` -4. Clicking on request triggers `RequestDetail` component -5. All actions use `CUSTOM_REQUEST_API_ENDPOINTS` - -### Claim Management Flow -1. User clicks "Existing Template" β†’ "Claim Management" -2. Navigates to ClaimManagementWizard -3. Fills out claim-specific form (dealer, activity, budget) -4. Submitted to `CLAIM_MANAGEMENT_DATABASE` -5. Clicking on claim triggers `ClaimManagementDetail` component -6. All actions use `CLAIM_MANAGEMENT_API_ENDPOINTS` - -## Database Schema Differences - -### Custom Request -```typescript -{ - id: string - title: string - description: string - category: string - subcategory: string - status: string - priority: string - template: 'custom' - approvalFlow: [...] // User-defined - // No claimDetails -} -``` - -### Claim Management Request -```typescript -{ - id: string - title: string - template: 'claim-management' - claimDetails: { - activityName: string - activityType: string - location: string - dealerCode: string - dealerName: string - dealerEmail: string - dealerPhone: string - dealerAddress: string - estimatedBudget: string - // ... more claim-specific fields - } - approvalFlow: [...] // Fixed 8-step process -} -``` - -## Visual Differences - -### Request Detail (Custom) -- Blue theme -- Standard file icon -- Category/Subcategory displayed -- "Request Detail" terminology -- Generic approval buttons - -### Claim Management Detail (Purple) -- Purple theme throughout -- Receipt/claim icon -- "Claim Management" badge -- Dealer and Activity sections -- "Claim Amount" instead of "Total Amount" -- Step-specific buttons (Upload Documents, Verify Amount, etc.) -- "Claim Activity Timeline" instead of "Activity Timeline" - -## Migration Notes - -### Legacy Database -- Old `REQUEST_DATABASE` in App.tsx is now marked as `LEGACY_REQUEST_DATABASE` -- Combined export `REQUEST_DATABASE` = custom + claim for backward compatibility -- Will be removed in future once all components updated - -### Components to Update (Future) -- Dashboard.tsx - update to use both databases -- RequestsList.tsx - update to use both databases -- MyRequests.tsx - update to use both databases - -## Testing Checklist - -- [ ] Custom request creation works -- [ ] Custom request detail page displays correctly -- [ ] Custom request actions (approve/reject) work -- [ ] Claim management creation works -- [ ] Claim management detail page displays correctly -- [ ] Claim-specific actions work (dealer upload, verification) -- [ ] No cross-contamination between types -- [ ] Routing correctly identifies request type -- [ ] Proper error handling for missing requests - -## Future Enhancements - -1. Add more template types (Budget Approval, Travel Request, etc.) -2. Create utility functions for database operations -3. Add TypeScript interfaces for better type safety -4. Implement actual API integration -5. Add request type indicators in lists -6. Create admin panel for template management diff --git a/SETUP_INSTRUCTIONS.md b/SETUP_INSTRUCTIONS.md deleted file mode 100644 index 1feb6f0..0000000 --- a/SETUP_INSTRUCTIONS.md +++ /dev/null @@ -1,283 +0,0 @@ -# 🎯 Quick Setup Instructions - -## βœ… Project Setup Complete! - -Your Royal Enfield Approval Portal has been configured with industry-standard React development tools and structure. - ---- - -## πŸš€ Quick Start (5 Minutes) - -### Option 1: Automated Migration (Recommended) - -**For Windows PowerShell:** -```powershell -# 1. Run the migration script -.\migrate-files.ps1 - -# 2. Install dependencies -npm install - -# 3. Start development server -npm run dev -``` - -### Option 2: Manual Migration - -**If you prefer manual control:** - -```bash -# 1. Create src directories -mkdir src\components src\utils src\styles - -# 2. Move files -move App.tsx src\ -move components src\ -move utils src\ -move styles src\ - -# 3. Install dependencies -npm install - -# 4. Start development server -npm run dev -``` - ---- - -## πŸ“¦ What Was Created - -### Core Configuration βœ… -- βœ… `package.json` - 50+ dependencies installed -- βœ… `vite.config.ts` - Build tool (fast, modern) -- βœ… `tsconfig.json` - TypeScript settings -- βœ… `tailwind.config.ts` - Styling configuration -- βœ… `eslint.config.js` - Code quality rules -- βœ… `.prettierrc` - Code formatting - -### Project Structure βœ… -``` -Re_Figma_Code/ -β”œβ”€β”€ src/ ← NEW! All code goes here -β”‚ β”œβ”€β”€ main.tsx ← Entry point (created) -β”‚ β”œβ”€β”€ App.tsx ← Move here -β”‚ β”œβ”€β”€ components/ ← Move here -β”‚ β”œβ”€β”€ utils/ ← Move here -β”‚ β”œβ”€β”€ styles/ ← Move here -β”‚ └── types/ ← Type definitions (created) -β”œβ”€β”€ public/ ← Static assets -β”œβ”€β”€ index.html ← HTML entry -└── [config files] ← All created -``` - -### VS Code Setup βœ… -- βœ… `.vscode/settings.json` - Auto-format, Tailwind IntelliSense -- βœ… `.vscode/extensions.json` - Recommended extensions - ---- - -## πŸ”§ After Running Setup - -### 1. Fix Imports in App.tsx - -**Update these imports:** -```typescript -// OLD (relative paths) -import { Layout } from './components/Layout'; -import { Dashboard } from './components/Dashboard'; -import { toast } from 'sonner@2.0.3'; - -// NEW (path aliases) -import { Layout } from '@/components/Layout'; -import { Dashboard } from '@/components/Dashboard'; -import { toast } from 'sonner'; -``` - -### 2. Update Component Imports - -**In all component files, change:** -```typescript -// OLD -import { Button } from './ui/button'; -import { Card } from '../ui/card'; - -// NEW -import { Button } from '@/components/ui/button'; -import { Card } from '@/components/ui/card'; -``` - -### 3. Verify Everything Works - -```bash -# Check for TypeScript errors -npm run type-check - -# Check for linting issues -npm run lint - -# Format code -npm run format - -# Build for production (test) -npm run build -``` - ---- - -## 🎨 Development Workflow - -### Daily Development -```bash -npm run dev # Start dev server (http://localhost:3000) -``` - -### Code Quality -```bash -npm run lint # Check for issues -npm run lint:fix # Auto-fix issues -npm run format # Format code with Prettier -``` - -### Building -```bash -npm run build # Production build -npm run preview # Preview production build -``` - ---- - -## πŸ†˜ Troubleshooting - -### Issue: "Module not found" -**Solution:** -```bash -# Clear cache and reinstall -rm -rf node_modules package-lock.json -npm install -``` - -### Issue: "@/ path alias not working" -**Solution:** -1. Restart VS Code -2. Press `Ctrl+Shift+P` β†’ "TypeScript: Restart TS Server" - -### Issue: "Tailwind classes not applying" -**Solution:** -1. Check `src/main.tsx` imports `'./styles/globals.css'` -2. Restart dev server: `Ctrl+C` then `npm run dev` - -### Issue: Build errors -**Solution:** -```bash -npm run type-check # See TypeScript errors -npm run lint # See ESLint errors -``` - ---- - -## πŸ“š Important Files - -### Environment Variables -Copy and edit `.env.example`: -```bash -cp .env.example .env -``` - -Edit values: -```env -VITE_API_BASE_URL=http://localhost:5000/api -VITE_APP_NAME=Royal Enfield Approval Portal -``` - -### Type Definitions -Use types from `src/types/index.ts`: -```typescript -import type { Request, DealerInfo, Priority } from '@/types'; - -const request: Request = { /* ... */ }; -``` - ---- - -## ✨ New Features Available - -### 1. Path Aliases -```typescript -import { Button } from '@/components/ui/button'; -import { getDealerInfo } from '@/utils/dealerDatabase'; -import type { Request } from '@/types'; -``` - -### 2. Code Quality Tools -- **ESLint** - Catches bugs and enforces best practices -- **Prettier** - Consistent code formatting -- **TypeScript** - Type safety and IntelliSense - -### 3. Optimized Build -- **Code splitting** - Faster load times -- **Tree shaking** - Smaller bundle size -- **Source maps** - Easy debugging - -### 4. Development Experience -- **Hot Module Replacement** - Instant updates -- **Fast Refresh** - Preserve component state -- **Better Error Messages** - Easier debugging - ---- - -## 🎯 Next Steps - -1. βœ… Run migration script or move files manually -2. βœ… Install dependencies: `npm install` -3. βœ… Update imports to use `@/` aliases -4. βœ… Fix sonner import -5. βœ… Start dev server: `npm run dev` -6. βœ… Test all features work -7. βœ… Commit changes to git - ---- - -## πŸ“– Documentation - -- **README.md** - Comprehensive project documentation -- **MIGRATION_GUIDE.md** - Detailed migration steps -- **package.json** - All available scripts - ---- - -## 🀝 Team Guidelines - -### Code Style -- Use path aliases (`@/`) for all imports -- Format code before committing (`npm run format`) -- Fix linting issues (`npm run lint:fix`) -- Write TypeScript types (avoid `any`) - -### Git Commits -```bash -git add . -git commit -m "feat: add new feature" -git commit -m "fix: resolve bug" -git commit -m "docs: update documentation" -``` - ---- - -## βœ… Success Checklist - -- [ ] Dependencies installed (`npm install`) -- [ ] Files migrated to `src/` -- [ ] Imports updated to use `@/` -- [ ] Sonner import fixed -- [ ] Dev server runs (`npm run dev`) -- [ ] No console errors -- [ ] Application loads correctly -- [ ] All features work -- [ ] Build succeeds (`npm run build`) - ---- - -**πŸŽ‰ You're all set! Happy coding!** - -For detailed help, see `MIGRATION_GUIDE.md` or `README.md` - diff --git a/SLA_TRACKING_GUIDE.md b/SLA_TRACKING_GUIDE.md deleted file mode 100644 index 53caabd..0000000 --- a/SLA_TRACKING_GUIDE.md +++ /dev/null @@ -1,183 +0,0 @@ -# SLA Tracking with Working Hours - Implementation Guide - -## Overview - -The SLA tracking system automatically **pauses during non-working hours** and **resumes during working hours**, ensuring accurate TAT (Turnaround Time) calculations. - -## 🎯 Features - -βœ… **Automatic Pause/Resume** - Stops counting during: -- Weekends (Saturday & Sunday) -- Non-working hours (before 9 AM, after 6 PM) -- Holidays (from database) - -βœ… **Real-Time Updates** - Progress updates every minute -βœ… **Visual Indicators** - Shows when paused vs active -βœ… **Working Hours Display** - Shows elapsed and remaining in working hours (e.g., "2d 3h") -βœ… **Next Resume Time** - Shows when tracking will resume during paused state - -## πŸ“ Components Created - -### 1. **Utility: `slaTracker.ts`** -Core calculation functions: -- `isWorkingTime()` - Check if current time is working hours -- `calculateElapsedWorkingHours()` - Count only working hours -- `calculateRemainingWorkingHours()` - Working hours until deadline -- `getSLAStatus()` - Complete SLA status with pause/resume info -- `formatWorkingHours()` - Format hours as "2d 3h" - -### 2. **Hook: `useSLATracking.ts`** -React hook for real-time tracking: -```typescript -const slaStatus = useSLATracking(startDate, deadline); -// Returns: { progress, elapsedHours, remainingHours, isPaused, statusText, ... } -``` - -### 3. **Component: `SLATracker.tsx`** -Visual component with pause/resume indicators: -```tsx - -``` - -## πŸš€ Usage Examples - -### In MyRequests Page (Already Integrated) -```tsx -{request.createdAt && request.dueDate && - request.status !== 'approved' && request.status !== 'rejected' && ( - -)} -``` - -### In RequestDetail Page -Replace the existing SLA progress bar with: -```tsx -import { SLATracker } from '@/components/sla/SLATracker'; - -// In the SLA Progress section: - -``` - -### In OpenRequests Page -```tsx -{request.createdAt && request.dueDate && ( - -)} -``` - -## 🎨 Visual States - -### Active (During Working Hours) -``` -SLA Progress [▢️ Active] [On track] -β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 45.2% -Elapsed: 1d 4h Remaining: 1d 4h -``` - -### Paused (Outside Working Hours) -``` -SLA Progress [⏸️ Paused] [On track] -β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβΈοΈβ–‘β–‘β–‘β–‘β–‘β–‘ 45.2% -Elapsed: 1d 4h Remaining: 1d 4h -⚠️ Resumes in 14h 30m -``` - -### Critical (>75%) -``` -SLA Progress [▢️ Active] [SLA critical] -β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘ 87.5% -Elapsed: 6d 6h Remaining: 1d 2h -``` - -### Breached (100%) -``` -SLA Progress [⏸️ Paused] [SLA breached] -β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 100.0% -Elapsed: 8d 0h Remaining: 0h -⚠️ Resumes in 2h 15m -``` - -## βš™οΈ Configuration - -Working hours are defined in `slaTracker.ts`: -```typescript -const WORK_START_HOUR = 9; // 9 AM -const WORK_END_HOUR = 18; // 6 PM -const WORK_START_DAY = 1; // Monday -const WORK_END_DAY = 5; // Friday -``` - -To change these, update the constants in the utility file. - -## πŸ”„ How It Works - -### Backend (Already Implemented) -1. βœ… Calculates deadlines using `addWorkingHours()` (skips weekends, holidays, non-work hours) -2. βœ… Stores calculated deadline in database -3. βœ… TAT scheduler triggers notifications at 50%, 75%, 100% (accounting for working hours) - -### Frontend (New Implementation) -1. **Receives** pre-calculated deadline from backend -2. **Calculates** real-time elapsed working hours from start to now -3. **Displays** accurate progress that only counts working time -4. **Shows** pause indicator when outside working hours -5. **Updates** every minute automatically - -### Example Flow: - -**Friday 4:00 PM** (within working hours) -- SLA Progress: [▢️ Active] 25% -- Shows real-time progress - -**Friday 6:01 PM** (after hours) -- SLA Progress: [⏸️ Paused] 25% -- Shows "Resumes in 15h" (Monday 9 AM) - -**Monday 9:00 AM** (work resumes) -- SLA Progress: [▢️ Active] 25% -- Continues from where it left off - -**Monday 10:00 AM** (1 working hour later) -- SLA Progress: [▢️ Active] 30% -- Progress updates only during working hours - -## 🎯 Benefits - -1. **Accurate SLA Tracking** - Only counts actual working time -2. **User Transparency** - Users see when SLA is paused -3. **Realistic Deadlines** - No false urgency during weekends -4. **Aligned with Backend** - Frontend display matches backend calculations -5. **Real-Time Updates** - Live progress without page refresh - -## πŸ§ͺ Testing - -Test different scenarios: -1. **During working hours** β†’ Should show "Active" badge -2. **After 6 PM** β†’ Should show "Paused" and resume time -3. **Weekends** β†’ Should show "Paused" and Monday 9 AM resume -4. **Progress calculation** β†’ Should only count working hours - -## πŸ“ Notes - -- The frontend assumes the backend has already calculated the correct deadline -- Progress bars update every 60 seconds -- Paused state is visual only - actual TAT calculations are on backend -- For holidays, consider integrating with backend holiday API in future enhancement - diff --git a/START_HERE.md b/START_HERE.md deleted file mode 100644 index 1d682f6..0000000 --- a/START_HERE.md +++ /dev/null @@ -1,342 +0,0 @@ -# πŸš€ START HERE - Royal Enfield Approval Portal - -## βœ… Your Project is Now Configured! - -All standard React configuration files have been created. Your project now follows industry best practices. - ---- - -## 🎯 Quick Start (Choose One Method) - -### Method 1: PowerShell Script (Easiest - Windows) - -```powershell -# Run in PowerShell -.\migrate-files.ps1 -npm install -npm run dev -``` - -### Method 2: Manual (All Platforms) - -```bash -# 1. Create src structure -mkdir -p src/components src/utils src/styles - -# 2. Move files -mv App.tsx src/ -mv components src/ -mv utils src/ -mv styles src/ - -# 3. Install & run -npm install -npm run dev -``` - ---- - -## πŸ“ What Changed - -### βœ… Created Configuration Files - -``` -βœ… package.json - Dependencies & scripts -βœ… vite.config.ts - Build configuration -βœ… tsconfig.json - TypeScript settings -βœ… tailwind.config.ts - Tailwind CSS config -βœ… eslint.config.js - Code quality rules -βœ… .prettierrc - Code formatting -βœ… postcss.config.js - CSS processing -βœ… .gitignore - Git ignore rules -βœ… index.html - Entry HTML file -``` - -### βœ… Created Project Structure - -``` -src/ -β”œβ”€β”€ main.tsx βœ… Created - App entry point -β”œβ”€β”€ vite-env.d.ts βœ… Created - Vite types -β”œβ”€β”€ types/ -β”‚ └── index.ts βœ… Created - TypeScript types -└── lib/ - └── utils.ts βœ… Created - Utility functions - -Need to move: -β”œβ”€β”€ App.tsx β†’ src/App.tsx -β”œβ”€β”€ components/ β†’ src/components/ -β”œβ”€β”€ utils/ β†’ src/utils/ -└── styles/ β†’ src/styles/ -``` - -### βœ… Created Documentation - -``` -βœ… README.md - Full project documentation -βœ… MIGRATION_GUIDE.md - Detailed migration steps -βœ… SETUP_INSTRUCTIONS.md - Quick setup guide -βœ… START_HERE.md - This file -``` - -### βœ… VS Code Configuration - -``` -.vscode/ -β”œβ”€β”€ settings.json βœ… Auto-format, Tailwind IntelliSense -└── extensions.json βœ… Recommended extensions -``` - ---- - -## πŸ”„ Migration Steps - -### Step 1: Move Files (Pick One) - -**Option A - PowerShell Script:** -```powershell -.\migrate-files.ps1 -``` - -**Option B - Manual:** -```bash -move App.tsx src\ -move components src\ -move utils src\ -move styles src\ -``` - -### Step 2: Install Dependencies - -```bash -npm install -``` - -This installs ~50 packages (takes 2-3 minutes). - -### Step 3: Update Imports in src/App.tsx - -**Find and Replace in App.tsx:** - -1. Change all component imports: -```typescript -// OLD -import { Layout } from './components/Layout'; -import { Dashboard } from './components/Dashboard'; -// ... all other component imports - -// NEW -import { Layout } from '@/components/Layout'; -import { Dashboard } from '@/components/Dashboard'; -// ... use @/ for all imports -``` - -2. Fix sonner import: -```typescript -// OLD -import { toast } from 'sonner@2.0.3'; - -// NEW -import { toast } from 'sonner'; -``` - -### Step 4: Update Component Files - -In all files under `src/components/`, change relative imports: - -```typescript -// OLD in any component file -import { Button } from './ui/button'; -import { Card } from '../ui/card'; - -// NEW -import { Button } from '@/components/ui/button'; -import { Card } from '@/components/ui/card'; -``` - -### Step 5: Start Development Server - -```bash -npm run dev -``` - -Visit: http://localhost:3000 - ---- - -## πŸ› οΈ Available Commands - -```bash -# Development -npm run dev # Start dev server (port 3000) - -# Build -npm run build # Build for production -npm run preview # Preview production build - -# Code Quality -npm run lint # Check for errors -npm run lint:fix # Auto-fix errors -npm run format # Format with Prettier -npm run type-check # Check TypeScript types -``` - ---- - -## ✨ New Features You Get - -### 1. **Path Aliases** - Cleaner Imports -```typescript -// Before -import { Button } from '../../../components/ui/button'; - -// After -import { Button } from '@/components/ui/button'; -``` - -### 2. **TypeScript Types** - Better IntelliSense -```typescript -import type { Request, DealerInfo } from '@/types'; - -const request: Request = { /* auto-complete works! */ }; -``` - -### 3. **Code Quality** - Auto-fix on Save -- ESLint catches bugs -- Prettier formats code -- TypeScript ensures type safety - -### 4. **Fast Development** -- Hot Module Replacement (HMR) -- Instant updates on file save -- Optimized build with code splitting - ---- - -## πŸ†˜ Common Issues & Fixes - -### Issue 1: "Cannot find module '@/...'" - -**Fix:** -```bash -# Restart TypeScript server -# In VS Code: Ctrl+Shift+P β†’ "TypeScript: Restart TS Server" -``` - -### Issue 2: "Module not found: sonner@2.0.3" - -**Fix in src/App.tsx:** -```typescript -// Change this: -import { toast } from 'sonner@2.0.3'; - -// To this: -import { toast } from 'sonner'; -``` - -### Issue 3: Tailwind classes not working - -**Fix:** -1. Ensure `src/main.tsx` has: `import './styles/globals.css';` -2. Restart dev server: `Ctrl+C` then `npm run dev` - -### Issue 4: Build fails - -**Fix:** -```bash -npm run type-check # See what TypeScript errors exist -npm run lint # See what ESLint errors exist -``` - ---- - -## πŸ“š Documentation - -| File | Purpose | -|------|---------| -| `README.md` | Full project documentation | -| `MIGRATION_GUIDE.md` | Step-by-step migration | -| `SETUP_INSTRUCTIONS.md` | Quick setup guide | -| `START_HERE.md` | This file - quick overview | - ---- - -## βœ… Success Checklist - -Track your progress: - -- [ ] Run migration script OR move files manually -- [ ] Run `npm install` (2-3 minutes) -- [ ] Update imports in `src/App.tsx` to use `@/` -- [ ] Fix sonner import in `src/App.tsx` -- [ ] Update imports in all component files -- [ ] Run `npm run dev` -- [ ] Open http://localhost:3000 -- [ ] Verify app loads without errors -- [ ] Test dashboard navigation -- [ ] Test creating new request -- [ ] Run `npm run build` to verify production build -- [ ] Commit changes to git - ---- - -## πŸŽ“ Tech Stack Overview - -| Technology | Purpose | Version | -|------------|---------|---------| -| **React** | UI Framework | 18.3+ | -| **TypeScript** | Type Safety | 5.6+ | -| **Vite** | Build Tool | 5.4+ | -| **Tailwind CSS** | Styling | 3.4+ | -| **shadcn/ui** | UI Components | Latest | -| **ESLint** | Code Quality | 9.15+ | -| **Prettier** | Formatting | 3.3+ | - ---- - -## 🎯 Next Actions - -1. **Immediate** - Run the migration (5 minutes) -2. **Today** - Update imports and test (15 minutes) -3. **This Week** - Review new features and documentation -4. **Future** - Add backend API, authentication, tests - ---- - -## πŸ’‘ Pro Tips - -### Tip 1: Use VS Code Extensions -Install the recommended extensions when VS Code prompts you. - -### Tip 2: Format on Save -Already configured! Your code auto-formats when you save. - -### Tip 3: Type Everything -Replace `any` types with proper TypeScript types from `@/types`. - -### Tip 4: Use Path Aliases -Always use `@/` imports for cleaner code. - ---- - -## πŸŽ‰ You're Ready! - -Your project is now set up with industry-standard React development tools. - -**Next Step:** Run the migration script and start coding! - -```powershell -.\migrate-files.ps1 -npm install -npm run dev -``` - -**Questions?** Check the detailed guides: -- `MIGRATION_GUIDE.md` - Detailed steps -- `README.md` - Full documentation -- `SETUP_INSTRUCTIONS.md` - Setup help - ---- - -**Happy Coding! πŸš€** - diff --git a/SYSTEM_CONFIGURATION.md b/SYSTEM_CONFIGURATION.md deleted file mode 100644 index 57c2455..0000000 --- a/SYSTEM_CONFIGURATION.md +++ /dev/null @@ -1,308 +0,0 @@ -# System Configuration - Frontend Integration Guide - -## πŸ“‹ Overview - -The Royal Enfield Workflow Management System now uses **centralized, backend-driven configuration**. All system settings are fetched from the backend API and cached on the frontend. - -## 🚫 **NO MORE HARDCODED VALUES!** - -### ❌ Before (Hardcoded): -```typescript -const MAX_MESSAGE_LENGTH = 2000; -const WORK_START_HOUR = 9; -const MAX_APPROVAL_LEVELS = 10; -``` - -### βœ… After (Backend-Driven): -```typescript -import { configService, getWorkNotesConfig } from '@/services/configService'; - -const config = await getWorkNotesConfig(); -const maxLength = config.maxMessageLength; // From backend -``` - ---- - -## 🎯 How to Use Configuration - -### **Method 1: Full Configuration Object** - -```typescript -import { configService } from '@/services/configService'; - -// In component -useEffect(() => { - const loadConfig = async () => { - const config = await configService.getConfig(); - console.log('Max file size:', config.upload.maxFileSizeMB); - console.log('Working hours:', config.workingHours); - }; - loadConfig(); -}, []); -``` - -### **Method 2: Helper Functions** - -```typescript -import { - getWorkingHours, - getTATThresholds, - getUploadLimits, - getWorkNotesConfig, - getFeatureFlags -} from '@/services/configService'; - -// Get specific configuration -const workingHours = await getWorkingHours(); -const tatThresholds = await getTATThresholds(); -const uploadLimits = await getUploadLimits(); -``` - -### **Method 3: React Hook (Recommended)** - -Create a custom hook: -```typescript -// src/hooks/useSystemConfig.ts -import { useState, useEffect } from 'react'; -import { configService, SystemConfig } from '@/services/configService'; - -export function useSystemConfig() { - const [config, setConfig] = useState(null); - const [loading, setLoading] = useState(true); - - useEffect(() => { - const loadConfig = async () => { - const cfg = await configService.getConfig(); - setConfig(cfg); - setLoading(false); - }; - loadConfig(); - }, []); - - return { config, loading }; -} - -// Usage in component: -function MyComponent() { - const { config, loading } = useSystemConfig(); - - if (loading) return
Loading...
; - - return ( -
- Max file size: {config.upload.maxFileSizeMB} MB -
- ); -} -``` - ---- - -## πŸ”„ Configuration Flow - -``` -β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” -β”‚ Backend (.env) β”‚ -β”‚ Environment β”‚ -β”‚ Variables β”‚ -β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ - β”‚ - β–Ό -β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” -β”‚ system.config.tsβ”‚ -β”‚ (Centralized) β”‚ -β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ - β”‚ - β”œβ”€β”€β”€β”€β”€β–Ί tat.config.ts (TAT settings) - β”œβ”€β”€β”€β”€β”€β–Ί tatTimeUtils.ts (Uses working hours) - └─────► config.routes.ts (API endpoint) - β”‚ - β–Ό - GET /api/v1/config - β”‚ - β–Ό - β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” - β”‚ Frontend configService β”‚ - β”‚ (Cached in memory) β”‚ - β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ - β”‚ - β”œβ”€β”€β”€β”€β”€β–Ί Components (via hook) - β”œβ”€β”€β”€β”€β”€β–Ί Utils (slaTracker) - └─────► Services -``` - ---- - -## πŸ“Š Configuration Values - -### **Working Hours** -```typescript -const workingHours = await getWorkingHours(); -// { -// START_HOUR: 9, -// END_HOUR: 18, -// START_DAY: 1, // Monday -// END_DAY: 5, // Friday -// TIMEZONE: 'Asia/Kolkata' -// } -``` - -### **TAT Thresholds** -```typescript -const thresholds = await getTATThresholds(); -// { -// warning: 50, // 50% - First reminder -// critical: 75, // 75% - Urgent reminder -// breach: 100 // 100% - Breach alert -// } -``` - -### **Upload Limits** -```typescript -const limits = await getUploadLimits(); -// { -// maxFileSizeMB: 10, -// allowedFileTypes: ['pdf', 'doc', ...], -// maxFilesPerRequest: 10 -// } -``` - -### **Feature Flags** -```typescript -const features = await getFeatureFlags(); -// { -// ENABLE_AI_CONCLUSION: true, -// ENABLE_TEMPLATES: false, -// ENABLE_ANALYTICS: true, -// ENABLE_EXPORT: true -// } -``` - ---- - -## 🎨 Example Integrations - -### **File Upload Component** -```typescript -import { getUploadLimits } from '@/services/configService'; - -function FileUpload() { - const [maxSize, setMaxSize] = useState(10); - - useEffect(() => { - const loadLimits = async () => { - const limits = await getUploadLimits(); - setMaxSize(limits.maxFileSizeMB); - }; - loadLimits(); - }, []); - - return ( - - ); -} -``` - -### **Work Notes Message Input** -```typescript -import { getWorkNotesConfig } from '@/services/configService'; - -function MessageInput() { - const [maxLength, setMaxLength] = useState(2000); - - useEffect(() => { - const loadConfig = async () => { - const config = await getWorkNotesConfig(); - setMaxLength(config.maxMessageLength); - }; - loadConfig(); - }, []); - - return ( -