-
Notifications
You must be signed in to change notification settings - Fork 1
[Feat/#69] 마이페이지 API 연결 & 글로우 표기 변경(온도) #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
0-hu
wants to merge
3
commits into
develop
Choose a base branch
from
feat/#69/MypageAPI
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file was deleted.
Oops, something went wrong.
111 changes: 111 additions & 0 deletions
111
src/app/(layout)/mypage/_components/MypageData/index.tsx
This file contains hidden or 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,111 @@ | ||
| 'use client'; | ||
|
|
||
| import { useState, useEffect, useRef } from 'react'; | ||
| import Image from 'next/image'; | ||
| import IconEdit from '@/assets/icons/icon-edit.svg'; | ||
| import IconProfilePic from '@/assets/icons/icon-profilepic.svg'; | ||
| import { usePatchUserProfileImage } from '@/hooks/user/usePatchUserProfileImage'; | ||
|
|
||
| interface MypageDataProps { | ||
| profileImage?: string; | ||
| nickname: string; | ||
| onNicknameChange: (nickname: string) => void; | ||
| isNicknameUpdating?: boolean; | ||
| } | ||
|
|
||
| export default function MypageData({ | ||
| profileImage, | ||
| nickname, | ||
| onNicknameChange, | ||
| isNicknameUpdating, | ||
| }: MypageDataProps) { | ||
| const [currentNickname, setCurrentNickname] = useState(nickname); | ||
| const { mutate: patchProfileImage, isPending: isPatchingProfileImage } = | ||
| usePatchUserProfileImage(); | ||
| const fileInputRef = useRef<HTMLInputElement>(null); | ||
|
|
||
| useEffect(() => { | ||
| setCurrentNickname(nickname); | ||
| }, [nickname]); | ||
|
|
||
| const handleNicknameInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| setCurrentNickname(e.target.value); | ||
| }; | ||
|
|
||
| const handleNicknameBlur = () => { | ||
| if (nickname !== currentNickname) { | ||
| onNicknameChange(currentNickname); | ||
| } | ||
| }; | ||
|
|
||
| const handleProfileImageEditClick = () => { | ||
| fileInputRef.current?.click(); | ||
| }; | ||
|
|
||
| const handleProfileImageChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| if (e.target.files && e.target.files[0]) { | ||
| const file = e.target.files[0]; | ||
| const formData = new FormData(); | ||
| formData.append('image', file); | ||
| patchProfileImage(formData, { | ||
| onError: (err) => { | ||
| console.error('프로필 이미지 변경 실패:', err); | ||
| }, | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="flex flex-col"> | ||
| <input | ||
| type="file" | ||
| ref={fileInputRef} | ||
| onChange={handleProfileImageChange} | ||
| accept="image/*" | ||
| style={{ display: 'none' }} | ||
| /> | ||
| <div className="flex items-end gap-4"> | ||
| <div className="bg-layout-grey2 h-[200px] w-[200px] overflow-hidden rounded-[12.5px]"> | ||
| {profileImage ? ( | ||
| <Image | ||
| src={profileImage} | ||
| alt="프로필 이미지" | ||
| width={200} | ||
| height={200} | ||
| className="h-full w-full object-cover" | ||
| /> | ||
| ) : ( | ||
| <div className="bg-layout-grey3 flex h-full w-full items-center justify-center"> | ||
| <IconProfilePic aria-label="기본 프로필 이미지" /> | ||
| </div> | ||
| )} | ||
| </div> | ||
|
|
||
| <button | ||
| type="button" | ||
| className="button-sm text-layout-grey6 flex items-center gap-1 disabled:opacity-50" | ||
| onClick={handleProfileImageEditClick} | ||
| disabled={isPatchingProfileImage} | ||
| > | ||
| <IconEdit aria-label="편집 아이콘" /> | ||
| {isPatchingProfileImage ? '업로드 중...' : '프로필 사진 수정'} | ||
| </button> | ||
| </div> | ||
|
|
||
| <div className="mt-10 flex h-[44px] w-[473px] items-center justify-between"> | ||
| <span className="button-lg text-layout-grey6">닉네임</span> | ||
| <div className="border-layout-grey5 flex h-[44px] w-[400px] items-center rounded-[6px] border px-3"> | ||
| <input | ||
| type="text" | ||
| value={currentNickname} | ||
| onChange={handleNicknameInputChange} | ||
| onBlur={handleNicknameBlur} | ||
| className="body-lg text-layout-grey7 h-full w-full bg-transparent outline-none disabled:opacity-50" | ||
| placeholder="닉네임을 입력하세요" | ||
| disabled={isNicknameUpdating} | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,76 @@ | ||
| import IconGlowScore from '@/assets/icons/icon-glow-score-big.svg'; | ||
|
|
||
| interface MypageGlowProps { | ||
| glowScore: number; | ||
| } | ||
|
|
||
| export default function MypageGlow({ glowScore }: MypageGlowProps) { | ||
| const getTemperatureStyle = (score: number) => { | ||
| // 0~100 범위로 제한 | ||
| const limitedScore = Math.min(Math.max(score, 0), 100); | ||
|
|
||
| if (limitedScore >= 90) { | ||
| return { | ||
| background: '#16135B', // purple7 | ||
| text: '#F0EFFA', | ||
| label: '셰익스피어, 시대를 초월한 문장의 마술사', | ||
| }; | ||
| } else if (limitedScore >= 75) { | ||
| return { | ||
| background: '#403AC0', // purple5 | ||
| text: '#F0EFFA', | ||
| label: '헤밍웨이, 간결하고 힘있는 문장의 대가', | ||
| }; | ||
| } else if (limitedScore >= 60) { | ||
| return { | ||
| background: '#7D76FA', // purple4 | ||
| text: '#F0EFFA', | ||
| label: '무라카미, 독특한 문체로 매력을 전하는 작가', | ||
| }; | ||
| } else if (limitedScore >= 45) { | ||
| return { | ||
| background: '#B3B0F9', // purple3 | ||
| text: '#161184', | ||
| label: '에세이스트, 일상의 감성을 글로 표현하는 작가', | ||
| }; | ||
| } else if (limitedScore >= 30) { | ||
| return { | ||
| background: '#E2E0FB', // purple2 | ||
| text: '#161184', | ||
| label: '필사가, 꾸준한 글쓰기로 성장하는 중', | ||
| }; | ||
| } else { | ||
| return { | ||
| background: '#F0EFFA', // purple1 | ||
| text: '#161184', | ||
| label: '새싹, 글쓰기를 시작하는 첫 걸음', | ||
| }; | ||
| } | ||
| }; | ||
|
|
||
| const style = getTemperatureStyle(glowScore); | ||
|
|
||
| return ( | ||
| <div className="bg-layout-grey1 h-[145px] w-[473px] rounded-[6px] p-4"> | ||
| <div className="flex flex-col"> | ||
| <div className="flex items-center gap-3"> | ||
| <IconGlowScore aria-label="글로우 점수 아이콘" /> | ||
| <div className={`rounded-full px-3 py-1`} style={{ backgroundColor: style.background }}> | ||
| <span className="button-lg" style={{ color: style.text }}> | ||
| {glowScore.toFixed(1)}℃ | ||
| </span> | ||
| </div> | ||
| <span className="detail text-layout-grey5">{style.label}</span> | ||
| </div> | ||
|
|
||
| <p className="detail text-layout-grey6 mt-2"> | ||
| 온도(글로우)는 나의 활동, 받은 좋아요 수 등을 통해 계산됩니다. | ||
| </p> | ||
|
|
||
| <div className="mt-4"> | ||
| <p className="button-lg text-layout-grey6">나의 템플릿 작성 내역</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p1) 닉네임 변경하면 로컬스토리지에도 반영하도록 해 주세요!
그리고 이건 디자인 이슈긴 한데 닉네임 변경 버튼이 따로 있어야 할 것 같아요!