From 2325a7a3034f28752b34d332b7714624eae08c48 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 18 Oct 2025 03:15:48 +0000 Subject: [PATCH] Create Teams page matching site theme cgen-0d85ca21950e4961b35e0fc2e33d6108 --- client/pages/Teams.tsx | 129 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 client/pages/Teams.tsx diff --git a/client/pages/Teams.tsx b/client/pages/Teams.tsx new file mode 100644 index 00000000..1fe1298e --- /dev/null +++ b/client/pages/Teams.tsx @@ -0,0 +1,129 @@ +import Layout from "@/components/Layout"; +import { useAuth } from "@/contexts/AuthContext"; +import { useEffect, useMemo, useState } from "react"; +import { useNavigate } from "react-router-dom"; +import { Card, CardHeader, CardTitle, CardDescription, CardContent } from "@/components/ui/card"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Textarea } from "@/components/ui/textarea"; +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { Badge } from "@/components/ui/badge"; +import { aethexCollabService } from "@/lib/aethex-collab-service"; +import LoadingScreen from "@/components/LoadingScreen"; + +export default function Teams() { + const { user, profile, loading } = useAuth(); + const navigate = useNavigate(); + const [isLoading, setIsLoading] = useState(true); + const [teams, setTeams] = useState([]); + const [name, setName] = useState(""); + const [description, setDescription] = useState(""); + const [creating, setCreating] = useState(false); + + useEffect(() => { + if (!loading && !user) navigate("/login", { replace: true }); + }, [loading, user, navigate]); + + useEffect(() => { + const load = async () => { + if (!user?.id) return; + setIsLoading(true); + try { + const myTeams = await aethexCollabService.listMyTeams(user.id); + setTeams(myTeams); + } finally { + setIsLoading(false); + } + }; + load(); + }, [user?.id]); + + const canCreate = useMemo(() => name.trim().length > 2 && !creating, [name, creating]); + + const handleCreate = async () => { + if (!user?.id) return; + if (!canCreate) return; + setCreating(true); + try { + const team = await aethexCollabService.createTeam(user.id, name.trim(), description.trim() || null, "private"); + setName(""); + setDescription(""); + setTeams((prev) => [{ team_id: team.id, teams: team }, ...prev]); + } finally { + setCreating(false); + } + }; + + if (loading || isLoading) return ; + + if (!user) return null; + + return ( + +
+
+
+

Teams

+

Create a team and collaborate with members across projects.

+
+ +
+
+ + + Your teams + Teams you belong to + + + {teams.length === 0 ? ( +

No teams yet. Create one to get started.

+ ) : ( + teams.map((t) => { + const team = (t as any).teams || t; + return ( +
+
+ + + {team.name?.[0]?.toUpperCase() || "T"} + +
+
{team.name}
+
{team.visibility || "private"}
+
+
+
+ Team + +
+
+ ); + }) + )} +
+
+
+ +