import type { SectionId } from "@shared/types"; import { NEW_ENTITY_ID } from "../../lib/constants"; import { Target, UserPlus, Kanban, } from "../../components/ui/icons"; import { AgentCreator } from "../../components/organization/AgentCreator"; import { AgentEditor } from "../../components/organization/AgentEditor"; import { AgentRoster } from "../../components/organization/AgentRoster"; import { GoalCreator } from "../../components/organization/GoalCreator"; import { GoalEditor } from "../../components/organization/GoalEditor"; import { GoalList } from "../../components/organization/GoalList"; import { OrgChart } from "../../components/organization/OrgChart"; import { TeamHeaderSummary } from "../../components/organization/TeamHeaderSummary"; import { ProjectCreator } from "../../components/organization/ProjectCreator"; import { ProjectEditor } from "../../components/organization/ProjectEditor"; import { ProjectList } from "../../components/organization/ProjectList"; import { HiringPipeline } from "../../components/hiring/HiringPipeline"; import { ActionButton, Modal, Panel } from "../../components/ui"; import { useT } from "../../i18n"; import { useAppStore } from "../../state/store"; import { useSectionContext } from "../../hooks/useSectionContext"; import { useAppActions } from "../../hooks/useAppActions"; interface OrganizationSectionsProps { section: SectionId; } export function OrganizationSections({ section }: OrganizationSectionsProps) { const t = useT(); const { snapshot, currentCompany, companyAgents, companyGoals, companyProjects, companyWorkspaces, pendingApprovals, editingAgent, selectedGoal, selectedProject, } = useSectionContext(); const { refresh } = useAppActions(); const selectedAgentId = useAppStore((s) => s.selectedAgentId); const setSelectedAgentId = useAppStore((s) => s.setSelectedAgentId); const editingAgentId = useAppStore((s) => s.editingAgentId); const setEditingAgentId = useAppStore((s) => s.setEditingAgentId); const selectedGoalId = useAppStore((s) => s.selectedGoalId); const setSelectedGoalId = useAppStore((s) => s.setSelectedGoalId); const selectedProjectId = useAppStore((s) => s.selectedProjectId); const setSelectedProjectId = useAppStore((s) => s.setSelectedProjectId); const setSection = useAppStore((s) => s.setSection); // Open the Edit modal on row / card click. `selectedAgentId` is updated // alongside so the roster highlight follows the user's last interaction // even after the modal closes. const openAgentEditor = (id: string) => { setSelectedAgentId(id); setEditingAgentId(id); }; if (!snapshot || !currentCompany) return null; return ( <> {section === "agents" ? ( <> setEditingAgentId(NEW_ENTITY_ID)} />}> setEditingAgentId(null)}> { setEditingAgentId(null); setSection("hiring"); await refresh(); }} /> setEditingAgentId(null)} > {editingAgent ? ( setEditingAgentId(null)} onDeleted={async () => { setEditingAgentId(null); await refresh(); }} /> ) : null} ) : null} {section === "hiring" && currentCompany ? ( a.companyId === currentCompany.id)} onNavigateToAgent={(id) => { setSelectedAgentId(id); setSection("agents"); }} /> ) : null} {section === "goals" ? ( <> setSelectedGoalId(NEW_ENTITY_ID)} />}> setSelectedGoalId(null)}> { setSelectedGoalId(null); await refresh(); }} /> setSelectedGoalId(null)}> {selectedGoal ? ( { setSelectedGoalId(null); await refresh(); }} onDeleted={async () => { setSelectedGoalId(null); await refresh(); }} /> ) : null} ) : null} {section === "projects" ? ( <> setSelectedProjectId(NEW_ENTITY_ID)} />}> setSelectedProjectId(null)}> { setSelectedProjectId(null); await refresh(); }} /> setSelectedProjectId(null)}> {selectedProject ? ( { setSelectedProjectId(null); await refresh(); }} onDeleted={async () => { setSelectedProjectId(null); await refresh(); }} /> ) : null} ) : null} ); }