Skip to content

Commit d07977b

Browse files
authored
Merge pull request #237 from DguFarmSystem/fix/#233
fix: 에러 메시지 줄바꿈 적용
2 parents e94d490 + 87a5668 commit d07977b

File tree

2 files changed

+59
-31
lines changed

2 files changed

+59
-31
lines changed

apps/farminglog/src/pages/auth/SocialRedirect.tsx

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,52 @@ export default function SocialRedirect() {
2626
return;
2727
}
2828

29-
const login = async () => {
30-
try {
31-
await socialLogin({ code, socialType: provider });
32-
navigate('/home');
33-
} catch (error: any) {
34-
const status = error?.status;
29+
const login = async () => {
30+
try {
31+
await socialLogin({ code, socialType: provider });
32+
navigate('/home');
33+
} catch (error: any) {
34+
const status = error?.status;
3535

36-
if (status === 404) {
37-
setErrorTitle("가입되지 않은 사용자입니다.");
38-
setErrorMessage("소속 정보를 확인하고 다시 시도해주세요.");
36+
if (status === 404) {
37+
setErrorTitle(
38+
<>
39+
가입되지 않은 <br /> 사용자입니다.
40+
</>
41+
);
42+
setErrorMessage(
43+
<>
44+
회원 인증 후 로그인해주세요. <br />
45+
인증이 계속 안 될 경우, 운영진에게 문의해주세요.
46+
</>
47+
);
3948
setButtonLabel("처음으로");
4049
navigate('/?status=not-member');
41-
} else if (status === 409) {
42-
setErrorTitle("이미 다른 소셜 계정으로 가입된 사용자입니다.");
43-
setErrorMessage("다른 계정으로 로그인해주세요.");
50+
51+
// 409 - 다른 계정으로 이미 가입된 사용자
52+
setErrorTitle(
53+
<>
54+
이미 다른 소셜 계정으로 <br /> 가입된 사용자입니다.
55+
</>
56+
);
57+
setErrorMessage(
58+
<>
59+
다른 계정으로 로그인해주세요. <br />
60+
계정을 찾을 수 없다면 운영진에게 문의해주세요.
61+
</>
62+
);
4463
setButtonLabel("처음으로");
4564
navigate('/?status=not-member&type=409');
46-
} else if (status === 500) {
47-
alert("로그인 중 문제가 발생했습니다.\n다시 로그인 해주세요.");
48-
navigate('/');
49-
} else {
50-
alert("계속 안되면 운영진에게 문의해주세요!");
51-
navigate('/');
52-
}
53-
}
65+
66+
} else if (status === 500) {
67+
alert("로그인 중 문제가 발생했습니다.\n다시 로그인 해주세요.");
68+
navigate('/');
69+
} else {
70+
alert("계속 안되면 운영진에게 문의해주세요!");
71+
navigate('/');
72+
}
73+
74+
}
5475
};
5576

5677
login();
Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1+
// useErrorStore.ts
2+
13
import { create } from 'zustand';
4+
import { ReactNode } from 'react';
25

36
interface ErrorState {
4-
errorMessage: string | null;
5-
errorTitle: string | null;
6-
buttonLabel: string;
7-
setErrorMessage: (msg: string | null) => void;
8-
setErrorTitle: (title: string | null) => void;
9-
setButtonLabel: (label: string) => void;
7+
errorTitle: ReactNode | null; // string → ReactNode
8+
errorMessage: ReactNode | null; // string → ReactNode
9+
buttonLabel: string | null;
10+
setErrorTitle: (title: ReactNode | null) => void;
11+
setErrorMessage: (msg: ReactNode | null) => void;
12+
setButtonLabel: (label: string | null) => void;
1013
resetError: () => void;
1114
}
1215

1316
export const useErrorStore = create<ErrorState>((set) => ({
14-
errorMessage: null,
1517
errorTitle: null,
16-
buttonLabel: '회원인증 하기',
17-
setErrorMessage: (msg) => set({ errorMessage: msg }),
18+
errorMessage: null,
19+
buttonLabel: null,
1820
setErrorTitle: (title) => set({ errorTitle: title }),
21+
setErrorMessage: (msg) => set({ errorMessage: msg }),
1922
setButtonLabel: (label) => set({ buttonLabel: label }),
20-
resetError: () => set({ errorMessage: null, errorTitle: null, buttonLabel: '회원인증 하기' }),
21-
}));
23+
resetError: () => set({
24+
errorTitle: null,
25+
errorMessage: null,
26+
buttonLabel: null,
27+
}),
28+
}));

0 commit comments

Comments
 (0)