Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | 4x 96x 96x 96x 96x 96x 96x 96x 96x 96x 1x 96x 96x 96x 96x 96x 96x 330x | import { Divider, Avatar } from "@mui/material";
import { palette } from "@palette";
import { MemberData, MemberRoleName } from "@customTypes/team.member";
import { CloseIcon } from "@assets/icons";
import { addSizeToImage } from "@components/UploadAvatar/UploadAvatar";
import InfoDisplay from "./InfoDisplay";
import moment from "moment";
import { PLATFORM_TIMEZONE } from "@utils/timezones";
import { useAppSelector } from "@redux/hooks";
import {
PanelContainer,
TeamInfoContainer,
StyledIconButton,
} from "./TeamPanelBody.styles";
import FadeInWrapper from "@components/animation/FadeInWrapper";
import ChangeRole from "./ChangeRole";
import DeleteMember from "./DeleteMember";
import { selectUser } from "@redux/slices/auth/auth";
import { useTeamPermissions } from "features/Permissions/AccessControl/hooks";
import { useState } from "react";
import { LoadingSkeleton } from "./components";
import InfoEdit from "features/Permissions/ModalV2/components/InfoEdit";
import { useCustomTheme } from "@theme/hooks/useCustomTheme";
type Props = {
rowData: MemberData;
handleClose?: () => void;
isLoading: boolean;
};
export interface EditInfo {
Joined: string;
"First name": string;
"Last name": string;
Email: string;
"Job Title": string;
Employer: string;
}
const TeamPanelBody = ({ rowData, handleClose, isLoading }: Props) => {
const { isMobileView } = useCustomTheme();
const { firstName, lastName, imageURL, email, accID, occupation, employer } =
rowData?.user || {};
const image = addSizeToImage(imageURL, "medium");
const { email: currentUserEmail } = useAppSelector(selectUser);
const [currentRole, setCurrentRole] = useState<MemberRoleName>(
rowData.roleName,
);
const [currentData, setCurrentData] = useState<EditInfo>({
Joined: moment(new Date(rowData.joinedAt * 1000)).tz(PLATFORM_TIMEZONE).format("MM/DD/YYYY"),
"First name": firstName,
"Last name": lastName,
Email: email,
"Job Title": occupation,
Employer: employer,
});
const ownerStatusName = rowData?.ownerStatusName;
const disableEdit = ownerStatusName === "approved";
const updateRole = (newRole: MemberRoleName) => {
setCurrentRole(newRole);
};
const isCurrentUser = currentUserEmail === email;
const { isEditAllowed, isDeleteAllowed, isDeleteOwnerAllowed } =
useTeamPermissions();
const [isEdit, setEdit] = useState(false);
function onClickEdit() {
setEdit(true);
}
const fullName = `${currentData["First name"]} ${currentData["Last name"]}`;
const teamMemberDetails = [
{
section: (
<Avatar
src={image}
sx={{
borderRadius: "50%",
width: 94,
height: 94,
marginInline: "auto",
}}
/>
),
delay: 250,
},
{
section: isEdit ? (
<InfoEdit
items={currentData}
setCurrentData={setCurrentData}
id={accID}
setEdit={setEdit}
disableEdit={disableEdit}
/>
) : (
<InfoDisplay
items={{
Joined: currentData.Joined,
"Full name": fullName === " " ? "-" : fullName,
Email: currentData.Email,
"Job Title": currentData["Job Title"] || "-",
Employer: currentData.Employer || "-",
}}
onClickEdit={onClickEdit}
isEditAllowed={isEditAllowed}
/>
),
delay: 300,
},
...(isMobileView
? []
: [
{
section: <Divider />,
delay: 300,
},
]),
{
section: (
<ChangeRole
role={currentRole}
updateRole={updateRole}
isCurrentUser={isCurrentUser}
isOwner={rowData?.roleName === "owner" || false}
id={accID}
isEditAllowed={isEditAllowed}
/>
),
delay: 350,
},
{
section: <Divider />,
delay: 350,
},
{
section: (
<DeleteMember
rowData={rowData}
isCurrentUser={isCurrentUser}
isDeleteAllowed={isDeleteAllowed}
isDeleteOwnerAllowed={isDeleteOwnerAllowed}
/>
),
delay: 400,
},
];
return (
<PanelContainer>
<TeamInfoContainer>
<StyledIconButton
data-testid="team-panel-close-button"
aria-label="close"
onClick={handleClose}
size="small"
sx={{
position: "absolute",
top: 0,
right: 16,
}}
>
<CloseIcon width={24} height={24} stroke={palette.neutral[70]} />
</StyledIconButton>
{isLoading ? (
<LoadingSkeleton />
) : (
teamMemberDetails.map(({ section, delay }, index) => (
<FadeInWrapper key={index} delay={delay}>
{section}
</FadeInWrapper>
))
)}
</TeamInfoContainer>
</PanelContainer>
);
};
export default TeamPanelBody;
|