@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.
Files changed (43) hide show
  1. package/dist/components/Daeryuntalk/ChatButton.jsx +3 -1
  2. package/dist/components/Daeryuntalk/ChatButton.tsx +3 -1
  3. package/dist/components/Daeryuntalk/ChatConversation.jsx +23 -5
  4. package/dist/components/Daeryuntalk/ChatConversation.tsx +27 -5
  5. package/dist/components/Daeryuntalk/ChatHomeView.jsx +26 -11
  6. package/dist/components/Daeryuntalk/ChatHomeView.tsx +32 -9
  7. package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +21 -3
  8. package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +32 -11
  9. package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +69 -23
  10. package/dist/components/Daeryuntalk/History/AuthForm.d.ts +8 -0
  11. package/dist/components/Daeryuntalk/History/AuthForm.jsx +140 -0
  12. package/dist/components/Daeryuntalk/History/AuthForm.tsx +186 -0
  13. package/dist/components/Daeryuntalk/HistoryView.d.ts +6 -0
  14. package/dist/components/Daeryuntalk/HistoryView.jsx +49 -35
  15. package/dist/components/Daeryuntalk/HistoryView.tsx +78 -47
  16. package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +1 -1
  17. package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +1 -1
  18. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +29 -1
  19. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +98 -7
  20. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +136 -8
  21. package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.d.ts +13 -0
  22. package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.ts +17 -0
  23. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +3 -2
  24. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +76 -8
  25. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +88 -12
  26. package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.d.ts +24 -0
  27. package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.js +75 -0
  28. package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.ts +90 -0
  29. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +1 -0
  30. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +12 -2
  31. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +16 -2
  32. package/dist/components/Daeryuntalk/_lib/utils.d.ts +10 -0
  33. package/dist/components/Daeryuntalk/_lib/utils.js +25 -0
  34. package/dist/components/Daeryuntalk/_lib/utils.ts +39 -0
  35. package/dist/components/Daeryuntalk/_ui/buttons/Button2.d.ts +10 -0
  36. package/dist/components/Daeryuntalk/_ui/buttons/Button2.jsx +12 -0
  37. package/dist/components/Daeryuntalk/_ui/buttons/Button2.tsx +28 -0
  38. package/dist/components/Daeryuntalk/_ui/inputs/Input2.d.ts +13 -0
  39. package/dist/components/Daeryuntalk/_ui/inputs/Input2.jsx +9 -0
  40. package/dist/components/Daeryuntalk/_ui/inputs/Input2.tsx +42 -0
  41. package/dist/styles/globals.css +27 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +1 -1
@@ -24,8 +24,7 @@ interface props {
24
24
  chatInquiryNumber: string | null;
25
25
  setIsNextPage: Dispatch<SetStateAction<boolean | null>>;
26
26
  setWorkFlowStack: Dispatch<SetStateAction<string[]>>;
27
- // 소켓 이벤트
28
- sendInquiryJoined: (chatInquiryNumber: string) => void;
27
+ setInquiryMainData: Dispatch<SetStateAction<IChatInquiryMainDataResponse | null>>;
29
28
  }
30
29
 
