import { AlertCircle, Calendar, CheckCircle, ChevronDown, ClipboardCheck, Clock, GitBranch, Info, Lock, Mail, MessageSquare, Star, User, XCircle, Zap, } from 'lucide-react'; import { cn, formatDateTime } from '@/components/ui/utils'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { Label } from '@/components/ui/label'; import { Progress } from '@/components/ui/progress'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Separator } from '@/components/ui/separator'; interface ApplicationDetailsSidebarProps { application: any; permissions: any; getDeposit: (type: string) => any; isNonResponsive: boolean; isAdmin: boolean; currentUserStageAction: any; currentUserEvaluation: any; onOpenApproveModal: () => void; onOpenRejectModal: () => void; onOpenWorknote: () => void; onOpenScheduleModal: () => void; currentUser: any; handleGenerateDealerCodes: () => void; onOpenAssignArchitectureModal: () => void; onOpenAssignFdd: () => void; showAssignFddModal: boolean; setShowAssignFddModal: (value: boolean) => void; fddAgencies: any[]; selectedAgencyId: string; setSelectedAgencyId: (value: string) => void; isAssigningAgency: boolean; handleAssignAgency: () => void; activeInterviewForUser: any; hasSubmittedFeedback: boolean; setSelectedInterviewForFeedback: (value: any) => void; setShowKTMatrixModal: (value: boolean) => void; setShowLevel2FeedbackModal: (value: boolean) => void; setShowLevel3FeedbackModal: (value: boolean) => void; onGoToDashboard: () => void; showAssignModal: boolean; setShowAssignModal: (value: boolean) => void; selectedUser: string; setSelectedUser: (value: string) => void; users: any[]; participantType: string; setParticipantType: (value: string) => void; handleAddParticipant: () => void; isAssigningParticipant: boolean; } export function ApplicationDetailsSidebar(props: ApplicationDetailsSidebarProps) { const { application, permissions, getDeposit, isNonResponsive, isAdmin, currentUserStageAction, currentUserEvaluation, onOpenApproveModal, onOpenRejectModal, onOpenWorknote, onOpenScheduleModal, currentUser, handleGenerateDealerCodes, onOpenAssignArchitectureModal, onOpenAssignFdd, showAssignFddModal, setShowAssignFddModal, fddAgencies, selectedAgencyId, setSelectedAgencyId, isAssigningAgency, handleAssignAgency, activeInterviewForUser, hasSubmittedFeedback, setSelectedInterviewForFeedback, setShowKTMatrixModal, setShowLevel2FeedbackModal, setShowLevel3FeedbackModal, onGoToDashboard, showAssignModal, setShowAssignModal, selectedUser, setSelectedUser, users, participantType, setParticipantType, handleAddParticipant, isAssigningParticipant, } = props; return (
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

{formatDateTime(application.deadline)}

)}
{(application.isShortlisted !== false || application.status === 'Submitted') && ( Actions {permissions.isLoaLocked && ( LOA approval locked First Fill (later-stage payment) must be verified by Finance before LOA approval can proceed. This is separate from the initial security deposit before LOI Issued. )} {getDeposit('FIRST_FILL')?.status === 'Verified' && application.status !== 'LOA Pending' && !['LOA Issued', 'EOR In Progress', 'EOR Complete', 'Inauguration', 'Approved', 'Onboarded', 'Rejected'].includes( application.status, ) && ( First Fill verified on file Finance has verified the First Fill payment. The application status was not changed until you reach{' '} LOA Pending. When you get there, LOA approval will not be blocked by payment (same pattern as recording the initial security deposit before the LOI security step). )} {permissions.isSecurityDetailsLocked && ( Security Details approval locked Finance must verify the Security Deposit before this stage can be approved. You can still use Reject if needed. )} {['Security Details', 'Payment Pending'].includes(application.status) && ( Security Details review Check the initial security deposit on the Payments tab (Finance may have already marked it verified). When satisfied, use Approve{' '} to move to LOI Issued. )} {isNonResponsive && isAdmin && ( ⚠️ Non-Responsive Flag FDD Audit has flagged this applicant. Review audit logs before approval. )} {isAdmin && (application.status === 'Level 3 Approved' || application.status === 'FDD Verification') && (!application.fddAssignments || application.fddAssignments.length === 0) && ( FDD Assignment Required This application is pending financial due diligence. Please assign an FDD Agency to proceed with the audit. )} {permissions.canApprove && ( )} {permissions.canReject && ( )} {permissions.showDecisionMessage && (
You have {(currentUserStageAction?.decision === 'Approved' || currentUserEvaluation?.decision === 'Approved' || currentUserEvaluation?.recommendation === 'Approved' || currentUserEvaluation?.decision === 'Selected') ? 'Approved' : 'Rejected'}
)} {permissions.canSchedule && ( )} {currentUser && ['DD Admin', 'Super Admin'].includes(currentUser.role) && ['Dealer Code Generation', 'LOA Pending', 'Architecture Team Assigned', 'Architecture Document Upload', 'Architecture Team Completion'].includes(application.status) && ( <> {!application.dealerCode && ( )} {application.dealerCode && !application.architectureAssignedTo && ( )} )} {isAdmin && ['Level 3 Approved', 'Level 3 Recommended', 'FDD Verification', 'FDD In Progress'].includes(application.status) && (!application.fddAssignments || application.fddAssignments.length === 0) && ( Assign FDD Agency Select an FDD partner agency to perform the financial due diligence audit for this application.
)} {activeInterviewForUser && !hasSubmittedFeedback && ( { setSelectedInterviewForFeedback(activeInterviewForUser); if (activeInterviewForUser.level === 1) setShowKTMatrixModal(true); else if (activeInterviewForUser.level === 2) setShowLevel2FeedbackModal(true); else setShowLevel3FeedbackModal(true); }} > Level {activeInterviewForUser.level} - {activeInterviewForUser.interviewType} )} {application.status === 'Questionnaire Pending' && ( <> )} {application.dealer && (
Dealer Profile Active
This application has been successfully onboarded as a dealer. A user account has been created for the dealer.
{application.dealerCode && (
Dealer Code: {application.dealerCode.code}
)}
)} {currentUser && ['DD Admin', 'Super Admin'].includes(currentUser.role) && ( Assign User to Application Select a user and their role for this application.
)}
)}
); }