import React, { useEffect, useState } from 'react'; import { useOrg } from '../contexts/OrgContext'; import { Card, Button } from '../components/UiKit'; import { FigmaAlert } from '../components/figma/FigmaAlert'; import { CompanyReport } from '../types'; import RadarPerformanceChart from '../components/charts/RadarPerformanceChart'; const CompanyWiki: React.FC = () => { const { org, employees, getFullCompanyReportHistory, generateCompanyWiki } = useOrg(); const [isGenerating, setIsGenerating] = useState(false); const [companyReport, setCompanyReport] = useState(null); const [error, setError] = useState(null); useEffect(() => { (async () => { try { const history = await getFullCompanyReportHistory(); if (history.length) setCompanyReport(history[0]); } catch (e) { console.error('Failed loading company report history', e); } })(); }, [getFullCompanyReportHistory]); const generateReport = async () => { setIsGenerating(true); setError(null); try { const report = await generateCompanyWiki(); setCompanyReport(report); } catch (e: any) { console.error(e); setError('Failed to generate company wiki'); } finally { setIsGenerating(false); } }; return (

Company Wiki

Organization overview and insights

Company Info

Name:
{org?.name}
Industry:
{org?.industry}
Size:
{org?.size}

Team Stats

Total Employees:
{employees.length}
Departments:
{[...new Set(employees.map(e => e.department))].length}
Roles:
{[...new Set(employees.map(e => e.role))].length}

Quick Actions

{error && } {!companyReport && !isGenerating && ( )}
{companyReport && (

Executive Summary

{companyReport.executiveSummary}

{companyReport.overview.totalEmployees}
Employees
{companyReport.overview?.departmentBreakdown?.length || 0}
Departments
{companyReport.organizationalStrengths?.length || 0}
Strength Areas
{companyReport.organizationalRisks?.length || 0}
Risks
{(Array.isArray(companyReport.gradingOverview) && companyReport.gradingOverview.length > 0) && (
({ label: g.category || g.department || g.subject || 'Metric', value: g.value ?? g.averageScore ?? 0 }))} />
)}

Strengths

    {(companyReport.organizationalStrengths || []).map((s: any, i) =>
  • • {s.area || s}
  • )}

Risks

    {(companyReport.organizationalRisks || []).map((r, i) =>
  • • {r}
  • )}

Forward Plan

Goals
    {(companyReport.operatingPlan?.nextQuarterGoals || companyReport.forwardOperatingPlan?.quarterlyGoals || []).map((g: string, i: number) =>
  • {g}
  • )}
Resource Needs
    {(companyReport.operatingPlan?.resourceNeeds || companyReport.forwardOperatingPlan?.resourceNeeds || []).map((g: string, i: number) =>
  • {g}
  • )}
Risk Mitigation
    {(companyReport.operatingPlan?.riskMitigation || companyReport.forwardOperatingPlan?.riskMitigation || []).map((g: string, i: number) =>
  • {g}
  • )}
)} {/* Company Profile - Q&A Format from Onboarding */}

Company Profile

{org?.mission && (

Question:

What is your company's mission?

Answer:

{org.mission}

)} {org?.vision && (

Question:

What is your company's vision?

Answer:

{org.vision}

)} {org?.evolution && (

Question:

How has your company evolved over time?

Answer:

{org.evolution}

)} {org?.advantages && (

Question:

What are your competitive advantages?

Answer:

{org.advantages}

)} {org?.vulnerabilities && (

Question:

What are your key vulnerabilities?

Answer:

{org.vulnerabilities}

)} {org?.shortTermGoals && (

Question:

What are your short-term goals?

Answer:

{org.shortTermGoals}

)} {org?.longTermGoals && (

Question:

What are your long-term goals?

Answer:

{org.longTermGoals}

)} {org?.cultureDescription && (

Question:

How would you describe your company culture?

Answer:

{org.cultureDescription}

)} {org?.workEnvironment && (

Question:

What is your work environment like?

Answer:

{org.workEnvironment}

)} {org?.additionalContext && (

Question:

Any additional context about your company?

Answer:

{org.additionalContext}

)}
{org?.description && (

About

{org.description}

)}
); }; export default CompanyWiki;