diff --git a/src/renderer/components/company-operations.tsx b/src/renderer/components/company-operations.tsx index 8f4facc2..2dfd0f57 100644 --- a/src/renderer/components/company-operations.tsx +++ b/src/renderer/components/company-operations.tsx @@ -1,725 +1,4 @@ -import { useMemo, useState } from "react"; -import { - CalendarBlank, - FileText, - FloppyDisk, - Lightbulb, - NotePencil, - Plus, - Rows, - Trash, -} from "@phosphor-icons/react"; -import type { - AgentRecord, - DocumentRecord, - GoalRecord, - KnowledgeEntryRecord, - MeetingRecord, - ProjectRecord, - SprintRecord, -} from "@shared/types"; -import { ActionButton, ConfirmDialog, InlineNotice, Input, ListFrame, ListRow, Modal, Select, StatusPill, TextArea } from "./ui"; -import { useT } from "../i18n"; - -const documentTypeOptions = [ - "prd", - "technical_spec", - "design_doc", - "test_plan", - "post_mortem", - "meeting_notes", - "budget_proposal", - "hiring_requisition", - "performance_review_doc", - "sop", - "knowledge_article", - "project_brief", - "sprint_report", - "incident_report", - "onboarding_guide", - "architecture_decision", - "status_report", - "contract", - "proposal", -].map((value) => ({ value, label: value.replaceAll("_", " ") })); - -const documentStatusOptions = ["draft", "in_review", "approved", "archived", "superseded"].map((value) => ({ - value, - label: value.replaceAll("_", " "), -})); - -const knowledgeCategoryOptions = [ - "lesson_learned", - "best_practice", - "decision", - "process", - "technical", - "business", - "onboarding", - "incident", -].map((value) => ({ value, label: value.replaceAll("_", " ") })); - -const importanceOptions = ["critical", "high", "medium", "low"].map((value) => ({ value, label: value })); - -const meetingTypeOptions = [ - "standup", - "sprint_planning", - "sprint_review", - "retrospective", - "one_on_one", - "all_hands", - "department_sync", - "incident_review", - "hiring_committee", - "budget_review", - "design_review", - "architecture_review", -].map((value) => ({ value, label: value.replaceAll("_", " ") })); - -const meetingStatusOptions = ["scheduled", "in_progress", "completed", "cancelled"].map((value) => ({ value, label: value.replaceAll("_", " ") })); -const sprintStatusOptions = ["planning", "active", "review", "completed", "cancelled"].map((value) => ({ value, label: value })); - -function splitTags(value: string) { - return JSON.stringify(value.split(",").map((item) => item.trim()).filter(Boolean)); -} - -function parseTags(value: string) { - try { - const tags = JSON.parse(value) as string[]; - return tags.join(", "); - } catch { - return ""; - } -} - -function parseParticipantIds(value: string) { - return value - .split(",") - .map((item) => item.trim()) - .filter(Boolean); -} - -function formatParticipantIds(raw: string, agents: AgentRecord[]) { - try { - const ids = JSON.parse(raw) as string[]; - return ids - .map((id) => agents.find((agent) => agent.id === id)?.name ?? id.slice(0, 8)) - .join(", "); - } catch { - return ""; - } -} - -function DocumentEditor({ - companyId, - agents, - projects, - goals, - document, - onSaved, -}: { - companyId: string; - agents: AgentRecord[]; - projects: ProjectRecord[]; - goals: GoalRecord[]; - document: DocumentRecord | null; - onSaved: () => Promise; -}) { - const [title, setTitle] = useState(document?.title ?? ""); - const [type, setType] = useState(document?.type ?? "technical_spec"); - const [content, setContent] = useState(document?.content ?? ""); - const [status, setStatus] = useState(document?.status ?? "draft"); - const [reviewerAgentId, setReviewerAgentId] = useState(document?.reviewerAgentId ?? ""); - const [projectId, setProjectId] = useState(document?.projectId ?? ""); - const [goalId, setGoalId] = useState(document?.goalId ?? ""); - const [tags, setTags] = useState(parseTags(document?.tagsJson ?? "[]")); - const [saving, setSaving] = useState(false); - const [error, setError] = useState(null); - - async function save() { - if (!title.trim()) { - setError("Document title is required."); - return; - } - setSaving(true); - setError(null); - try { - const result = await window.agentCompany.saveDocument({ - id: document?.id ?? null, - companyId, - type: type as Parameters[0]["type"], - title: title.trim(), - content, - authorAgentId: document?.authorAgentId ?? null, - reviewerAgentId: reviewerAgentId || null, - projectId: projectId || null, - goalId: goalId || null, - parentDocId: document?.parentDocId ?? null, - version: document?.version ?? 1, - status: status as Parameters[0]["status"], - tagsJson: splitTags(tags), - }); - if (!result.ok) { - setError(result.error.message); - return; - } - await onSaved(); - } finally { - setSaving(false); - } - } - - return ( -
- {error ? : null} - -
- setStatus(value as typeof status)} options={documentStatusOptions} /> -
-
- -
-
- ({ value: goal.id, label: goal.title }))]} /> -
-