Skip to content
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: 에러를 쓰고있는쪽에서 변경된 error interface에 맞지 않는 문제 대응 #229

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@bcsdlab/koin": "^0.0.15",
"@hookform/resolvers": "^3.1.0",
"@tanstack/react-query": "^5.8.1",
"@testing-library/jest-dom": "^5.14.1",
Expand Down
33 changes: 24 additions & 9 deletions src/page/Auth/Signup/component/ErrorMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,31 @@ import { ReactComponent as Warn } from 'assets/svg/auth/warning.svg';
import styles from './ErrorMessage.module.scss';

interface ErrorMessageProps {
message:string | (string | undefined)[]
message: string | (string | undefined | null)[]
}

export default function ErrorMessage({ message }:ErrorMessageProps) {
return (
<div className={styles.warn}>
<Warn />
<span className={styles['warn--phrase']}>
{typeof message === 'string' ? message : message[0]}
</span>
</div>
);
if (typeof message === 'string') {
return (
<div className={styles.warn}>
<Warn />
<span className={styles['warn--phrase']}>
{message}
</span>
</div>
);
}

if (message.length > 0) {
return (
<div className={styles.warn}>
<Warn />
<span className={styles['warn--phrase']}>
{typeof message === 'string' ? message : message[0]}
</span>
</div>
);
}

return null;
}
3 changes: 2 additions & 1 deletion src/page/Auth/Signup/hooks/useCheckEmailDuplicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
import { SubmitHandler } from 'react-hook-form';
import { User } from 'page/Auth/Signup/types/User';
import useRegisterInfo from 'store/registerStore';
import { isKoinError } from '@bcsdlab/koin';

export default function useCheckEmailDuplicate(isMobile: boolean) {
const [email, setEmail] = useState<string>('');
const { status, refetch, error } = useCheckDuplicate(email);
const { userInfo: userData, setUserInfo: setId } = useRegisterInfo();
const debounceSearch = useRef<NodeJS.Timeout>();
const errorMessage:string | undefined = status === 'error' ? Object(error).response.data.message : null;
const errorMessage = isKoinError(error) && error.status === 409 ? '이미 사용중인 아이디입니다.' : null;
const onSubmit:SubmitHandler<User> = (data) => {
setEmail(() => (data.email ? data.email : ''));
};
Expand Down
2 changes: 1 addition & 1 deletion src/query/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useErrorMessageStore } from 'store/errorMessageStore';
import usePrevPathStore from 'store/path';
import { isKoinError } from 'utils/ts/isKoinError';
import useStepStore from 'store/useStepStore';
import { isKoinError } from '@bcsdlab/koin';

interface VerifyInput {
email: string;
Expand Down
10 changes: 0 additions & 10 deletions src/utils/ts/isKoinError.ts

This file was deleted.

10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,15 @@ __metadata:
languageName: node
linkType: hard

"@bcsdlab/koin@npm:^0.0.15":
version: 0.0.15
resolution: "@bcsdlab/koin@npm:0.0.15"
peerDependencies:
axios: ^0.27.2
checksum: 30b1904180a8278bdc45cbb487e10c88da6034d74964070a2837694df16b87606535b45bc5675f4f8038d7530b9d2ecf009b11d360bc572141fe92ba3ef6059e
languageName: node
linkType: hard

"@csstools/normalize.css@npm:*":
version: 12.1.1
resolution: "@csstools/normalize.css@npm:12.1.1"
Expand Down Expand Up @@ -8982,6 +8991,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "koin_owner_web@workspace:."
dependencies:
"@bcsdlab/koin": ^0.0.15
"@hookform/resolvers": ^3.1.0
"@tanstack/react-query": ^5.8.1
"@testing-library/jest-dom": ^5.14.1
Expand Down
Loading