@daeryun/dr_components 0.8.2 → 0.8.3

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 (29) hide show
  1. package/dist/components/Daeryuntalk/ChatButton.d.ts +2 -0
  2. package/dist/components/Daeryuntalk/ChatButton.jsx +12 -3
  3. package/dist/components/Daeryuntalk/ChatButton.tsx +15 -3
  4. package/dist/components/Daeryuntalk/ChatHomeView.d.ts +7 -2
  5. package/dist/components/Daeryuntalk/ChatHomeView.jsx +20 -22
  6. package/dist/components/Daeryuntalk/ChatHomeView.tsx +38 -31
  7. package/dist/components/Daeryuntalk/ChatWidget.d.ts +3 -1
  8. package/dist/components/Daeryuntalk/ChatWidget.jsx +16 -20
  9. package/dist/components/Daeryuntalk/ChatWidget.tsx +21 -21
  10. package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +1 -1
  11. package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +1 -1
  12. package/dist/components/Daeryuntalk/HistoryView.jsx +6 -6
  13. package/dist/components/Daeryuntalk/HistoryView.tsx +11 -9
  14. package/dist/components/Daeryuntalk/NavigationFooter.d.ts +1 -1
  15. package/dist/components/Daeryuntalk/NavigationFooter.jsx +3 -0
  16. package/dist/components/Daeryuntalk/NavigationFooter.tsx +4 -1
  17. package/dist/components/Daeryuntalk/Toast/ToastRender.jsx +0 -1
  18. package/dist/components/Daeryuntalk/Toast/ToastRender.tsx +0 -1
  19. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +4 -0
  20. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +24 -1
  21. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +30 -1
  22. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +1 -1
  23. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +18 -2
  24. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +17 -3
  25. package/dist/components/Daeryuntalk/index.jsx +22 -5
  26. package/dist/components/Daeryuntalk/index.tsx +34 -10
  27. package/dist/styles/globals.css +12 -18
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +1 -1
@@ -49,7 +49,9 @@ const ENDPOINTS = {
49
49
  HISTORY_PHONE_REQUEST: '/chatctm/his/occupancycertificationnumbersend', // 점유 인증 번호 요청
50
50
  HISTORY_PHONE_AUTHENTICATION: '/chatctm/his/occupancycertificationnumberverification', // 점유 인증 번호 검증
51
51
  HISTORY_LIST: '/chatctm/his/historychatinquirylistsearch', // 히스토리 채팅 문의 목록 조회
52
- ATTEND_CHAT_BY_HISTORY: '/chatctm/his/historychatinquiryparticipation' // 채팅문의 참여
52
+ ATTEND_CHAT_BY_HISTORY: '/chatctm/his/historychatinquiryparticipation', // 채팅문의 참여
53
+ /* 팔로업 알림 인증 */
54
+ FOLLOWUP_ATTENTD: '/chatctm/chi/chatinquiryalarmparticipation' // 채팅 문의 알림 참여
53
55
  };
54
56
 
55
57
  // 메인
@@ -931,3 +933,30 @@ export const attendChatRoomByHistory = async ({
931
933
  throw error;
932
934
  }
933
935
  };
936
+
937
+ export const followupAttend = async ({ token, version = DEFAULT_API_VERSION }: { token: string; version?: string }) => {
938
+ const consoleName = '히스토리 채팅 문의 참여';
939
+ try {
940
+ console.log(`[${consoleName} 진행]`);
941
+
942
+ const body = {
943
+ d: {
944
+ token: token // required
945
+ }
946
+ };
947
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<HistoryListResponse>>(
948
+ `${API_BASE_URL}${ENDPOINTS.FOLLOWUP_ATTENTD}`,
949
+ {
950
+ method: 'POST',
951
+ body: JSON.stringify(body)
952
+ },
953
+ version
954
+ );
955
+
956
+ console.log(`[${consoleName} 완료]`, response);
957
+ return response;
958
+ } catch (error) {
959
+ console.error(`[${consoleName} 실패] 오류:`, error);
960
+ throw error;
961
+ }
962
+ };
@@ -13,7 +13,7 @@ interface props {
13
13
  setInquiryStatus: Dispatch<SetStateAction<string>>;
14
14
  }