31
30
  export const useChatHandler = ({
@@ -38,8 +37,7 @@ export const useChatHandler = ({
38
37
  chatInquiryNumber,
39
38
  setIsNextPage,
40
39
  setWorkFlowStack,
41
- //
42
- sendInquiryJoined
40
+ setInquiryMainData
43
41
  }: props) => {
44
42
  // 채팅 시작 (문의하기 버튼 클릭 시)
45
43
  const startChat = useCallback(async () => {
@@ -87,10 +85,6 @@ export const useChatHandler = ({
87
85
 
88
86
  // 메시지 처리
89
87
  if (detailResponse.data && chatList.data) {
90
- // 해당 무의 입장 소켓1
91
-
92
- sendInquiryJoined(currentChatInquiryNumber);
93
-
94
88
  // 메세지 리스트 후처리
95
89
  if (chatList.data?.message_list && chatList.data.message_list.length > 0) {
96
90
  const uiMessages = chatList.data.message_list
@@ -145,6 +139,89 @@ export const useChatHandler = ({
145
139
  }
146
140
  }, [inquiryMainData]);
147
141
 
142
+ // 선택된 히스토리의 채팅창 시작
143
+ const startSelectedChat = useCallback(
144
+ async (chatInquiryNumber: string) => {
145
+ try {
146
+ setIsLoading(true);
147
+
148
+ // 문의 상세 조회
149
+ const detailResponse = await getChatInquiryDetailNew(chatInquiryNumber);
150
+ console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
151
+
152
+ const chatList = await getChatInquiryMessageList(chatInquiryNumber);
153
+ console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
154
+
155
+ console.log('detailResponse.data.message_list', chatList?.data?.message_list);
156
+
157
+ // 메시지 처리
158
+ if (detailResponse.data && chatList.data) {
159
+ // 문의 정보 저장
160
+ setChatInquiryNumber(chatInquiryNumber);
161
+ //
162
+ setInquiryMainData(prev => {
163
+ if (prev) {
164
+ return {
165
+ ...prev,
166
+ progress_inquiry_number: chatInquiryNumber
167
+ };
168
+ } else {
169
+ return null;
170
+ }
171
+ });
172
+ // 메세지 리스트 후처리
173
+ if (chatList.data?.message_list && chatList.data.message_list.length > 0) {
174
+ const uiMessages = chatList.data.message_list
175
+ .sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
176
+ .map(convertApiMessageToUiMessage);
177
+ setMessages(uiMessages);
178
+
179
+ // const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
180
+ setMessages(uiMessages);
181
+
182
+ console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
183
+ }
184
+ if (chatList.data?.next_page_yn !== null) {
185
+ setIsNextPage(chatList.data.next_page_yn);
186
+ }
187
+
188
+ // 해당 문의 상태
189
+ if (detailResponse.data?.chat_inquiry_state_code) {
190
+ setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
191
+ }
192
+ // 해당 문의 오브젝트
193
+ if (detailResponse.data?.object_expose_info) {
194
+ const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
195
+ setMessageObject(uiObject);
196
+ }
197
+
198
+ // 해당 문의 상태
199
+ if (detailResponse.data?.chat_inquiry_state_code) {
200
+ setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
201
+ }
202
+ // 워크플로우 스택 업데이트
203
+ if (detailResponse.data?.work_flow_progress_stack) {
204
+ setWorkFlowStack(detailResponse.data?.work_flow_progress_stack ?? []);
205
+ }
206
+ } else {
207
+ setMessages([]);
208
+ setInquiryStatus('');
209
+ setMessageObject(null);
210
+ setIsNextPage(null);
211
+ console.log('[DaeryuntalkContext] 메시지 없음');
212
+ }
213
+
214
+ return chatInquiryNumber;
215
+ } catch (error) {
216
+ console.error('[DaeryuntalkContext] 채팅 시작 오류:', error);
217
+ throw error;
218
+ } finally {
219
+ setIsLoading(false);
220
+ }
221
+ },
222
+ [inquiryMainData]
223
+ );
224
+
148
225
  // 메시지 전송
149
226
  const sendMessage = useCallback(
150
227
  async (htmlContent: string, jsonData: any, retry?: boolean) => {
@@ -186,9 +263,7 @@ export const useChatHandler = ({
186
263
 
187
264
  // 메시지 처리
188
265
  if (detailResponse.data && chatList.data) {
189
- // 해당 무의 입장 소켓
190
- sendInquiryJoined(currentChatInquiryNumber);
191
-
266
+ setChatInquiryNumber(currentChatInquiryNumber);
192
267
  // 메세지 리스트 후처리
193
268
  if (chatList.data?.message_list && chatList.data.message_list.length > 0) {
194
269
  const uiMessages = chatList.data.message_list
@@ -359,6 +434,7 @@ export const useChatHandler = ({
359
434
  workFlowBack,
360
435
  chatUserUpdate,
361
436
  getNextMessageList,
362
- getDownLoadUrl
437
+ getDownLoadUrl,
438
+ startSelectedChat
363
439
  };
364
440
  };
@@ -0,0 +1,24 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { History } from '../../_api/daeryuntalk/type/response';
3
+ interface props {
4
+ setLoading?: (loading: boolean) => void;
5
+ setIsAuthenticated?: Dispatch<SetStateAction<boolean>>;
6
+ setHistoryList?: Dispatch<SetStateAction<History[]>>;
7
+ }
8
+ export declare const useHistoryHandler: ({ setLoading, setIsAuthenticated, setHistoryList }: props) => {
9
+ goRequestPhone: ({ name, cellPhoneNumber, version }: {
10
+ name: string;
11
+ cellPhoneNumber: string;
12
+ version?: string;
13
+ }) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<import("../../_api/daeryuntalk/type/response").RequestConfirmNumberResponse> | undefined>;
14
+ goHistoryPhoneAuth: ({ name, cellPhoneNumber, certificationNumber, version }: {
15
+ name: string;
16
+ cellPhoneNumber: string;
17
+ certificationNumber: string;
18
+ version?: string;
19
+ }) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<unknown> | undefined>;
20
+ goGetHistoryList: ({ version }: {
21
+ version?: string;
22
+ }) => Promise<void>;
23
+ };
24
+ export {};
@@ -0,0 +1,75 @@
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 { useCallback } from 'react';
11
+ import { DEFAULT_API_VERSION, getHistoryList, historyPhoneAuth, requestPhone } from '../../_api';
12
+ export const useHistoryHandler = ({ setLoading, setIsAuthenticated, setHistoryList }) => {
13
+ const goRequestPhone = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ name, cellPhoneNumber, version = DEFAULT_API_VERSION }) {
14
+ const consoleName = '점유 인증 번호 요청';
15
+ setLoading === null || setLoading === void 0 ? void 0 : setLoading(true);
16
+ if (!name)
17
+ throw new Error('이름이 없습니다.');
18
+ if (!cellPhoneNumber)
19
+ throw new Error('번호가 없습니다.');
20
+ try {
21
+ return yield requestPhone({ name, cellPhoneNumber, version });
22
+ }
23
+ catch (error) {
24
+ console.error(`[${consoleName} 실패]:`, error);
25
+ }
26
+ finally {
27
+ setLoading === null || setLoading === void 0 ? void 0 : setLoading(false);
28
+ }
29
+ }), []);
30
+ const goHistoryPhoneAuth = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ name, cellPhoneNumber, certificationNumber, version = DEFAULT_API_VERSION }) {
31
+ const consoleName = '점유 인증 번호 검증';
32
+ setLoading === null || setLoading === void 0 ? void 0 : setLoading(true);
33
+ if (!name)
34
+ throw new Error('이름이 없습니다.');
35
+ if (!cellPhoneNumber)
36
+ throw new Error('번호가 없습니다.');
37
+ if (!certificationNumber)
38
+ throw new Error('인증번호가 없습니다.');
39
+ try {
40
+ return yield historyPhoneAuth({ name, cellPhoneNumber, certificationNumber, version });
41
+ }
42
+ catch (error) {
43
+ console.error(`[${consoleName} 실패]:`, error);
44
+ }
45
+ finally {
46
+ setLoading === null || setLoading === void 0 ? void 0 : setLoading(false);
47
+ }
48
+ }), []);
49
+ const goGetHistoryList = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ version = DEFAULT_API_VERSION }) {
50
+ var _b;
51
+ const consoleName = '인증 이력 조회';
52
+ setLoading === null || setLoading === void 0 ? void 0 : setLoading(true);
53
+ try {
54
+ const res = yield getHistoryList({ version });
55
+ if (res.result_info.result_type_cd === '401') {
56
+ setIsAuthenticated === null || setIsAuthenticated === void 0 ? void 0 : setIsAuthenticated(false);
57
+ }
58
+ else {
59
+ setHistoryList === null || setHistoryList === void 0 ? void 0 : setHistoryList((_b = res.data.chat_inquiry_list) !== null && _b !== void 0 ? _b : []);
60
+ setIsAuthenticated === null || setIsAuthenticated === void 0 ? void 0 : setIsAuthenticated(true);
61
+ }
62
+ }
63
+ catch (error) {
64
+ console.error(`[${consoleName} 실패]:`, error);
65
+ }
66
+ finally {
67
+ setLoading === null || setLoading === void 0 ? void 0 : setLoading(false);
68
+ }
69
+ }), []);
70
+ return {
71
+ goRequestPhone,
72
+ goHistoryPhoneAuth,
73
+ goGetHistoryList
74
+ };
75
+ };
@@ -0,0 +1,90 @@
1
+ import { Dispatch, SetStateAction, useCallback } from 'react';
2
+ import { DEFAULT_API_VERSION, getHistoryList, historyPhoneAuth, requestPhone } from '../../_api';
3
+ import { History } from '../../_api/daeryuntalk/type/response';
4
+
5
+ interface props {
6
+ setLoading?: (loading: boolean) => void;
7
+ setIsAuthenticated?: Dispatch<SetStateAction<boolean>>;
8
+ setHistoryList?: Dispatch<SetStateAction<History[]>>;
9
+ }
10
+
11
+ export const useHistoryHandler = ({ setLoading, setIsAuthenticated, setHistoryList }: props) => {
12
+ const goRequestPhone = useCallback(
13
+ async ({
14
+ name,
15
+ cellPhoneNumber,
16
+ version = DEFAULT_API_VERSION
17
+ }: {
18
+ name: string;
19
+ cellPhoneNumber: string;
20
+ version?: string;
21
+ }) => {
22
+ const consoleName = '점유 인증 번호 요청';
23
+ setLoading?.(true);
24
+ if (!name) throw new Error('이름이 없습니다.');
25
+ if (!cellPhoneNumber) throw new Error('번호가 없습니다.');
26
+
27
+ try {
28
+ return await requestPhone({ name, cellPhoneNumber, version });
29
+ } catch (error) {
30
+ console.error(`[${consoleName} 실패]:`, error);
31
+ } finally {
32
+ setLoading?.(false);
33
+ }
34
+ },
35
+ []
36
+ );
37
+
38
+ const goHistoryPhoneAuth = useCallback(
39
+ async ({
40
+ name,
41
+ cellPhoneNumber,
42
+ certificationNumber,
43
+ version = DEFAULT_API_VERSION
44
+ }: {
45
+ name: string;
46
+ cellPhoneNumber: string;
47
+ certificationNumber: string;
48
+ version?: string;
49
+ }) => {
50
+ const consoleName = '점유 인증 번호 검증';
51
+ setLoading?.(true);
52
+ if (!name) throw new Error('이름이 없습니다.');
53
+ if (!cellPhoneNumber) throw new Error('번호가 없습니다.');
54
+ if (!certificationNumber) throw new Error('인증번호가 없습니다.');
55
+
56
+ try {
57
+ return await historyPhoneAuth({ name, cellPhoneNumber, certificationNumber, version });
58
+ } catch (error) {
59
+ console.error(`[${consoleName} 실패]:`, error);
60
+ } finally {
61
+ setLoading?.(false);
62
+ }
63
+ },
64
+ []
65
+ );
66
+
67
+ const goGetHistoryList = useCallback(async ({ version = DEFAULT_API_VERSION }: { version?: string }) => {
68
+ const consoleName = '인증 이력 조회';
69
+ setLoading?.(true);
70
+ try {
71
+ const res = await getHistoryList({ version });
72
+ if (res.result_info.result_type_cd === '401') {
73
+ setIsAuthenticated?.(false);
74
+ } else {
75
+ setHistoryList?.(res.data.chat_inquiry_list ?? []);
76
+ setIsAuthenticated?.(true);
77
+ }
78
+ } catch (error) {
79
+ console.error(`[${consoleName} 실패]:`, error);
80
+ } finally {
81
+ setLoading?.(false);
82
+ }
83
+ }, []);
84
+
85
+ return {
86
+ goRequestPhone,
87
+ goHistoryPhoneAuth,
88
+ goGetHistoryList
89
+ };
90
+ };
@@ -17,5 +17,6 @@ export declare const useSocketEventHandler: ({ setIsConnected, setIsLoading, set
17
17
  sendInquiryJoined: (chatInquiryNumber: string) => void;
18
18
  sendInquiryLeft: (chatInquiryNumber: string) => void;
19
19
  sendHistoryEntered: (chatInquiryNumbers: string[]) => void;
20
+ sendHistoryLeft: (chatInquiryNumbers: string[]) => void;
20
21
  };
21
22
  export {};
@@ -104,6 +104,16 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
104
104
  console.log('[WebSocket] history.entered 전송');
105
105
  }
106
106
  }, []);
