@daeryun/dr_components 0.7.87 → 0.7.88
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/ChatButton.jsx +3 -1
- package/dist/components/Daeryuntalk/ChatButton.tsx +3 -1
- package/dist/components/Daeryuntalk/ChatConversation.jsx +23 -5
- package/dist/components/Daeryuntalk/ChatConversation.tsx +27 -5
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +26 -11
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +32 -9
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +21 -3
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +32 -11
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +69 -23
- package/dist/components/Daeryuntalk/History/AuthForm.d.ts +8 -0
- package/dist/components/Daeryuntalk/History/AuthForm.jsx +140 -0
- package/dist/components/Daeryuntalk/History/AuthForm.tsx +186 -0
- package/dist/components/Daeryuntalk/HistoryView.d.ts +6 -0
- package/dist/components/Daeryuntalk/HistoryView.jsx +49 -35
- package/dist/components/Daeryuntalk/HistoryView.tsx +78 -47
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +1 -1
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +1 -1
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +29 -1
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +98 -7
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +136 -8
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.d.ts +13 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.ts +17 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +3 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +76 -8
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +88 -12
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.d.ts +24 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.js +75 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.ts +90 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +12 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +16 -2
- package/dist/components/Daeryuntalk/_lib/utils.d.ts +10 -0
- package/dist/components/Daeryuntalk/_lib/utils.js +25 -0
- package/dist/components/Daeryuntalk/_lib/utils.ts +39 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button2.d.ts +10 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button2.jsx +12 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button2.tsx +28 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input2.d.ts +13 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input2.jsx +9 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input2.tsx +42 -0
- package/dist/styles/globals.css +27 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React, { useState } from 'react';
|
|
11
|
+
import Input2 from '../_ui/inputs/Input2';
|
|
12
|
+
import { formatSecondsToMMSS, nameFilter, onlyNumbers, phoneCheck } from '../_lib/utils';
|
|
13
|
+
import Button2 from '../_ui/buttons/Button2';
|
|
14
|
+
import { historyPhoneAuth, requestPhone } from '../_api';
|
|
15
|
+
const AuthForm = ({ goGetHistoryList }) => {
|
|
16
|
+
const [name, setName] = useState({ value: '', isValid: false });
|
|
17
|
+
const [phone, setPhone] = useState({ value: '', isValid: false });
|
|
18
|
+
const [authNumber, setAuthNumber] = useState('');
|
|
19
|
+
const [isConfirmState, setIsConfirmState] = useState(false);
|
|
20
|
+
const [timer, setTimer] = useState(180); // 3분(180초)
|
|
21
|
+
const [timerId, setTimerId] = useState(null);
|
|
22
|
+
// 3분 인증시간 start 필요
|
|
23
|
+
const handleInput = (e) => {
|
|
24
|
+
const { name: formName, value } = e.currentTarget;
|
|
25
|
+
if (formName === 'name') {
|
|
26
|
+
const { name: propsName, isValid } = nameFilter(value);
|
|
27
|
+
setName(prev => {
|
|
28
|
+
return {
|
|
29
|
+
value: propsName,
|
|
30
|
+
isValid: isValid
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (formName === 'phone') {
|
|
35
|
+
const { phoneNumber, isValid } = phoneCheck(value);
|
|
36
|
+
setPhone(prev => {
|
|
37
|
+
return {
|
|
38
|
+
value: phoneNumber,
|
|
39
|
+
isValid: isValid
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (formName === 'authNumber') {
|
|
44
|
+
setAuthNumber(onlyNumbers(value));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
// 인증번호 발송 클릭
|
|
48
|
+
const handleSendAuth = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
try {
|
|
50
|
+
const res = yield requestPhone({ name: name.value, cellPhoneNumber: phone.value });
|
|
51
|
+
if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
|
|
52
|
+
// 인증번호 발송 API 호출 등 처리
|
|
53
|
+
setIsConfirmState(true);
|
|
54
|
+
setAuthNumber('');
|
|
55
|
+
setTimer(180);
|
|
56
|
+
if (timerId)
|
|
57
|
+
clearInterval(timerId);
|
|
58
|
+
const id = setInterval(() => {
|
|
59
|
+
setTimer(prev => {
|
|
60
|
+
if (prev <= 1) {
|
|
61
|
+
clearInterval(id);
|
|
62
|
+
setIsConfirmState(false); // 타이머 종료시 인증상태 해제
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
return prev - 1;
|
|
66
|
+
});
|
|
67
|
+
}, 1000);
|
|
68
|
+
setTimerId(id);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
console.error('e', e);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// 인증번호 확인
|
|
78
|
+
const handleSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
try {
|
|
80
|
+
const res = yield historyPhoneAuth({
|
|
81
|
+
name: name.value,
|
|
82
|
+
cellPhoneNumber: phone.value,
|
|
83
|
+
certificationNumber: authNumber
|
|
84
|
+
});
|
|
85
|
+
if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
|
|
86
|
+
yield goGetHistoryList({});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
console.error('e', e);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return (<div className={`
|
|
96
|
+
mt-[24px] p-4
|
|
97
|
+
`}>
|
|
98
|
+
<div className={`p-[20px]`}>
|
|
99
|
+
<div className={`text-[16px] font-[700] leading-[140%] tracking-[-4%]`}>
|
|
100
|
+
문의 히스토리 확인을 위해 이전에 문의하실 때 입력하신 정보를 입력해 주세요.
|
|
101
|
+
</div>
|
|
102
|
+
<div className={`flex flex-col`}>
|
|
103
|
+
<div className={`mt-[40px] flex flex-col gap-[8px]`}>
|
|
104
|
+
<div className={`text-[14px] font-[700] leading-[100%] tracking-[-4%]`}>이름</div>
|
|
105
|
+
<Input2 onChange={handleInput} value={name.value} type="text" name="name" placeholder={'이름'} readOnly={isConfirmState}/>
|
|
106
|
+
</div>
|
|
107
|
+
<div className={`mt-[20px] flex flex-col gap-[8px]`}>
|
|
108
|
+
<div className={`text-[14px] font-[700] leading-[100%] tracking-[-4%]`}>휴대폰 번호</div>
|
|
109
|
+
<div className={`flex flex-row gap-[4px]`}>
|
|
110
|
+
<Input2 onChange={handleInput} value={phone.value} type="text" name="phone" className={`!py-[12.5px]`} readOnly={isConfirmState} maxLength={11} placeholder="숫자만 입력"/>
|
|
111
|
+
<Button2 isDisabled={isConfirmState || !name.isValid || !phone.isValid} onClick={handleSendAuth} type={'button'} className={`w-[120px]`}>
|
|
112
|
+
인증번호 발송
|
|
113
|
+
</Button2>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
{isConfirmState && (<div className={`mt-[4px] text-[12px] leading-[140%] tracking-[-4%] text-[#000] text-[#000]/80`}>
|
|
117
|
+
인증번호가 발송되었습니다.
|
|
118
|
+
</div>)}
|
|
119
|
+
|
|
120
|
+
{isConfirmState && (<div className={`relative mt-[10px]`}>
|
|
121
|
+
<Input2 onChange={handleInput} value={authNumber} type="text" name="authNumber" maxLength={6} placeholder={'인증 번호 입력'}/>
|
|
122
|
+
<div className={`absolute right-[8px] top-[15px] text-[12px] font-[400] leading-[100%] tracking-[-4%] text-[#AA1D36] `}>
|
|
123
|
+
{formatSecondsToMMSS(timer)}
|
|
124
|
+
</div>
|
|
125
|
+
</div>)}
|
|
126
|
+
|
|
127
|
+
{isConfirmState && (<div className={`mt-[20px] text-[12px] leading-[140%] tracking-[-4%] text-[#000] text-[#000]/80`}>
|
|
128
|
+
인증번호가 오지 않는 경우 휴대폰 번호 차단 여부를 확인해주세요.(대륜 고객센터 1800-7905)
|
|
129
|
+
</div>)}
|
|
130
|
+
|
|
131
|
+
{isConfirmState && (<div className="mt-[40px]">
|
|
132
|
+
<button disabled={authNumber.length < 5} className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white" onClick={handleSubmit}>
|
|
133
|
+
인증번호 확인
|
|
134
|
+
</button>
|
|
135
|
+
</div>)}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</div>);
|
|
139
|
+
};
|
|
140
|
+
export default AuthForm;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import Input2 from '../_ui/inputs/Input2';
|
|
3
|
+
import { formatSecondsToMMSS, nameFilter, onlyNumbers, phoneCheck } from '../_lib/utils';
|
|
4
|
+
import Button2 from '../_ui/buttons/Button2';
|
|
5
|
+
import { historyPhoneAuth, requestPhone } from '../_api';
|
|
6
|
+
|
|
7
|
+
interface IProps {
|
|
8
|
+
goGetHistoryList: (data: { version?: string }) => void;
|
|
9
|
+
}
|
|
10
|
+
const AuthForm = ({ goGetHistoryList }: IProps) => {
|
|
11
|
+
const [name, setName] = useState<{ value: string; isValid: boolean }>({ value: '', isValid: false });
|
|
12
|
+
const [phone, setPhone] = useState<{ value: string; isValid: boolean }>({ value: '', isValid: false });
|
|
13
|
+
const [authNumber, setAuthNumber] = useState<string>('');
|
|
14
|
+
const [isConfirmState, setIsConfirmState] = useState<boolean>(false);
|
|
15
|
+
const [timer, setTimer] = useState<number>(180); // 3분(180초)
|
|
16
|
+
const [timerId, setTimerId] = useState<NodeJS.Timeout | null>(null);
|
|
17
|
+
|
|
18
|
+
// 3분 인증시간 start 필요
|
|
19
|
+
|
|
20
|
+
const handleInput = (e: React.FormEvent<HTMLInputElement>) => {
|
|
21
|
+
const { name: formName, value } = e.currentTarget;
|
|
22
|
+
if (formName === 'name') {
|
|
23
|
+
const { name: propsName, isValid } = nameFilter(value);
|
|
24
|
+
setName(prev => {
|
|
25
|
+
return {
|
|
26
|
+
value: propsName,
|
|
27
|
+
isValid: isValid
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (formName === 'phone') {
|
|
32
|
+
const { phoneNumber, isValid } = phoneCheck(value);
|
|
33
|
+
setPhone(prev => {
|
|
34
|
+
return {
|
|
35
|
+
value: phoneNumber,
|
|
36
|
+
isValid: isValid
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (formName === 'authNumber') {
|
|
41
|
+
setAuthNumber(onlyNumbers(value));
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// 인증번호 발송 클릭
|
|
46
|
+
const handleSendAuth = async () => {
|
|
47
|
+
try {
|
|
48
|
+
const res = await requestPhone({ name: name.value, cellPhoneNumber: phone.value });
|
|
49
|
+
if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
|
|
50
|
+
// 인증번호 발송 API 호출 등 처리
|
|
51
|
+
setIsConfirmState(true);
|
|
52
|
+
setAuthNumber('');
|
|
53
|
+
setTimer(180);
|
|
54
|
+
if (timerId) clearInterval(timerId);
|
|
55
|
+
const id = setInterval(() => {
|
|
56
|
+
setTimer(prev => {
|
|
57
|
+
if (prev <= 1) {
|
|
58
|
+
clearInterval(id);
|
|
59
|
+
setIsConfirmState(false); // 타이머 종료시 인증상태 해제
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
return prev - 1;
|
|
63
|
+
});
|
|
64
|
+
}, 1000);
|
|
65
|
+
setTimerId(id);
|
|
66
|
+
}
|
|
67
|
+
} catch (e) {
|
|
68
|
+
console.error('e', e);
|
|
69
|
+
} finally {
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// 인증번호 확인
|
|
74
|
+
const handleSubmit = async () => {
|
|
75
|
+
try {
|
|
76
|
+
const res = await historyPhoneAuth({
|
|
77
|
+
name: name.value,
|
|
78
|
+
cellPhoneNumber: phone.value,
|
|
79
|
+
certificationNumber: authNumber
|
|
80
|
+
});
|
|
81
|
+
if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
|
|
82
|
+
await goGetHistoryList({});
|
|
83
|
+
}
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.error('e', e);
|
|
86
|
+
} finally {
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
className={`
|
|
93
|
+
mt-[24px] p-4
|
|
94
|
+
`}
|
|
95
|
+
>
|
|
96
|
+
<div className={`p-[20px]`}>
|
|
97
|
+
<div className={`text-[16px] font-[700] leading-[140%] tracking-[-4%]`}>
|
|
98
|
+
문의 히스토리 확인을 위해 이전에 문의하실 때 입력하신 정보를 입력해 주세요.
|
|
99
|
+
</div>
|
|
100
|
+
<div className={`flex flex-col`}>
|
|
101
|
+
<div className={`mt-[40px] flex flex-col gap-[8px]`}>
|
|
102
|
+
<div className={`text-[14px] font-[700] leading-[100%] tracking-[-4%]`}>이름</div>
|
|
103
|
+
<Input2
|
|
104
|
+
onChange={handleInput}
|
|
105
|
+
value={name.value}
|
|
106
|
+
type="text"
|
|
107
|
+
name="name"
|
|
108
|
+
placeholder={'이름'}
|
|
109
|
+
readOnly={isConfirmState}
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
<div className={`mt-[20px] flex flex-col gap-[8px]`}>
|
|
113
|
+
<div className={`text-[14px] font-[700] leading-[100%] tracking-[-4%]`}>휴대폰 번호</div>
|
|
114
|
+
<div className={`flex flex-row gap-[4px]`}>
|
|
115
|
+
<Input2
|
|
116
|
+
onChange={handleInput}
|
|
117
|
+
value={phone.value}
|
|
118
|
+
type="text"
|
|
119
|
+
name="phone"
|
|
120
|
+
className={`!py-[12.5px]`}
|
|
121
|
+
readOnly={isConfirmState}
|
|
122
|
+
maxLength={11}
|
|
123
|
+
placeholder="숫자만 입력"
|
|
124
|
+
/>
|
|
125
|
+
<Button2
|
|
126
|
+
isDisabled={isConfirmState || !name.isValid || !phone.isValid}
|
|
127
|
+
onClick={handleSendAuth}
|
|
128
|
+
type={'button'}
|
|
129
|
+
className={`w-[120px]`}
|
|
130
|
+
>
|
|
131
|
+
인증번호 발송
|
|
132
|
+
</Button2>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
{isConfirmState && (
|
|
136
|
+
<div
|
|
137
|
+
className={`mt-[4px] text-[12px] leading-[140%] tracking-[-4%] text-[#000] text-[#000]/80`}
|
|
138
|
+
>
|
|
139
|
+
인증번호가 발송되었습니다.
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
142
|
+
|
|
143
|
+
{isConfirmState && (
|
|
144
|
+
<div className={`relative mt-[10px]`}>
|
|
145
|
+
<Input2
|
|
146
|
+
onChange={handleInput}
|
|
147
|
+
value={authNumber}
|
|
148
|
+
type="text"
|
|
149
|
+
name="authNumber"
|
|
150
|
+
maxLength={6}
|
|
151
|
+
placeholder={'인증 번호 입력'}
|
|
152
|
+
/>
|
|
153
|
+
<div
|
|
154
|
+
className={`absolute right-[8px] top-[15px] text-[12px] font-[400] leading-[100%] tracking-[-4%] text-[#AA1D36] `}
|
|
155
|
+
>
|
|
156
|
+
{formatSecondsToMMSS(timer)}
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
)}
|
|
160
|
+
|
|
161
|
+
{isConfirmState && (
|
|
162
|
+
<div
|
|
163
|
+
className={`mt-[20px] text-[12px] leading-[140%] tracking-[-4%] text-[#000] text-[#000]/80`}
|
|
164
|
+
>
|
|
165
|
+
인증번호가 오지 않는 경우 휴대폰 번호 차단 여부를 확인해주세요.(대륜 고객센터 1800-7905)
|
|
166
|
+
</div>
|
|
167
|
+
)}
|
|
168
|
+
|
|
169
|
+
{isConfirmState && (
|
|
170
|
+
<div className="mt-[40px]">
|
|
171
|
+
<button
|
|
172
|
+
disabled={authNumber.length < 5}
|
|
173
|
+
className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white"
|
|
174
|
+
onClick={handleSubmit}
|
|
175
|
+
>
|
|
176
|
+
인증번호 확인
|
|
177
|
+
</button>
|
|
178
|
+
</div>
|
|
179
|
+
)}
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export default AuthForm;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { History } from './_api/daeryuntalk/type/response';
|
|
2
3
|
type HistoryViewProps = {
|
|
3
4
|
onBackClick: () => void;
|
|
4
5
|
onChatHistoryClick: (historyId: string) => void;
|
|
5
6
|
onNewChatClick: () => void;
|
|
7
|
+
isAuthenticated: boolean;
|
|
8
|
+
historyLit: History[];
|
|
9
|
+
goGetHistoryList: (data: {
|
|
10
|
+
version?: string;
|
|
11
|
+
}) => void;
|
|
6
12
|
};
|
|
7
13
|
declare const HistoryView: React.FC<HistoryViewProps>;
|
|
8
14
|
export default HistoryView;
|
|
@@ -3,28 +3,37 @@ import LinkRight from '../../asset/images/daeryuntalk/link_right.svg';
|
|
|
3
3
|
import EmptyMessage from '../../asset/images/daeryuntalk/empty_message.svg';
|
|
4
4
|
import SendIcon from '../../asset/images/daeryuntalk/send.svg';
|
|
5
5
|
import PrevIcon from '../../asset/images/daeryuntalk/prev.svg';
|
|
6
|
+
import AuthForm from './History/AuthForm';
|
|
6
7
|
const mockChatHistories = [];
|
|
7
|
-
const HistoryView = ({ onBackClick, onChatHistoryClick, onNewChatClick }) => {
|
|
8
|
+
const HistoryView = ({ onBackClick, onChatHistoryClick, onNewChatClick, isAuthenticated, historyLit, goGetHistoryList }) => {
|
|
8
9
|
const formatTimestamp = (timestamp) => {
|
|
10
|
+
if (!timestamp)
|
|
11
|
+
return '';
|
|
12
|
+
// UTC string을 Date 객체로 변환
|
|
13
|
+
const date = new Date(timestamp);
|
|
9
14
|
const now = new Date();
|
|
10
|
-
|
|
15
|
+
// 시간 차이(초)
|
|
16
|
+
const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
|
11
17
|
if (diffInSeconds < 5) {
|
|
12
18
|
return '방금';
|
|
13
19
|
}
|
|
14
20
|
if (diffInSeconds < 60 * 60 * 24) {
|
|
15
|
-
|
|
16
|
-
const
|
|
21
|
+
// 오늘 내 메시지: 시:분
|
|
22
|
+
const hours = date.getHours().toString().padStart(2, '0');
|
|
23
|
+
const minutes = date.getMinutes().toString().padStart(2, '0');
|
|
17
24
|
return `${hours}:${minutes}`;
|
|
18
25
|
}
|
|
19
26
|
if (diffInSeconds < 60 * 60 * 24 * 7) {
|
|
27
|
+
// 일주일 내: N일전
|
|
20
28
|
const days = Math.floor(diffInSeconds / (60 * 60 * 24));
|
|
21
29
|
return `${days}일전`;
|
|
22
30
|
}
|
|
23
|
-
|
|
24
|
-
const
|
|
31
|
+
// 그 외: 월일
|
|
32
|
+
const month = date.getMonth() + 1;
|
|
33
|
+
const day = date.getDate();
|
|
25
34
|
return `${month}월${day}일`;
|
|
26
35
|
};
|
|
27
|
-
const hasHistories =
|
|
36
|
+
const hasHistories = historyLit.length > 0;
|
|
28
37
|
return (<div className="flex h-full flex-col">
|
|
29
38
|
<div className="flex items-center justify-between border-b border-gray-200 p-4">
|
|
30
39
|
<button className="flex h-7 w-7 items-center justify-center" aria-label="이전" onClick={onBackClick}>
|
|
@@ -35,35 +44,40 @@ const HistoryView = ({ onBackClick, onChatHistoryClick, onNewChatClick }) => {
|
|
|
35
44
|
</div>
|
|
36
45
|
<div className="w-7"></div>
|
|
37
46
|
</div>
|
|
47
|
+
{!isAuthenticated ? (<AuthForm goGetHistoryList={goGetHistoryList}/>) : (<>
|
|
48
|
+
<div className="flex-1 overflow-y-auto px-[20px] pb-[20px] pt-[24px]">
|
|
49
|
+
{hasHistories ? (historyLit.map(history => (<div key={history.chat_inquiry_number} className="cursor-pointer border-b border-gray-100 px-[12px] py-[18px] hover:bg-gray-50" onClick={() => onChatHistoryClick(history.chat_inquiry_number)}>
|
|
50
|
+
<div className="flex items-center justify-between">
|
|
51
|
+
<span className="font-medium">{history.customer_name}</span>
|
|
52
|
+
<span className="text-xs text-gray-500">
|
|
53
|
+
{formatTimestamp(history.recent_message_date_time)}
|
|
54
|
+
</span>
|
|
55
|
+
</div>
|
|
56
|
+
<div className="mt-1 flex items-center justify-between">
|
|
57
|
+
<p className="line-clamp-2 w-[85%] text-sm text-gray-700">
|
|
58
|
+
{history.recent_message_content}
|
|
59
|
+
</p>
|
|
60
|
+
<LinkRight width={24} height={24} className="flex-shrink-0"/>
|
|
61
|
+
</div>
|
|
62
|
+
</div>))) : (<div className="flex h-full flex-col items-center justify-center p-4">
|
|
63
|
+
<div className="mb-4">
|
|
64
|
+
<EmptyMessage />
|
|
65
|
+
</div>
|
|
66
|
+
<p className="text-center text-gray-500">
|
|
67
|
+
이전 대화기록이 없습니다
|
|
68
|
+
<br />
|
|
69
|
+
대화를 시작해 보세요
|
|
70
|
+
</p>
|
|
71
|
+
</div>)}
|
|
72
|
+
</div>
|
|
38
73
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<p className="line-clamp-2 w-[85%] text-sm text-gray-700">{history.lastMessage}</p>
|
|
47
|
-
<LinkRight width={24} height={24} className="flex-shrink-0"/>
|
|
48
|
-
</div>
|
|
49
|
-
</div>))) : (<div className="flex h-full flex-col items-center justify-center p-4">
|
|
50
|
-
<div className="mb-4">
|
|
51
|
-
<EmptyMessage />
|
|
52
|
-
</div>
|
|
53
|
-
<p className="text-center text-gray-500">
|
|
54
|
-
이전 대화기록이 없습니다
|
|
55
|
-
<br />
|
|
56
|
-
대화를 시작해 보세요
|
|
57
|
-
</p>
|
|
58
|
-
</div>)}
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<div className="p-4">
|
|
62
|
-
<button className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white" onClick={onNewChatClick}>
|
|
63
|
-
새 문의하기
|
|
64
|
-
<SendIcon width={24} height={24}/>
|
|
65
|
-
</button>
|
|
66
|
-
</div>
|
|
74
|
+
<div className="p-4">
|
|
75
|
+
<button className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white" onClick={onNewChatClick}>
|
|
76
|
+
새 문의하기
|
|
77
|
+
<SendIcon width={24} height={24}/>
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
</>)}
|
|
67
81
|
</div>);
|
|
68
82
|
};
|
|
69
83
|
export default HistoryView;
|
|
@@ -3,6 +3,9 @@ import LinkRight from '../../asset/images/daeryuntalk/link_right.svg';
|
|
|
3
3
|
import EmptyMessage from '../../asset/images/daeryuntalk/empty_message.svg';
|
|
4
4
|
import SendIcon from '../../asset/images/daeryuntalk/send.svg';
|
|
5
5
|
import PrevIcon from '../../asset/images/daeryuntalk/prev.svg';
|
|
6
|
+
import Input1 from './_ui/inputs/Input1';
|
|
7
|
+
import AuthForm from './History/AuthForm';
|
|
8
|
+
import { History } from './_api/daeryuntalk/type/response';
|
|
6
9
|
|
|
7
10
|
const mockChatHistories: any[] = [];
|
|
8
11
|
|
|
@@ -10,34 +13,53 @@ type HistoryViewProps = {
|
|
|
10
13
|
onBackClick: () => void;
|
|
11
14
|
onChatHistoryClick: (historyId: string) => void;
|
|
12
15
|
onNewChatClick: () => void;
|
|
16
|
+
isAuthenticated: boolean;
|
|
17
|
+
historyLit: History[];
|
|
18
|
+
goGetHistoryList: (data: { version?: string }) => void;
|
|
13
19
|
};
|
|
14
20
|
|
|
15
|
-
const HistoryView: React.FC<HistoryViewProps> = ({
|
|
16
|
-
|
|
21
|
+
const HistoryView: React.FC<HistoryViewProps> = ({
|
|
22
|
+
onBackClick,
|
|
23
|
+
onChatHistoryClick,
|
|
24
|
+
onNewChatClick,
|
|
25
|
+
isAuthenticated,
|
|
26
|
+
historyLit,
|
|
27
|
+
goGetHistoryList
|
|
28
|
+
}) => {
|
|
29
|
+
const formatTimestamp = (timestamp: string): string => {
|
|
30
|
+
if (!timestamp) return '';
|
|
31
|
+
|
|
32
|
+
// UTC string을 Date 객체로 변환
|
|
33
|
+
const date = new Date(timestamp);
|
|
17
34
|
const now = new Date();
|
|
18
|
-
|
|
35
|
+
|
|
36
|
+
// 시간 차이(초)
|
|
37
|
+
const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
|
19
38
|
|
|
20
39
|
if (diffInSeconds < 5) {
|
|
21
40
|
return '방금';
|
|
22
41
|
}
|
|
23
42
|
|
|
24
43
|
if (diffInSeconds < 60 * 60 * 24) {
|
|
25
|
-
|
|
26
|
-
const
|
|
44
|
+
// 오늘 내 메시지: 시:분
|
|
45
|
+
const hours = date.getHours().toString().padStart(2, '0');
|
|
46
|
+
const minutes = date.getMinutes().toString().padStart(2, '0');
|
|
27
47
|
return `${hours}:${minutes}`;
|
|
28
48
|
}
|
|
29
49
|
|
|
30
50
|
if (diffInSeconds < 60 * 60 * 24 * 7) {
|
|
51
|
+
// 일주일 내: N일전
|
|
31
52
|
const days = Math.floor(diffInSeconds / (60 * 60 * 24));
|
|
32
53
|
return `${days}일전`;
|
|
33
54
|
}
|
|
34
55
|
|
|
35
|
-
|
|
36
|
-
const
|
|
56
|
+
// 그 외: 월일
|
|
57
|
+
const month = date.getMonth() + 1;
|
|
58
|
+
const day = date.getDate();
|
|
37
59
|
return `${month}월${day}일`;
|
|
38
60
|
};
|
|
39
61
|
|
|
40
|
-
const hasHistories =
|
|
62
|
+
const hasHistories = historyLit.length > 0;
|
|
41
63
|
|
|
42
64
|
return (
|
|
43
65
|
<div className="flex h-full flex-col">
|
|
@@ -50,48 +72,57 @@ const HistoryView: React.FC<HistoryViewProps> = ({ onBackClick, onChatHistoryCli
|
|
|
50
72
|
</div>
|
|
51
73
|
<div className="w-7"></div>
|
|
52
74
|
</div>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
{!isAuthenticated ? (
|
|
76
|
+
<AuthForm goGetHistoryList={goGetHistoryList} />
|
|
77
|
+
) : (
|
|
78
|
+
<>
|
|
79
|
+
<div className="flex-1 overflow-y-auto px-[20px] pb-[20px] pt-[24px]">
|
|
80
|
+
{hasHistories ? (
|
|
81
|
+
historyLit.map(history => (
|
|
82
|
+
<div
|
|
83
|
+
key={history.chat_inquiry_number}
|
|
84
|
+
className="cursor-pointer border-b border-gray-100 px-[12px] py-[18px] hover:bg-gray-50"
|
|
85
|
+
onClick={() => onChatHistoryClick(history.chat_inquiry_number)}
|
|
86
|
+
>
|
|
87
|
+
<div className="flex items-center justify-between">
|
|
88
|
+
<span className="font-medium">{history.customer_name}</span>
|
|
89
|
+
<span className="text-xs text-gray-500">
|
|
90
|
+
{formatTimestamp(history.recent_message_date_time)}
|
|
91
|
+
</span>
|
|
92
|
+
</div>
|
|
93
|
+
<div className="mt-1 flex items-center justify-between">
|
|
94
|
+
<p className="line-clamp-2 w-[85%] text-sm text-gray-700">
|
|
95
|
+
{history.recent_message_content}
|
|
96
|
+
</p>
|
|
97
|
+
<LinkRight width={24} height={24} className="flex-shrink-0" />
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
))
|
|
101
|
+
) : (
|
|
102
|
+
<div className="flex h-full flex-col items-center justify-center p-4">
|
|
103
|
+
<div className="mb-4">
|
|
104
|
+
<EmptyMessage />
|
|
105
|
+
</div>
|
|
106
|
+
<p className="text-center text-gray-500">
|
|
107
|
+
이전 대화기록이 없습니다
|
|
108
|
+
<br />
|
|
109
|
+
대화를 시작해 보세요
|
|
110
|
+
</p>
|
|
69
111
|
</div>
|
|
70
|
-
|
|
71
|
-
))
|
|
72
|
-
) : (
|
|
73
|
-
<div className="flex h-full flex-col items-center justify-center p-4">
|
|
74
|
-
<div className="mb-4">
|
|
75
|
-
<EmptyMessage />
|
|
76
|
-
</div>
|
|
77
|
-
<p className="text-center text-gray-500">
|
|
78
|
-
이전 대화기록이 없습니다
|
|
79
|
-
<br />
|
|
80
|
-
대화를 시작해 보세요
|
|
81
|
-
</p>
|
|
112
|
+
)}
|
|
82
113
|
</div>
|
|
83
|
-
)}
|
|
84
|
-
</div>
|
|
85
114
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
115
|
+
<div className="p-4">
|
|
116
|
+
<button
|
|
117
|
+
className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white"
|
|
118
|
+
onClick={onNewChatClick}
|
|
119
|
+
>
|
|
120
|
+
새 문의하기
|
|
121
|
+
<SendIcon width={24} height={24} />
|
|
122
|
+
</button>
|
|
123
|
+
</div>
|
|
124
|
+
</>
|
|
125
|
+
)}
|
|
95
126
|
</div>
|
|
96
127
|
);
|
|
97
128
|
};
|
|
@@ -23,7 +23,7 @@ const ZOOM_LEVELS = [25, 50, 75, 100, 125, 150, 200];
|
|
|
23
23
|
const ImageViewer = () => {
|
|
24
24
|
var _a;
|
|
25
25
|
const { isImageViewerOpen, selectedImageFile, imageViewerMessage, closeImageViewer } = useDaeryuntalk();
|
|
26
|
-
const images = ((_a = imageViewerMessage === null || imageViewerMessage === void 0 ? void 0 : imageViewerMessage.files) === null || _a === void 0 ? void 0 : _a.filter(item => item.type === 'image')) || [];
|
|
26
|
+
const images = ((_a = imageViewerMessage === null || imageViewerMessage === void 0 ? void 0 : imageViewerMessage.files) === null || _a === void 0 ? void 0 : _a.filter(item => (item === null || item === void 0 ? void 0 : item.type) === 'image')) || [];
|
|
27
27
|
const initialIndex = images.findIndex(img => img.fileNumber === (selectedImageFile === null || selectedImageFile === void 0 ? void 0 : selectedImageFile.fileNumber));
|
|
28
28
|
const [currentIndex, setCurrentIndex] = useState(initialIndex >= 0 ? initialIndex : 0);
|
|
29
29
|
const [rotation, setRotation] = useState(0);
|
|
@@ -22,7 +22,7 @@ type PreviewImage = {
|
|
|
22
22
|
const ImageViewer = () => {
|
|
23
23
|
const { isImageViewerOpen, selectedImageFile, imageViewerMessage, closeImageViewer } = useDaeryuntalk();
|
|
24
24
|
|
|
25
|
-
const images = imageViewerMessage?.files?.filter(item => item
|
|
25
|
+
const images = imageViewerMessage?.files?.filter(item => item?.type === 'image') || [];
|
|
26
26
|
const initialIndex = images.findIndex(img => img.fileNumber === selectedImageFile?.fileNumber);
|
|
27
27
|
|
|
28
28
|
const [currentIndex, setCurrentIndex] = useState(initialIndex >= 0 ? initialIndex : 0);
|