15
15
  export declare const useSocketEventHandler: ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus }: props) => {
16
- initializeDaeryuntalk: (version?: string) => Promise<void>;
16
+ initializeDaeryuntalk: (hashValue: string | null, version?: string) => Promise<void>;
17
17
  sendHeartbeat: (chatInquiryNumber: string) => void;
18
18
  sendInquiryJoined: (chatInquiryNumber: string) => void;
19
19
  sendInquiryLeft: (chatInquiryNumber: string) => void;
@@ -8,11 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { useCallback } from 'react';
11
- import { initializeDaeryuntalk as apiInitializeDaeryuntalk } from '../../_api/daeryuntalk';
11
+ import { followupAttend, initializeDaeryuntalk as apiInitializeDaeryuntalk } from '../../_api/daeryuntalk';
12
12
  import { convertApiMessageToUiMessage, convertSocketObjectToUiMessage } from '../../_lib';
13
13
  import { MessageSocketType } from '../../_enums/socket_type';
14
14
  import { InquiryStatus } from '../../_enums/ask-status';
15
+ import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
15
16
  export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus }) => {
17
+ const toast = useDaeryunTalkToast();
16
18
  /**
17
19
  * 1. heartbeat
18
20
  * - 목적: 사용자의 이탈 여부를 추적하기 위한 주기적 하트비트 전송
@@ -116,11 +118,25 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
116
118
  }
117
119
  }, []);
118
120
  // Daeryuntalk API 초기화 메소드
119
- const initializeDaeryuntalk = useCallback((version) => __awaiter(void 0, void 0, void 0, function* () {
121
+ const initializeDaeryuntalk = useCallback((hashValue, version) => __awaiter(void 0, void 0, void 0, function* () {
122
+ var _a, _b;
120
123
  console.log('[DaeryuntalkContext] 초기화 메소드 호출됨', version ? `버전: ${version}` : '기본 버전 사용');
121
124
  try {
122
125
  setIsLoading(true);
123
126
  console.log('[DaeryuntalkContext] 로딩 상태 설정: true');
127
+ // 만약 해쉬값이 있으면 이것부터 해여함
128
+ if (hashValue) {
129
+ const hashAuth = yield followupAttend({ token: hashValue });
130
+ console.log('hashAuth', hashAuth);
131
+ if (((_a = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _a === void 0 ? void 0 : _a.result_type_cd) === 'OK' || ((_b = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _b === void 0 ? void 0 : _b.result_cd) === 'OK') {
132
+ // 인증 완
133
+ }
134
+ else {
135
+ toast.error('인증에 실패했습니다.');
136
+ window.location.href = '/';
137
+ return;
138
+ }
139
+ }
124
140
  const { inquiryData, socket } = yield apiInitializeDaeryuntalk(socket => {
125
141
  console.log('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
126
142
  setIsConnected(true);
@@ -1,6 +1,6 @@
1
1
  import { Dispatch, MutableRefObject, SetStateAction, useCallback, useRef } from 'react';
2
2
 
3
- import { initializeDaeryuntalk as apiInitializeDaeryuntalk } from '../../_api/daeryuntalk';
3
+ import { followupAttend, initializeDaeryuntalk as apiInitializeDaeryuntalk } from '../../_api/daeryuntalk';
4
4
  import { Message } from '../../_types/message';
5
5
  import { IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/response';
6
6
  import { convertApiMessageToUiMessage, convertSocketObjectToUiMessage } from '../../_lib';
@@ -8,6 +8,7 @@ import { MessageObject } from '../../_types/message_object';
8
8
  import { IInquiryWorkFlowUpdate } from '../../_types/socket/workflow';
9
9
  import { MessageSocketType } from '../../_enums/socket_type';
10
10
  import { InquiryStatus } from '../../_enums/ask-status';
11
+ import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
11
12
 
12
13
  interface props {
13
14
  setIsConnected: Dispatch<SetStateAction<boolean>>;
@@ -29,6 +30,7 @@ export const useSocketEventHandler = ({
29
30
  setMessageObject,
30
31
  setInquiryStatus
31
32
  }: props) => {
33
+ const toast = useDaeryunTalkToast();
32
34
  /**
33
35
  * 1. heartbeat
34
36
  * - 목적: 사용자의 이탈 여부를 추적하기 위한 주기적 하트비트 전송
@@ -147,11 +149,23 @@ export const useSocketEventHandler = ({
147
149
  }, []);
148
150
 
149
151
  // Daeryuntalk API 초기화 메소드
150
- const initializeDaeryuntalk = useCallback(async (version?: string) => {
152
+ const initializeDaeryuntalk = useCallback(async (hashValue: string | null, version?: string) => {
151
153
  console.log('[DaeryuntalkContext] 초기화 메소드 호출됨', version ? `버전: ${version}` : '기본 버전 사용');
152
154
  try {
153
155
  setIsLoading(true);
154
156
  console.log('[DaeryuntalkContext] 로딩 상태 설정: true');
157
+ // 만약 해쉬값이 있으면 이것부터 해여함
158
+ if (hashValue) {
159
+ const hashAuth = await followupAttend({ token: hashValue });
160
+ console.log('hashAuth', hashAuth);
161
+ if (hashAuth?.result_info?.result_type_cd === 'OK' || hashAuth?.result_info?.result_cd === 'OK') {
162
+ // 인증 완
163
+ } else {
164
+ toast.error('인증에 실패했습니다.');
165
+ window.location.href = '/';
166
+ return;
167
+ }
168
+ }
155
169
 
156
170
  const { inquiryData, socket } = await apiInitializeDaeryuntalk(
157
171
  socket => {
@@ -200,7 +214,7 @@ export const useSocketEventHandler = ({
200
214
  }
201
215
  // 안읽음 count
202
216
  if (data.type === MessageSocketType.INQUIRY_PREVIEW_UPDATED) {
203
- console.log('히스토리??')
217
+ console.log('히스토리??');
204
218
  }
205
219
  // 새로운 문의가 생성됨
206
220
  if (data.type === MessageSocketType.INQUIRY_OPENED) {
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import React, { useState } from 'react';
2
+ import React, { useEffect, useState } from 'react';
3
3
  import ChatButton from './ChatButton';
4
4
  import ChatWidget from './ChatWidget';
5
5
  import { DaeryuntalkProvider } from './DaeryuntalkContext';
@@ -7,18 +7,35 @@ import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
7
7
  import mobile from 'is-mobile';
8
8
  const Daeryuntalk = ({ tel = '1800-7905' }) => {
9
9
  const [isOpen, setIsOpen] = useState(false);
10
- const isMobile = mobile();
10
+ const [isMobile, setIsMobile] = useState(false);
11
+ // const isMobile = mobile();
12
+ const [hashValue, setHashValue] = useState(null);
13
+ const isLocal = process.env.NODE_ENV === 'development';
11
14
  const toggleChat = () => {
12
15
  setIsOpen(prev => !prev);
13
16
  };
14
17
  const closeChatWidget = () => {
15
18
  setIsOpen(false);
16
19
  };
20
+ useEffect(() => {
21
+ if (typeof window !== 'undefined') {
22
+ setIsMobile(mobile());
23
+ const path = window.location.pathname;
24
+ if (path === (isLocal ? '/chat-test' : '/daeryuntalk')) {
25
+ const hash = window.location.hash;
26
+ const value = hash ? hash.substring(1) : null;
27
+ if (value) {
28
+ setHashValue(value);
29
+ // 해시 제거 (주소창에서 #... 부분 삭제)
30
+ window.history.replaceState(null, '', window.location.pathname + window.location.search);
31
+ }
32
+ }
33
+ }
34
+ }, []);
17
35
  return (<DaeryuntalkToastProvider>
18
36
  <DaeryuntalkProvider propsTel={tel}>
19
- {/* 버튼 */}
20
- {isMobile ? (!isOpen && <ChatButton isOpen={isOpen} onClick={toggleChat}/>) : (<ChatButton isOpen={isOpen} onClick={toggleChat}/>)}
21
- <ChatWidget isOpen={isOpen} isMobile={false} onClose={closeChatWidget}/>
37
+ <ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat}/>
38
+ <ChatWidget isOpen={hashValue ? true : isOpen} isMobile={isMobile} onClose={closeChatWidget} hashValue={hashValue} setHashValue={setHashValue}/>
22
39
  </DaeryuntalkProvider>
