@daeryun/dr_components 0.8.67 → 0.8.68

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.
@@ -53,7 +53,9 @@ const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
53
53
  }
54
54
  }, [viewState, isAuthenticated]);
55
55
  const renderWithNavigation = (content, activeView) => {
56
- return (<main className={`
56
+ return (
57
+ //
58
+ <main className={`
57
59
  relative flex justify-end
58
60
  ${isMobile ? 'h-[100dvh]' : 'h-[100dvh] xs:h-auto xs:rounded-[30px] '}
59
61
  `}>
@@ -76,9 +78,8 @@ const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
76
78
  `}
77
79
 
78
80
  `}>
79
- <div className="flex h-full flex-col ">
80
- {/* 해당 컨텐츠만 스크롤 되고 */}
81
- <div className="flex-1 overflow-hidden">{content}</div>
81
+ <div className="flex h-full flex-col ">
82
+ <div className="overflow-hidden border-2">{content}</div>
82
83
  {/* 얘는 아래 64px로 고정 */}
83
84
  <NavigationFooter activeView={activeView} onHomeClick={handleBackToHome} onHistoryClick={handleHistoryClick} historyList={historyList} isAuthenticated={isAuthenticated}/>
84
85
  </div>
@@ -105,12 +105,12 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobil
105
105
 
106
106
  const renderWithNavigation = (content: React.ReactNode, activeView: 'home' | 'history' | 'conversation') => {
107
107
  return (
108
+ //
108
109
  <main
109
110
  className={`
110
111
  relative flex justify-end
111
112
  ${isMobile ? 'h-[100dvh]' : 'h-[100dvh] xs:h-auto xs:rounded-[30px] '}
112
113
  `}
113
- // ${isMobile ? 'h-[100dvh] w-screen' : ''} relative flex items-center justify-center rounded-[30px]
114
114
  >
115
115
  <div
116
116
  className={`
@@ -137,9 +137,8 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobil
137
137
 
138
138
  `}
139
139
  >
140
- <div className="flex h-full flex-col ">
141
- {/* 해당 컨텐츠만 스크롤 되고 */}
142
- <div className="flex-1 overflow-hidden">{content}</div>
140
+ <div className="flex h-full flex-col ">
141
+ <div className="overflow-hidden border-2">{content}</div>
143
142
  {/* 얘는 아래 64px로 고정 */}
144
143
  <NavigationFooter
145
144
  activeView={activeView}
@@ -43,12 +43,10 @@ const ChatWidget = ({ isOpen, isMobile, onClose, hashValue, setHashValue }) => {
43
43
  `;
44
44
  const innerWebSmallWrapperCss = `
45
45
  rounded-none
46
- xs:max-h-[690px]
47
- xs:mx-[10px] xs:shadow-[0px_4px_10px_0px_#00000026]
46
+
48
47
  `;
49
48
  // 웹 480~1023px , pc 1024px~
50
49
  const innerWebTbPCWrapperCss = `
51
-
52
50
  xs:rounded-[30px]
53
51
  `;
54
52
  // 웹 모바일
@@ -56,15 +54,16 @@ const ChatWidget = ({ isOpen, isMobile, onClose, hashValue, setHashValue }) => {
56
54
  return (<>
57
55
  <ImageViewer />
58
56
 
59
- <div className="relative z-[999998] ">
57
+ <div className="relative ">
60
58
  <div className={`
61
59
  flex justify-end
62
60
  ${isMobile ? `${mobileWrapperCss}` : `${webSmallWrapperCss} ${webTbPCWrapperCss} `}
63
61
 
64
62
  `}>
65
- {/* 여기서 스크롤이 생김 */}
63
+ {/* 여기서 외각 스크롤 생김 */}
66
64
  <div ref={containerRef} className={`
67
- no-scrollbar relative flex h-full items-center justify-center overflow-auto
65
+ no-scrollbar
66
+ relative z-[999998] flex h-full flex-col items-center justify-end
68
67
  ${isMobile ? `${innerMobileWrapperCss}` : `${innerWebSmallWrapperCss} ${innerWebTbPCWrapperCss}`}
69
68
  `}>
70
69
  <ChatHomeView hashValue={hashValue} isMobile={isMobile} isHash={isHash} onClose={onClose}/>
@@ -60,13 +60,11 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen, isMobile, onClose, hash
60
60
 
61
61
  const innerWebSmallWrapperCss = `
62
62
  rounded-none
63
- xs:max-h-[690px]
64
- xs:mx-[10px] xs:shadow-[0px_4px_10px_0px_#00000026]
63
+
65
64
  `;
66
65
 
67
66
  // 웹 480~1023px , pc 1024px~
68
67
  const innerWebTbPCWrapperCss = `
69
-
70
68
  xs:rounded-[30px]
71
69
  `;
72
70
 
@@ -78,7 +76,7 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen, isMobile, onClose, hash
78
76
  <>
79
77
  <ImageViewer />
80
78
 
81
- <div className="relative z-[999998] ">
79
+ <div className="relative ">
82
80
  <div
83
81
  className={`
84
82
  flex justify-end
@@ -86,11 +84,12 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen, isMobile, onClose, hash
86
84
 
87
85
  `}
88
86
  >
89
- {/* 여기서 스크롤이 생김 */}
87
+ {/* 여기서 외각 스크롤 생김 */}
90
88
  <div
91
89
  ref={containerRef}
92
90
  className={`
93
- no-scrollbar relative flex h-full items-center justify-center overflow-auto
91
+ no-scrollbar
92
+ relative z-[999998] flex h-full flex-col items-center justify-end
94
93
  ${isMobile ? `${innerMobileWrapperCss}` : `${innerWebSmallWrapperCss} ${innerWebTbPCWrapperCss}`}
95
94
  `}
96
95
  >
@@ -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) {