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 183 184 185 186 187 188 189 190 191 192 | 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 27x 4x 4x 27x 54x 15x 27x 27x 27x 27x 27x | import { Card, CardActions, styled, Tooltip, Typography } from "@mui/material";
import Avatar from "components/Avatar";
import BarWithHelp from "components/Bar/BarWithHelp";
import Divider from "components/Divider";
import { CouchIcon, LocationIcon } from "components/Icons";
import IconText from "components/IconText";
import StrongVerificationBadge from "components/StrongVerificationBadge";
import StyledLink from "components/StyledLink";
import {
hostingStatusLabels,
meetupStatusLabels,
} from "features/profile/constants";
import { useTranslation } from "i18n";
import { GLOBAL, PROFILE } from "i18n/namespaces";
import Link from "next/link";
import { HostingStatus, MeetupStatus } from "proto/api_pb";
import React from "react";
import { routeToEditProfile, routeToUser } from "routes";
import { useProfileUser } from "../hooks/useProfileUser";
import { Badges } from "./Badges";
import { ReferencesLastActiveLabels, ResponseRateLabel } from "./userLabels";
const StyledCard = styled(Card)(({ theme }) => ({
flexShrink: 0,
borderRadius: theme.shape.borderRadius * 2,
padding: theme.spacing(3),
[theme.breakpoints.down("sm")]: {
marginBottom: theme.spacing(1),
width: "100%",
},
}));
const StyledAvatarContainer = styled("div")({
maxWidth: "75%",
margin: "0 auto",
});
const ClickableAvatarContainer = styled(Link)({
maxWidth: "75%",
margin: "0 auto",
display: "block",
cursor: "pointer",
transition: "transform 0.2s ease-in-out, opacity 0.2s ease-in-out",
"&:hover": {
transform: "scale(1.05)",
opacity: 0.8,
},
"&:active": {
transform: "scale(0.98)",
},
});
const StyledWrapper = styled("div")(({ theme }) => ({
marginTop: theme.spacing(2),
"& h1": {
textAlign: "center",
marginBottom: theme.spacing(0.5),
},
}));
const StyledIntro = styled(Typography)(({ theme }) => ({
display: "flex",
justifyContent: "center",
wordBreak: "break-word",
overflowWrap: "break-word",
textAlign: "center",
marginBottom: theme.spacing(1),
}));
const StyledCardActions = styled(CardActions)(({ theme }) => ({
flexDirection: "column",
justifyContent: "center",
alignItems: "stretch",
gap: theme.spacing(0.2),
padding: theme.spacing(0.5),
"&.MuiCardActions-root > *": {
marginLeft: 0,
marginRight: 0,
marginTop: theme.spacing(0.5),
marginBottom: theme.spacing(0.5),
},
}));
const StyledInfo = styled("div")(({ theme }) => ({
marginTop: theme.spacing(0.5),
}));
type UserOverviewProps = {
showHostAndMeetAvailability: boolean;
actions?: React.ReactNode;
isOwnProfile?: boolean;
};
// @todo: move this into /components and decouple it from features/profile because it's used
// from the dashboard as well
export default function UserOverview({
showHostAndMeetAvailability,
actions,
isOwnProfile = false,
}: UserOverviewProps) {
const { t } = useTranslation([GLOBAL, PROFILE]);
const user = useProfileUser();
const shouldMakeAvatarClickable = isOwnProfile && !user.avatarUrl;
return (
<StyledCard>
{shouldMakeAvatarClickable ? (
<Tooltip title={t("profile:click_to_add_photo")} arrow placement="top">
<ClickableAvatarContainer href={`${routeToEditProfile()}#gallery`}>
<Avatar user={user} highRes grow isProfileLink={false} />
</ClickableAvatarContainer>
</Tooltip>
) : (
<StyledAvatarContainer>
<Avatar user={user} highRes grow />
</StyledAvatarContainer>
)}
<StyledWrapper>
<StyledIntro variant="h1">
<span>
{user.name}
{user.hasStrongVerification ? <StrongVerificationBadge /> : null}
</span>
</StyledIntro>
<StyledLink
href={routeToUser(user.username)}
sx={{
display: "flex",
justifyContent: "center",
marginBottom: 1,
}}
>
@{user.username}
</StyledLink>
<StyledIntro>{user.city}</StyledIntro>
<Badges user={user} />
</StyledWrapper>
<Divider />
{actions && <StyledCardActions>{actions}</StyledCardActions>}
{showHostAndMeetAvailability && (
<>
<IconText
icon={CouchIcon}
text={
hostingStatusLabels(t)[
user.hostingStatus || HostingStatus.HOSTING_STATUS_UNKNOWN
]
}
/>
<IconText
icon={LocationIcon}
text={
meetupStatusLabels(t)[
user.meetupStatus || MeetupStatus.MEETUP_STATUS_UNKNOWN
]
}
/>
</>
)}
{Boolean(showHostAndMeetAvailability || actions) && (
<Divider spacing={3} />
)}
{process.env.NEXT_PUBLIC_IS_VERIFICATION_ENABLED && (
<>
<BarWithHelp
value={user.communityStanding || 0}
label={t("global:community_standing")}
description={t("global:community_standing_description")}
/>
<BarWithHelp
value={user.verification || 0}
label={t("global:verification_score")}
description={t("global:verification_score_description")}
/>
</>
)}
<StyledInfo>
<ReferencesLastActiveLabels user={user} />
<ResponseRateLabel user={user} />
</StyledInfo>
</StyledCard>
);
}
|