/** * Domain Validation Modal * * CRITICAL UI COMPONENT for resume-first architecture. * * This modal: * 1. Shows when user-selected domain doesn't match resume domain * 2. BLOCKS interview flow until user confirms or switches domain * 3. Shows clear warning with confidence scores * 4. Provides options to switch domain or continue anyway */ import React from 'react'; import { AlertTriangle, CheckCircle, XCircle, ArrowRight, RefreshCw, Shield, Code, Cpu, Zap, Building2, Palette, Cog } from 'lucide-react'; // Domain icon mapping const DOMAIN_ICONS = { computer_science: Code, electronics: Cpu, electrical: Zap, mechanical: Cog, civil: Building2, architecture: Palette, }; // Domain color mapping const DOMAIN_COLORS = { computer_science: '#8b5cf6', electronics: '#06b6d4', electrical: '#f59e0b', mechanical: '#ef4444', civil: '#10b981', architecture: '#ec4899', }; function DomainValidationModal({ validationResult, selectedBranch, selectedRole, onSwitchDomain, onContinueAnyway, onClose, isLoading = false, }) { if (!validationResult) return null; const { is_match, warning_level, message, recommendation, can_proceed, requires_confirmation, resume_domain, resume_domain_name, resume_confidence, allowed_rounds, // NEW: Role-level mismatch fields mismatch_type, resume_specialization, resume_specialization_name, selected_role_specialization, selected_role_specialization_name, resume_skills, match_confidence, } = validationResult; // Check if this is a role-level mismatch (within CS domain) const isRoleMismatch = mismatch_type === 'role'; // Get icons for domains const ResumeDomainIcon = DOMAIN_ICONS[resume_domain] || Code; const SelectedDomainIcon = DOMAIN_ICONS[selectedBranch] || Code; const resumeDomainColor = DOMAIN_COLORS[resume_domain] || '#8b5cf6'; const selectedDomainColor = DOMAIN_COLORS[selectedBranch] || '#8b5cf6'; // Determine modal severity const isHardWarning = warning_level === 'hard'; const isSoftWarning = warning_level === 'soft'; // Modal style based on severity const severityStyles = { hard: { borderColor: '#ef4444', iconBg: 'rgba(239, 68, 68, 0.1)', iconColor: '#ef4444', }, soft: { borderColor: '#f59e0b', iconBg: 'rgba(245, 158, 11, 0.1)', iconColor: '#f59e0b', }, none: { borderColor: '#10b981', iconBg: 'rgba(16, 185, 129, 0.1)', iconColor: '#10b981', }, }; const styles = severityStyles[warning_level] || severityStyles.none; // If it's a match, don't show modal (auto-proceed) if (is_match && can_proceed && !requires_confirmation) { return null; } return (
{/* Header Icon */}
{isHardWarning ? ( ) : isSoftWarning ? ( ) : ( )}
{/* Title */}

{isHardWarning ? (isRoleMismatch ? '🚫 Role Mismatch Detected' : '🚫 Domain Mismatch Detected') : isSoftWarning ? (isRoleMismatch ? '⚠️ Role Mismatch' : '⚠️ Domain Mismatch') : '✅ Validated'}

{/* Message */}

{message}

{/* Domain Comparison */}
{/* Resume Domain */}
Your Resume {isRoleMismatch ? resume_specialization_name : resume_domain_name} {Math.round((match_confidence || resume_confidence || 0) * 100)}% confidence {isRoleMismatch && resume_skills && resume_skills.length > 0 && ( Skills: {resume_skills.slice(0, 3).join(', ')} )}
{/* Arrow */}
{/* Selected Domain */}
You Selected {isRoleMismatch ? selectedRole : selectedBranch.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase())} {!isRoleMismatch && {selectedRole}} {isRoleMismatch && selected_role_specialization_name && ( ({selected_role_specialization_name}) )}
{/* Role Mismatch Explanation */} {isRoleMismatch && (
Both roles are in Computer Science, but they require different skill sets. Interview questions will be tailored to your selected role.
)} {/* Recommendation */} {recommendation && (
{recommendation}
)} {/* Blocked Rounds Warning */} {allowed_rounds && allowed_rounds.blocked_rounds && (
Note: The following rounds are not applicable for non-CS domains:{' '} {allowed_rounds.blocked_rounds.join(', ')}
)} {/* Action Buttons */}
{/* Switch Domain Button - Always shown for mismatch */} {!is_match && ( )} {/* Continue Anyway Button */} {(can_proceed || requires_confirmation) && ( )} {/* Cancel/Close Button */} {!can_proceed && !requires_confirmation && ( )}
{/* Warning Footer for Hard Mismatch */} {isHardWarning && (
⚠️ Continuing with mismatched domain may result in irrelevant questions and lower scores.
)}
); } export default DomainValidationModal;