-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/etc-apply
- Loading branch information
Showing
12 changed files
with
162 additions
and
48 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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,19 @@ | ||
import ErrorIcon from '@/assets/icon/errorIcon.svg?react'; | ||
import BackButton from '../commons/BackButton'; | ||
|
||
const ErrorPage = () => { | ||
return ( | ||
<section className="flex-1 w-full flex flex-col gap-[32px] p-horizontal"> | ||
<BackButton /> | ||
<h1 className="font-bold text-header px-3"> | ||
요청하신 페이지를 찾는 중 <br /> | ||
오류가 발생했습니다. | ||
</h1> | ||
<div className="absolute bottom-0 w-full left-1/2 transform -translate-x-1/2"> | ||
<ErrorIcon className="w-full h-auto" /> | ||
</div> | ||
</section> | ||
); | ||
}; | ||
|
||
export default ErrorPage; |
This file contains 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,83 @@ | ||
import Modal from '@/components/modal'; | ||
import Button from '../commons/Button'; | ||
import { useModal } from '@/contexts/ModalContext'; | ||
import Input from '../commons/Input'; | ||
import useUserStore from '@/store/useUserStore'; | ||
import { z } from 'zod'; | ||
import { accountNumberVerificationSchema } from '@/libs/schemas/auth'; | ||
import { AccountNumberVerificationTypes } from 'gachTaxi-types'; | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { useForm, SubmitHandler, useWatch } from 'react-hook-form'; | ||
import { useToast } from '@/contexts/ToastContext'; | ||
import handleAxiosError from '@/libs/apis/axiosError.api'; | ||
import { getAccountNumber } from '@/libs/apis/getAccountNumber.api'; | ||
|
||
const AccountNumberModal = () => { | ||
const { closeModal } = useModal(); | ||
|
||
const { user } = useUserStore(); | ||
|
||
const profileForm = useForm<z.infer<typeof accountNumberVerificationSchema>>({ | ||
resolver: zodResolver(accountNumberVerificationSchema), | ||
defaultValues: { | ||
accountNumber: user?.accountNumber || '', | ||
}, | ||
mode: 'onSubmit', | ||
}); | ||
const { setUser } = useUserStore(); | ||
const { openToast } = useToast(); | ||
const accountNumber = useWatch({ | ||
control: profileForm.control, | ||
name: 'accountNumber', | ||
}); | ||
|
||
const handleSubmitChange: SubmitHandler< | ||
AccountNumberVerificationTypes | ||
> = async () => { | ||
try { | ||
const updateData = profileForm.getValues(); | ||
|
||
const res = await getAccountNumber(updateData); | ||
if (res?.code === 200) { | ||
const userData = res?.data; | ||
setUser(userData); | ||
openToast(res.message, 'success'); | ||
closeModal(); | ||
} | ||
} catch (error) { | ||
const errorMessage = handleAxiosError(error); | ||
openToast(errorMessage, 'error'); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Modal.Header className="font-bold text-header mt-4 px-3"> | ||
계좌번호 | ||
</Modal.Header> | ||
<Modal.Content className="font-medium text-captionHeader text-textDarkGray"> | ||
<form | ||
className="flex flex-col gap-2 w-full" | ||
onSubmit={profileForm.handleSubmit( | ||
handleSubmitChange as SubmitHandler< | ||
z.infer<typeof accountNumberVerificationSchema> | ||
>, | ||
)} | ||
> | ||
<Input | ||
control={profileForm.control} | ||
name="accountNumber" | ||
placeholder="계좌번호를 입력해주세요" | ||
type="text" | ||
/> | ||
|
||
<Button type="submit" className="w-full mt-8"> | ||
{accountNumber ? '변경하기' : '확인'} | ||
</Button> | ||
</form> | ||
</Modal.Content> | ||
</> | ||
); | ||
}; | ||
|
||
export default AccountNumberModal; |
This file contains 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
This file contains 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
This file contains 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,13 @@ | ||
import client from './clients'; | ||
import { AccountNumberVerificationTypes } from 'gachTaxi-types'; | ||
|
||
export const getAccountNumber = async ( | ||
data: AccountNumberVerificationTypes, | ||
) => { | ||
try { | ||
const res = await client.post('/api/accounts', data); | ||
return res.data; | ||
} catch (error) { | ||
console.log('프로필 업데이트 실패', error); | ||
} | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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