-
Notifications
You must be signed in to change notification settings - Fork 4
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
[ Fix ] 온보딩 완료 후 이탈한 선배 대비 SENIOR_PENDING 추가 반영 #357
base: develop
Are you sure you want to change the base?
Changes from 8 commits
0d83653
234aa59
f6e8896
51fc154
0e7adf5
e61f1e5
ac9abb6
3b52a73
d6666d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,19 +14,20 @@ import { SENIOR_PROFILE_STEPS } from './constants'; | |
import { Header } from '../../components/commons/Header'; | ||
import ProgressBar from '../../components/commons/ProgressBar'; | ||
import theme from '../../styles/theme'; | ||
import { useLocation, useNavigate } from 'react-router-dom'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { getSeniorNickname } from '@utils/storage'; | ||
|
||
const SeniorProfilePage = () => { | ||
const [step, setStep] = useState(0); | ||
const [profile, setProfile] = useState<seniorProfileRegisterType>(seniorProfileInitial); | ||
const location = useLocation(); | ||
|
||
const navigate = useNavigate(); | ||
const { seniorId, nickname } = location.state || {}; | ||
const nickname = getSeniorNickname(); | ||
const userName = step >= 2 && step <= 4 ? nickname : ''; | ||
|
||
useEffect(() => { | ||
if (!seniorId || !nickname) navigate('/'); | ||
}, [seniorId, nickname, navigate]); | ||
if (!nickname) navigate('/'); | ||
}, [nickname]); | ||
|
||
const getComponent = () => { | ||
switch (step) { | ||
|
@@ -43,7 +44,7 @@ const SeniorProfilePage = () => { | |
case 5: | ||
return <TimeSelect profile={profile} setProfile={setProfile} setStep={setStep} />; | ||
case 6: | ||
return <PreView setStep={setStep} profile={profile} seniorId={seniorId} />; | ||
return <PreView setStep={setStep} profile={profile} seniorId="" />; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 헉 오케이 확인이요! |
||
case 7: | ||
return <Complete />; | ||
default: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import { dayOfWeekTimeList, seniorProfileRegisterType } from '@pages/seniorProfi | |
import { deleteProfileField } from '@pages/seniorProfile/utils/deleteProfileField'; | ||
import { weekToDay } from '@pages/seniorProfile/utils/weekToDay'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { setRole } from '@utils/storage'; | ||
|
||
interface preViewPropType { | ||
seniorId: string; | ||
|
@@ -25,20 +26,30 @@ interface preViewPropType { | |
} | ||
|
||
const PreView = ({ seniorId, profile, setStep, variant = 'default' }: preViewPropType) => { | ||
const { data: cardData, error: cardDataError, isLoading: isCardDataLoading } = useSeniorCardQuery(seniorId); | ||
// 선배 카드 정보 조회 (온보딩 정보) | ||
const { | ||
data: cardData, | ||
error: cardDataError, | ||
isLoading: isCardDataLoading, | ||
} = useSeniorCardQuery(seniorId, variant === 'secondary'); | ||
// 선배 상세 프로필 조회 (프로필 정보) | ||
const { | ||
data: profileData, | ||
error: profileDataError, | ||
isLoading: isProfileDataLoading, | ||
} = useGetSeniorProfileQuery(seniorId); | ||
} = useGetSeniorProfileQuery(seniorId, variant === 'secondary'); | ||
// 선배 선호 시간대 조회 | ||
const { | ||
data: secondaryPreferredTimeList, | ||
isError: secondTimeListError, | ||
isLoading: isSecondTimeListLoading, | ||
} = useSeniorTimeQuery(+seniorId); | ||
} = useSeniorTimeQuery(+seniorId, variant === 'secondary'); | ||
|
||
const navigate = useNavigate(); | ||
const isRegister = variant === 'default'; | ||
|
||
// profile : 선배가 프로필 등록할 때 넘어온 값 | ||
// profileData : 이미 가입된 선배의 서버값 (후배가 카드 클릭시 받아오는 값) | ||
const career = (isRegister ? profile?.career : profileData?.career) + ''; | ||
const award = (isRegister ? profile?.award : profileData?.award) + ''; | ||
const catchphrase = (isRegister ? profile?.catchphrase : profileData?.catchphrase) + ''; | ||
|
@@ -47,6 +58,7 @@ const PreView = ({ seniorId, profile, setStep, variant = 'default' }: preViewPro | |
isRegister ? profile && weekToDay(profile.isDayOfWeek, profile.preferredTimeList) : secondaryPreferredTimeList | ||
) as dayOfWeekTimeList; | ||
|
||
// 선배 프로필 등록 | ||
const mutation = useSeniorProfileHook(); | ||
const handleRegisterClick = () => { | ||
mutation.mutate( | ||
|
@@ -60,6 +72,11 @@ const PreView = ({ seniorId, profile, setStep, variant = 'default' }: preViewPro | |
{ | ||
onSuccess: () => { | ||
setStep && setStep((prev) => prev + 1); | ||
// 온보딩 + 프로필 등록 완료 | ||
// 선배 role SENIOR_PENDING -> SENIOR로 변경 | ||
// 선배 닉네임 local storage에서 제거 | ||
setRole('SENIOR'); | ||
localStorage.removeItem('seniorNickname'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p3) localStorage removeItem 함수도 utils storage에 함께 분리시켜주면 좋을 것 같아요/! |
||
}, | ||
} | ||
); | ||
|
@@ -69,7 +86,7 @@ const PreView = ({ seniorId, profile, setStep, variant = 'default' }: preViewPro | |
cardDataError || | ||
(!isRegister && profileDataError) || | ||
(!isRegister && secondTimeListError) || | ||
(!isCardDataLoading && !cardData) || | ||
(!isRegister && !isCardDataLoading && !cardData) || | ||
(!isRegister && !isProfileDataLoading && !profileData) || | ||
(!isRegister && !isSecondTimeListLoading && !secondaryPreferredTimeList) | ||
) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { getSeniorProfileAxios } from "@pages/seniorProfile/apis/getSeniorProfileAxios"; | ||
import { SeniorProfileAPIResType } from "@pages/seniorProfile/types"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { getSeniorProfileAxios } from '@pages/seniorProfile/apis/getSeniorProfileAxios'; | ||
import { SeniorProfileAPIResType } from '@pages/seniorProfile/types'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export const useGetSeniorProfileQuery = (seniorId: string) => { | ||
export const useGetSeniorProfileQuery = (seniorId: string, isJuniorRequest: boolean) => { | ||
return useQuery<SeniorProfileAPIResType, Error>({ | ||
queryKey: ['seniorProfile', seniorId], | ||
queryFn: () => getSeniorProfileAxios(seniorId).then(response => response.data.data), | ||
}) | ||
queryFn: () => getSeniorProfileAxios(seniorId).then((response) => response.data.data), | ||
enabled: !!isJuniorRequest, | ||
}); | ||
}; | ||
|
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.
헉 제 PR에도 이 부분 적용했었는데 제 PR 먼저 머지하고 컨플릭잡을 때 언니 파일 우선으로 해서 머지하면 좋을 것 같앙요!!