107
+ const sendHistoryLeft = useCallback((chatInquiryNumbers) => {
108
+ const socket = socketRef.current;
109
+ if (socket && socket.readyState === WebSocket.OPEN) {
110
+ socket.send(JSON.stringify({
111
+ type: 'history.exited',
112
+ payload: { chat_inquiry_numbers: chatInquiryNumbers }
113
+ }));
114
+ console.log('[WebSocket] history.exited 전송');
115
+ }
116
+ }, []);
107
117
  // Daeryuntalk API 초기화 메소드
108
118
  const initializeDaeryuntalk = useCallback((version) => __awaiter(void 0, void 0, void 0, function* () {
109
119
  console.log('[DaeryuntalkContext] 초기화 메소드 호출됨', version ? `버전: ${version}` : '기본 버전 사용');
@@ -128,7 +138,6 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
128
138
  return isDuplicate ? prev : [...prev, newMessage];
129
139
  });
130
140
  }
131
- // 수정 기능 있었나??
132
141
  if (data.type === MessageSocketType.MESSAGE_UPDATED) {
133
142
  const newMessage = convertApiMessageToUiMessage(data.payload.message);
134
143
  setMessages(prev => {
@@ -203,6 +212,7 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
203
212
  sendHeartbeat,
204
213
  sendInquiryJoined,
205
214
  sendInquiryLeft,
206
- sendHistoryEntered
215
+ sendHistoryEntered,
216
+ sendHistoryLeft
207
217
  };
208
218
  };
@@ -130,6 +130,19 @@ export const useSocketEventHandler = ({
130
130
  }
131
131
  }, []);
