diff --git a/src/combined/ClientApp/src/components/TeamsInfo/TeamDetails.tsx b/src/combined/ClientApp/src/components/TeamsInfo/TeamDetails.tsx index a6887ca0..30ddd223 100644 --- a/src/combined/ClientApp/src/components/TeamsInfo/TeamDetails.tsx +++ b/src/combined/ClientApp/src/components/TeamsInfo/TeamDetails.tsx @@ -30,7 +30,7 @@ export function TeamDetails() { if (list[1] !== null) { ownerId = parseInt(list[1]); // parse the string back to a number. } - + console.log("I am the owner Id", ownerId); const accessToken = localStorage.getItem("access_token"); const config = useMemo(() => { @@ -41,6 +41,7 @@ export function TeamDetails() { const api = process.env.PUBLIC_URL + `/api/teams/${tId}`; + const personApi = process.env.PUBLIC_URL + `/api/Person/${ownerId}`; const [currentTeam, setCurrentTeam] = useState(); const [loggedInUserId, setLoggedInUserId] = useState(); const [loggedInUserTeamId, setLoggedInUserTeamId] = useState(); @@ -62,7 +63,7 @@ export function TeamDetails() { const [progressBarIsUptodate, setprogressBarIsUptodate] = useState(false); const [previousTeam, setpreviousTeam] = useState(); - + const [teamOwner, setteamOwner] = useState(); useEffect(() => { const config = { @@ -76,7 +77,7 @@ export function TeamDetails() { setCanSwitchTeam(false) } }); - } + } async function PreviousTeamInfo() { @@ -84,7 +85,7 @@ export function TeamDetails() { var res = await axios.get(process.env.PUBLIC_URL + `/api/PersonTeamAssociation/${loggedInUserId}/${currentEvent?.id}`) if (res.status === 200) { - console.log("previous team name", res.data?.name) + setpreviousTeam(res.data) } } @@ -172,6 +173,7 @@ export function TeamDetails() { await currentTeamMembers(); await getDonationTotal(); await PreviousTeamInfo(); + }; if(currentEvent?.id != null){ @@ -190,7 +192,26 @@ if(currentEvent?.id != null){ } - }, [api, ownerId, currentEvent, loggedInUserId, tId, currentTeam?.ownerID, deleteUserId, members.length, currentEvent?.id, currentTeam?.id]); + }, [api, personApi, ownerId, currentEvent, loggedInUserId, tId, currentTeam?.ownerID, deleteUserId, members.length, currentEvent?.id, currentTeam?.id]); + + + useEffect(() => { + async function fetchTeamOwner() { + + var perRes = await axios.get(personApi, config); + var personResponse = perRes.data; + setteamOwner(personResponse); + + } + + + const callServise = async () => { + await fetchTeamOwner(); + }; + + callServise(); + }, [personApi, config]); + const closeModal = () => { setopenArchiveModal(false) setOpenSwitchTeamsModal(false) @@ -416,20 +437,29 @@ if(currentEvent?.id != null){
    {members.map((j: any) => (
  • - {(isAdmin || loggedInUserId === currentTeam?.ownerID) ? ( - - ) : null} - {j.nickname} - - { + {!isAdmin && loggedInUserId !== currentTeam?.ownerID ? null : ( + j.id !== teamOwner?.id && ( + + ) + )} + {j.id === teamOwner?.id ? ( +

    Team owner: {teamOwner?.name}

    + ) : ( + {j.nickname} + )} + {openErrorModal && ( - } - { + )} + {openZeroPersonModal && ( - } - { - !openErrorModal && !openZeroPersonModal && ( - handleDeleteUser()} - isOkConfirm={isOkModal} - /> - ) - } + )} + {!openErrorModal && !openZeroPersonModal && ( + handleDeleteUser()} + isOkConfirm={isOkModal} + /> + )}
  • ))}
+ +