2021-08-02 20:51:57 +00:00
|
|
|
import { useState } from "react";
|
2021-06-05 22:53:33 +00:00
|
|
|
import TeamListItem from "./TeamListItem";
|
|
|
|
import EditTeamModal from "./EditTeamModal";
|
|
|
|
import MemberInvitationModal from "./MemberInvitationModal";
|
|
|
|
|
|
|
|
export default function TeamList(props) {
|
2021-08-02 20:51:57 +00:00
|
|
|
const [showMemberInvitationModal, setShowMemberInvitationModal] = useState(false);
|
|
|
|
const [showEditTeamModal, setShowEditTeamModal] = useState(false);
|
|
|
|
const [team, setTeam] = useState(null);
|
2021-06-05 22:53:33 +00:00
|
|
|
|
|
|
|
const selectAction = (action: string, team: any) => {
|
|
|
|
setTeam(team);
|
|
|
|
switch (action) {
|
2021-08-02 20:51:57 +00:00
|
|
|
case "edit":
|
2021-06-05 22:53:33 +00:00
|
|
|
setShowEditTeamModal(true);
|
|
|
|
break;
|
2021-08-02 20:51:57 +00:00
|
|
|
case "invite":
|
2021-06-05 22:53:33 +00:00
|
|
|
setShowMemberInvitationModal(true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-08-02 20:51:57 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<ul className="bg-white border px-2 mb-2 rounded divide-y divide-gray-200">
|
|
|
|
{props.teams.map((team: any) => (
|
|
|
|
<TeamListItem
|
|
|
|
onChange={props.onChange}
|
|
|
|
key={team.id}
|
|
|
|
team={team}
|
|
|
|
onActionSelect={(action: string) => selectAction(action, team)}></TeamListItem>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
{showEditTeamModal && (
|
|
|
|
<EditTeamModal
|
|
|
|
team={team}
|
|
|
|
onExit={() => {
|
|
|
|
props.onChange();
|
|
|
|
setShowEditTeamModal(false);
|
|
|
|
}}></EditTeamModal>
|
2021-06-05 22:53:33 +00:00
|
|
|
)}
|
2021-08-02 20:51:57 +00:00
|
|
|
{showMemberInvitationModal && (
|
|
|
|
<MemberInvitationModal
|
|
|
|
team={team}
|
|
|
|
onExit={() => setShowMemberInvitationModal(false)}></MemberInvitationModal>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
2021-07-30 23:05:38 +00:00
|
|
|
}
|