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 | import { Avatar, Card, CardContent, styled, Typography } from "@mui/material";
import { PinIcon } from "components/Icons";
import IconText from "components/IconText";
import StyledLink from "components/StyledLink";
import useCurrentUser from "features/userQueries/useCurrentUser";
import { useTranslation } from "i18n";
import { AUTH } from "i18n/namespaces";
import { GetMyVolunteerInfoRes } from "proto/account_pb";
import { theme } from "theme";
import { getLinkTypeIcon } from "./utils";
const VolunteerCardWrapper = styled("div")(() => ({
marginTop: theme.spacing(2),
marginBottom: theme.spacing(2),
maxWidth: "400px",
}));
const StyledVolunteerCard = styled(Card)(() => ({
height: "13rem",
border: `1px solid ${theme.palette.grey[400]}`,
}));
const StyledCardContent = styled(CardContent)(() => ({
display: "flex",
}));
const DetailDiv = styled("div")(() => ({
display: "flex",
flexFlow: "column nowrap",
gap: theme.spacing(0.5),
padding: theme.spacing(1, 2),
}));
const StyledAvatar = styled(Avatar)(() => ({
width: theme.typography.pxToRem(96),
height: theme.typography.pxToRem(96),
}));
const VolunteerStatus = styled("div")(() => ({
marginTop: theme.spacing(1),
display: "flex",
flexDirection: "column",
gap: theme.spacing(0.5),
}));
const LocationText = styled(Typography)(() => ({
display: "-webkit-box",
WebkitLineClamp: 2,
WebkitBoxOrient: "vertical",
overflow: "hidden",
textOverflow: "ellipsis",
}));
interface VolunteerCardProps {
volunteerInfo: GetMyVolunteerInfoRes.AsObject;
}
export default function VolunteerCard({ volunteerInfo }: VolunteerCardProps) {
const { t } = useTranslation([AUTH]);
const { data: currentUser } = useCurrentUser();
const LinkIcon = getLinkTypeIcon(volunteerInfo.linkType);
return (
<VolunteerCardWrapper>
<Typography
variant="body2"
color="textSecondary"
sx={{ marginBottom: 1 }}
>
{t("auth:volunteer_management.card_preview_label")}
</Typography>
<StyledVolunteerCard variant="outlined">
<StyledCardContent>
<StyledAvatar
alt={volunteerInfo.displayName || currentUser?.name}
src={currentUser?.avatarUrl}
/>
<DetailDiv>
<Typography variant="h3" component="h3">
{volunteerInfo.displayName || currentUser?.name}
</Typography>
<Typography variant="body1">{volunteerInfo.role}</Typography>
<div>
{(volunteerInfo.displayLocation || currentUser?.city) && (
<IconText
icon={PinIcon}
text={
<LocationText variant="body1">
{volunteerInfo.displayLocation || currentUser?.city || ""}
</LocationText>
}
/>
)}
{volunteerInfo.linkUrl && (
<IconText
icon={LinkIcon}
text={
<Typography variant="body1">
<StyledLink href={volunteerInfo.linkUrl}>
{volunteerInfo.linkText}
</StyledLink>
</Typography>
}
/>
)}
</div>
</DetailDiv>
</StyledCardContent>
</StyledVolunteerCard>
<VolunteerStatus>
<Typography variant="body2" color="textSecondary">
{volunteerInfo.stoppedVolunteering
? t("auth:volunteer_management.past_volunteer", {
startDate: volunteerInfo.startedVolunteering,
endDate: volunteerInfo.stoppedVolunteering,
})
: t("auth:volunteer_management.current_volunteer", {
startDate: volunteerInfo.startedVolunteering,
})}
</Typography>
<Typography variant="body2" color="textSecondary">
{volunteerInfo.showOnTeamPage
? t(
volunteerInfo.stoppedVolunteering
? "auth:volunteer_management.shown_on_team_page_past"
: "auth:volunteer_management.shown_on_team_page_current",
)
: t("auth:volunteer_management.not_shown_on_team_page")}
</Typography>
</VolunteerStatus>
</VolunteerCardWrapper>
);
}
|