import { useState, useEffect } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import { mockApplications, mockAuditLogs, mockDocuments, mockWorkNotes, mockLevel1Scores, mockQuestionnaireResponses, Application, ApplicationStatus } from '../../lib/mock-data'; import { onboardingService } from '../../services/onboarding.service'; import { WorkNotesPage } from './WorkNotesPage'; import QuestionnaireForm from '../dealer/QuestionnaireForm'; import QuestionnaireResponseView from './QuestionnaireResponseView'; import { Button } from '../ui/button'; import { Badge } from '../ui/badge'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'; import { Card, CardContent, CardHeader, CardTitle } from '../ui/card'; import { ArrowLeft, CheckCircle, XCircle, MessageSquare, Calendar, Clock, Upload, Download, FileText, User, MapPin, Mail, Phone, GraduationCap, Bike, Award, AlertCircle, ClipboardList, ChevronDown, ChevronRight, GitBranch, Star } from 'lucide-react'; import { Progress } from '../ui/progress'; import { Textarea } from '../ui/textarea'; import { Input } from '../ui/input'; import { Label } from '../ui/label'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '../ui/dialog'; import { ScrollArea } from '../ui/scroll-area'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '../ui/table'; import { Checkbox } from '../ui/checkbox'; import { Separator } from '../ui/separator'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/select'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '../ui/dropdown-menu'; interface ProcessStage { id: number | string; name: string; status: 'completed' | 'active' | 'pending'; date?: string; description?: string; evaluators?: string[]; documentsUploaded?: number; isParallel?: boolean; branches?: { name: string; color: string; stages: ProcessStage[]; }[]; } export function ApplicationDetails() { const { id } = useParams<{ id: string }>(); const navigate = useNavigate(); const applicationId = id || ''; const onBack = () => navigate(-1); // const application = mockApplications.find(app => app.id === applicationId); const [application, setApplication] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { const fetchApplication = async () => { try { setLoading(true); const data = await onboardingService.getApplicationById(applicationId); // Helper to find stage date const getStageDate = (stageName: string) => { const stage = data.progressTracking?.find((p: any) => p.stageName === stageName); return stage?.stageCompletedAt ? new Date(stage.stageCompletedAt).toISOString().split('T')[0] : stage?.stageStartedAt ? new Date(stage.stageStartedAt).toISOString().split('T')[0] : undefined; }; // Map backend data to frontend Application interface const mappedApp: Application = { id: data.id, registrationNumber: data.applicationId || 'N/A', name: data.applicantName, email: data.email, phone: data.phone, age: data.age, education: data.education, residentialAddress: data.address || data.city || '', businessAddress: data.address || '', preferredLocation: data.preferredLocation, state: data.state, ownsBike: data.ownRoyalEnfield === 'yes', pastExperience: data.experienceYears ? `${data.experienceYears} years` : (data.description || ''), status: data.overallStatus as ApplicationStatus, questionnaireMarks: data.score || data.questionnaireMarks || 0, // Read from score or correct field questionnaireResponses: data.questionnaireResponses || [], // Map responses rank: 0, totalApplicantsAtLocation: 0, submissionDate: data.createdAt, assignedUsers: [], progress: data.progressPercentage || 0, isShortlisted: data.isShortlisted || true, // Default to true for now // Add other fields to match interface companyName: data.companyName, source: data.source, existingDealer: data.existingDealer, royalEnfieldModel: data.royalEnfieldModel, description: data.description, pincode: data.pincode, locationType: data.locationType, ownRoyalEnfield: data.ownRoyalEnfield, address: data.address, // Map timeline dates from progressTracking level1InterviewDate: getStageDate('1st Level Interview'), level2InterviewDate: getStageDate('2nd Level Interview'), level3InterviewDate: getStageDate('3rd Level Interview'), fddDate: getStageDate('FDD'), loiApprovalDate: getStageDate('LOI Approval'), securityDetailsDate: getStageDate('Security Details'), loiIssueDate: getStageDate('LOI Issue'), dealerCodeDate: getStageDate('Dealer Code Generation'), architectureAssignedDate: getStageDate('Architecture Team Assigned'), architectureDocumentDate: getStageDate('Architecture Document Upload'), architectureCompletionDate: getStageDate('Architecture Team Completion'), loaDate: getStageDate('LOA'), eorCompleteDate: getStageDate('EOR Complete'), inaugurationDate: getStageDate('Inauguration'), }; setApplication(mappedApp); } catch (error) { console.error('Failed to fetch application details', error); } finally { setLoading(false); } }; if (applicationId) { fetchApplication(); } }, [applicationId]); const [activeTab, setActiveTab] = useState('questionnaire'); const [showApproveModal, setShowApproveModal] = useState(false); const [showRejectModal, setShowRejectModal] = useState(false); const [showWorkNoteModal, setShowWorkNoteModal] = useState(false); const [showWorkNotesPage, setShowWorkNotesPage] = useState(false); const [showScheduleModal, setShowScheduleModal] = useState(false); const [showKTMatrixModal, setShowKTMatrixModal] = useState(false); const [showLevel2FeedbackModal, setShowLevel2FeedbackModal] = useState(false); const [showLevel3FeedbackModal, setShowLevel3FeedbackModal] = useState(false); const [showDocumentsModal, setShowDocumentsModal] = useState(false); const [selectedStage, setSelectedStage] = useState(null); const [interviewMode, setInterviewMode] = useState('virtual'); const [approvalRemark, setApprovalRemark] = useState(''); const [rejectionReason, setRejectionReason] = useState(''); const [workNote, setWorkNote] = useState(''); const [expandedBranches, setExpandedBranches] = useState<{ [key: string]: boolean }>({ 'architectural-work': true, 'statutory-documents': true }); if (loading) { return
Loading application details...
; } if (!application) { return
Application not found
; } const processStages: ProcessStage[] = [ { id: 1, name: 'Submitted', status: 'completed', date: application.submissionDate, description: 'Application submitted', documentsUploaded: 3 }, { id: 2, name: 'Questionnaire', status: application.questionnaireMarks ? 'completed' : 'pending', date: '2025-10-03', description: 'Questionnaire completed', documentsUploaded: 0 }, { id: 3, name: 'Shortlist', status: ['Shortlisted', 'Level 1 Pending', 'Level 1 Approved', 'Level 2 Pending', 'Level 2 Approved', 'Level 3 Pending', 'FDD Verification', 'Payment Pending', 'Dealer Code Generation', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : 'pending', date: '2025-10-04', description: 'Application shortlisted by DD', documentsUploaded: 2 }, { id: 4, name: '1st Level Interview', status: ['Level 1 Approved', 'Level 2 Pending', 'Level 2 Approved', 'Level 3 Pending', 'FDD Verification', 'Payment Pending', 'Dealer Code Generation', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Level 1 Pending' ? 'active' : 'pending', date: application.level1InterviewDate, description: 'DD-ZM + RBM evaluation', evaluators: ['DD-ZM', 'RBM'], documentsUploaded: 1 }, { id: 5, name: '2nd Level Interview', status: ['Level 2 Approved', 'Level 2 Recommended', 'Level 3 Pending', 'FDD Verification', 'Payment Pending', 'Dealer Code Generation', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Level 2 Pending' ? 'active' : 'pending', date: application.level2InterviewDate, description: 'DD Lead + ZBH evaluation', evaluators: ['DD Lead', 'ZBH'], documentsUploaded: 1 }, { id: 6, name: '3rd Level Interview', status: ['FDD Verification', 'Payment Pending', 'Dealer Code Generation', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Level 3 Pending' ? 'active' : 'pending', date: application.level3InterviewDate, description: 'NBH + DD-Head evaluation', evaluators: ['NBH', 'DD-Head'], documentsUploaded: 2 }, { id: 7, name: 'FDD', status: ['Payment Pending', 'Dealer Code Generation', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'FDD Verification' ? 'active' : 'pending', date: application.fddDate, description: 'Financial Due Diligence', documentsUploaded: 5 }, { id: 8, name: 'LOI Approval', status: ['Payment Pending', 'Dealer Code Generation', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : 'pending', date: application.loiApprovalDate, description: 'Letter of Intent approval', documentsUploaded: 1 }, { id: 9, name: 'Security Details', status: ['Payment Pending', 'Dealer Code Generation', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : 'pending', date: application.securityDetailsDate, description: 'Security verification', documentsUploaded: 3 }, { id: 10, name: 'LOI Issue', status: ['Dealer Code Generation', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Payment Pending' ? 'active' : 'pending', date: application.loiIssueDate, description: 'Letter of Intent issued', documentsUploaded: 1 }, { id: 11, name: 'Dealer Code Generation', status: ['Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion', 'Statutory GST', 'Statutory PAN', 'Statutory Nodal', 'Statutory Check', 'Statutory Partnership', 'Statutory Firm Reg', 'Statutory Rental', 'Statutory Virtual Code', 'Statutory Domain', 'Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Dealer Code Generation' ? 'active' : 'pending', date: application.dealerCodeDate, description: 'Dealer code generated and assigned', documentsUploaded: 0, isParallel: true, branches: [ { name: 'Architectural Work', color: 'blue', stages: [ { id: '11a-1', name: 'Assigned to Architecture Team', status: ['Architecture Document Upload', 'Architecture Team Completion', 'Statutory GST', 'Statutory PAN', 'Statutory Nodal', 'Statutory Check', 'Statutory Partnership', 'Statutory Firm Reg', 'Statutory Rental', 'Statutory Virtual Code', 'Statutory Domain', 'Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Architecture Team Assigned' ? 'active' : 'pending', date: application.architectureAssignedDate, description: 'Assigned to architecture team for site planning', documentsUploaded: 0 }, { id: '11a-2', name: 'Architectural Document Upload', status: ['Architecture Team Completion', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Architecture Document Upload' ? 'active' : 'pending', date: application.architectureDocumentDate, description: 'Architectural documents and blueprints uploaded', documentsUploaded: 8 }, { id: '11a-3', name: 'Architecture Team Completion', status: ['LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Architecture Team Completion' ? 'active' : 'pending', date: application.architectureCompletionDate, description: 'Architecture team work completed', documentsUploaded: 4 } ] }, { name: 'Statutory Documents', color: 'green', stages: [ { id: '11b-1', name: 'GST', status: ['Statutory PAN', 'Statutory Nodal', 'Statutory Check', 'Statutory Partnership', 'Statutory Firm Reg', 'Statutory Rental', 'Statutory Virtual Code', 'Statutory Domain', 'Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory GST' ? 'active' : 'pending', description: 'GST certificate', documentsUploaded: 1 }, { id: '11b-2', name: 'PAN', status: ['Statutory Nodal', 'Statutory Check', 'Statutory Partnership', 'Statutory Firm Reg', 'Statutory Rental', 'Statutory Virtual Code', 'Statutory Domain', 'Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory PAN' ? 'active' : 'pending', description: 'PAN card', documentsUploaded: 1 }, { id: '11b-3', name: 'Nodal Agreement', status: ['Statutory Check', 'Statutory Partnership', 'Statutory Firm Reg', 'Statutory Rental', 'Statutory Virtual Code', 'Statutory Domain', 'Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory Nodal' ? 'active' : 'pending', description: 'Nodal agreement document', documentsUploaded: 1 }, { id: '11b-4', name: 'Cancelled Check', status: ['Statutory Partnership', 'Statutory Firm Reg', 'Statutory Rental', 'Statutory Virtual Code', 'Statutory Domain', 'Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory Check' ? 'active' : 'pending', description: 'Cancelled check copy', documentsUploaded: 1 }, { id: '11b-5', name: 'Partnership Deed/LLP/MOA/AOA/COI', status: ['Statutory Firm Reg', 'Statutory Rental', 'Statutory Virtual Code', 'Statutory Domain', 'Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory Partnership' ? 'active' : 'pending', description: 'Business entity documents', documentsUploaded: 2 }, { id: '11b-6', name: 'Firm Registration Certificate', status: ['Statutory Rental', 'Statutory Virtual Code', 'Statutory Domain', 'Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory Firm Reg' ? 'active' : 'pending', description: 'Firm registration certificate', documentsUploaded: 1 }, { id: '11b-7', name: 'Rental agreement/ Lease agreement / Own/ Land agreement', status: ['Statutory Virtual Code', 'Statutory Domain', 'Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory Rental' ? 'active' : 'pending', description: 'Property agreement document', documentsUploaded: 1 }, { id: '11b-8', name: 'Virtual Code', status: ['Statutory Domain', 'Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory Virtual Code' ? 'active' : 'pending', description: 'Virtual code availability', documentsUploaded: 0 }, { id: '11b-9', name: 'Domain ID', status: ['Statutory MSD', 'Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory Domain' ? 'active' : 'pending', description: 'Domain ID setup', documentsUploaded: 0 }, { id: '11b-10', name: 'MSD Configuration', status: ['Statutory LOI Ack', 'LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory MSD' ? 'active' : 'pending', description: 'Microsoft Dynamics configuration', documentsUploaded: 0 }, { id: '11b-11', name: 'LOI Acknowledgement Copy', status: ['LOA Pending', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'Statutory LOI Ack' ? 'active' : 'pending', description: 'LOI acknowledgement copy', documentsUploaded: 1 } ] } ] }, { id: 12, name: 'LOA', status: ['EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'LOA Pending' ? 'active' : 'pending', date: application.loaDate, description: 'Letter of Authorization', documentsUploaded: 1 }, { id: 13, name: 'EOR Complete', status: ['Inauguration', 'Approved'].includes(application.status) ? 'completed' : application.status === 'EOR Complete' ? 'active' : 'pending', date: application.eorCompleteDate, description: 'Essential Operating Requirements completed', documentsUploaded: 6 }, { id: 14, name: 'Inauguration', status: application.status === 'Approved' ? 'completed' : application.status === 'Inauguration' ? 'active' : 'pending', date: application.inaugurationDate, description: 'Dealership inauguration ceremony', documentsUploaded: 2 } ]; const eorChecklist = [ { id: 1, item: 'Sales Standards', completed: true }, { id: 2, item: 'Service & Spares', completed: true }, { id: 3, item: 'DMS infra', completed: application.status === 'Approved' }, { id: 4, item: 'Manpower Training', completed: application.status === 'Approved' }, { id: 5, item: 'Trade certificate with test ride bikes registration', completed: false }, { id: 6, item: 'GST certificate including Accessories & Apparels billing', completed: true }, { id: 7, item: 'Inventory Funding', completed: false }, { id: 8, item: 'Virtual code availability', completed: true }, { id: 9, item: 'Vendor payments', completed: false }, { id: 10, item: 'Details for website submission', completed: true }, { id: 11, item: 'Infra Insurance both Showroom and Service center', completed: false }, { id: 12, item: 'Auto ordering', completed: application.status === 'Approved' } ]; const eorProgress = (eorChecklist.filter(item => item.completed).length / eorChecklist.length) * 100; // Mock stage-specific documents const stageDocuments: { [key: string]: typeof mockDocuments } = { 'Submitted': [ { id: 'd1', name: 'Application Form.pdf', type: 'PDF', uploadDate: '2025-10-01', status: 'Verified', uploader: 'Amit Sharma' }, { id: 'd2', name: 'Aadhaar Card.pdf', type: 'PDF', uploadDate: '2025-10-01', status: 'Verified', uploader: 'Amit Sharma' }, { id: 'd3', name: 'PAN Card.pdf', type: 'PDF', uploadDate: '2025-10-01', status: 'Verified', uploader: 'Amit Sharma' } ], 'Shortlist': [ { id: 'd4', name: 'Business Plan.pdf', type: 'PDF', uploadDate: '2025-10-04', status: 'Verified', uploader: 'Amit Sharma' }, { id: 'd5', name: 'Financial Projections.xlsx', type: 'Excel', uploadDate: '2025-10-04', status: 'Verified', uploader: 'Amit Sharma' } ], '1st Level Interview': [ { id: 'd6', name: 'Level 1 Evaluation Sheet.pdf', type: 'PDF', uploadDate: '2025-10-05', status: 'Verified', uploader: 'DD-ZM' } ], '2nd Level Interview': [ { id: 'd7', name: 'Level 2 Evaluation Sheet.pdf', type: 'PDF', uploadDate: '2025-10-07', status: 'Verified', uploader: 'DD Lead' } ], '3rd Level Interview': [ { id: 'd8', name: 'Level 3 Evaluation Sheet.pdf', type: 'PDF', uploadDate: '2025-10-09', status: 'Verified', uploader: 'NBH' }, { id: 'd9', name: 'Final Interview Notes.pdf', type: 'PDF', uploadDate: '2025-10-09', status: 'Verified', uploader: 'DD-Head' } ], 'FDD': [ { id: 'd10', name: 'Bank Statements.pdf', type: 'PDF', uploadDate: '2025-10-10', status: 'Verified', uploader: 'FDD Team' }, { id: 'd11', name: 'Income Tax Returns.pdf', type: 'PDF', uploadDate: '2025-10-10', status: 'Verified', uploader: 'Amit Sharma' }, { id: 'd12', name: 'Credit Report.pdf', type: 'PDF', uploadDate: '2025-10-10', status: 'Verified', uploader: 'FDD Team' }, { id: 'd13', name: 'Property Documents.pdf', type: 'PDF', uploadDate: '2025-10-10', status: 'Pending', uploader: 'Amit Sharma' }, { id: 'd14', name: 'Business Valuation.pdf', type: 'PDF', uploadDate: '2025-10-10', status: 'Verified', uploader: 'FDD Team' } ], 'LOI Approval': [ { id: 'd15', name: 'LOI Approval Document.pdf', type: 'PDF', uploadDate: '2025-10-11', status: 'Verified', uploader: 'DD Admin' } ], 'Security Details': [ { id: 'd16', name: 'Police Verification.pdf', type: 'PDF', uploadDate: '2025-10-12', status: 'Verified', uploader: 'Security Team' }, { id: 'd17', name: 'Background Check Report.pdf', type: 'PDF', uploadDate: '2025-10-12', status: 'Verified', uploader: 'Security Team' }, { id: 'd18', name: 'Character Certificate.pdf', type: 'PDF', uploadDate: '2025-10-12', status: 'Verified', uploader: 'Amit Sharma' } ], 'LOI Issue': [ { id: 'd19', name: 'Letter of Intent.pdf', type: 'PDF', uploadDate: '2025-10-13', status: 'Verified', uploader: 'DD Admin' } ], 'Architectural Document Upload': [ { id: 'd20', name: 'Site Plan.dwg', type: 'CAD', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Architecture Team' }, { id: 'd21', name: 'Floor Plan.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Architecture Team' }, { id: 'd22', name: 'Elevation Design.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Architecture Team' }, { id: 'd23', name: '3D Renders.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Architecture Team' }, { id: 'd24', name: 'Structural Design.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Architecture Team' }, { id: 'd25', name: 'Electrical Layout.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Architecture Team' }, { id: 'd26', name: 'Plumbing Layout.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Architecture Team' }, { id: 'd27', name: 'HVAC Design.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Architecture Team' } ], 'Architecture Team Completion': [ { id: 'd28', name: 'Final Approval Certificate.pdf', type: 'PDF', uploadDate: '2025-10-15', status: 'Verified', uploader: 'Architecture Team' }, { id: 'd29', name: 'As-Built Drawings.pdf', type: 'PDF', uploadDate: '2025-10-15', status: 'Verified', uploader: 'Architecture Team' }, { id: 'd30', name: 'Compliance Certificate.pdf', type: 'PDF', uploadDate: '2025-10-15', status: 'Verified', uploader: 'Architecture Team' }, { id: 'd31', name: 'Quality Assurance Report.pdf', type: 'PDF', uploadDate: '2025-10-15', status: 'Verified', uploader: 'Architecture Team' } ], 'GST': [ { id: 'd32', name: 'GST Certificate.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Amit Sharma' } ], 'PAN': [ { id: 'd33', name: 'PAN Card.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Amit Sharma' } ], 'Nodal Agreement': [ { id: 'd34', name: 'Nodal Agreement.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Amit Sharma' } ], 'Cancelled Check': [ { id: 'd35', name: 'Cancelled Cheque.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Amit Sharma' } ], 'Partnership Deed/LLP/MOA/AOA/COI': [ { id: 'd36', name: 'Partnership Deed.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Amit Sharma' }, { id: 'd37', name: 'MOA.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Amit Sharma' } ], 'Firm Registration Certificate': [ { id: 'd38', name: 'Firm Registration.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Amit Sharma' } ], 'Rental agreement/ Lease agreement / Own/ Land agreement': [ { id: 'd39', name: 'Lease Agreement.pdf', type: 'PDF', uploadDate: '2025-10-14', status: 'Verified', uploader: 'Amit Sharma' } ], 'LOI Acknowledgement Copy': [ { id: 'd40', name: 'LOI Acknowledgement.pdf', type: 'PDF', uploadDate: '2025-10-15', status: 'Verified', uploader: 'Amit Sharma' } ], 'LOA': [ { id: 'd41', name: 'Letter of Authorization.pdf', type: 'PDF', uploadDate: '2025-10-16', status: 'Verified', uploader: 'DD Admin' } ], 'EOR Complete': [ { id: 'd42', name: 'EOR Completion Certificate.pdf', type: 'PDF', uploadDate: '2025-10-17', status: 'Verified', uploader: 'DD Admin' }, { id: 'd43', name: 'Training Completion Certificates.pdf', type: 'PDF', uploadDate: '2025-10-17', status: 'Verified', uploader: 'Training Team' }, { id: 'd44', name: 'Infrastructure Photos.pdf', type: 'PDF', uploadDate: '2025-10-17', status: 'Verified', uploader: 'Amit Sharma' }, { id: 'd45', name: 'Trade License.pdf', type: 'PDF', uploadDate: '2025-10-17', status: 'Verified', uploader: 'Amit Sharma' }, { id: 'd46', name: 'Insurance Policy.pdf', type: 'PDF', uploadDate: '2025-10-17', status: 'Verified', uploader: 'Amit Sharma' }, { id: 'd47', name: 'Vendor Agreements.pdf', type: 'PDF', uploadDate: '2025-10-17', status: 'Verified', uploader: 'Amit Sharma' } ], 'Inauguration': [ { id: 'd48', name: 'Inauguration Invitation.pdf', type: 'PDF', uploadDate: '2025-10-18', status: 'Verified', uploader: 'DD Admin' }, { id: 'd49', name: 'Event Photos.pdf', type: 'PDF', uploadDate: '2025-10-18', status: 'Verified', uploader: 'DD Admin' } ] }; const getDocumentsForStage = (stageName: string) => { return stageDocuments[stageName] || []; }; const handleApprove = () => { if (!approvalRemark.trim()) { alert('Please enter a remark'); return; } alert(`Application ${application.registrationNumber} approved!\nRemark: ${approvalRemark}`); setShowApproveModal(false); setApprovalRemark(''); }; const handleReject = () => { if (!rejectionReason.trim()) { alert('Please enter a reason for rejection'); return; } alert(`Application ${application.registrationNumber} rejected!\nReason: ${rejectionReason}`); setShowRejectModal(false); setRejectionReason(''); }; const handleWorkNote = () => { if (!workNote.trim()) { alert('Please enter a note'); return; } alert(`Work note added: ${workNote}`); setShowWorkNoteModal(false); setWorkNote(''); }; // If Work Notes page is open, show that instead if (showWorkNotesPage) { return ( setShowWorkNotesPage(false)} initialNotes={mockWorkNotes} /> ); } return (
{/* Header */}

{application.name}

{application.registrationNumber}

{/* Main Content */}
{/* Core Details Card */} Applicant Information

Full Name

{application.name}

Email

{application.email}

Phone

{application.phone}

Age

{application.age ? `${application.age} years` : 'N/A'}

Education

{application.education || 'N/A'}

Preferred Location

{application.preferredLocation || 'N/A'}

Location Type

{application.locationType || 'N/A'}

Owns Bike

{application.ownRoyalEnfield === 'yes' ? 'Yes' : 'No'}

{application.ownRoyalEnfield === 'yes' && (

Bike Model

{application.royalEnfieldModel || 'N/A'}

)}

Existing Dealer

{application.existingDealer === 'yes' ? 'Yes' : 'No'}

{application.existingDealer === 'yes' && (

Company Name

{application.companyName || 'N/A'}

)}

Source

{application.source || 'N/A'}

{application.questionnaireMarks !== undefined && (

Questionnaire Score

{application.questionnaireMarks}/100

)}

Address

{application.address || 'N/A'}

Pincode

{application.pincode || 'N/A'}

Description

{application.description || 'N/A'}

Past Experience

{application.pastExperience || 'N/A'}

{/* Tabs Section */} {/* Only show tabs for shortlisted applications (opportunity requests and regular dealership requests) */} {/* Hide tabs for unopportunity requests (lead generation) */} {application.isShortlisted !== false && (
Questionnaire Response Progress Documents Interviews EOR Checklist Payments Audit Trail
{/* Questionnaire Response Tab */} {/* Progress Tab */}

Application Journey

{application.progress}% Complete
{processStages.map((stage, index) => (
{stage.isParallel ? ( ) : ( <> {stage.status === 'completed' && ( )} {stage.status === 'active' && ( )} {stage.status === 'pending' && (
)} )}
{index < processStages.length - 1 && !stage.isParallel && (
)}

{stage.name}

{stage.description && (

{stage.description}

)} {stage.evaluators && (

Evaluators: {stage.evaluators.join(' + ')}

)} {stage.documentsUploaded !== undefined && stage.documentsUploaded > 0 && (

{ setSelectedStage(stage.name); setShowDocumentsModal(true); }} > Documents uploaded = {stage.documentsUploaded}

)}

{stage.status === 'completed' && stage.date && `Completed: ${new Date(stage.date).toLocaleDateString()}`} {stage.status === 'active' && 'In Progress'} {stage.status === 'pending' && 'Pending'}

{/* Parallel Branches */} {stage.isParallel && stage.branches && (
{stage.branches.map((branch, branchIndex) => { const branchKey = branch.name.toLowerCase().replace(/\s+/g, '-'); const isExpanded = expandedBranches[branchKey]; const branchColor = branch.color === 'blue' ? 'blue' : 'green'; return (
{/* Branch Header - Clickable */} {/* Branch Content - Expandable */} {isExpanded && (
{branch.stages.map((branchStage, stageIndex) => (
{branchStage.status === 'completed' && ( )} {branchStage.status === 'active' && ( )} {branchStage.status === 'pending' && (
)}

{branchStage.name}

{branchStage.description && (

{branchStage.description}

)} {branchStage.documentsUploaded !== undefined && branchStage.documentsUploaded > 0 && (

{ setSelectedStage(branchStage.name); setShowDocumentsModal(true); }} > Documents uploaded = {branchStage.documentsUploaded}

)}

{branchStage.status === 'completed' && branchStage.date && `Completed: ${new Date(branchStage.date).toLocaleDateString()}`} {branchStage.status === 'active' && 'In Progress'} {branchStage.status === 'pending' && 'Pending'}

))}
)}
); })} {/* Connecting line to next stage */}
)}
))}
{/* Documents Tab */}

Uploaded Documents

File Name Type Upload Date Uploader Actions {mockDocuments.map((doc) => ( {doc.name} {doc.type} {new Date(doc.uploadDate).toLocaleDateString()} {doc.uploader || '-'}
))}
{/* Interviews Tab */}

Level 1 Interview - KT Matrix

Interviewer Role Score Remarks Feedback {mockLevel1Scores.map((score, idx) => ( {score.user} {score.role} {score.score}/50 {score.remarks} {score.feedback} ))}
{['Level 2 Approved', 'Level 3 Pending', 'Approved'].includes(application.status) && (

Level 2 Interview Summary

Decision: Approved by both ZBH and DD Lead

Overall Assessment: Strong candidate with excellent business plan

)}
{/* EOR Checklist Tab */}

Essential Operating Requirements

{Math.round(eorProgress)}% Complete
{eorChecklist.map((item) => (
{item.item} {item.completed && ( )}
))}
{/* Payments Tab */}

Payment Information

Advance Payment Paid

₹5,00,000

Receipt: RCP-2025-001.pdf

Final Payment Pending

₹15,00,000

{application.status === 'EOR In Progress' && ( )}
{/* Audit Trail Tab */}
{mockAuditLogs.map((log) => (

{log.action}

{log.timestamp}

by {log.user}

{log.details}

))}
)}
{/* Right Sidebar - Summary and Actions */}
{/* Summary Card */} Summary

Registration ID

{application.registrationNumber}

Current Status

{application.status}
{application.rank && (

Rank

{application.rank} of {application.totalApplicantsAtLocation} in {application.preferredLocation}

)}

Progress

{application.progress}%
{application.deadline && (

Questionnaire Deadline

{new Date(application.deadline).toLocaleDateString()}

)}
{/* Actions Card */} {/* Only show Actions card for shortlisted applications (opportunity requests and regular dealership requests) */} {/* Hide Actions for unopportunity requests (lead generation) - these are read-only records */} {application.isShortlisted !== false && ( Actions setShowKTMatrixModal(true)}> Fill KT Matrix setShowLevel2FeedbackModal(true)}> Level 2 Feedback setShowLevel3FeedbackModal(true)}> Level 3 Feedback {application.status === 'Questionnaire Pending' && ( <> )} )} {/* Work Notes Chat */} {/* Only show Work Notes card for shortlisted applications (opportunity requests and regular dealership requests) */} {/* Hide Work Notes for unopportunity requests (lead generation) - no workflow tracking needed */} {application.isShortlisted !== false && ( Work Notes
{mockWorkNotes.map((note) => (
{note.user.charAt(0)}

{note.user}

{note.timestamp}

{note.message}

))}
)}
{/* Approve Modal */} Approve Application Provide approval remarks and optionally attach supporting documents.