"use client"; import Link from "next/link"; import { MessageCircle, Home, Users, FlaskConical, Shield, Gavel, Hash, Users2, Bot, PlusCircle, Crown } from "lucide-react"; import { CityRoomSummary } from "@/lib/types/microdao"; import { CityChatWidget } from "@/components/city/CityChatWidget"; import { Button } from "@/components/ui/button"; import { useState } from "react"; interface MicrodaoRoomsSectionProps { rooms: CityRoomSummary[]; primaryRoomSlug?: string | null; showAllChats?: boolean; canManage?: boolean; onEnsureOrchestratorRoom?: () => Promise; } const ROLE_META: Record = { primary: { label: "Primary / Lobby", chipClass: "bg-emerald-500/10 text-emerald-300 border-emerald-500/30", icon: , }, lobby: { label: "Lobby", chipClass: "bg-sky-500/10 text-sky-300 border-sky-500/30", icon: , }, team: { label: "Team", chipClass: "bg-indigo-500/10 text-indigo-300 border-indigo-500/30", icon: , }, research: { label: "Research", chipClass: "bg-violet-500/10 text-violet-300 border-violet-500/30", icon: , }, security: { label: "Security", chipClass: "bg-rose-500/10 text-rose-300 border-rose-500/30", icon: , }, governance: { label: "Governance", chipClass: "bg-amber-500/10 text-amber-300 border-amber-500/30", icon: , }, orchestrator_team: { label: "Orchestrator Team", chipClass: "bg-fuchsia-500/10 text-fuchsia-300 border-fuchsia-500/30", icon: , }, // New room roles for MicroDAO operations: { label: "Operations", chipClass: "bg-orange-500/10 text-orange-300 border-orange-500/30", icon: , }, knowledge: { label: "Knowledge Base", chipClass: "bg-cyan-500/10 text-cyan-300 border-cyan-500/30", icon: , }, treasury: { label: "Treasury", chipClass: "bg-yellow-500/10 text-yellow-300 border-yellow-500/30", icon: , }, "ai-core": { label: "AI Core", chipClass: "bg-purple-500/10 text-purple-300 border-purple-500/30", icon: , }, // District-specific events: { label: "Events", chipClass: "bg-pink-500/10 text-pink-300 border-pink-500/30", icon: , }, masters: { label: "Masters", chipClass: "bg-indigo-500/10 text-indigo-300 border-indigo-500/30", icon: , }, supply: { label: "Supply Chain", chipClass: "bg-green-500/10 text-green-300 border-green-500/30", icon: , }, producers: { label: "Producers", chipClass: "bg-lime-500/10 text-lime-300 border-lime-500/30", icon: , }, compute: { label: "Compute Grid", chipClass: "bg-amber-500/10 text-amber-300 border-amber-500/30", icon: , }, providers: { label: "Providers", chipClass: "bg-orange-500/10 text-orange-300 border-orange-500/30", icon: , }, }; export function MicrodaoRoomsSection({ rooms, primaryRoomSlug, showAllChats = false, canManage = false, onEnsureOrchestratorRoom }: MicrodaoRoomsSectionProps) { const [isCreatingTeam, setIsCreatingTeam] = useState(false); const handleCreateTeam = async () => { if (!onEnsureOrchestratorRoom) return; setIsCreatingTeam(true); try { await onEnsureOrchestratorRoom(); } catch (e) { console.error("Failed to create team room", e); } finally { setIsCreatingTeam(false); } }; if (!rooms || rooms.length === 0) { return (

Кімнати MicroDAO

Для цього MicroDAO ще не налаштовані кімнати міста.

); } // Find special rooms const teamRoom = rooms.find(r => r.room_role === 'orchestrator_team'); // Filter out team room from general list if we show it separately const generalRooms = rooms.filter(r => r.room_role !== 'orchestrator_team'); // Find primary room const primary = generalRooms.find(r => r.slug === primaryRoomSlug) ?? generalRooms.find(r => r.room_role === 'primary') ?? generalRooms[0]; // Others (excluding primary and team room) const others = generalRooms.filter(r => r.id !== primary?.id); // Group by role for mini-map (include all rooms for stats) const byRole = rooms.reduce((acc, r) => { const role = r.room_role || 'other'; if (!acc[role]) acc[role] = []; acc[role].push(r); return acc; }, {} as Record); // Get meta for primary room const primaryMeta = primary?.room_role ? ROLE_META[primary.room_role] : undefined; return (
{/* Orchestrator Team Chat Section */} {(teamRoom || canManage) && (

Orchestrator Team Chat

{teamRoom && ( Team Room )}
{teamRoom ? ( ) : (

Командний чат оркестратора

Створіть закриту кімнату для команди агентів оркестратора (CrewAI integration).

)}
)} {/* General Rooms Section */}

Кімнати MicroDAO ({rooms.length})

{/* Mini-map */}
{Object.entries(byRole).map(([role, list]) => { const meta = ROLE_META[role]; return (
{meta?.icon || } {meta?.label ?? (role === 'other' ? 'Other' : role)} ({list.length})
); })}
{/* Primary room with inline chat (if exists) */} {primary && (
{primaryMeta?.icon || }
{primary.name} Primary
{primaryMeta?.label || primary.room_role || 'Main Room'}
Відкрити окремо →
)} {/* Other rooms */} {others.length > 0 && (
Інші кімнати
{others.map(room => { const meta = room.room_role ? ROLE_META[room.room_role] : undefined; return (
{meta?.icon || }
{room.name}
{meta && (
{meta.label}
)}
Увійти →
{showAllChats && (
)}
); })}
)}
); }