import { useEffect, useState } from 'react' import type { OrgRole, TalentTemplate, HireTalentHandler } from '../types/visual' import { asRoleId, asTemplateId } from '../types/visual' interface TalentDetailModalProps { template: TalentTemplate vacantRoles: OrgRole[] hiringId?: string | null readOnly?: boolean onHire: HireTalentHandler onClose: () => void } export function TalentDetailModal({ template: t, vacantRoles, hiringId, readOnly, onHire, onClose, }: TalentDetailModalProps) { const [selectedRoleId, setSelectedRoleId] = useState('') const isHiring = hiringId === t.template_id const noVacancies = vacantRoles.length === 0 const canHire = !readOnly && !isHiring && !noVacancies && selectedRoleId !== '' useEffect(() => { setSelectedRoleId('') }, [t.template_id]) const handleHire = () => { if (!canHire) return onHire(asTemplateId(t.template_id), asRoleId(selectedRoleId)) } return (
e.stopPropagation()}> {/* Header */}
{t.emoji && {t.emoji}}

{t.name}

{t.category}
{/* Body */}
{t.vibe && (
"{t.vibe}"
)} {t.description && (

{t.description}

)} {t.domains.length > 0 && (
Domains
{t.domains.map(d => {d})}
)} {t.tags.length > 0 && (
Tags
{t.tags.map(tag => {tag})}
)} {t.preferred_external_agent && (
Recommended Agent
{t.preferred_external_agent}
)} {!readOnly && (
Hire into role
{noVacancies ? (

No vacant roles. Create a role in the Team tab first.

) : (
{vacantRoles.map(role => { const selected = role.role_id === selectedRoleId return ( ) })}
)}
)}
{/* Hire footer */} {!readOnly && (
)}
) }