@daeryun/dr_components 0.8.67 → 0.8.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/asset/images/daeryuntalk/daeryuntalk_home_bg.png +0 -0
  2. package/dist/asset/images/daeryuntalk/home_bg_logo.png +0 -0
  3. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  4. package/dist/components/Daeryuntalk/ChatHomeView.jsx +5 -4
  5. package/dist/components/Daeryuntalk/ChatHomeView.tsx +3 -4
  6. package/dist/components/Daeryuntalk/ChatWidget.jsx +5 -6
  7. package/dist/components/Daeryuntalk/ChatWidget.tsx +5 -6
  8. package/dist/components/Daeryuntalk/HomeView.jsx +75 -29
  9. package/dist/components/Daeryuntalk/HomeView.tsx +92 -37
  10. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +4 -3
  11. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +52 -4
  12. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +61 -6
  13. package/dist/components/Daeryuntalk/_enums/error.d.ts +106 -0
  14. package/dist/components/Daeryuntalk/_enums/error.js +125 -1
  15. package/dist/components/Daeryuntalk/_enums/error.ts +142 -1
  16. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +1 -1
  17. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +5 -2
  18. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +6 -2
  19. package/dist/components/Footer/IFooterTypes.js +4 -4
  20. package/dist/components/Footer/IFooterTypes.ts +4 -4
  21. package/dist/components/Footer/index.jsx +1 -1
  22. package/dist/components/Footer/index.tsx +1 -1
  23. package/dist/components/common/integrate/index.d.ts +1 -1
  24. package/dist/components/common/strength/index.js +5 -5
  25. package/dist/components/common/strength/index.ts +5 -5
  26. package/dist/components/common/system/index.jsx +1 -1
  27. package/dist/components/common/system/index.tsx +1 -1
  28. package/dist/components/page/Strength/StrengthIntro.jsx +1 -1
  29. package/dist/components/page/Strength/StrengthIntro.tsx +1 -1
  30. package/dist/styles/globals.css +363 -340
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +1 -1
@@ -1,25 +1,67 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import Image from 'next/image';
3
3
  import TimeIcon from '../../asset/images/daeryuntalk/time.svg';
4
4
  import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
5
5
  import ShadowBox from './_ui/ShadowBox';
6
6
  import SendIcon from '../../asset/images/daeryuntalk/send.svg';
7
7
  import InfoIcon from '../../asset/images/daeryuntalk/info.svg';
8
+ // import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk_home_bg.png';
8
9
  import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
10
+ import DaeryuntalkHomeLogo from '../../asset/images/daeryuntalk/home_bg_logo.png';
9
11
  import CloseSvgIcon from '../../asset/images/daeryuntalk/close.svg';
10
12
  import { useScrollShadow } from './_hooks/useScrollShadow';
11
13
  import Button3 from './_ui/buttons/Button3';
