Skip to content

Commit 6b2a4da

Browse files
committed
feat: 깃허브로 회원가입 시 아이콘 반영
1 parent 8a9c599 commit 6b2a4da

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

components/home/ProfileSection.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import Image from 'next/image';
12
import { Profile } from '@/lib/home/profileService';
23
import Card from './Card';
34
import { getRandomProfileIcon } from '@/utils/getRandomProfileIcon';
5+
46
interface ProfileSectionProps {
57
className?: string;
68
profile: Profile | null;
@@ -9,12 +11,27 @@ interface ProfileSectionProps {
911

1012
const ProfileSection = ({ className, profile, uid }: ProfileSectionProps) => {
1113
const icon = getRandomProfileIcon(uid);
14+
const avatarUrl = profile?.avatar_url;
15+
console.log(avatarUrl);
16+
1217
return (
1318
<div className={className}>
1419
<div className="md:col-span-2">
1520
<Card className="flex items-center gap-4">
1621
<div className="flex h-16 w-16 items-center justify-center overflow-hidden rounded-full border border-gray-100 bg-purple-100 pt-1">
17-
<span className="text-3xl">{icon}</span>
22+
<span className="text-3xl">
23+
{avatarUrl ? (
24+
<Image
25+
src={avatarUrl}
26+
alt="profile avatar"
27+
width={50}
28+
height={50}
29+
className="h-full w-full object-cover"
30+
/>
31+
) : (
32+
<span className="text-3xl">{icon}</span>
33+
)}
34+
</span>
1835
</div>
1936

2037
<div>

lib/home/profileService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface Profile {
77
email: string;
88
streakDays: number;
99
tilCount: number;
10+
avatar_url: string;
1011
}
1112

1213
// 1. 유저 프로필 정보 가져오기

next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { NextConfig } from 'next';
22

33
const nextConfig: NextConfig = {
4-
/* config options here */
4+
images: { domains: ['avatars.githubusercontent.com'] },
55
};
66

77
export default nextConfig;

services/auth/signup.service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,19 @@ export const signupWithGithub = async () => {
3535

3636
const info = getAdditionalUserInfo(result);
3737
const githubUsername = info?.username ?? null;
38-
38+
const avatar_url = info?.profile?.avatar_url;
39+
console.log(info);
3940
const userRef = doc(db, 'users', user.uid);
4041
const snap = await getDoc(userRef);
4142

4243
if (!snap.exists()) {
4344
await setDoc(userRef, {
44-
userId: user.uid,
4545
nickname: user.displayName ?? githubUsername ?? '익명',
4646
email: user.email ?? '',
47-
provider: 'github.com',
48-
githubUsername,
4947
createdAt: serverTimestamp(),
5048
streakDays: 0,
5149
tilCount: 0,
50+
avatar_url: avatar_url,
5251
});
5352
}
5453
return user;

0 commit comments

Comments
 (0)