Skip to content

Commit f3419f8

Browse files
committed
feat(ui): utilize next/image for user avatars
1 parent cfe1ae3 commit f3419f8

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

apps/ui/src/components/AccountDropdown/AccountDropdown.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import { signOut, useSession } from 'next-auth/react';
4+
import Image from 'next/image';
45

56
import { Avatar, Dropdown, Space, Spin } from 'antd';
67
import { LogoutOutlined, UserOutlined } from '@ant-design/icons';
@@ -29,9 +30,18 @@ function AccountDropdown() {
2930
<Dropdown menu={{ items }} trigger={['click']} placement="bottomRight">
3031
<Space className={classes.userWrapper}>
3132
<Avatar
32-
icon={<UserOutlined />}
33-
src={session?.user?.image}
34-
alt={session?.user?.name ?? 'Default User Avatar'}
33+
icon={
34+
!session?.user?.image ? (
35+
<UserOutlined />
36+
) : (
37+
<Image
38+
src={session?.user?.image}
39+
alt={session?.user?.name ?? 'Default User Avatar'}
40+
layout="fill"
41+
objectFit="cover"
42+
/>
43+
)
44+
}
3545
/>
3646
<span className={classes.userName}>{session?.user?.name}</span>
3747
</Space>

apps/ui/src/components/UserFollowEvents/UserFollowEvents.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
'use client';
22

3+
import Image from 'next/image';
34
import { useState } from 'react';
45

56
import { Avatar, Table, Tag } from 'antd';
67
import type { GetProp, TableProps } from 'antd';
8+
import { UserOutlined } from '@ant-design/icons';
79

810
import type { ResponseEventWithUserReference } from '@follytics/sdk';
911

@@ -60,11 +62,26 @@ const columns: TableProps<ResponseEventWithUserReference>['columns'] = [
6062
title: 'Avatar',
6163
key: 'user',
6264
dataIndex: 'userAvatar',
63-
render: (_, { user }) => (
64-
<>
65-
<Avatar src={user?.avatar} />
66-
</>
67-
),
65+
render: (_, { user }) => {
66+
return (
67+
<>
68+
<Avatar
69+
icon={
70+
!user?.avatar ? (
71+
<UserOutlined />
72+
) : (
73+
<Image
74+
src={user?.avatar}
75+
alt={user?.name ?? 'Default User Avatar'}
76+
layout="fill"
77+
objectFit="cover"
78+
/>
79+
)
80+
}
81+
/>
82+
</>
83+
);
84+
},
6885
},
6986
];
7087

0 commit comments

Comments
 (0)