import { useState } from 'react' import { useQuery, useMutation } from '@tanstack/react-query' import { apiFetch } from '@/lib/http' import { Channel, CreateChannelInput, ChannelSensitivity } from '@/types/settings' import { LoadingSkeleton } from '../common/LoadingSkeleton' const SENSITIVITY_COLORS: Record = { public: 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200', internal: 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200', confidential: 'bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200', restricted: 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200', } const SENSITIVITY_ICONS: Record = { public: '🌐', internal: '🔒', confidential: '🔐', restricted: '🚫', } export function AdminChannelManagement() { const [showAddForm, setShowAddForm] = useState(false) const [formData, setFormData] = useState({ name: '', sensitivity: 'internal', }) // Fetch channels const { data: channels, isLoading, refetch } = useQuery({ queryKey: ['workspace-channels'], queryFn: async () => { // TODO: GET /api/workspace/channels return [] as Channel[] }, }) // Create channel const { mutate: createChannel, isPending: isCreating } = useMutation({ mutationFn: async (input: CreateChannelInput) => { // TODO: POST /api/workspace/channels console.log('Create channel:', input) }, onSuccess: () => { setFormData({ name: '', sensitivity: 'internal' }) setShowAddForm(false) refetch() }, }) const handleCreateChannel = () => { if (!formData.name.trim()) return createChannel(formData) } return (
{/* Header */}

Channels

{channels?.length || 0} channels total

{/* Create Channel Form */} {showAddForm && (
setFormData({ ...formData, name: e.target.value })} placeholder="e.g., Engineering, HR, Finance" className="mt-1 block w-full rounded border border-stone-300 bg-white px-3 py-2 text-stone-900 placeholder-stone-400 focus:border-brand focus:outline-none focus:ring-1 focus:ring-brand dark:border-stone-600 dark:bg-stone-800 dark:text-white" />
{(Object.keys(SENSITIVITY_COLORS) as ChannelSensitivity[]).map((level) => ( ))}

• Public: visible to all • Internal: team members only • Confidential: executives only • Restricted: need approval

)} {/* Channels List */}
{isLoading ? ( ) : channels && channels.length > 0 ? (
{channels.map((channel) => (

{channel.name}

{SENSITIVITY_ICONS[channel.sensitivity]} {channel.sensitivity}
{channel.source_type && 📁 {channel.source_type}} Created {new Date(channel.created_at).toLocaleDateString()}
))}
) : (

No channels yet

Create your first channel to organize data by team or department

)}
) }