-
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] 마이페이지에서 자신의 기본 계좌 번호 수정 기능 추가 #880
Changes from 38 commits
cd4d385
b8534ad
95c202e
cd05817
f266747
5940a0a
9f935b8
7639328
ed80902
0b3310a
b222f04
574258a
3e98142
f5fd29b
bbba225
b07b6df
d6f0d14
2ac74e0
be415bd
566f210
9bc1eec
e0e5f67
276047b
3f6c685
1d6bd84
71cf6bf
7341ed5
7975f20
f7209e1
5f3def2
cd959b9
9aadcee
a995b93
d39f8ed
770bcdf
7bab2cb
f7c47d5
aff607f
baed7e1
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// TODO: (@weadie) 반복되서 쓰이는 이 api/events가 추후 수정 가능성이 있어서 일단 편집하기 편하게 이 변수를 재사용하도록 했습니다. | ||
export const USER_API_PREFIX = '/api/events'; | ||
export const MEMBER_API_PREFIX = '/api/events'; | ||
export const ADMIN_API_PREFIX = '/api/admin/events'; | ||
export const MEMBER_API_PREFIX = '/api/users'; | ||
export const USER_API_PREFIX = '/api/users'; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
import {User} from 'types/serviceType'; | ||
import {User, UserInfo} from 'types/serviceType'; | ||
|
||
import {BASE_URL} from '@apis/baseUrl'; | ||
import {MEMBER_API_PREFIX} from '@apis/endpointPrefix'; | ||
import {requestDelete} from '@apis/fetcher'; | ||
import {requestGet} from '@apis/fetcher'; | ||
import {USER_API_PREFIX} from '@apis/endpointPrefix'; | ||
import {requestDelete, requestPatchWithoutResponse} from '@apis/request'; | ||
import {requestGet} from '@apis/request'; | ||
|
||
export const requestDeleteUser = async () => { | ||
await requestDelete({ | ||
baseUrl: BASE_URL.HD, | ||
endpoint: `${MEMBER_API_PREFIX}`, | ||
endpoint: USER_API_PREFIX, | ||
}); | ||
}; | ||
|
||
export const requestGetUserInfo = async () => { | ||
return await requestGet<User>({ | ||
return await requestGet<UserInfo>({ | ||
baseUrl: BASE_URL.HD, | ||
endpoint: `/api/users/mine`, | ||
endpoint: `${USER_API_PREFIX}/mine`, | ||
errorHandlingStrategy: 'unsubscribe', | ||
}); | ||
}; | ||
|
||
export type RequestPatchUser = Partial<User>; | ||
|
||
export const requestPatchUser = async (args: RequestPatchUser) => { | ||
await requestPatchWithoutResponse({ | ||
endpoint: USER_API_PREFIX, | ||
body: { | ||
...args, | ||
}, | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import {useState} from 'react'; | ||
import {useNavigate} from 'react-router-dom'; | ||
|
||
import BankSelectModal from '@components/Modal/BankSelectModal/BankSelectModal'; | ||
import {BankAccount, BankName} from 'types/serviceType'; | ||
|
||
import useAccount from '@hooks/useAccount'; | ||
|
||
import {FixedButton, Flex, FunnelLayout, Input, MainLayout, Top, TopNav} from '@components/Design'; | ||
|
||
type EditAccountPageProps = { | ||
bankName: BankName; | ||
accountNumber: string; | ||
onSubmit: (args: Partial<BankAccount>) => Promise<void>; | ||
redirectUrlOnSubmit: string; | ||
}; | ||
|
||
const EditAccountPageView = ({ | ||
bankName: defaultBankName, | ||
accountNumber: defaultAccountNumber, | ||
onSubmit, | ||
redirectUrlOnSubmit, | ||
}: EditAccountPageProps) => { | ||
const navigate = useNavigate(); | ||
|
||
const [isBottomSheetOpen, setIsBottomSheetOpen] = useState(false); | ||
|
||
const { | ||
bankName, | ||
accountNumber, | ||
accountNumberErrorMessage, | ||
canSubmit, | ||
selectBank, | ||
handleAccountOnTyping, | ||
handleAccountOnPaste, | ||
enrollAccount, | ||
} = useAccount({ | ||
bankName: defaultBankName, | ||
accountNumber: defaultAccountNumber, | ||
onSubmit, | ||
}); | ||
|
||
const enrollAccountAndRedirectTo = async () => { | ||
await enrollAccount(); | ||
|
||
navigate(redirectUrlOnSubmit); | ||
Comment on lines
+44
to
+46
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. 이 부분에서 await을 해줘서 이전 데이터가 보이는 문제를 해결했다는 거죠? 좋습니다. 사진을 보면 mutate async, await과 onSuccess의 경우 함수가 실행되어 요청을 기다린 후 onSuccess가 호출된 후 navigate하는 모습을 보여줬어요. 하지만 mutate와 onSuccess의 경우 함수가 실행되어 navigate하게 되어 함수가 종료된 후 onSuccess가 실행되는 모습을 확인할 수 있었어요. 이 부분에서 일어난 오류가 아니었을까.. 예상합니다 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. 해결되었으니 다행이에요~ |
||
}; | ||
|
||
return ( | ||
<MainLayout backgroundColor="white"> | ||
<TopNav> | ||
<TopNav.Item displayName="뒤로가기" noEmphasis routePath="-1" /> | ||
</TopNav> | ||
<FunnelLayout> | ||
<Top> | ||
<Top.Line text="행사 정산 금액은" /> | ||
<Top.Line text="어떤 계좌로 받을까요?" emphasize={['어떤 계좌']} /> | ||
</Top> | ||
<Flex flexDirection="column" gap="1rem"> | ||
<Input | ||
labelText="은행" | ||
placeholder="은행을 선택해주세요" | ||
value={bankName ?? ''} | ||
errorText={null} | ||
autoFocus={false} | ||
readOnly | ||
onClick={() => setIsBottomSheetOpen(true)} | ||
/> | ||
<Input | ||
labelText="계좌번호" | ||
placeholder="ex) 030302-04-191806" | ||
errorText={accountNumberErrorMessage} | ||
isError={accountNumberErrorMessage !== null} | ||
value={accountNumber ?? ''} | ||
onChange={handleAccountOnTyping} | ||
onPaste={handleAccountOnPaste} | ||
autoFocus={false} | ||
/> | ||
{isBottomSheetOpen && ( | ||
<BankSelectModal | ||
isBottomSheetOpened={isBottomSheetOpen} | ||
setIsBottomSheetOpened={setIsBottomSheetOpen} | ||
selectBank={selectBank} | ||
/> | ||
)} | ||
</Flex> | ||
</FunnelLayout> | ||
<FixedButton disabled={!canSubmit} onClick={enrollAccountAndRedirectTo} onBackClick={() => navigate(-1)}> | ||
확인 | ||
</FixedButton> | ||
</MainLayout> | ||
); | ||
}; | ||
|
||
export default EditAccountPageView; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {Outlet} from 'react-router-dom'; | ||
|
||
import useEventPageLoader from '@hooks/useEventPageLoader'; | ||
|
||
import EventDataProvider from './EventDataProvider'; | ||
|
||
const EventDataLoader = () => { | ||
const eventData = useEventPageLoader(); | ||
|
||
return ( | ||
<EventDataProvider {...eventData}> | ||
<Outlet /> | ||
</EventDataProvider> | ||
); | ||
}; | ||
|
||
export default EventDataLoader; |
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.
이 부분은 merge할 때 다른 pr로 인해 사라졌는지? 잘 확인해야 할 것 같네요!