-
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.
Browse files
Browse the repository at this point in the history
Feat/#118
- Loading branch information
Showing
10 changed files
with
158 additions
and
15 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,19 @@ | ||
import axiosInstance from "./axiosInstance" | ||
|
||
export interface NickNameModificationResData { | ||
data: { | ||
id: 0 | ||
nickname: "string" | ||
} | ||
} | ||
|
||
export const modifyNickName = async (uid: number, newNickName: string): Promise<NickNameModificationResData> => { | ||
try { | ||
const res = await axiosInstance.put(`/users/${uid}/nickname`, { | ||
nickname: newNickName, | ||
}) | ||
return res.data | ||
} catch (e) { | ||
throw e | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,55 @@ | ||
import { ModalProps } from "@/contexts/ModalsContext" | ||
import ModalContainer from "@components/ModalContainer" | ||
import { useState } from "react" | ||
|
||
const NickNameModal = (props: ModalProps & { id: string }): React.ReactElement => { | ||
const { onClose, onSubmit } = props | ||
const [nickName, setNickName] = useState("") | ||
|
||
const onClickModifyNickNameButton = () => { | ||
if (nickName && nickName.length <= 200) { | ||
onSubmit?.(nickName) | ||
} | ||
} | ||
|
||
return ( | ||
<ModalContainer onClose={onClose}> | ||
<div className="flex flex-col items-center"> | ||
{/* header */} | ||
<div className="flex items-center"> | ||
<div className="text-xl font-bold text-zinc-900">닉네임</div> | ||
</div> | ||
|
||
<div className="flex w-full flex-col gap-1 pb-6 pt-10"> | ||
<input | ||
className={`w-full rounded-xl border border-gray-200 p-3 font-normal focus:outline-none focus:ring-2 ${ | ||
nickName.length > 200 | ||
? "border-red-500 focus:border-red-500 focus:ring-red-200" | ||
: "focus:border-blue-500 focus:ring-blue-200" | ||
}`} | ||
placeholder="닉네임을 입력해 주세요." | ||
onChange={(e) => setNickName(e.target.value)} | ||
/> | ||
<div className="mt-1 h-6"> | ||
{nickName.length > 200 && ( | ||
<span className={`text-[14px] font-semibold text-red-500 `}>닉네임은 200자를 초과할 수 없어요.</span> | ||
)} | ||
</div> | ||
</div> | ||
|
||
{/* button */} | ||
<div className="pb-10"> | ||
<button | ||
className="w-[256px] rounded-[40px] bg-[#1A75FF] px-10 py-3 text-base font-semibold text-white disabled:bg-zinc-300" | ||
onClick={onClickModifyNickNameButton} | ||
disabled={!nickName} | ||
> | ||
변경하기 | ||
</button> | ||
</div> | ||
</div> | ||
</ModalContainer> | ||
) | ||
} | ||
|
||
export default NickNameModal |
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,48 @@ | ||
import { modifyNickName } from "@/api/nickname" | ||
import { modals } from "@/components/Modal/Modals" | ||
import { useModals } from "@/hooks/useModals" | ||
import { useAuthStore } from "@/store" | ||
|
||
export default function MyPage() { | ||
const { user, setNickName } = useAuthStore() | ||
|
||
const { openModal } = useModals() | ||
|
||
const onClickModifyNickName = () => { | ||
openModal(modals.nickNameModal, { | ||
onSubmit: (newNickName) => { | ||
if (user && newNickName) { | ||
modifyNickName(user.uid, newNickName).then(({ data }) => { | ||
setNickName(data.nickname) | ||
}) | ||
} | ||
}, | ||
}) | ||
} | ||
|
||
return ( | ||
<div className="bg-gray-50 pl-[110px] pt-12"> | ||
<h1 className="text-[22px] font-bold text-zinc-900">마이 페이지</h1> | ||
<div className="flex flex-col gap-4 pt-11"> | ||
<div className="flex h-[56px] max-w-[998px] items-center justify-between rounded-xl border border-gray-200 bg-white pl-6"> | ||
<div className="flex items-center gap-6"> | ||
<div className="text-sm">닉네임</div> | ||
<div>{user?.nickname}</div> | ||
</div> | ||
<div className="pr-[27px]"> | ||
<button | ||
className="rounded-full bg-[#1A75FF] px-[22px] py-[6px] text-[13px] font-semibold text-white" | ||
onClick={onClickModifyNickName} | ||
> | ||
변경하기 | ||
</button> | ||
</div> | ||
</div> | ||
<div className="flex h-[56px] max-w-[998px] items-center gap-6 rounded-xl border border-gray-200 bg-white pl-6"> | ||
<div className="text-sm">로그인 수단</div> | ||
<div>카카오 계정</div> | ||
</div> | ||
</div> | ||
</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