blob: fae73a53fdd0ddb10316303ab38841602ba0d9d6 (
plain) (
blame)
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
|
import { Column, Label, Row } from '@umami/react-zen';
import { useConfig, useLoginQuery, useMessages } from '@/components/hooks';
import { ROLES } from '@/lib/constants';
import { PasswordChangeButton } from './PasswordChangeButton';
export function ProfileSettings() {
const { user } = useLoginQuery();
const { formatMessage, labels } = useMessages();
const { cloudMode } = useConfig();
if (!user) {
return null;
}
const { username, role } = user;
const renderRole = (value: string) => {
if (value === ROLES.user) {
return formatMessage(labels.user);
}
if (value === ROLES.admin) {
return formatMessage(labels.admin);
}
if (value === ROLES.viewOnly) {
return formatMessage(labels.viewOnly);
}
return formatMessage(labels.unknown);
};
return (
<Column width="400px" gap="6">
<Column>
<Label>{formatMessage(labels.username)}</Label>
{username}
</Column>
<Column>
<Label>{formatMessage(labels.role)}</Label>
{renderRole(role)}
</Column>
{!cloudMode && (
<Column>
<Label>{formatMessage(labels.password)}</Label>
<Row>
<PasswordChangeButton />
</Row>
</Column>
)}
</Column>
);
}
|