"use client"; import { useState } from "react"; import type { Team } from "@mosaic/shared"; import { Card, CardHeader, CardContent, CardFooter, Button, Input, Textarea } from "@mosaic/ui"; interface TeamSettingsProps { team: Team; onUpdate: (data: { name?: string; description?: string }) => Promise; onDelete: () => Promise; } export function TeamSettings({ team, onUpdate, onDelete }: TeamSettingsProps) { const [name, setName] = useState(team.name); const [description, setDescription] = useState(team.description || ""); const [isEditing, setIsEditing] = useState(false); const [isSaving, setIsSaving] = useState(false); const [isDeleting, setIsDeleting] = useState(false); const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); const hasChanges = name !== team.name || description !== (team.description || ""); const handleSave = async () => { if (!hasChanges) return; setIsSaving(true); try { const updates: { name?: string; description?: string } = {}; if (name !== team.name) { updates.name = name; } if (description !== (team.description || "")) { updates.description = description; } await onUpdate(updates); setIsEditing(false); } catch (error) { console.error("Failed to update team:", error); alert("Failed to update team. Please try again."); } finally { setIsSaving(false); } }; const handleCancel = () => { setName(team.name); setDescription(team.description || ""); setIsEditing(false); }; const handleDelete = async () => { setIsDeleting(true); try { await onDelete(); } catch (error) { console.error("Failed to delete team:", error); alert("Failed to delete team. Please try again."); setIsDeleting(false); } }; return (

Team Settings

{ setName(e.target.value); setIsEditing(true); }} placeholder="Enter team name" fullWidth disabled={isSaving} />