@giteeteam/apps-team-components 1.11.15 → 1.11.16-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
2
2
|
import React__default, { useMemo } from 'react';
|
|
3
3
|
import { ClassNames } from '@emotion/react';
|
|
4
|
+
import useCurrentWorkspace from '../../../lib/hooks/useCurrentWorkspace.js';
|
|
4
5
|
import { getNameBadge, getBackgroundColor } from '../utils.js';
|
|
5
6
|
import { avatarItemStyle, avatarStyle, defaultAvatarStyle } from './style/index.js';
|
|
6
7
|
|
|
7
8
|
const UserAvatar = React__default.memo(({ user, className }) => {
|
|
8
|
-
const
|
|
9
|
+
const { workspaceKey } = useCurrentWorkspace();
|
|
10
|
+
const avatarUrl = useMemo(() => {
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
|
+
const url = (_a = user === null || user === void 0 ? void 0 : user.avatar) === null || _a === void 0 ? void 0 : _a.url;
|
|
13
|
+
if (url)
|
|
14
|
+
return url;
|
|
15
|
+
const bosKey = (_d = (_c = (_b = user === null || user === void 0 ? void 0 : user.bosKey) === null || _b === void 0 ? void 0 : _b.trim) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : user === null || user === void 0 ? void 0 : user.bosKey;
|
|
16
|
+
if (!workspaceKey || !bosKey)
|
|
17
|
+
return undefined;
|
|
18
|
+
return `/api/one/${workspaceKey}/rest/v1/companies/${workspaceKey}/users/logo/picture?url=${encodeURIComponent(bosKey)}`;
|
|
19
|
+
}, [user, workspaceKey]);
|
|
9
20
|
const displayName = useMemo(() => (user === null || user === void 0 ? void 0 : user.name) || (user === null || user === void 0 ? void 0 : user.nickname) || (user === null || user === void 0 ? void 0 : user.username), [user]);
|
|
10
21
|
const userBadge = useMemo(() => getNameBadge(displayName), [displayName]);
|
|
11
22
|
return (jsx(ClassNames, { children: ({ cx, css }) => {
|