132
132
 
133
+ const sendHistoryLeft = useCallback((chatInquiryNumbers: string[]) => {
134
+ const socket = socketRef.current;
135
+ if (socket && socket.readyState === WebSocket.OPEN) {
136
+ socket.send(
137
+ JSON.stringify({
138
+ type: 'history.exited',
139
+ payload: { chat_inquiry_numbers: chatInquiryNumbers }
140
+ })
141
+ );
142
+ console.log('[WebSocket] history.exited 전송');
143
+ }
144
+ }, []);
145
+
133
146
  // Daeryuntalk API 초기화 메소드
134
147
  const initializeDaeryuntalk = useCallback(async (version?: string) => {
135
148
  console.log('[DaeryuntalkContext] 초기화 메소드 호출됨', version ? `버전: ${version}` : '기본 버전 사용');
@@ -156,7 +169,7 @@ export const useSocketEventHandler = ({
156
169
  return isDuplicate ? prev : [...prev, newMessage];
157
170
  });
158
171
  }
159
- // 수정 기능 있었나??
172
+
160
173
  if (data.type === MessageSocketType.MESSAGE_UPDATED) {
161
174
  const newMessage = convertApiMessageToUiMessage(data.payload.message);
162
175
  setMessages(prev => {
@@ -241,6 +254,7 @@ export const useSocketEventHandler = ({
241
254
  sendHeartbeat,
242
255
  sendInquiryJoined,
243
256
  sendInquiryLeft,
244
- sendHistoryEntered
257
+ sendHistoryEntered,
258
+ sendHistoryLeft
245
259
  };
246
260
  };
@@ -1,2 +1,12 @@
1
1
  export declare const formatFileSize: (size: number) => string;
2
2
  export declare const formatDateToKorean: (timestamp: string) => string;
3
+ export declare const onlyNumbers: (phoneNumber: string) => string;
4
+ export declare const phoneCheck: (value: string) => {
5
+ phoneNumber: string;
6
+ isValid: boolean;
7
+ };
8
+ export declare const nameFilter: (value: string) => {
9
+ name: string;
10
+ isValid: boolean;
11
+ };
12
+ export declare const formatSecondsToMMSS: (seconds: number) => string;
@@ -14,3 +14,28 @@ export const formatDateToKorean = (timestamp) => {
14
14
  const minute = date.getMinutes().toString().padStart(2, '0');
15
15
  return `${year}년 ${month}월 ${day}일 ${hour}:${minute}`;
16
16
  };
17
+ export const onlyNumbers = (phoneNumber) => {
18
+ return phoneNumber.replace(/\D/g, '');
19
+ };
20
+ export const phoneCheck = (value) => {
21
+ const phoneNumber = onlyNumbers(value);
22
+ // 10자리 또는 11자리만 통과
23
+ const isValid = /^010\d{7,8}$/.test(phoneNumber);
24
+ return { phoneNumber, isValid };
25
+ };
26
+ const keepOnlyKoreanCharacters = (text) => {
27
+ // 한글(자음, 모음, 결합된 문자)을 제외한 모든 문자를 제거하는 정규식
28
+ return text.replace(/[^\u3131-\u318E\uAC00-\uD7A3]+/g, '') || '';
29
+ };
30
+ export const nameFilter = (value) => {
31
+ const nameRegex = /^[가-힣]*$/;
32
+ const ko = keepOnlyKoreanCharacters(value);
33
+ return { name: ko, isValid: ko !== '' && ko.length >= 2 && ko.length <= 6 && nameRegex.test(ko) };
34
+ };
35
+ export const formatSecondsToMMSS = (seconds) => {
36
+ const min = Math.floor(seconds / 60);
37
+ const sec = seconds % 60;
38
+ const paddedMin = String(min).padStart(2, '0');
39
+ const paddedSec = String(sec).padStart(2, '0');
40
+ return `${paddedMin}:${paddedSec}`;
41
+ };
@@ -15,3 +15,42 @@ export const formatDateToKorean = (timestamp: string) => {
15
15
 
16
16
  return `${year}년 ${month}월 ${day}일 ${hour}:${minute}`;
17
17
  };
18
+
19
+ export const onlyNumbers = (phoneNumber: string): string => {
20
+ return phoneNumber.replace(/\D/g, '');
21
+ };
22
+
23
+ export const phoneCheck = (
24
+ value: string
25
+ ): {
26
+ phoneNumber: string;
27
+ isValid: boolean;
28
+ } => {
29
+ const phoneNumber = onlyNumbers(value);
30
+ // 10자리 또는 11자리만 통과
31
+ const isValid = /^010\d{7,8}$/.test(phoneNumber);
32
+ return { phoneNumber, isValid };
33
+ };
34
+
35
+ const keepOnlyKoreanCharacters = (text: string) => {
36
+ // 한글(자음, 모음, 결합된 문자)을 제외한 모든 문자를 제거하는 정규식
37
+ return text.replace(/[^\u3131-\u318E\uAC00-\uD7A3]+/g, '') || '';
38
+ };
39
+
40
+ export const nameFilter = (value: string): { name: string; isValid: boolean } => {
41
+ const nameRegex = /^[가-힣]*$/;
42
+
43
+ const ko = keepOnlyKoreanCharacters(value);
44
+
45
+ return { name: ko, isValid: ko !== '' && ko.length >= 2 && ko.length <= 6 && nameRegex.test(ko) };
46
+ };
47
+
48
+ export const formatSecondsToMMSS = (seconds: number): string => {
49
+ const min = Math.floor(seconds / 60);
50
+ const sec = seconds % 60;
51
+
52
+ const paddedMin = String(min).padStart(2, '0');
53
+ const paddedSec = String(sec).padStart(2, '0');
54
+
55
+ return `${paddedMin}:${paddedSec}`;
56
+ };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface Button2Props {
3
+ onClick?: () => void | Promise<void>;
4
+ type?: 'button' | 'submit' | 'reset';
5
+ className?: string;
6
+ children: React.ReactNode;
7
+ isDisabled?: boolean;
8
+ }
9
+ declare const Button2: ({ onClick, type, className, children, isDisabled }: Button2Props) => React.JSX.Element;
10
+ export default Button2;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ const Button2 = ({ onClick, type = 'button', className = '', children, isDisabled = false }) => {
3
+ return (<button disabled={isDisabled} type={type} onClick={onClick} className={`
4
+ h-[40px] rounded-[6px] bg-[#AA1D36] text-center text-[12px]
5
+ font-[400] leading-[140%] tracking-[-4%] text-white
6
+ disabled:bg-[#D2D2D2]
7
+ ${className}
8
+ `}>
9
+ {children}
10
+ </button>);
11
+ };
12
+ export default Button2;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+
3
+ interface Button2Props {
4
+ onClick?: () => void | Promise<void>;
5
+ type?: 'button' | 'submit' | 'reset';
6
+ className?: string;
7
+ children: React.ReactNode;
8
+ isDisabled?: boolean;
9
+ }
10
+ const Button2 = ({ onClick, type = 'button', className = '', children, isDisabled = false }: Button2Props) => {
11
+ return (
12
+ <button
13
+ disabled={isDisabled}
14
+ type={type}
15
+ onClick={onClick}
16
+ className={`
17
+ h-[40px] rounded-[6px] bg-[#AA1D36] text-center text-[12px]
18
+ font-[400] leading-[140%] tracking-[-4%] text-white
19
+ disabled:bg-[#D2D2D2]
20
+ ${className}
21
+ `}
22
+ >
23
+ {children}
24
+ </button>
25
+ );
26
+ };
27
+
28
+ export default Button2;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ interface Input2Props {
3
+ value?: string;
4
+ name?: string;
5
+ readOnly?: boolean;
6
+ className?: string;
7
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
8
+ placeholder?: string;
9
+ type?: string;
10
+ maxLength?: number;
11
+ }
12
+ declare const Input2: ({ value, name, readOnly, className, onChange, placeholder, type, maxLength }: Input2Props) => React.JSX.Element;
13
+ export default Input2;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ const Input2 = ({ value, name, readOnly = false, className = '', onChange, placeholder, type = 'text', maxLength = 99999 }) => {
3
+ return (<input type={type} readOnly={readOnly} name={name} value={value} onChange={onChange} maxLength={maxLength} placeholder={placeholder} className={`
4
+ h-[40px] w-full rounded-[6px] border-[1px] border-solid
5
+ border-[#D9D9D9] px-[8px] py-[12.5px] text-[14px] font-[400] leading-[110%] tracking-[-4%] outline-none
6
+ ${className}
7
+ `}/>);
8
+ };
9
+ export default Input2;
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+
3
+ interface Input2Props {
4
+ value?: string;
5
+ name?: string;
6
+ readOnly?: boolean;
7
+ className?: string;
8
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
9
+ placeholder?: string;
10
+ type?: string;
11
+ maxLength?: number;
12
+ }
13
+
14
+ const Input2 = ({
15
+ value,
16
+ name,
17
+ readOnly = false,
18
+ className = '',
19
+ onChange,
20
+ placeholder,
21
+ type = 'text',
22
+ maxLength = 99999
23
+ }: Input2Props) => {
24
+ return (
25
+ <input
26
+ type={type}
27
+ readOnly={readOnly}
28
+ name={name}
29
+ value={value}
30
+ onChange={onChange}
31
+ maxLength={maxLength}
32
+ placeholder={placeholder}
33
+ className={`
34
+ h-[40px] w-full rounded-[6px] border-[1px] border-solid
35
+ border-[#D9D9D9] px-[8px] py-[12.5px] text-[14px] font-[400] leading-[110%] tracking-[-4%] outline-none
36
+ ${className}
37
+ `}
38
+ />
39
+ );
40
+ };
41
+
42
+ export default Input2;