This repository was archived by the owner on Apr 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathUserOverview.tsx
More file actions
165 lines (147 loc) · 4.14 KB
/
Copy pathUserOverview.tsx
File metadata and controls
165 lines (147 loc) · 4.14 KB
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
import { Card, CardActions, Typography } from "@material-ui/core";
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 {
hostingStatusLabels,
meetupStatusLabels,
} from "features/profile/constants";
import { useTranslation } from "i18n";
import { GLOBAL, PROFILE } from "i18n/namespaces";
import { HostingStatus, MeetupStatus } from "proto/api_pb";
import React from "react";
import makeStyles from "utils/makeStyles";
import { useProfileUser } from "../../features/profile/hooks/useProfileUser";
import {
ReferencesLastActiveLabels,
ResponseRateLabel,
} from "../../features/profile/view/userLabels";
import { HTML_SYMBOLS } from "../constants";
const useStyles = makeStyles((theme) => ({
card: {
flexShrink: 0,
borderRadius: theme.shape.borderRadius * 2,
padding: theme.spacing(3),
[theme.breakpoints.down("xs")]: {
marginBottom: theme.spacing(1),
width: "100%",
},
},
info: {
marginTop: theme.spacing(0.5),
},
intro: {
wordBreak: "break-word",
overflowWrap: "break-word",
},
wrapper: {
marginTop: theme.spacing(2),
"& h1": {
marginBottom: theme.spacing(0.5),
},
},
cardActions: {
flexDirection: "column",
justifyContent: "center",
alignItems: "stretch",
padding: "0px",
"& > *": {
margin: theme.spacing(0.5),
},
"& > :not(:first-child)": {
marginLeft: theme.spacing(0.5),
marginTop: theme.spacing(1.5),
},
"& > button": {
fontWeight: "bold",
padding: theme.spacing(1.6),
},
},
avatarContainer: {
maxWidth: "75%",
margin: "0 auto",
},
}));
type UserOverviewProps = {
showHostAndMeetAvailability: boolean;
actions?: React.ReactNode;
};
export default function UserOverview({
showHostAndMeetAvailability,
actions,
}: UserOverviewProps) {
const { t } = useTranslation([GLOBAL, PROFILE]);
const classes = useStyles();
const user = useProfileUser();
const { username, name, city } = user;
return (
<Card className={classes.card}>
<div className={classes.avatarContainer}>
<Avatar user={user} grow />
</div>
<div className={classes.wrapper}>
<Typography variant="h1" className={classes.intro} align={"left"}>
{name}
</Typography>
<Typography
color={"textSecondary"}
>{`${HTML_SYMBOLS["@"]}${username}`}</Typography>
</div>
<Divider />
<Typography color={"primary"} variant="body1" className={classes.intro}>
{city}
</Typography>
<Divider />
{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={2} />
)}
{actions && (
<>
<CardActions className={classes.cardActions}>{actions}</CardActions>
<Divider spacing={2} />
</>
)}
{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")}
/>
<Divider spacing={2} />
</>
)}
<div className={classes.info}>
<ReferencesLastActiveLabels user={user} />
<ResponseRateLabel user={user} />
</div>
</Card>
);
}