-
Notifications
You must be signed in to change notification settings - Fork 5
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
[FE] 마이페이지 기능 고도화 및 행사 이름 변경 기능 구현 #869
Changes from 9 commits
5ac3ece
69ed50c
d773e69
b6bbe8f
504b0e4
4e75e69
2b8fd37
dff22e1
3e1e4ad
db297a7
7024812
341e0d6
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {useSuspenseQuery} from '@tanstack/react-query'; | ||
|
||
import {requestGetUserInfo} from '@apis/request/auth'; | ||
|
||
import QUERY_KEYS from '@constants/queryKeys'; | ||
|
||
const useRequestSuspenseGetUserInfo = () => { | ||
const {data, ...rest} = useSuspenseQuery({ | ||
queryKey: [QUERY_KEYS.userInfo], | ||
queryFn: () => requestGetUserInfo(), | ||
}); | ||
|
||
const userInfo = { | ||
isGuest: data.isGuest, | ||
nickname: data.nickname, | ||
profileImage: data.profileImage, | ||
accountNumber: data.accountNumber, | ||
bankName: data.bankName, | ||
}; | ||
|
||
return { | ||
userInfo, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useRequestSuspenseGetUserInfo; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,10 @@ const AdminPage = () => { | |
navigate(`/event/${eventId}/admin/edit-account`, {state: {accountNumber, bankName}}); | ||
}; | ||
|
||
const navigateEditEventName = () => { | ||
navigate(`/event/${eventId}/admin/edit-event-name`, {state: eventName}); | ||
}; | ||
|
||
const navigateEventMemberManage = () => { | ||
navigate(`/event/${eventId}/admin/members`); | ||
}; | ||
|
@@ -52,6 +56,7 @@ const AdminPage = () => { | |
amount={totalExpenseAmount} | ||
dropdown={ | ||
<Dropdown> | ||
<DropdownButton text="행사 이름 변경" onClick={navigateEditEventName} /> | ||
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. 예전부터 제가 바라던 기능 드디어 생겨서 너무 좋네여..!👍🏻 |
||
<DropdownButton text="전체 참여자 관리" onClick={navigateEventMemberManage} /> | ||
<DropdownButton text="계좌번호 입력하기" onClick={navigateAccountInputPage} /> | ||
<DropdownButton text="사진 첨부하기" onClick={navigateAddImages} /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import {useLocation, useNavigate} from 'react-router-dom'; | |
|
||
import BankSelectModal from '@components/Modal/BankSelectModal/BankSelectModal'; | ||
|
||
import useAccount from '@hooks/useAccount'; | ||
import useEventAccount from '@hooks/useEventAccount'; | ||
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. 혹시 EventAccount로 이름을 바꾼 이유가 무엇인가요? 아마 제가 수정한 부분과 충돌할 것 같아서..! 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. 계좌 번호 수정이 행사 단계와 유저 단계 두 가지가 있잖아요! 저는 재사용을 생각하지 않고 새로 훅을 만들 것이라 생각하여 useEventAccount라는 행사계좌번호 수정이라는 훅으로 이름을 바꿨어요. |
||
|
||
import {FixedButton, Flex, FunnelLayout, Input, MainLayout, Top, TopNav} from '@components/Design'; | ||
|
||
|
@@ -24,7 +24,7 @@ const EditAccountPage = () => { | |
handleAccount, | ||
handleAccountOnPaste, | ||
enrollAccount, | ||
} = useAccount(); | ||
} = useEventAccount(); | ||
|
||
const enrollAccountAndNavigateAdmin = async () => { | ||
await enrollAccount(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import {useLocation, useNavigate} from 'react-router-dom'; | ||
import {useEffect} from 'react'; | ||
|
||
import useSetEventNameStep from '@hooks/createEvent/useSetEventNameStep'; | ||
import useRequestPatchEvent from '@hooks/queries/event/useRequestPatchEvent'; | ||
import {EventName} from 'types/serviceType'; | ||
|
||
import {FixedButton, FunnelLayout, Input, MainLayout, Top, TopNav} from '@components/Design'; | ||
|
||
import getEventBaseUrl from '@utils/getEventBaseUrl'; | ||
|
||
const EditEventNamePage = () => { | ||
const location = useLocation(); | ||
const locationState = location.state as EventName | null; | ||
console.log(locationState); | ||
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. 콘솔 로그는 지워주세용! |
||
|
||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
if (locationState === null) { | ||
navigate(-1); | ||
} | ||
}, [locationState]); | ||
|
||
const {eventName, errorMessage, canSubmit, handleEventNameChange} = useSetEventNameStep(locationState ?? ''); | ||
const {patchEvent} = useRequestPatchEvent(); | ||
|
||
const disabled = !canSubmit || eventName === locationState; | ||
|
||
const onSubmit = async (event: React.FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
|
||
await patchEvent({eventName}); | ||
navigate(`/${getEventBaseUrl(location.pathname)}/admin`); | ||
}; | ||
|
||
return ( | ||
<MainLayout backgroundColor="white"> | ||
<TopNav> | ||
<TopNav.Item displayName="뒤로가기" noEmphasis routePath="-1" /> | ||
</TopNav> | ||
<FunnelLayout> | ||
<Top> | ||
<Top.Line text="변경하려는" /> | ||
<Top.Line text="행사의 이름은 무엇인가요?" emphasize={['행사의 이름']} /> | ||
</Top> | ||
<form onSubmit={event => onSubmit(event)}> | ||
<Input | ||
labelText="행사 이름" | ||
errorText={errorMessage ?? ''} | ||
value={eventName} | ||
type="text" | ||
placeholder="행동대장 야유회" | ||
onChange={handleEventNameChange} | ||
isError={!!errorMessage} | ||
autoFocus | ||
/> | ||
<FixedButton disabled={disabled}>변경완료</FixedButton> | ||
</form> | ||
</FunnelLayout> | ||
</MainLayout> | ||
); | ||
}; | ||
|
||
export default EditEventNamePage; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {useNavigate} from 'react-router-dom'; | ||
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. 오 좋은데요! path로 들어올 수도 있긴 하니까요 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. 이 경우는 쿠키가 없을 때 마이페이지를 접근한 경우에 대한 에러 처리 입니다! path로 들어와도 쿠키가 있으면 정상적으로 접근할 수 있어야 한다고 생각해요 |
||
|
||
import Image from '@components/Design/components/Image/Image'; | ||
|
||
import {Button, Flex, Text} from '@components/Design'; | ||
|
||
import getImageUrl from '@utils/getImageUrl'; | ||
|
||
const MyPageError = () => { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<Flex flexDirection="column" justifyContent="center" alignItems="center" gap="1.5rem"> | ||
<Image src={getImageUrl('cryingDog', 'webp')} fallbackSrc={getImageUrl('cryingDog', 'png')} width={200} /> | ||
<Text | ||
size="bodyBold" | ||
css={{whiteSpace: 'pre-line', textAlign: 'center'}} | ||
>{`로그인 후\n사용할 수 있는 서비스입니다.`}</Text> | ||
<Button onClick={() => navigate(-1)}>이전으로 돌아가기</Button> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default MyPageError; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Image from '@components/Design/components/Image/Image'; | ||
|
||
import {Flex, Text} from '@components/Design'; | ||
|
||
import getImageUrl from '@utils/getImageUrl'; | ||
|
||
const MyPageLoading = () => { | ||
return ( | ||
<Flex flexDirection="column" justifyContent="center" alignItems="center" gap="1.5rem"> | ||
<Image src={getImageUrl('runningDog', 'webp')} fallbackSrc={getImageUrl('runningDog', 'png')} width={200} /> | ||
<Text | ||
size="bodyBold" | ||
css={{whiteSpace: 'pre-line', textAlign: 'center'}} | ||
>{`로딩중입니다.\n 잠시만 기다려주세요.`}</Text> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default MyPageLoading; |
This file was deleted.
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.
호오~~ 그러네요!! 감사합니다!