23
40
  </DaeryuntalkToastProvider>);
24
41
  };
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
 
3
- import React, { useState } from 'react';
3
+ import React, { useEffect, useState } from 'react';
4
4
  import ChatButton from './ChatButton';
5
5
  import ChatWidget from './ChatWidget';
6
- import { DaeryuntalkProvider } from './DaeryuntalkContext';
6
+ import { DaeryuntalkProvider, useDaeryuntalk } from './DaeryuntalkContext';
7
7
  import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
8
8
  import mobile from 'is-mobile';
9
9
 
@@ -13,7 +13,11 @@ type DaeryuntalkProps = {
13
13
 
14
14
  const Daeryuntalk: React.FC<DaeryuntalkProps> = ({ tel = '1800-7905' }) => {
15
15
  const [isOpen, setIsOpen] = useState(false);
16
- const isMobile = mobile();
16
+ const [isMobile, setIsMobile] = useState(false);
17
+
18
+ // const isMobile = mobile();
19
+ const [hashValue, setHashValue] = useState<string | null>(null);
20
+ const isLocal = process.env.NODE_ENV === 'development';
17
21
 
18
22
  const toggleChat = () => {
19
23
  setIsOpen(prev => !prev);
@@ -23,16 +27,36 @@ const Daeryuntalk: React.FC<DaeryuntalkProps> = ({ tel = '1800-7905' }) => {
23
27
  setIsOpen(false);
24
28
  };
25
29
 
30
+ useEffect(() => {
31
+ if (typeof window !== 'undefined') {
32
+ setIsMobile(mobile());
33
+
34
+ const path = window.location.pathname;
35
+ if (path === (isLocal ? '/chat-test' : '/daeryuntalk')) {
36
+ const hash = window.location.hash;
37
+ const value = hash ? hash.substring(1) : null;
38
+
39
+ if (value) {
40
+ setHashValue(value);
41
+
42
+ // 해시 제거 (주소창에서 #... 부분 삭제)
43
+ window.history.replaceState(null, '', window.location.pathname + window.location.search);
44
+ }
45
+ }
46
+ }
47
+ }, []);
48
+
26
49
  return (
27
50
  <DaeryuntalkToastProvider>
28
51
  <DaeryuntalkProvider propsTel={tel}>
29
- {/* 버튼 */}
30
- {isMobile ? (
31
- !isOpen && <ChatButton isOpen={isOpen} onClick={toggleChat} />
32
- ) : (
33
- <ChatButton isOpen={isOpen} onClick={toggleChat} />
34
- )}
35
- <ChatWidget isOpen={isOpen} isMobile={false} onClose={closeChatWidget} />
52
+ <ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat} />
53
+ <ChatWidget
54
+ isOpen={hashValue ? true : isOpen}
55
+ isMobile={isMobile}
56
+ onClose={closeChatWidget}
57
+ hashValue={hashValue}
58
+ setHashValue={setHashValue}
59
+ />
36
60
  </DaeryuntalkProvider>
37
61
  </DaeryuntalkToastProvider>
38
62
  );
@@ -1050,6 +1050,10 @@ video {
1050
1050
  bottom: 15px;
1051
1051
  }
1052
1052
 
1053
+ .bottom-\[165px\] {
1054
+ bottom: 165px;
1055
+ }
1056
+
1053
1057
  .bottom-\[36px\] {
1054
1058
  bottom: 36px;
1055
1059
  }
@@ -1134,10 +1138,6 @@ video {
1134
1138
  right: 2.5rem;
1135
1139
  }
1136
1140
 
1137
- .right-4 {
1138
- right: 1rem;
1139
- }
1140
-
1141
1141
  .right-5 {
1142
1142
  right: 1.25rem;
1143
1143
  }
@@ -1222,10 +1222,6 @@ video {
1222
1222
  top: 50%;
1223
1223
  }
1224
1224
 
1225
- .top-4 {
1226
- top: 1rem;
1227
- }
1228
-
1229
1225
  .top-5 {
1230
1226
  top: 1.25rem;
1231
1227
  }
@@ -2220,6 +2216,10 @@ video {
2220
2216
  height: 1000px;
2221
2217
  }
2222
2218
 
2219
+ .h-\[100dvh\] {
2220
+ height: 100dvh;
2221
+ }
2222
+
2223
2223
  .h-\[100px\] {
2224
2224
  height: 100px;
2225
2225
  }
@@ -5360,10 +5360,6 @@ video {
5360
5360
  background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
5361
5361
  }
5362
5362
 
5363
- .bg-white\/70 {
5364
- background-color: rgb(255 255 255 / 0.7);
5365
- }
5366
-
5367
5363
  .bg-opacity-0 {
5368
5364
  --tw-bg-opacity: 0;
5369
5365
  }
@@ -7521,12 +7517,6 @@ video {
7521
7517
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
7522
7518
  }
7523
7519
 
7524
- .backdrop-blur {
7525
- --tw-backdrop-blur: blur(8px);
7526
- -webkit-backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
7527
- backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
7528
- }
7529
-
7530
7520
  .backdrop-blur-sm {
7531
7521
  --tw-backdrop-blur: blur(4px);
7532
7522
  -webkit-backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
@@ -16587,6 +16577,10 @@ body {
16587
16577
  }
16588
16578
 
16589
16579
  @media (min-width: 1024px) {
16580
+ .lg\:bottom-\[110px\] {
16581
+ bottom: 110px;
16582
+ }
16583
+
16590
16584
  .lg\:bottom-\[30px\] {
16591
16585
  bottom: 30px;
16592
16586
  }