-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
153 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use client' | ||
|
||
// Error components must be Client Components | ||
import { useEffect } from 'react' | ||
|
||
export default function Error({ | ||
error, | ||
reset, | ||
}: { | ||
error: Error & { digest?: string } | ||
reset: () => void | ||
}) { | ||
useEffect(() => { | ||
// Log the error to an error reporting service | ||
console.error(error) | ||
}, [error]) | ||
|
||
return ( | ||
<div> | ||
<h2>Something went wrong!</h2> | ||
<button | ||
onClick={ | ||
// Attempt to recover by trying to re-render the segment | ||
() => reset() | ||
} | ||
> | ||
Try again | ||
</button> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
import UserInfo from './section/UserInfo' | ||
|
||
const MyPage = () => { | ||
return ( | ||
<main className="flex flex-col items-center gap-5 mt-5"> | ||
<header> | ||
<h1>마이페이지</h1> | ||
</header> | ||
<section> | ||
<UserInfo /> | ||
</section> | ||
<section>{/* TODO: 각 내용에 대한 라우팅 추가 */}</section> | ||
</main> | ||
) | ||
} | ||
|
||
export default MyPage |
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 React, { useState } from 'react' | ||
import AvatarEditable from '@/components/domain/AvatarEditable' | ||
import { putUserProfile } from '@/services/user/user' | ||
|
||
const UserInfo = () => { | ||
const [isProfileChanged, setIsProfileChanged] = useState(true) | ||
const [isNicknameChanged, setIsNicknameChanged] = useState(true) | ||
|
||
const fileChangeHandler = async (file: File) => { | ||
setIsProfileChanged(true) | ||
try { | ||
const _data = await putUserProfile({ file: file }) | ||
} catch (error) { | ||
setIsProfileChanged(false) | ||
console.log(error) | ||
// TODO: toast error message 추가 | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
<AvatarEditable | ||
fileChangeHandler={fileChangeHandler} | ||
changedSuccessfully={isProfileChanged} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default UserInfo |
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
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,27 @@ | ||
import { rest } from 'msw' | ||
import ApiEndPoint from '@/config/apiEndPoint' | ||
import { Environment } from '@/config/environment' | ||
|
||
const baseUrl = Environment.apiAddress() | ||
|
||
const userHandlers = [ | ||
rest.put( | ||
`${baseUrl}${ApiEndPoint.putUserProfile()}`, | ||
async (_req, res, ctx) => { | ||
return res( | ||
ctx.status(200), | ||
ctx.json({ | ||
data: { | ||
userInfo: { | ||
userId: 1, | ||
nickname: '귀염둥이파김치', | ||
profileUrl: 'xxx', | ||
}, | ||
}, | ||
}), | ||
) | ||
}, | ||
), | ||
] | ||
|
||
export { userHandlers } |
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,23 @@ | ||
import ApiEndPoint from '@/config/apiEndPoint' | ||
import apiClient from '../apiClient' | ||
|
||
type putUserProfileReq = { | ||
file: File | ||
} | ||
|
||
const putUserProfile = async ({ file }: putUserProfileReq) => { | ||
const formData = new FormData() | ||
formData.append('profile', file) | ||
const response = await apiClient.put( | ||
ApiEndPoint.putUserProfile(), | ||
formData, | ||
{}, | ||
{ | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
) | ||
console.log(response) | ||
return response | ||
} | ||
|
||
export { putUserProfile } |