12
14
  const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClose, isHash }) => {
13
15
  const { containerRef, isScroll, isBottom, checkScroll } = useScrollShadow();
16
+ const wrapperRef = useRef(null); // 부모 감싸는 영역\
17
+ const [wrapperHeight, setWrapperHeight] = useState(626);
18
+ const [clampHeight, setClampHeight] = useState(210);
19
+ const updateDistance = () => {
20
+ if (wrapperRef.current) {
21
+ const rect = wrapperRef.current.getBoundingClientRect();
22
+ const distanceTop = rect.top;
23
+ // 0이하면
24
+ if (distanceTop < 0) {
25
+ setClampHeight(210 + distanceTop);
26
+ setWrapperHeight(626 + distanceTop);
27
+ }
28
+ // 플러스일경우
29
+ else {
30
+ if (wrapperHeight !== 626) {
31
+ setWrapperHeight(626);
32
+ }
33
+ if (clampHeight !== 210) {
34
+ setClampHeight(210);
35
+ }
36
+ }
37
+ }
38
+ };
39
+ useEffect(() => {
40
+ updateDistance(); // 초기 계산
41
+ const resizeObserver = new ResizeObserver(updateDistance);
42
+ if (wrapperRef.current) {
43
+ resizeObserver.observe(wrapperRef.current);
44
+ }
45
+ // window resize에도 반응
46
+ window.addEventListener('resize', updateDistance);
47
+ return () => {
48
+ resizeObserver.disconnect();
49
+ window.removeEventListener('resize', updateDistance);
50
+ };
51
+ }, []);
14
52
  useEffect(() => {
15
53
  checkScroll();
16
54
  }, [inquiryMainData]);
17
55
  // 아직 커버이미지 url이 안나옴
18
56
  const backgroundImage = (inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.sleeve_image_url) ? inquiryMainData.sleeve_image_url : DaeryuntalkIntro;
19
- return (<div className={`
20
- relative h-full w-full
57
+ return (
58
+ // 중간 부분에 min-h-[80px]이 되면 여기서 스크롤이 생겨야함
59
+ <div ref={wrapperRef} className={`
60
+ relative w-full
21
61
  ${isMobile ? `flex flex-col items-center justify-between` : `flex flex-col items-center `}
22
- `}>
62
+ `} style={{
63
+ height: `${wrapperHeight}px`
64
+ }}>
23
65
  <header className={`
24
66
  z-10
25
67
  flex h-[56px] w-full justify-between px-[20px]
@@ -28,13 +70,15 @@ const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClo
28
70
  dr_talk_subtitle_small flex items-center gap-[2px] pt-[31.5px] text-drTalkGrayscale1
29
71
  `}>
30
72
  <TimeIcon width={20} height={20}/>
31
- <span>24시간 운영</span>
73
+ <span>24시간 운영{wrapperHeight}</span>
32
74
  </div>
33
-
34
75
  <div className={`${isHash ? 'pointer-events-none !opacity-0' : ''} ${isMobile ? 'block' : ' xs:pointer-events-none xs:!opacity-0 '} py-[14px] text-drTalkGrayscale2 hover:cursor-pointer`} onClick={onClose}>
35
76
  <CloseSvgIcon width={28} height={28}/>
36
77
  </div>
37
78
  </header>
79
+ <div>
80
+ <Image src={DaeryuntalkHomeLogo} width={200} height={100} alt="헤더 로고" className={``}/>
81
+ </div>
38
82
  <div className={'absolute left-0 top-0 z-0 h-full w-full overflow-hidden'}>
39
83
  <Image src={backgroundImage} alt="대화 배경" fill className={`
40
84
  ${isMobile ? `h-full max-h-[360px] w-full object-center will-change-transform ` : `w-full object-contain object-top will-change-transform`}`}/>
@@ -49,39 +93,41 @@ const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClo
49
93
  `}
50
94
  `}>
51
95
  <section className={`
52
- flex h-[408px] flex-col overflow-auto rounded-[12px] bg-white px-[16px] py-[24px]
96
+ flex flex-col rounded-[12px] bg-white px-[16px] py-[24px]
53
97
  ${isMobile ? `w-full` : ``}
54
98
  `} style={{
55
99
  boxShadow: '0px 4px 10px 0px #00000026'
56
100
  }}>
57
- {/*mx-auto mt-[150px] flex w-[320px] flex-col gap-5 rounded-[12px] bg-white px-4 py-6*/}
58
- <div className={`flex items-center gap-[10px]`}>
59
- {(inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_logo_image_url) ? (<Image src={inquiryMainData.channel_logo_image_url} alt="로고" width={32} height={32} className={''}/>) : (<DaeryunLogoIcon width={24} height={24} className="mr-2"/>)}
60
- <h1 className={`dr_talk_title_small text-drTalkBlack`}>
61
- {(inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_name) || '법무법인(유한)대륜'}
62
- </h1>
63
- </div>
64
-
65
- <div className={`dr_talk_body_medium2 relative ml-[42px] mr-[16px] mt-[16px]`}>
101
+ <div className={`relative`}>
102
+ {/* 해당 높이가 먼저 줄어둘고 */}
66
103
  <div ref={containerRef} className={`
67
-
68
- no-scrollbar
69
- relative max-h-[144px] overflow-auto
70
- whitespace-pre-line
71
- `}>
72
- {(inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.salutation) ||
104
+ no-scrollbar flex max-h-[210px] min-h-[80px] flex-col overflow-auto
105
+ `} style={{
106
+ height: `${clampHeight}px`
107
+ }}>
108
+ <div className={`flex items-center gap-[10px]`}>
109
+ {(inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_logo_image_url) ? (<Image src={inquiryMainData.channel_logo_image_url} alt="로고" width={32} height={32} className={''}/>) : (<DaeryunLogoIcon width={24} height={24} className="mr-2"/>)}
110
+ <h1 className={`dr_talk_title_small text-drTalkBlack`}>
111
+ {(inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_name) || '법무법인(유한)대륜'}
112
+ </h1>
113
+ </div>
114
+ <div className={`dr_talk_body_medium2 relative ml-[42px] mr-[16px] mt-[16px]`}>
115
+ <div className={`whitespace-pre-line `}>
116
+ {(inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.salutation) ||
73
117
  `안녕하세요.
74
- 법무법인(유한)대륜입니다.
75
- 방문해 주셔서 감사합니다.
76
- 궁금한 점이나 도움이 필요하신 부분
77
- 말씀해 주시면 도와드리겠습니다.
78
-
79
- 6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.`}
118
+ 법무법인(유한)대륜입니다.
119
+ 방문해 주셔서 감사합니다.\n
120
+ 궁금한 점이나 도움이 필요하신 부분
121
+ 말씀해 주시면 도와드리겠습니다.
122
+ 6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.
123
+ `}
124
+ </div>
125
+ </div>
80
126
  </div>
81
127
  {isScroll && !isBottom && <ShadowBox />}
82
128
  </div>
83
129
 
84
- <Button3 onClick={handleStartChat} isDisabled={isLoading} className={`mt-auto`}>
130
+ <Button3 onClick={handleStartChat} isDisabled={isLoading} className={`mt-[40px]`}>
85
131
  <div className={`flex items-center justify-center gap-[4px]`}>
86
132
  <div>{isLoading ? '로딩 중...' : '문의하기'}</div>
87
133
  {!isLoading && <SendIcon width={24} height={24}/>}
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import Image from 'next/image';
3
3
  import TimeIcon from '../../asset/images/daeryuntalk/time.svg';
4
4
  import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
@@ -6,7 +6,9 @@ import ShadowBox from './_ui/ShadowBox';
6
6
  import SendIcon from '../../asset/images/daeryuntalk/send.svg';
7
7
  import InfoIcon from '../../asset/images/daeryuntalk/info.svg';
8
8
  import { IChatInquiryMainDataResponse } from './_api/daeryuntalk/type/response';
9
+ // import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk_home_bg.png';
9
10
  import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
11
+ import DaeryuntalkHomeLogo from '../../asset/images/daeryuntalk/home_bg_logo.png';
10
12
  import CloseSvgIcon from '../../asset/images/daeryuntalk/close.svg';
11
13
  import { useScrollShadow } from './_hooks/useScrollShadow';
12
14
  import Button3 from './_ui/buttons/Button3';
@@ -21,6 +23,49 @@ interface IHomeViewProps {
21
23
  }
22
24
  const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClose, isHash }: IHomeViewProps) => {
23
25
  const { containerRef, isScroll, isBottom, checkScroll } = useScrollShadow<HTMLDivElement>();
26
+
27
+ const wrapperRef = useRef<HTMLDivElement | null>(null); // 부모 감싸는 영역\
28
+ const [wrapperHeight, setWrapperHeight] = useState<number>(626);
29
+ const [clampHeight, setClampHeight] = useState<number>(210);
30
+
31
+ const updateDistance = () => {
32
+ if (wrapperRef.current) {
33
+ const rect = wrapperRef.current.getBoundingClientRect();
34
+ const distanceTop = rect.top;
35
+ // 0이하면
36
+ if (distanceTop < 0) {
37
+ setClampHeight(210 + distanceTop);
38
+ setWrapperHeight(626 + distanceTop);
39
+ }
40
+ // 플러스일경우
41
+ else {
42
+ if (wrapperHeight !== 626) {
43
+ setWrapperHeight(626);
44
+ }
45
+ if (clampHeight !== 210) {
46
+ setClampHeight(210);
47
+ }
48
+ }
49
+ }
50
+ };
51
+
52
+ useEffect(() => {
53
+ updateDistance(); // 초기 계산
54
+
55
+ const resizeObserver = new ResizeObserver(updateDistance);
56
+ if (wrapperRef.current) {
57
+ resizeObserver.observe(wrapperRef.current);
58
+ }
59
+
60
+ // window resize에도 반응
61
+ window.addEventListener('resize', updateDistance);
62
+
63
+ return () => {
64
+ resizeObserver.disconnect();
65
+ window.removeEventListener('resize', updateDistance);
66
+ };
67
+ }, []);
68
+
24
69
  useEffect(() => {
25
70
  checkScroll();
26
71
  }, [inquiryMainData]);
@@ -28,11 +73,16 @@ const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClo
28
73
  const backgroundImage = inquiryMainData?.sleeve_image_url ? inquiryMainData.sleeve_image_url : DaeryuntalkIntro;
29
74
 
30
75
  return (
76
+ // 중간 부분에 min-h-[80px]이 되면 여기서 스크롤이 생겨야함
31
77
  <div
78
+ ref={wrapperRef}
32
79
  className={`
33
- relative h-full w-full
80
+ relative w-full
34
81
  ${isMobile ? `flex flex-col items-center justify-between` : `flex flex-col items-center `}
35
82
  `}
83
+ style={{
84
+ height: `${wrapperHeight}px`
85
+ }}
36
86
  >
37
87
  <header
38
88
  className={`
@@ -46,9 +96,8 @@ const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClo
46
96
  `}
47
97
  >
48
98
  <TimeIcon width={20} height={20} />
49
- <span>24시간 운영</span>
99
+ <span>24시간 운영{wrapperHeight}</span>
50
100
  </div>
51
-
52
101
  <div
53
102
  className={`${isHash ? 'pointer-events-none !opacity-0' : ''} ${isMobile ? 'block' : ' xs:pointer-events-none xs:!opacity-0 '} py-[14px] text-drTalkGrayscale2 hover:cursor-pointer`}
54
103
  onClick={onClose}
@@ -56,6 +105,9 @@ const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClo
56
105
  <CloseSvgIcon width={28} height={28} />
57
106
  </div>
58
107
  </header>
108
+ <div>
109
+ <Image src={DaeryuntalkHomeLogo} width={200} height={100} alt="헤더 로고" className={``} />
110
+ </div>
59
111
  <div className={'absolute left-0 top-0 z-0 h-full w-full overflow-hidden'}>
60
112
  <Image
61
113
  src={backgroundImage}
@@ -80,54 +132,57 @@ const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClo
80
132
  >
81
133
  <section
82
134
  className={`
83
- flex h-[408px] flex-col overflow-auto rounded-[12px] bg-white px-[16px] py-[24px]
135
+ flex flex-col rounded-[12px] bg-white px-[16px] py-[24px]
84
136
  ${isMobile ? `w-full` : ``}
85
137
  `}
86
138
  style={{
87
139
  boxShadow: '0px 4px 10px 0px #00000026'
88
140
  }}
89
141
  >
90
- {/*mx-auto mt-[150px] flex w-[320px] flex-col gap-5 rounded-[12px] bg-white px-4 py-6*/}
91
- <div className={`flex items-center gap-[10px]`}>
92
- {inquiryMainData?.channel_logo_image_url ? (
93
- <Image
94
- src={inquiryMainData.channel_logo_image_url}
95
- alt="로고"
96
- width={32}
97
- height={32}
98
- className={''}
99
- />
100
- ) : (
101
- <DaeryunLogoIcon width={24} height={24} className="mr-2" />
102
- )}
103
- <h1 className={`dr_talk_title_small text-drTalkBlack`}>
104
- {inquiryMainData?.channel_name || '법무법인(유한)대륜'}
105
- </h1>
106
- </div>
107
-
108
- <div className={`dr_talk_body_medium2 relative ml-[42px] mr-[16px] mt-[16px]`}>
142
+ <div className={`relative`}>
143
+ {/* 해당 높이가 먼저 줄어둘고 */}
109
144
  <div
110
145
  ref={containerRef}
111
146
  className={`
112
-
113
- no-scrollbar
114
- relative max-h-[144px] overflow-auto
115
- whitespace-pre-line
147
+ no-scrollbar flex max-h-[210px] min-h-[80px] flex-col overflow-auto
116
148
  `}
149
+ style={{
150
+ height: `${clampHeight}px`
151
+ }}
117
152
  >
118
- {inquiryMainData?.salutation ||
119
- `안녕하세요.
120
- 법무법인(유한)대륜입니다.
121
- 방문해 주셔서 감사합니다.
122
- 궁금한 점이나 도움이 필요하신 부분
123
- 말씀해 주시면 도와드리겠습니다.
124
-
125
- 6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.`}
153
+ <div className={`flex items-center gap-[10px]`}>
154
+ {inquiryMainData?.channel_logo_image_url ? (
155
+ <Image
156
+ src={inquiryMainData.channel_logo_image_url}
157
+ alt="로고"
158
+ width={32}
159
+ height={32}
160
+ className={''}
161
+ />
162
+ ) : (
163
+ <DaeryunLogoIcon width={24} height={24} className="mr-2" />
164
+ )}
165
+ <h1 className={`dr_talk_title_small text-drTalkBlack`}>
166
+ {inquiryMainData?.channel_name || '법무법인(유한)대륜'}
167
+ </h1>
168
+ </div>
169
+ <div className={`dr_talk_body_medium2 relative ml-[42px] mr-[16px] mt-[16px]`}>
170
+ <div className={`whitespace-pre-line `}>
171
+ {inquiryMainData?.salutation ||
172
+ `안녕하세요.
173
+ 법무법인(유한)대륜입니다.
174
+ 방문해 주셔서 감사합니다.\n
175
+ 궁금한 점이나 도움이 필요하신 부분
176
+ 말씀해 주시면 도와드리겠습니다.
177
+ 6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.
178
+ `}
179
+ </div>
180
+ </div>
126
181
  </div>
127
182
  {isScroll && !isBottom && <ShadowBox />}
128
183
  </div>
129
184
 
130
- <Button3 onClick={handleStartChat} isDisabled={isLoading} className={`mt-auto`}>
185
+ <Button3 onClick={handleStartChat} isDisabled={isLoading} className={`mt-[40px]`}>
131
186
  <div className={`flex items-center justify-center gap-[4px]`}>
132
187
  <div>{isLoading ? '로딩 중...' : '문의하기'}</div>
133
188
  {!isLoading && <SendIcon width={24} height={24} />}
@@ -22,7 +22,7 @@ export declare const MESSAGE_TYPES: {
22
22
  * @param version API 버전 (기본값: 1.0.0)
23
23
  * @returns 인증 응답
24
24
  */
25
- export declare function authenticateUser(centerCode: string, version?: string): Promise<any>;
25
+ export declare function authenticateUser(centerCode: string, version?: string, retry?: boolean): Promise<any>;
26
26
  /**
27
27
  * 웹소켓 연결 초기화
28
28
  * @param version API 버전 (기본값: 1.0.0)
@@ -69,9 +69,10 @@ export declare function getChatInquiryMessageList(chatInquiryNumber: string, sta
69
69
  * @returns 웹소켓 인스턴스 및 문의 데이터
70
70
  */
71
71
  export declare function initializeDaeryuntalk(hashValue: string, isOpen: boolean, setIsConnected: Dispatch<SetStateAction<boolean | null>>, isMobile: boolean, onWebSocketConnected?: (socket: WebSocket) => void, onWebSocketMessage?: (event: MessageEvent) => void, version?: string): Promise<{
72
- inquiryData: IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>;
73
- socket: WebSocket;
72
+ inquiryData: IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse> | null;
73
+ socket: WebSocket | null;
74
74
  hashAuth: any;
75
+ errorCode: IDaeryunTalkResponseWrapper<any> | null;
75
76
  }>;
76
77
  /**
77
78
  * 채팅 워크플로우 진행 처리
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { ErrorEnum } from '../../_enums/error';
10
11
  // API 기본 URL
11
12
  const API_BASE_URL = 'https://chat-client-api.lawmance.com';
12
13
  // API 기본 버전
@@ -138,9 +139,10 @@ function fetchWithCookies(url_1) {
138
139
  * @param version API 버전 (기본값: 1.0.0)
139
140
  * @returns 인증 응답
140
141
  */
141
- export function authenticateUser(centerCode, version) {
142
+ export function authenticateUser(centerCode, version, retry) {
142
143
  return __awaiter(this, void 0, void 0, function* () {
143
144
  var _a;
145
+ console.log('retry', retry);
144
146
  console.log('[인증 시작] 사용자 인증 요청', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
145
147
  try {
146
148
  const body = {
@@ -243,7 +245,12 @@ export function connectWebSocket(wsUrl, token, isOpen, setIsConnected, onMessage
243
245
  // 새로운 initData 요청
244
246
  const newInitData = yield initializeWebSocket(); // 직접 구현한 API 요청 함수
245
247
  const newSocket = new WebSocket(`${(_a = newInitData === null || newInitData === void 0 ? void 0 : newInitData.data) === null || _a === void 0 ? void 0 : _a.connection_url}?token=${(_b = newInitData === null || newInitData === void 0 ? void 0 : newInitData.data) === null || _b === void 0 ? void 0 : _b.connection_token}`);
246
- setIsConnected(true);
248
+ if (newSocket) {
249
+ setIsConnected(true);
250
+ }
251
+ else {
252
+ setIsConnected(false);
253
+ }
247
254
  // 새 소켓에 핸들러 등록
248
255
  setupSocketHandlers(newSocket);
249
256
  }
@@ -284,6 +291,7 @@ export function getChatInquiryMain(channelNumber, version) {
284
291
  channel_number: channelNumber
285
292
  }
286
293
  };
294
+ console.log('body', body);
287
295
  console.log('[채팅 문의 메인 조회 시작] 채널 번호:', body.d.channel_number, version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
288
296
  try {
289
297
  const response = yield fetchWithCookies(`${API_BASE_URL}${ENDPOINTS.CHAT_INQUIRY_MAIN}`, {
@@ -396,16 +404,55 @@ export function getChatInquiryMessageList(chatInquiryNumber, standardDateTime, s
396
404
  */
397
405
  export function initializeDaeryuntalk(hashValue, isOpen, setIsConnected, isMobile, onWebSocketConnected, onWebSocketMessage, version) {
398
406
  return __awaiter(this, void 0, void 0, function* () {
407
+ var _a, _b, _c, _d, _e, _f, _g;
399
408
  if (typeof window !== 'undefined' && hashValue) {
400
409
  localStorage.removeItem('daeryunchatinquirytoken');
401
410
  }
402
411
  console.log('[Daeryuntalk 초기화 시작] 전체 흐름 실행', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
403
412
  try {
404
413
  console.log('[Daeryuntalk 초기화] 전체 흐름 시작');
414
+ let errorData = null;
405
415
  // 1단계: 사용자 인증
406
- const authResponse = yield retryable(() => authenticateUser(TEST_CENTER_CODE, version), 3, 350, '사용자 인증');
416
+ let authResponse = yield retryable(() => authenticateUser(TEST_CENTER_CODE, version), 1, 350, '사용자 인증');
417
+ // 9379809eec4c09ea276496b15b5d2778a2ef7af312c25d95bd2a0f884cb72bf3
418
+ // 만약 만료된 토큰이라면?
419
+ // console.log('authResponse', authResponse);
420
+ // console.log('ErrorEnum.CE_TOKEN_EXPIRED', ErrorEnum.CE_TOKEN_EXPIRED);
421
+ // console.log('authResponse?.result_info?.result_cd', authResponse?.result_info?.result_cd);
422
+ console.log(((_a = authResponse === null || authResponse === void 0 ? void 0 : authResponse.result_info) === null || _a === void 0 ? void 0 : _a.result_cd) === ErrorEnum.CE_TOKEN_EXPIRED);
423
+ if (((_b = authResponse === null || authResponse === void 0 ? void 0 : authResponse.result_info) === null || _b === void 0 ? void 0 : _b.result_cd) === 'OK' || ((_c = authResponse === null || authResponse === void 0 ? void 0 : authResponse.result_info) === null || _c === void 0 ? void 0 : _c.result_type_cd) === 'OK') {
424
+ }
425
+ else {
426
+ if (((_d = authResponse === null || authResponse === void 0 ? void 0 : authResponse.result_info) === null || _d === void 0 ? void 0 : _d.result_cd) === ErrorEnum.CE_TOKEN_EXPIRED ||
427
+ ((_e = authResponse === null || authResponse === void 0 ? void 0 : authResponse.result_info) === null || _e === void 0 ? void 0 : _e.result_type_cd) === ErrorEnum.CE_TOKEN_EXPIRED) {
428
+ // 재인증 시작
429
+ errorData = authResponse;
430
+ console.log('재인증 시작');
431
+ localStorage.removeItem('daeryunchatinquirytoken');
432
+ authResponse = yield retryable(() => authenticateUser(TEST_CENTER_CODE, version, true), 3, 350, '사용자 인증');
433
+ }
434
+ else {
435
+ errorData = authResponse;
436
+ return {
437
+ inquiryData: null,
438
+ socket: null,
439
+ hashAuth: '',
440
+ errorCode: errorData
441
+ };
442
+ }
443
+ }
444
+ console.log('authResponse', authResponse);
407
445
  // 2단계: 웹소켓 초기화
408
446
  const wsInitData = yield retryable(() => initializeWebSocket(version), 3, 350, '웹소켓 초기화');
447
+ if (!(((_f = authResponse === null || authResponse === void 0 ? void 0 : authResponse.result_info) === null || _f === void 0 ? void 0 : _f.result_cd) === 'OK' || ((_g = authResponse === null || authResponse === void 0 ? void 0 : authResponse.result_info) === null || _g === void 0 ? void 0 : _g.result_type_cd) === 'OK')) {
448
+ errorData = wsInitData;
449
+ return {
450
+ inquiryData: null,
451
+ socket: null,
452
+ hashAuth: '',
453
+ errorCode: errorData
454
+ };
455
+ }
409
456
  // 3단계: 웹소켓 연결
410
457
  const socket = yield retryable(() => new Promise((resolve, reject) => {
411
458
  try {
@@ -433,7 +480,8 @@ export function initializeDaeryuntalk(hashValue, isOpen, setIsConnected, isMobil
433
480
  return {
434
481
  inquiryData: chatInquiryData,
435
482
  socket,
436
- hashAuth
483
+ hashAuth,
484
+ errorCode: null
437
485
  };
438
486
  }
439
487
  catch (error) {
@@ -21,6 +21,7 @@ import {
21
21
  RequestConfirmNumberResponse
22
22
  } from './type/response';
23
23
  import { Dispatch, SetStateAction } from 'react';
24
+ import { ErrorEnum } from '../../_enums/error';
24
25
 
25
26
  // API 기본 URL
26
27
  const API_BASE_URL = 'https://chat-client-api.lawmance.com';
@@ -172,7 +173,8 @@ async function fetchWithCookies<T>(
172
173
  * @returns 인증 응답
173
174
  */
174
175
 
175
- export async function authenticateUser(centerCode: string, version?: string): Promise<any> {
176
+ export async function authenticateUser(centerCode: string, version?: string, retry?: boolean): Promise<any> {
177
+ console.log('retry', retry);
176
178
  console.log('[인증 시작] 사용자 인증 요청', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
177
179
  try {
178
180
  const body = {
@@ -305,7 +307,11 @@ export function connectWebSocket(
305
307
  const newSocket = new WebSocket(
306
308
  `${newInitData?.data?.connection_url}?token=${newInitData?.data?.connection_token}`
307
309
  );
308
- setIsConnected(true);
310
+ if (newSocket) {
311
+ setIsConnected(true);
312
+ } else {
313
+ setIsConnected(false);
314
+ }
309
315
 
310
316
  // 새 소켓에 핸들러 등록
311
317
  setupSocketHandlers(newSocket);
@@ -348,6 +354,7 @@ export async function getChatInquiryMain(
348
354
  channel_number: channelNumber
349
355
  }
350
356
  };
357
+ console.log('body', body);
351
358
 
352
359
  console.log(
353
360
  '[채팅 문의 메인 조회 시작] 채널 번호:',
@@ -508,9 +515,10 @@ export async function initializeDaeryuntalk(
508
515
  onWebSocketMessage?: (event: MessageEvent) => void,
509
516
  version?: string
510
517
  ): Promise<{
511
- inquiryData: IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>;
512
- socket: WebSocket;
518
+ inquiryData: IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse> | null;
519
+ socket: WebSocket | null;
513
520
  hashAuth: any;
521
+ errorCode: IDaeryunTalkResponseWrapper<any> | null;
514
522
  }> {
515
523
  if (typeof window !== 'undefined' && hashValue) {
516
524
  localStorage.removeItem('daeryunchatinquirytoken');
@@ -521,13 +529,59 @@ export async function initializeDaeryuntalk(
521
529
  );
522
530
  try {
523
531
  console.log('[Daeryuntalk 초기화] 전체 흐름 시작');
532
+ let errorData: IDaeryunTalkResponseWrapper<any> | null = null;
524
533
 
525
534
  // 1단계: 사용자 인증
526
- const authResponse = await retryable(() => authenticateUser(TEST_CENTER_CODE, version), 3, 350, '사용자 인증');
535
+ let authResponse = await retryable(() => authenticateUser(TEST_CENTER_CODE, version), 1, 350, '사용자 인증');
536
+
537
+ // 9379809eec4c09ea276496b15b5d2778a2ef7af312c25d95bd2a0f884cb72bf3
538
+ // 만약 만료된 토큰이라면?
539
+ // console.log('authResponse', authResponse);
540
+ // console.log('ErrorEnum.CE_TOKEN_EXPIRED', ErrorEnum.CE_TOKEN_EXPIRED);
541
+ // console.log('authResponse?.result_info?.result_cd', authResponse?.result_info?.result_cd);
542
+ console.log(authResponse?.result_info?.result_cd === ErrorEnum.CE_TOKEN_EXPIRED);
543
+ if (authResponse?.result_info?.result_cd === 'OK' || authResponse?.result_info?.result_type_cd === 'OK') {
544
+ } else {
545
+ if (
546
+ authResponse?.result_info?.result_cd === ErrorEnum.CE_TOKEN_EXPIRED ||
547
+ authResponse?.result_info?.result_type_cd === ErrorEnum.CE_TOKEN_EXPIRED
548
+ ) {
549
+ // 재인증 시작
550
+ errorData = authResponse;
551
+ console.log('재인증 시작');
552
+ localStorage.removeItem('daeryunchatinquirytoken');
553
+ authResponse = await retryable(
554
+ () => authenticateUser(TEST_CENTER_CODE, version, true),
555
+ 3,
556
+ 350,
557
+ '사용자 인증'
558
+ );
559
+ } else {
560
+ errorData = authResponse;
561
+ return {
562
+ inquiryData: null,
563
+ socket: null,
564
+ hashAuth: '',
565
+ errorCode: errorData
566
+ };
567
+ }
568
+ }
569
+
570
+ console.log('authResponse', authResponse);
527
571
 
528
572
  // 2단계: 웹소켓 초기화
529
573
  const wsInitData = await retryable(() => initializeWebSocket(version), 3, 350, '웹소켓 초기화');
530
574
 
575
+ if (!(authResponse?.result_info?.result_cd === 'OK' || authResponse?.result_info?.result_type_cd === 'OK')) {
576
+ errorData = wsInitData;
577
+ return {
578
+ inquiryData: null,
579
+ socket: null,
580
+ hashAuth: '',
581
+ errorCode: errorData
582
+ };
583
+ }
584
+
531
585
  // 3단계: 웹소켓 연결
532
586
  const socket = await retryable(
533
587
  () =>
@@ -577,7 +631,8 @@ export async function initializeDaeryuntalk(
577
631
  return {
578
632
  inquiryData: chatInquiryData,
579
633
  socket,
580
- hashAuth
634
+ hashAuth,
635
+ errorCode: null
581
636
  };
582
637
  } catch (error) {
583
638
  console.error('[Daeryuntalk 초기화 실패] 오류 발생:', error);