merge: add CompanyOrchestrationHQ into main
Deploy Canina / deploy (push) Successful in 37s

This commit is contained in:
devops committed 2026-10-19 13:03:56 +00:00
commit b3e1869724
1 file changed
+435
@@ -0,0 +1,435 @@
import React, { useEffect, useState, useRef } from 'react';
import {
Building2,
BrainCircuit,
CheckCircle2,
Clock,
AlertTriangle,
ArrowUpRight,
RefreshCw,
Sparkles,
ShieldCheck,
Briefcase,
FileText,
Stethoscope,
Search,
Headphones,
Cpu,
ExternalLink,
ChevronRight,
Layers,
Terminal,
Activity
} from 'lucide-react';
import { Link } from 'react-router-dom';
import api from '../services/api';
interface DepartmentCard {
id: string;
name: string;
role: string;
agentName: string;
avatarColor: string;
icon: any;
status: 'ACTIVE' | 'PROCESSING' | 'STANDBY';
currentFocus: string;
pendingApprovals: number;
completedTasks: number;
recentReasoningSnippet: string;
}
export default function CompanyOrchestrationHQ() {
const [activeTab, setActiveTab] = useState<'3D_VIEW' | 'BOARD_VIEW'>('3D_VIEW');
const [selectedDept, setSelectedDept] = useState<DepartmentCard | null>(null);
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const departments: DepartmentCard[] = [
{
id: 'CONTENT',
name: 'واحد محتوا و وبلاگ تخصصی',
role: 'تحقیق عمیق، مقالات بالینی، تولید تصویر با FLUX و سئوی محتوایی',
agentName: 'Canina-Content-Agent',
avatarColor: 'from-blue-600 to-indigo-700',
icon: FileText,
status: 'ACTIVE',
currentFocus: 'پایش تغییرات کاتالوگ و مقالات فصلی پاییز',
pendingApprovals: 2,
completedTasks: 154,
recentReasoningSnippet: 'تحلیل مکانیسم اثر گلیکوزآمینوگلیکان (GAG) صدف لب‌سبز آلمان در مقایسه با کندرویتین و تهیه پیش‌نویس لندینگ مفاصل.'
},
{
id: 'CLINICAL_RD',
name: 'واحد تحقیق و توسعه بالینی (R&D)',
role: 'فکت‌چکینگ پزشکی، اعتبارسنجی دوزها و مراجع داروسازی آلمان',
agentName: 'Canina-Medical-Agent',
avatarColor: 'from-emerald-600 to-teal-700',
icon: Stethoscope,
status: 'STANDBY',
currentFocus: 'ممیزی دوزهای کلسیم و تائورین گربه بر اساس گایدلاین WSAVA',
pendingApprovals: 1,
completedTasks: 155,
recentReasoningSnippet: 'بررسی مقادیر فسفر در پودر پوسته تخم‌مرغ جهت استفاده به عنوان بایندر طبیعی فسفات در بیماران کلیوی.'
},
{
id: 'SEO',
name: 'واحد سئو و هوش بازار',
role: 'پایش سرچ کنسول، شناسایی کلمات کلیدی، بهینه‌سازی اسکیما و فید ترب',
agentName: 'Canina-SEO-Agent',
avatarColor: 'from-amber-500 to-orange-600',
icon: Search,
status: 'ACTIVE',
currentFocus: 'هدف‌گذاری کلیدواژه‌های ریزش موی پاییزه و سلامت مفاصل سگ مسن',
pendingApprovals: 2,
completedTasks: 155,
recentReasoningSnippet: 'رصد ترافیک و ایمپرشن‌های صفحات دسته‌بندی و تطبیق ساختار اسکیما در JSON-LD.'
},
{
id: 'B2B',
name: 'واحد توسعه سازمانی و B2B',
role: 'پایپ‌لاین کلینیک‌ها، بیمارستان‌های دامپزشکی و بسته‌های نمایندگی',
agentName: 'Canina-B2B-Agent',
avatarColor: 'from-purple-600 to-violet-800',
icon: Building2,
status: 'STANDBY',
currentFocus: 'ارزیابی ۲ سرنخ جدید کلینیک‌ها و تدوین گایدلاین همکاری',
pendingApprovals: 1,
completedTasks: 153,
recentReasoningSnippet: 'طراحی بسته معرفی مکمل‌های تخصصی برای کلینیک‌های ارجاعی با نرخ تخفیف همکار و بدون فروش مستقیم سایت.'
},
{
id: 'DEVOPS',
name: 'واحد مهندسی، زیرساخت و امنیت',
role: 'پایش سلامت کانتینرها، مصرف دیسک، SSL و پایپ‌لاین آزمون‌محور TDD',
agentName: 'Canina-DevOps-Agent',
avatarColor: 'from-rose-600 to-red-700',
icon: Cpu,
status: 'ACTIVE',
currentFocus: 'نگهبانی دیسک سرور (۸۷٪ - ۱۳GB آزاد) و دیده‌بان‌های دوره‌ای',
pendingApprovals: 0,
completedTasks: 156,
recentReasoningSnippet: 'اجرای دیده‌بان سلامت خودکار هر ۱۵ دقیقه با استعلام کانتینرهای پروداکشن و روت‌های حیاتی.'
},
{
id: 'SUPPORT',
name: 'واحد پشتیبانی و مشاوره هوشمند',
role: 'پاسخ‌گویی به مشتریان، تریاژ پرسش‌های پت و ثبت تیکت‌های پیگیری',
agentName: 'Canina-Support-Agent',
avatarColor: 'from-cyan-600 to-blue-700',
icon: Headphones,
status: 'STANDBY',
currentFocus: 'پاسخ به سوالات کاتالوگ و هدایت کاربران به تماس بدون ادعای خرید آنلاین',
pendingApprovals: 0,
completedTasks: 154,
recentReasoningSnippet: 'محافظت از حریم خصوصی نشست‌های مهمان و هدایت پرسش‌های اورژانسی به دامپزشک حضوری.'
}
];
useEffect(() => {
const canvas = canvasRef.current;
if (!canvas) return;
const ctx = canvas.getContext('2d');
if (!ctx) return;
let animationFrameId: number;
let angle = 0;
const render = () => {
ctx.clearRect(0, 0, canvas.width, canvas.height);
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
ctx.strokeStyle = 'rgba(139, 92, 246, 0.15)';
ctx.lineWidth = 1.5;
ctx.beginPath();
ctx.arc(centerX, centerY, 130, 0, Math.PI * 2);
ctx.stroke();
ctx.strokeStyle = 'rgba(59, 130, 246, 0.1)';
ctx.beginPath();
ctx.arc(centerX, centerY, 210, 0, Math.PI * 2);
ctx.stroke();
ctx.fillStyle = '#8b5cf6';
ctx.shadowColor = '#8b5cf6';
ctx.shadowBlur = 20;
ctx.beginPath();
ctx.arc(centerX, centerY, 32, 0, Math.PI * 2);
ctx.fill();
ctx.shadowBlur = 0;
const totalNodes = departments.length;
departments.forEach((dept, idx) => {
const theta = angle + (idx * (Math.PI * 2 / totalNodes));
const radius = 170;
const nodeX = centerX + Math.cos(theta) * radius;
const nodeY = centerY + Math.sin(theta) * radius * 0.55;
ctx.strokeStyle = 'rgba(139, 92, 246, 0.25)';
ctx.beginPath();
ctx.moveTo(centerX, centerY);
ctx.lineTo(nodeX, nodeY);
ctx.stroke();
ctx.fillStyle = dept.status === 'ACTIVE' ? '#10b981' : '#3b82f6';
ctx.shadowColor = ctx.fillStyle;
ctx.shadowBlur = 10;
ctx.beginPath();
ctx.arc(nodeX, nodeY, 14, 0, Math.PI * 2);
ctx.fill();
ctx.shadowBlur = 0;
});
angle += 0.006;
animationFrameId = requestAnimationFrame(render);
};
render();
return () => {
cancelAnimationFrame(animationFrameId);
};
}, []);
return (
<div className="space-y-6 font-vazir" dir="rtl">
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4 bg-gradient-to-l from-purple-950/40 via-gray-900 to-gray-950 p-6 rounded-3xl border border-purple-500/20 shadow-2xl backdrop-blur-xl">
<div>
<div className="flex items-center gap-3">
<div className="p-3 bg-purple-600/20 text-purple-400 rounded-2xl border border-purple-500/30">
<Building2 className="w-8 h-8" />
</div>
<div>
<h1 className="text-2xl font-black text-white flex items-center gap-3">
اتاق وضعیت و ارکستراسیون هوشمند کنینا (Autonomous Corporate HQ)
<span className="text-[10px] px-2.5 py-1 rounded-full font-black bg-emerald-500/20 text-emerald-400 border border-emerald-500/30 animate-pulse">
سیستم زنده و فعال
</span>
</h1>
<p className="text-xs text-gray-400 mt-1 font-medium">
نمای سه بعدی و پانورامای مدیریت دپارتمان‌ها، تصمیمات استراتژیک، و جریان تفکر ایجنت‌های هوش مصنوعی
</p>
</div>
</div>
</div>
<div className="flex items-center gap-3">
<div className="flex bg-gray-900/80 p-1.5 rounded-2xl border border-gray-800">
<button
onClick={() => setActiveTab('3D_VIEW')}
className={
activeTab === '3D_VIEW'
? 'flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all bg-purple-600 text-white shadow-lg shadow-purple-600/30'
: 'flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all text-gray-400 hover:text-white'
}
>
<BrainCircuit className="w-4 h-4" />
<span>نمای سه‌بعدی و بصری</span>
</button>
<button
onClick={() => setActiveTab('BOARD_VIEW')}
className={
activeTab === 'BOARD_VIEW'
? 'flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all bg-purple-600 text-white shadow-lg shadow-purple-600/30'
: 'flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all text-gray-400 hover:text-white'
}
>
<Briefcase className="w-4 h-4" />
<span>فهرست دپارتمان‌ها</span>
</button>
</div>
<Link
to="/approvals"
className="flex items-center gap-2 px-4 py-2.5 bg-gradient-to-r from-amber-500 to-amber-600 hover:from-amber-600 hover:to-amber-700 text-white rounded-2xl text-xs font-black shadow-lg shadow-amber-500/20 transition-all"
>
<ShieldCheck className="w-4 h-4" />
<span>میز تاییدات مدیرعامل (۹ مورد)</span>
</Link>
</div>
</div>
{activeTab === '3D_VIEW' && (
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6">
<div className="lg:col-span-7 bg-gray-950 rounded-3xl p-6 border border-gray-800 relative overflow-hidden flex flex-col items-center justify-center min-h-[460px] shadow-2xl">
<div className="absolute top-5 right-5 z-10 flex items-center gap-2">
<span className="w-2.5 h-2.5 rounded-full bg-emerald-500 animate-ping" />
<span className="text-[11px] font-bold text-gray-400">مرکز فرماندهی PMO زنده</span>
</div>
<canvas
ref={canvasRef}
width={560}
height={380}
className="max-w-full h-auto cursor-pointer"
/>
<div className="absolute bottom-5 inset-x-5 flex items-center justify-between text-[11px] text-gray-500 bg-gray-900/60 backdrop-blur-md px-4 py-2.5 rounded-2xl border border-gray-800/80">
<span className="flex items-center gap-1.5 font-bold text-purple-400">
<BrainCircuit className="w-4 h-4" />
هسته مرکزی: Hermes PMO Autonomous Loop
</span>
<span>مدل فعال عملیاتی: Canina-content</span>
</div>
</div>
<div className="lg:col-span-5 space-y-4">
<h3 className="text-sm font-black text-gray-200 flex items-center gap-2">
<Layers className="w-4 h-4 text-purple-400" />
<span>دپارتمان‌های فعال در مدار سازمانی</span>
</h3>
<div className="space-y-3">
{departments.slice(0, 4).map((dept) => (
<div
key={dept.id}
onClick={() => setSelectedDept(dept)}
className="p-4 bg-gray-900/60 hover:bg-gray-900 border border-gray-800/80 hover:border-purple-500/40 rounded-2xl transition-all cursor-pointer group shadow-sm"
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-3">
<div className={`p-2.5 rounded-xl bg-gradient-to-br ${dept.avatarColor} text-white shadow-md`}>
<dept.icon className="w-4 h-4" />
</div>
<div>
<h4 className="text-xs font-black text-white group-hover:text-purple-300 transition-colors">
{dept.name}
</h4>
<span className="text-[10px] text-gray-400 font-medium">
{dept.agentName}
</span>
</div>
</div>
<div className="flex items-center gap-2">
{dept.pendingApprovals > 0 && (
<span className="px-2 py-0.5 rounded-full text-[10px] font-black bg-amber-500/20 text-amber-300 border border-amber-500/30">
{dept.pendingApprovals} تایید معلق
</span>
)}
<ChevronRight className="w-4 h-4 text-gray-600 group-hover:text-white transition-colors" />
</div>
</div>
<p className="text-[11px] text-gray-400 mt-2.5 line-clamp-1 font-medium bg-gray-950/60 p-2 rounded-xl border border-gray-800/50">
<span className="text-purple-400 font-bold ml-1">تمرکز جاری:</span>
{dept.currentFocus}
</p>
</div>
))}
</div>
</div>
</div>
)}
{activeTab === 'BOARD_VIEW' && (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5">
{departments.map((dept) => (
<div
key={dept.id}
className="bg-gray-900/60 border border-gray-800/90 rounded-3xl p-5 hover:border-purple-500/40 transition-all flex flex-col justify-between shadow-xl"
>
<div>
<div className="flex items-start justify-between gap-3">
<div className="flex items-center gap-3">
<div className={`p-3 rounded-2xl bg-gradient-to-br ${dept.avatarColor} text-white shadow-md`}>
<dept.icon className="w-5 h-5" />
</div>
<div>
<h3 className="text-sm font-black text-white">{dept.name}</h3>
<p className="text-[11px] text-purple-400 font-bold">{dept.agentName}</p>
</div>
</div>
<span className={`text-[10px] font-black px-2 py-0.5 rounded-full border ${
dept.status === 'ACTIVE'
? 'bg-emerald-500/20 text-emerald-400 border-emerald-500/30'
: 'bg-blue-500/20 text-blue-400 border-blue-500/30'
}`}>
{dept.status === 'ACTIVE' ? 'در حال کار' : 'آماده‌باش'}
</span>
</div>
<p className="text-xs text-gray-400 mt-3 font-medium leading-relaxed">
{dept.role}
</p>
<div className="mt-4 p-3 rounded-2xl bg-gray-950/80 border border-gray-800/80 space-y-1.5">
<div className="text-[10px] font-bold text-gray-500 flex items-center gap-1.5">
<Terminal className="w-3.5 h-3.5 text-purple-400" />
<span>آخرین استدلال و تفکر مدل:</span>
</div>
<p className="text-[11px] text-gray-300 font-mono leading-relaxed line-clamp-2">
{dept.recentReasoningSnippet}
</p>
</div>
</div>
<div className="mt-5 pt-4 border-t border-gray-800/80 flex items-center justify-between text-xs">
<span className="text-gray-400 font-medium">
تسک‌های تکمیل‌شده: <strong className="text-white font-bold">{dept.completedTasks}</strong>
</span>
<Link
to="/tasks"
className="flex items-center gap-1 text-purple-400 hover:text-purple-300 font-bold text-[11px]"
>
<span>مشاهده صف کارتابل</span>
<ArrowUpRight className="w-3.5 h-3.5" />
</Link>
</div>
</div>
))}
</div>
)}
{selectedDept && (
<div className="fixed inset-0 z-50 bg-black/80 backdrop-blur-md flex items-center justify-center p-4">
<div className="bg-gray-900 border border-purple-500/30 rounded-3xl max-w-2xl w-full p-6 shadow-2xl space-y-4">
<div className="flex items-center justify-between border-b border-gray-800 pb-4">
<div className="flex items-center gap-3">
<div className={`p-3 rounded-2xl bg-gradient-to-br ${selectedDept.avatarColor} text-white`}>
<selectedDept.icon className="w-6 h-6" />
</div>
<div>
<h3 className="text-base font-black text-white">{selectedDept.name}</h3>
<p className="text-xs text-purple-400 font-bold">{selectedDept.agentName}</p>
</div>
</div>
<button
onClick={() => setSelectedDept(null)}
className="text-gray-400 hover:text-white text-xs font-bold px-3 py-1.5 rounded-xl bg-gray-800"
>
بستن
</button>
</div>
<div className="space-y-3">
<div>
<h4 className="text-xs font-bold text-gray-400">ماموریت اصلی دپارتمان:</h4>
<p className="text-xs text-gray-200 mt-1 font-medium">{selectedDept.role}</p>
</div>
<div className="p-4 bg-gray-950 rounded-2xl border border-gray-800 space-y-2">
<h4 className="text-xs font-bold text-purple-400 flex items-center gap-2">
<Terminal className="w-4 h-4" />
<span>لاگ استدلال و آخرین فعالیت زنده:</span>
</h4>
<p className="text-xs text-gray-300 font-mono leading-relaxed">
{selectedDept.recentReasoningSnippet}
</p>
</div>
</div>
<div className="flex items-center justify-end gap-3 pt-4 border-t border-gray-800">
<Link
to="/tasks"
className="px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-xl text-xs font-bold transition-all shadow-md"
>
رفتن به کارتابل وظایف این واحد
</Link>
</div>
</div>
</div>
)}
</div>
);
}