@daeryun/dr_components 0.8.7 → 0.8.8
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.
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +5 -3
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +5 -4
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useFullURL.d.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useFullURL.jsx +17 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useFullURL.tsx +22 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -12,11 +12,13 @@ import { attendChatRoomByHistory, chatUserUpdate as apiChatUserUpdate, chatWorkF
|
|
|
12
12
|
import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage } from '../../_lib';
|
|
13
13
|
import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
14
14
|
import { usePathname, useSearchParams } from 'next/navigation';
|
|
15
|
+
import { useFullURL } from './useFullURL';
|
|
15
16
|
export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData }) => {
|
|
16
17
|
const toast = useDaeryunTalkToast();
|
|
17
18
|
const pathname = usePathname(); // => "/daeryuntalk"
|
|
18
19
|
const searchParams = useSearchParams(); // => URLSearchParams 객체
|
|
19
|
-
const
|
|
20
|
+
const fullUrl = useFullURL();
|
|
21
|
+
console.log('fullUrl', fullUrl);
|
|
20
22
|
// 채팅 시작 (문의하기 버튼 클릭 시)
|
|
21
23
|
const startChat = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
24
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
@@ -34,7 +36,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
34
36
|
else {
|
|
35
37
|
// 새 문의 생성
|
|
36
38
|
console.log('[DaeryuntalkContext] 새 문의 생성 시작');
|
|
37
|
-
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '',
|
|
39
|
+
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullUrl);
|
|
38
40
|
if (createResponse && createResponse.data && createResponse.data.chat_inquiry_number) {
|
|
39
41
|
currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
40
42
|
console.log('[DaeryuntalkContext] 새 문의 생성 완료:', currentChatInquiryNumber);
|
|
@@ -205,7 +207,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
205
207
|
}
|
|
206
208
|
setIsLoading(true);
|
|
207
209
|
console.log('chatInquiryNumber', chatInquiryNumber);
|
|
208
|
-
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '',
|
|
210
|
+
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullUrl);
|
|
209
211
|
console.log('[DaeryuntalkContext] 새 문의 생성 완료:', createResponse);
|
|
210
212
|
if (createResponse.data) {
|
|
211
213
|
const currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
@@ -17,6 +17,7 @@ import { MessageObject } from '../../_types/message_object';
|
|
|
17
17
|
import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
18
18
|
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
|
19
19
|
import { router } from 'next/client';
|
|
20
|
+
import { useFullURL } from './useFullURL';
|
|
20
21
|
interface props {
|
|
21
22
|
setIsLoading: Dispatch<SetStateAction<boolean>>;
|
|
22
23
|
inquiryMainData: IChatInquiryMainDataResponse | null;
|
|
@@ -45,8 +46,8 @@ export const useChatHandler = ({
|
|
|
45
46
|
const toast = useDaeryunTalkToast();
|
|
46
47
|
const pathname = usePathname(); // => "/daeryuntalk"
|
|
47
48
|
const searchParams = useSearchParams(); // => URLSearchParams 객체
|
|
48
|
-
const
|
|
49
|
-
|
|
49
|
+
const fullUrl = useFullURL();
|
|
50
|
+
console.log('fullUrl', fullUrl);
|
|
50
51
|
// 채팅 시작 (문의하기 버튼 클릭 시)
|
|
51
52
|
const startChat = useCallback(async () => {
|
|
52
53
|
try {
|
|
@@ -66,7 +67,7 @@ export const useChatHandler = ({
|
|
|
66
67
|
} else {
|
|
67
68
|
// 새 문의 생성
|
|
68
69
|
console.log('[DaeryuntalkContext] 새 문의 생성 시작');
|
|
69
|
-
const createResponse = await generateChatInquiry(inquiryMainData?.channel_number || '',
|
|
70
|
+
const createResponse = await generateChatInquiry(inquiryMainData?.channel_number || '', fullUrl);
|
|
70
71
|
|
|
71
72
|
if (createResponse && createResponse.data && createResponse.data.chat_inquiry_number) {
|
|
72
73
|
currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
@@ -258,7 +259,7 @@ export const useChatHandler = ({
|
|
|
258
259
|
}
|
|
259
260
|
setIsLoading(true);
|
|
260
261
|
console.log('chatInquiryNumber', chatInquiryNumber);
|
|
261
|
-
const createResponse = await generateChatInquiry(inquiryMainData?.channel_number || '',
|
|
262
|
+
const createResponse = await generateChatInquiry(inquiryMainData?.channel_number || '', fullUrl);
|
|
262
263
|
console.log('[DaeryuntalkContext] 새 문의 생성 완료:', createResponse);
|
|
263
264
|
if (createResponse.data) {
|
|
264
265
|
const currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFullURL(): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { usePathname, useSearchParams } from 'next/navigation';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
export function useFullURL() {
|
|
4
|
+
const pathname = usePathname();
|
|
5
|
+
const searchParams = useSearchParams();
|
|
6
|
+
const [fullUrl, setFullUrl] = useState('');
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (typeof window !== 'undefined') {
|
|
9
|
+
const origin = window.location.origin; // https://example.com
|
|
10
|
+
const query = searchParams.toString(); // scrollToMsg=true
|
|
11
|
+
const hash = window.location.hash; // #1234 or ''
|
|
12
|
+
const fullPath = origin + pathname + (query ? `?${query}` : '') + hash;
|
|
13
|
+
setFullUrl(fullPath);
|
|
14
|
+
}
|
|
15
|
+
}, [pathname, searchParams]);
|
|
16
|
+
return fullUrl;
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { usePathname, useSearchParams } from 'next/navigation';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
export function useFullURL() {
|
|
5
|
+
const pathname = usePathname();
|
|
6
|
+
const searchParams = useSearchParams();
|
|
7
|
+
const [fullUrl, setFullUrl] = useState('');
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (typeof window !== 'undefined') {
|
|
11
|
+
const origin = window.location.origin; // https://example.com
|
|
12
|
+
const query = searchParams.toString(); // scrollToMsg=true
|
|
13
|
+
const hash = window.location.hash; // #1234 or ''
|
|
14
|
+
|
|
15
|
+
const fullPath = origin + pathname + (query ? `?${query}` : '') + hash;
|
|
16
|
+
|
|
17
|
+
setFullUrl(fullPath);
|
|
18
|
+
}
|
|
19
|
+
}, [pathname, searchParams]);
|
|
20
|
+
|
|
21
|
+
return fullUrl;
|
|
22
|
+
}
|