import Head from 'next/head'; import prisma from '../../lib/prisma'; import Modal from '../../components/Modal'; import Shell from '../../components/Shell'; import SettingsShell from '../../components/Settings'; import { useEffect, useState } from 'react'; import { useSession, getSession } from 'next-auth/client'; import { UsersIcon, } from "@heroicons/react/outline"; import TeamList from "../../components/team/TeamList"; import TeamListItem from "../../components/team/TeamListItem"; export default function Teams(props) { const [session, loading] = useSession(); const [teams, setTeams] = useState([]); const [invites, setInvites] = useState([]); const [showCreateTeamModal, setShowCreateTeamModal] = useState(false); const loadTeams = () => fetch('/api/user/membership').then((res: any) => res.json()).then( (data) => { setTeams(data.membership.filter((m) => m.role !== "INVITEE")); setInvites(data.membership.filter((m) => m.role === "INVITEE")); } ); useEffect(() => { loadTeams(); }, []); if (loading) { return
Loading...
; } const createTeam = (e) => { e.preventDefault(); return fetch('/api/teams', { method: 'POST', body: JSON.stringify({ name: e.target.elements['name'].value }), headers: { 'Content-Type': 'application/json' } }).then(() => { loadTeams(); setShowCreateTeamModal(false); }); } return (View, edit and create teams to organise relationships between users
{!(invites.length || teams.length) &&Create your first team and invite other users to work together with you.
{membership.length !== 0 && "You cannot convert this account into a team until you leave all teams that you’re a member of."} {membership.length === 0 && "A user account can be turned into a team, as a team ...."}
Create a new team to collaborate with users.