8.0 KiB
8.0 KiB
Complete Flow Segregation - Implementation Summary
Overview
This document describes the complete segregation of request flows into dedicated folders. Each flow type (CUSTOM, DEALER_CLAIM) now has ALL its related components, hooks, services, utilities, and types in its own folder. Only truly shared components remain in the shared/ folder.
What Was Done
1. Created Complete Folder Structure
Custom Flow (src/flows/custom/)
custom/
├── components/
│ ├── request-detail/
│ │ ├── OverviewTab.tsx # Custom request overview
│ │ └── WorkflowTab.tsx # Custom request workflow
│ └── request-creation/
│ └── CreateRequest.tsx # Custom request creation
└── index.ts # Exports all custom components
Dealer Claim Flow (src/flows/dealer-claim/)
dealer-claim/
├── components/
│ ├── request-detail/
│ │ ├── OverviewTab.tsx # Dealer claim overview
│ │ ├── WorkflowTab.tsx # Dealer claim workflow
│ │ ├── IOTab.tsx # IO management (dealer claim specific)
│ │ ├── claim-cards/ # All dealer claim cards
│ │ │ ├── ActivityInformationCard.tsx
│ │ │ ├── DealerInformationCard.tsx
│ │ │ ├── ProcessDetailsCard.tsx
│ │ │ ├── ProposalDetailsCard.tsx
│ │ │ └── RequestInitiatorCard.tsx
│ │ └── modals/ # All dealer claim modals
│ │ ├── CreditNoteSAPModal.tsx
│ │ ├── DealerCompletionDocumentsModal.tsx
│ │ ├── DealerProposalSubmissionModal.tsx
│ │ ├── DeptLeadIOApprovalModal.tsx
│ │ ├── EditClaimAmountModal.tsx
│ │ ├── EmailNotificationTemplateModal.tsx
│ │ └── InitiatorProposalApprovalModal.tsx
│ └── request-creation/
│ └── ClaimManagementWizard.tsx # Dealer claim creation
└── index.ts # Exports all dealer claim components
Shared Components (src/flows/shared/)
shared/
└── components/
└── request-detail/
├── DocumentsTab.tsx # Used by all flows
├── ActivityTab.tsx # Used by all flows
├── WorkNotesTab.tsx # Used by all flows
├── SummaryTab.tsx # Used by all flows
├── RequestDetailHeader.tsx # Used by all flows
├── QuickActionsSidebar.tsx # Used by all flows
└── RequestDetailModals.tsx # Used by all flows
2. Updated Flow Registry
The flow registry (src/flows/index.ts) now:
- Exports all flow modules
- Provides utility functions to get flow-specific components
- Includes
getCreateRequestComponent()for request creation - Exports
SharedComponentsfor shared components
3. Updated RequestDetail Component
The RequestDetail component now:
- Uses flow registry to get flow-specific components
- Imports shared components from
SharedComponents - Dynamically loads appropriate tabs based on flow type
- Maintains backward compatibility
File Organization Rules
✅ Flow-Specific Files → Flow Folders
Custom Flow:
- Custom request creation wizard
- Custom request detail tabs (Overview, Workflow)
- Custom request hooks (future)
- Custom request services (future)
- Custom request utilities (future)
- Custom request types (future)
Dealer Claim Flow:
- Dealer claim creation wizard
- Dealer claim detail tabs (Overview, Workflow, IO)
- Dealer claim cards (Activity, Dealer, Process, Proposal, Initiator)
- Dealer claim modals (all 7 modals)
- Dealer claim hooks (future)
- Dealer claim services (future)
- Dealer claim utilities (future)
- Dealer claim types (future)
✅ Shared Files → Shared Folder
Shared Components:
- DocumentsTab (used by all flows)
- ActivityTab (used by all flows)
- WorkNotesTab (used by all flows)
- SummaryTab (used by all flows)
- RequestDetailHeader (used by all flows)
- QuickActionsSidebar (used by all flows)
- RequestDetailModals (used by all flows)
Usage Examples
Getting Flow-Specific Components
import { getOverviewTab, getWorkflowTab, getCreateRequestComponent } from '@/flows';
import { getRequestFlowType } from '@/utils/requestTypeUtils';
const flowType = getRequestFlowType(request);
const OverviewTab = getOverviewTab(flowType);
const WorkflowTab = getWorkflowTab(flowType);
const CreateRequest = getCreateRequestComponent(flowType);
Using Shared Components
import { SharedComponents } from '@/flows';
const { DocumentsTab, ActivityTab, WorkNotesTab, SummaryTab } = SharedComponents;
Direct Access to Flow Components
import { CustomFlow, DealerClaimFlow } from '@/flows';
// Custom flow
<CustomFlow.CustomOverviewTab {...props} />
<CustomFlow.CustomCreateRequest {...props} />
// Dealer claim flow
<DealerClaimFlow.DealerClaimOverviewTab {...props} />
<DealerClaimFlow.IOTab {...props} />
<DealerClaimFlow.ClaimManagementWizard {...props} />
Benefits
- Complete Segregation: Each flow is completely isolated
- Easy Navigation: All files for a flow type are in one place
- Maintainability: Changes to one flow don't affect others
- Scalability: Easy to add new flow types
- Clarity: Clear separation between flow-specific and shared code
- Type Safety: TypeScript ensures correct usage
Next Steps (Future Enhancements)
-
Move Flow-Specific Hooks
- Custom hooks →
flows/custom/hooks/ - Dealer claim hooks →
flows/dealer-claim/hooks/
- Custom hooks →
-
Move Flow-Specific Services
- Custom services →
flows/custom/services/ - Dealer claim services →
flows/dealer-claim/services/
- Custom services →
-
Move Flow-Specific Utilities
- Custom utilities →
flows/custom/utils/ - Dealer claim utilities →
flows/dealer-claim/utils/
- Custom utilities →
-
Move Flow-Specific Types
- Custom types →
flows/custom/types/ - Dealer claim types →
flows/dealer-claim/types/
- Custom types →
Files Created
Custom Flow
src/flows/custom/components/request-detail/OverviewTab.tsxsrc/flows/custom/components/request-detail/WorkflowTab.tsxsrc/flows/custom/components/request-creation/CreateRequest.tsxsrc/flows/custom/index.ts(updated)
Dealer Claim Flow
src/flows/dealer-claim/components/request-detail/OverviewTab.tsxsrc/flows/dealer-claim/components/request-detail/WorkflowTab.tsxsrc/flows/dealer-claim/components/request-detail/IOTab.tsxsrc/flows/dealer-claim/components/request-detail/claim-cards/index.tssrc/flows/dealer-claim/components/request-detail/modals/index.tssrc/flows/dealer-claim/components/request-creation/ClaimManagementWizard.tsxsrc/flows/dealer-claim/index.ts(updated)
Shared Components
src/flows/shared/components/request-detail/DocumentsTab.tsxsrc/flows/shared/components/request-detail/ActivityTab.tsxsrc/flows/shared/components/request-detail/WorkNotesTab.tsxsrc/flows/shared/components/request-detail/SummaryTab.tsxsrc/flows/shared/components/request-detail/RequestDetailHeader.tsxsrc/flows/shared/components/request-detail/QuickActionsSidebar.tsxsrc/flows/shared/components/request-detail/RequestDetailModals.tsxsrc/flows/shared/components/index.ts(updated)
Registry
src/flows/index.ts(updated with new structure)
Files Modified
src/pages/RequestDetail/RequestDetail.tsx- Uses new flow structuresrc/flows/README.md- Updated with complete segregation documentation
Conclusion
The complete segregation is now in place. Each flow type has its own dedicated folder with all related components. This makes it easy to:
- Find all files related to a specific flow type
- Maintain and update flow-specific code
- Add new flow types without affecting existing ones
- Understand what is shared vs. flow-specific
The architecture is now truly modular and plug-and-play!