-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
- App.tsx에 path 문제 수정 - PortfoliosPage 구현 - ProfileEditPage 구현
fe/src/pages/PortfoliosPage.tsx
Outdated
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.
말씀하신대로 컴포넌트로 만들어서 watchlist 표도 적용하면 좋을 것 같네요 👍
fe/src/pages/ProfileEditPage.tsx
Outdated
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.
이전 프로젝트에서 프로필 사진 관련한 훅을 만들어놔서 재사용해도 좋을 것 같네요
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.
이전 프로젝트에서 hook으로 따로 만드셨군요.
저는 이전 프로젝트에서 그냥 프로필을 클릭하면 업로더가 나오는 하나의 버튼을 component로 만들었어서 그냥 그 부분 내용을 가져왔네요.
custom hook을 만들면 꼭 프로필이 아니더라도 이미지를 업로드하는데 재사용 가능한 hook 만들 수 있을 것 같습니다.
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.
추후에 리팩토링하며 만들어 놓겠습니다!
fe/src/pages/MyProfilePage.tsx
Outdated
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.
pages/ProfilePage/
안에 MyProfilePage.tsx
, PortfoliosSection.tsx
, ProfileEditSection.tsx
형태로 파일이 정리되면 구조를 파악하기 훨씬 쉬울 것 같습니다👍
fe/src/pages/MyProfilePage.tsx
Outdated
const { section } = useParams(); | ||
const [selectedSection, setSelectedSection] = useState(section || "edit"); | ||
|
||
const onChange = (_: React.MouseEvent<HTMLElement>, section: string) => { |
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.
onSectionChange
가 좋을 것 같습니다
fe/src/pages/PortfoliosPage.tsx
Outdated
type Props = { portfolio: Portfolio }; | ||
|
||
function PortfolioItem({ portfolio }: Props) { | ||
const onClickPortfolio = () => { |
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.
on
+ Target/Subject
+ Event
형태로 handler 네이밍하는거 어떠신가요?
fe/src/pages/ProfileEditPage.tsx
Outdated
export default function ProfileEditPage() { | ||
// TODO : isCheckedNickname state를 이용해 닉네임 중복 체크 여부를 화면에 css color 또는 icon으로 표시 | ||
|
||
const [isCheckedNickname, setIsCheckedNickname] = useState(false); |
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.
전 isNicknameChecked
이 더 잘 읽히는 것 같습니다
fe/src/pages/ProfileEditPage.tsx
Outdated
const [profileImg, setProfileImg] = useState<String | undefined>(SAMPLE_IMG); | ||
|
||
const nickname = useText({ | ||
initialValue: "", |
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.
useText
에서 기본으로 ""
이기 때문에 initialValue
를 인자로 안넣으셔도 됩니다
fe/src/pages/ProfileEditPage.tsx
Outdated
const onSaveProfile = () => { | ||
// TODO : api 추가 예정 | ||
|
||
if (!imgFile) return; | ||
|
||
console.log(imgFile); | ||
}; | ||
|
||
const onNicknameCheck = () => { |
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.
on
+ Event/Action
+ Target/Subject
로 할지,
아니면 on
+ Target/Subject
+ Event/Action
으로 할지 정하면 좋을 것 같습니다 👍
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.
on
+ Target/Subject
+ Event/Action
으로 통일 하도록 노력해 보겠습니다!
fe/src/pages/ProfileEditPage.tsx
Outdated
}; | ||
|
||
return ( | ||
<ProfileEdit> |
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.
styled-components docs 예시에도 그렇고, 전 주로 최상단의 태그를 해당 함수에 Styled
를 prefix로 주고 있는데 어떻게 생각하시나요? 이렇게 통일하면 파악이 빨라지는 것 같습니다
Ex: 컴포넌트 이름이 ProfileEditPage
이면, styled components으로 StyledProfileEditPage
.
|
export default function MyProfilePage() { | ||
const navigate = useNavigate(); | ||
const { section } = useParams(); | ||
const [selectedSection, setSelectedSection] = useState(section || "edit"); |
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.
시도해보지는 않아서 될지 잘 모르겠지만, 아래처럼 useState
을 제거하고도 가능하지 않을까요?
const { section = "portfolios" } = useParams(); // 기본을 "portfolios" section으로 (혹시 다른 곳에서 "/portfolio/portfolios"간 아닌 "/portfolio"로 이동했을 시)
const onSectionChange = (
_: MouseEvent<HTMLElement>,
newSection: string
) => {
navigate(`${Routes.PROFILE}/${newSection}`);
}
return (
<ToggleButtonGroup value={section} onChange={onSectionChange}>
// ...
</ToggleButtonGroup>
);
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.
우선 카카모토비가 작성해 주신 코드를 사용하면 state 없이 동작이 가능 합니다!
혹시 다른 곳에서 "/portfolio/portfolios"가 아닌 "/portfolio"로 이동했을 시
위 로직을 처리하려면 route에서 따로 리다이렉트를 시키든,
MyProfilePage
컴포넌트에서 section이 비어 있는 경우 /profile/portfolios
로 리다이렉트 시키는 방법이 필요 할 것 같습니다.
추가
route에서 이미 걸러지기 때문에 route에서 리다이렉트 시켜야 할 것 같네요.
ex)
<Route
path={Routes.PROFILE}
element={<Navigate to={`${Routes.PROFILE}/${Routes.PORTFOLIOS}`} />}
/>
<Route
path={`${Routes.PROFILE}/:section`}
element={<MyProfilePage />}
/>
- 불필요한 state 제거 - MyProfilePage에 section 없이 이동시 portfoliosPage로 리다이렉트
구현한 것
이미지
내 프로필
내 포트폴리오
ToReviewers
프로필 삭제, 저장 로직
내 프로필 변경의 구조
테이블 컴포넌트