From 8346eb582f6aaa32b5bfe4ea81455ec90515957e Mon Sep 17 00:00:00 2001 From: Durli Date: Fri, 7 Apr 2023 09:09:09 -0600 Subject: [PATCH 1/2] fixed the team owner appearance --- .../src/components/TeamsInfo/TeamDetails.tsx | 97 ++++++++++++------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/src/combined/ClientApp/src/components/TeamsInfo/TeamDetails.tsx b/src/combined/ClientApp/src/components/TeamsInfo/TeamDetails.tsx index 146e2abd..21c7bef2 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,14 +77,14 @@ export function TeamDetails() { setCanSwitchTeam(false) } }); - } + } async function PreviousTeamInfo() { try { 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) } @@ -171,6 +172,7 @@ export function TeamDetails() { await currentTeamMembers(); await getDonationTotal(); await PreviousTeamInfo(); + }; callServise(); @@ -187,7 +189,28 @@ export function TeamDetails() { } - }, [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); + console.log("I am the perRes", perRes); + var personResponse = perRes.data; + console.log("I am the person Respone", personResponse); + setteamOwner(perRes.data); + console.log("I am the persondata", perRes.data.name); + } + + + const callServise = async () => { + await fetchTeamOwner(); + }; + + callServise(); + }, [personApi]); + const closeModal = () => { setopenArchiveModal(false) setOpenSwitchTeamsModal(false) @@ -414,20 +437,29 @@ export function TeamDetails() {
    {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} + /> + )}
  • ))}
+ From baf5c40bd9b979f17ccac948ca3f31d2060f7106 Mon Sep 17 00:00:00 2001 From: Durli Date: Fri, 7 Apr 2023 09:11:40 -0600 Subject: [PATCH 2/2] fixed lint issues --- .../src/components/TeamsInfo/TeamDetails.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/combined/ClientApp/src/components/TeamsInfo/TeamDetails.tsx b/src/combined/ClientApp/src/components/TeamsInfo/TeamDetails.tsx index 21c7bef2..19ea8242 100644 --- a/src/combined/ClientApp/src/components/TeamsInfo/TeamDetails.tsx +++ b/src/combined/ClientApp/src/components/TeamsInfo/TeamDetails.tsx @@ -195,12 +195,10 @@ export function TeamDetails() { useEffect(() => { async function fetchTeamOwner() { - var perRes = await axios.get(personApi, config); - console.log("I am the perRes", perRes); - var personResponse = perRes.data; - console.log("I am the person Respone", personResponse); - setteamOwner(perRes.data); - console.log("I am the persondata", perRes.data.name); + var perRes = await axios.get(personApi, config); + var personResponse = perRes.data; + setteamOwner(personResponse); + } @@ -209,7 +207,7 @@ export function TeamDetails() { }; callServise(); - }, [personApi]); + }, [personApi, config]); const closeModal = () => { setopenArchiveModal(false)