-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: 마이페이지 이미지, 자기소개 연동, 회원정보 수정 추가 작업 필요
- Loading branch information
Showing
10 changed files
with
139 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import MyInfoForm from '@/components/MyInfoForm'; | ||
import { getUserInfo2 } from '@/service/auth'; | ||
|
||
type Props = { | ||
params: { | ||
slug: number; | ||
}; | ||
}; | ||
|
||
export default async function MySettingPage({ params: { slug } }: Props) { | ||
const userInfo = await getUserInfo2(slug); | ||
|
||
return ( | ||
<section className="flex flex-col w-full items-center max-w-screen-sm mx-auto mt-24 shadow-lg py-5 px-32"> | ||
<h1 className="text-3xl font-bold my-5">Inforum</h1> | ||
<MyInfoForm userId={slug} userInfo={userInfo} isSignup={false} /> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use client'; | ||
|
||
import { checkUser } from '@/service/auth'; | ||
import Link from 'next/link'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
type Props = { | ||
userId: number; | ||
}; | ||
|
||
export default function SettingBtns({ userId }: Props) { | ||
const [uid, setUid] = useState<number | null>(null); | ||
|
||
async function first() { | ||
await checkUser().then((data) => setUid(data.id)); | ||
} | ||
|
||
useEffect(() => { | ||
first(); | ||
}, []); | ||
return ( | ||
uid === Number(userId) && ( | ||
<div className="flex flex-col"> | ||
<Link href={`/me/setting/${userId}`} className="text-center"> | ||
<button className="mt-8 text-soma-grey-50 text-sm"> | ||
회원 정보 수정 | ||
</button> | ||
</Link> | ||
</div> | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,31 @@ | ||
import Image from 'next/image'; | ||
import exampleImg from '../../../public/img/profile.png'; | ||
import basicProfileImg from '../../assets/profile.svg'; | ||
import { UserInfo2 } from '@/types'; | ||
|
||
type Props = { | ||
userInfo: { | ||
userName: string; | ||
}; | ||
userInfo: UserInfo2; | ||
}; | ||
|
||
export default function Profile({ userInfo }: Props) { | ||
return ( | ||
<section className="flex flex-col items-center"> | ||
<div className="text-center"> | ||
<Image | ||
src={exampleImg} | ||
alt="exampleImg" | ||
height={130} | ||
src={userInfo.profileImageFilePath ?? basicProfileImg} | ||
alt="profileImg" | ||
width={100} | ||
height={100} | ||
className="rounded-full" | ||
/> | ||
<p className="font-bold mt-1">{userInfo.userName}</p> | ||
<p className="font-bold mt-1">{userInfo.nickname}</p> | ||
{/* <p>15301</p> */} | ||
</div> | ||
|
||
{/* <div className="self-start mt-5"> | ||
<div className="self-start mt-5 w-full"> | ||
<h3 className="font-semibold">자기소개</h3> | ||
<p className="bg-gray-200 p-3 rounded-md mt-1"> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Earum | ||
explicabo deserunt at minima! Eligendi impedit culpa, natus vero | ||
repudiandae suscipit voluptatem at nobis iste quibusdam tempore labore | ||
rerum nemo accusantium! | ||
<p className="bg-soma-blue-5 p-3 rounded-md mt-1 w-full text-sm h-[150px] overflow-scroll text-soma-grey-60"> | ||
{userInfo.introduce} | ||
</p> | ||
</div> */} | ||
</div> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,44 @@ | ||
import { UserInfo, Record, Memo } from '@/types' | ||
import { UserInfo, Record, Memo } from '@/types'; | ||
|
||
export async function getUserInfo(userId: number): Promise<UserInfo> { | ||
return fetch(`${process.env.NEXT_PUBLIC_SERVER_IP_ADDRESS}/mypage/${userId}`) | ||
.then((res) => { | ||
if (!res.ok) throw new Error('error 발생!'); | ||
return res.json(); | ||
return fetch(`${process.env.NEXT_PUBLIC_SERVER_IP_ADDRESS}/mypage/${userId}`) | ||
.then((res) => { | ||
if (!res.ok) throw new Error('error 발생!'); | ||
return res.json(); | ||
}) | ||
.catch(console.error); | ||
} | ||
|
||
|
||
export async function getHistory(userId: number,year: number, month: number, isSSR: boolean): Promise<Record[]> { | ||
return fetch(`${isSSR ? process.env.NEXT_PUBLIC_SERVER_IP_ADDRESS : process.env.NEXT_PUBLIC_SERVER_IP_ADDRESS_SECURE}/mypage/${userId}/history?year=${year}&month=${month}`) | ||
.then((res) => { | ||
if (!res.ok) throw new Error('error 발생!'); | ||
return res.json(); | ||
export async function getHistory( | ||
userId: number, | ||
year: number, | ||
month: number, | ||
isSSR: boolean | ||
): Promise<Record[]> { | ||
return fetch( | ||
`${ | ||
isSSR | ||
? process.env.NEXT_PUBLIC_SERVER_IP_ADDRESS | ||
: process.env.NEXT_PUBLIC_SERVER_IP_ADDRESS_SECURE | ||
}/mypage/${userId}/history?year=${year}&month=${month}` | ||
) | ||
.then((res) => { | ||
if (!res.ok) throw new Error('error 발생!'); | ||
return res.json(); | ||
}) | ||
.catch(console.error); | ||
} | ||
|
||
export async function getMemosByUserId(userId: number): Promise<Memo[]> { | ||
return fetch( | ||
`${process.env.NEXT_PUBLIC_SERVER_IP_ADDRESS}/mypage/${userId}/memos`, | ||
{ | ||
next: { revalidate: 0 }, | ||
} | ||
) | ||
.then((res) => { | ||
if (!res.ok) throw new Error('error 발생!'); | ||
return res.json(); | ||
}) | ||
.catch(console.error); | ||
} | ||
return fetch( | ||
`${process.env.NEXT_PUBLIC_SERVER_IP_ADDRESS}/mypage/${userId}/memos`, | ||
{ | ||
next: { revalidate: 0 }, | ||
} | ||
) | ||
.then((res) => { | ||
if (!res.ok) throw new Error('error 발생!'); | ||
return res.json(); | ||
}) | ||
.catch(console.error); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters