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 | 55x 275x 275x 4x 829x 550x | import { Button } from "@common/Button";
import { Text, TruncateText } from "@common/Text";
import { EDIT_DENY_MESSAGE } from "@constants/permissions";
import { Box, Stack, StackProps, styled } from "@mui/material";
import { palette } from "@palette";
import { PencilIcon } from "@phosphor-icons/react";
interface InfoDisplayProps extends StackProps {
items: {
Joined: string;
"Full name": string;
Email: string;
"Job Title": string;
Employer: string;
};
onClickEdit: () => void;
isEditAllowed?: boolean;
}
function InfoDisplay({
items,
onClickEdit,
isEditAllowed,
...rest
}: InfoDisplayProps) {
return (
<Stack {...rest} gap="4px" mb={4}>
{Object.keys(items).map((key, index) => {
const value = items[key as keyof InfoDisplayProps["items"]];
return (
<Box
key={index}
sx={{
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
}}
>
<Box
sx={{
backgroundColor: "inherit",
padding: "4px 8px",
borderRadius: "4px",
display: "flex",
flexDirection: "column",
}}
>
<StyledText lineClamp={1}>{key}</StyledText>
<StyledText isValue lineClamp={1}>
{value}
</StyledText>
</Box>
{index === 0 && (
<Button
background="tertiary"
size="medium"
startIcon={<PencilIcon />}
onClick={onClickEdit}
disabled={!isEditAllowed}
tooltipProps={{
message: EDIT_DENY_MESSAGE,
show: !isEditAllowed,
}}
>
<Text fontWeight="book" color={palette.neutral[90]}>
Edit Profile
</Text>
</Button>
)}
</Box>
);
})}
</Stack>
);
}
export default InfoDisplay;
const StyledText = styled(TruncateText, {
shouldForwardProp: (prop) => prop !== "isValue",
})<{ isValue?: boolean }>(({ theme, isValue }) => ({
color: isValue ? theme.palette.neutral["600"] : theme.palette.neutral["400"],
fontWeight: isValue ? 350 : 300,
lineHeight: "16.8px",
...(isValue && {
minHeight: "16.8px",
}),
}));
|