admin(ui): actually get avatar for users

This commit is contained in:
Matthew Penner 2021-01-07 09:55:04 -07:00
parent 56c098a316
commit 9eed88b430
3 changed files with 8 additions and 4 deletions

View file

@ -43,9 +43,11 @@ class UserTransformer extends BaseTransformer
'language' => $model->language,
'root_admin' => (bool) $model->root_admin,
'2fa' => (bool) $model->use_totp,
'role_name' => $model->root_admin ? 'Super Administrator' : 'None',
'avatar_url' => 'https://www.gravatar.com/avatar/' . md5($model->email) . '.jpg?s=40',
'role_name' => $model->root_admin ? 'Super Administrator' : null,
'created_at' => $this->formatTimestamp($model->created_at),
'updated_at' => $this->formatTimestamp($model->updated_at),
'avatar'
];
}

View file

@ -13,7 +13,8 @@ export interface User {
language: string;
rootAdmin: boolean;
tfa: boolean;
roleName: string;
avatarURL: string;
roleName: string | null;
createdAt: Date;
updatedAt: Date;
}
@ -29,6 +30,7 @@ export const rawDataToUser = ({ attributes }: FractalResponseData): User => ({
language: attributes.language,
rootAdmin: attributes.root_admin,
tfa: attributes['2fa'],
avatarURL: attributes.avatar_url,
roleName: attributes.role_name,
createdAt: new Date(attributes.created_at),
updatedAt: new Date(attributes.updated_at),

View file

@ -117,7 +117,7 @@ const UsersContainer = () => {
<NavLink to={`${match.url}/${user.id}`}>
<div css={tw`flex items-center`}>
<div css={tw`flex-shrink-0 h-10 w-10`}>
<img css={tw`h-10 w-10 rounded-full`} alt="" src="https://www.gravatar.com/avatar/92623b66155f7e475250b549226a5023"/>
<img css={tw`h-10 w-10 rounded-full`} alt="" src={user.avatarURL}/>
</div>
<div css={tw`ml-4`}>
@ -141,7 +141,7 @@ const UsersContainer = () => {
</span>
</td>
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>{user.roleName}</td>
<td css={tw`px-6 text-sm text-neutral-200 text-left whitespace-nowrap`}>{user.roleName || 'None'}</td>
</tr>
))
}