@daeryun/dr_components 0.7.89 → 0.7.90

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.
@@ -33,7 +33,15 @@ const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, wor
33
33
  // 텍스트 블록 렌더링
34
34
  const renderText = (message) => {
35
35
  /**
36
- * 메세지 UICode 기반으로 바꿔야할 듯함
36
+ * 메세지 UICode 기반으로 바꿔야할 듯함 ->
37
+ *
38
+ * MSP00300001 텍스트 -> 시스템 메시지 템플릿 1
39
+ * MSP00300101 텍스트+(이미지)+(파일) -> 시스템 메시지 템플릿 2
40
+ *
41
+ * MSP00300201 텍스트 -> 워크플로우 메시지 템플릿 1
42
+ * MSP00300202 워크플로우이미지+(텍스트) -> 워크플로우 메시지 템플릿 2
43
+ * MSP00300203 아이콘+텍스트 -> 워크플로우 메시지 템플릿 3
44
+ * MSP00300204 텍스트+폼 -> 워크플로우 메시지 템플릿 4
37
45
  */
38
46
  const isWorkFlowImg = hasWorkFlowImg(message);
39
47
  const isBlock = hasBlocks(message);
@@ -41,8 +49,6 @@ const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, wor
41
49
  const isAuthForm = hasForm(message);
42
50
  const isRichForm = hasRichForm(message);
43
51
  const isFile = hasFileArray(message);
44
- // const isHasFile = hasFiles(message);
45
- // const isHasImage = hasImages(message);
46
52
  if (isFile) {
47
53
  return (<div className={`flex flex-col gap-[10px]`}>
48
54
  {isRichForm && (<div className={`flex flex-row items-end gap-[4px]`}>
@@ -54,16 +60,24 @@ const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, wor
54
60
  <ChatFile message={message} isOperator={isOperator} isHovered={isHovered} time={time}/>
55
61
  </div>);
56
62
  }
63
+ //
64
+ // if (message.templateType === InquiryMessageTemplateType.WORK_FLOW_TEMPLATE_1) {
65
+ // } else if (message.templateType === InquiryMessageTemplateType.WORK_FLOW_TEMPLATE_1) {
66
+ // }
57
67
  if (isAuthForm) {
58
68
  return (<div className={`max-w-[80%]`}>
59
69
  <WorkFlowAuthForm message={message} isOperator={isOperator}/>
60
70
  </div>);
61
71
  }
62
72
  if (isWorkFlowCustomerClickData) {
63
- return <WorkFlowClickData message={message}/>;
73
+ return (<div className={`max-w-[80%]`}>
74
+ <WorkFlowClickData message={message}/>
75
+ </div>);
64
76
  }
65
77
  if (isWorkFlowImg) {
66
- return <WorkFlowImg message={message}/>;
78
+ return (<div className={``}>
79
+ <WorkFlowImg message={message}/>
80
+ </div>);
67
81
  }
68
82
  if (isRichForm) {
69
83
  return (<div className={`flex flex-row items-end gap-[4px]`}>
@@ -79,26 +93,12 @@ const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, wor
79
93
  <p className="whitespace-pre-line text-sm leading-[130%] tracking-[-4%]">{message.plainText}</p>
80
94
  </ChatWrapper>);
81
95
  };
82
- /** todo 메시지 내용 렌더링 추후 추가 될듯 */
83
96
  const renderMessageContent = () => {
84
97
  var _a, _b, _c;
85
98
  const objectFirstQuestionCheck = Array.isArray(object === null || object === void 0 ? void 0 : object.objectList)
86
99
  ? Object.values(ObjectNumber).every(enumValue => { var _a; return (_a = object === null || object === void 0 ? void 0 : object.objectList) === null || _a === void 0 ? void 0 : _a.some(obj => (obj === null || obj === void 0 ? void 0 : obj.objectNumber) === enumValue); })
87
100
  : false;
88
101
  const objectIsBack = workFlowStack.length >= 3;
89
- // // PK없어서 이렇게
90
- // const fieldKeywords = [
91
- // '기업법무',
92
- // '지식재산권',
93
- // '공정거래',
94
- // '건설',
95
- // '이혼',
96
- // '상속',
97
- // '조세',
98
- // '형사',
99
- // '노동',
100
- // '금융'
101
- // ];
102
102
  const isAllFieldOfWork = !!(object === null || object === void 0 ? void 0 : object.objectList) && ((_a = object === null || object === void 0 ? void 0 : object.objectList) === null || _a === void 0 ? void 0 : _a.length) > 20;
103
103
  return (<div className={`
104
104
  message-content
@@ -108,19 +108,17 @@ const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, wor
108
108
  {/* 오브젝트 박스 */}
109
109
  {object && object.exposeObjectListYn && (<div className={`mt-[10px] flex flex-col gap-[10px]`}>
110
110
  <div className={`
111
- ${WorkFlowButtonUiCode.TILE_BUTTON === (object === null || object === void 0 ? void 0 : object.objectGroupUiCode)
111
+ ${WorkFlowButtonUiCode.TILE_BUTTON === (object === null || object === void 0 ? void 0 : object.objectGroupUiCode)
112
112
  ? 'flex flex-row flex-wrap gap-x-[4px] gap-y-[8px]'
113
113
  : 'flex flex-col gap-[8px]'}
114
-
115
- `}>
116
- {/* 업무분야 리스트면 따로 빼자 */}
114
+ `}>
117
115
  {!isAllFieldOfWork
118
116
  ? (_c = (_b = object.objectList) === null || _b === void 0 ? void 0 : _b.sort((a, b) => a.sequence - b.sequence)) === null || _c === void 0 ? void 0 : _c.map((item, index) => {
119
117
  var _a;
120
118
  return (<ObjectButton key={`object-expose-${index}`} object={item} messageNumber={(object === null || object === void 0 ? void 0 : object.messageNumber) || ''} workFlowNumber={((_a = message === null || message === void 0 ? void 0 : message.workFlow) === null || _a === void 0 ? void 0 : _a.workFlowNumber) || ''} isFirstObject={objectFirstQuestionCheck} objectGroupUiCode={(object === null || object === void 0 ? void 0 : object.objectGroupUiCode) || ''}/>);
121
119
  })
122
120
  : null}
123
- {isAllFieldOfWork && (<FieldWorkObject object={object} message={message} isFirstObject={objectFirstQuestionCheck} scrollEnd={scrollEnd}/>)}
121
+ {WorkFlowButtonUiCode.TILE_BUTTON === (object === null || object === void 0 ? void 0 : object.objectGroupUiCode) && (<FieldWorkObject object={object} message={message} isFirstObject={objectFirstQuestionCheck} scrollEnd={scrollEnd}/>)}
124
122
  </div>
125
123
  {!objectFirstQuestionCheck && (<ObjectBack isBack={objectIsBack} handleBtn={() => __awaiter(void 0, void 0, void 0, function* () {
126
124
  if (handelObjectBack) {
@@ -27,6 +27,7 @@ import RichText from './ChatItem/RichText';
27
27
  import ChatFile from './ChatItem/ChatFile';
28
28
  import { getMessageFileDownloadUrl } from './_api';
29
29
  import FieldWorkObject from './ChatObject/FieldWorkObject';
30
+ import { InquiryMessageTemplateType } from './_enums/template';
30
31
 
31
32
  type ChatMessageProps = {
32
33
  message: Message;
@@ -65,16 +66,24 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
65
66
  // 텍스트 블록 렌더링
66
67
  const renderText = (message: Message) => {
67
68
  /**
68
- * 메세지 UICode 기반으로 바꿔야할 듯함
69
+ * 메세지 UICode 기반으로 바꿔야할 듯함 ->
70
+ *
71
+ * MSP00300001 텍스트 -> 시스템 메시지 템플릿 1
72
+ * MSP00300101 텍스트+(이미지)+(파일) -> 시스템 메시지 템플릿 2
73
+ *
74
+ * MSP00300201 텍스트 -> 워크플로우 메시지 템플릿 1
75
+ * MSP00300202 워크플로우이미지+(텍스트) -> 워크플로우 메시지 템플릿 2
76
+ * MSP00300203 아이콘+텍스트 -> 워크플로우 메시지 템플릿 3
77
+ * MSP00300204 텍스트+폼 -> 워크플로우 메시지 템플릿 4
69
78
  */
79
+
70
80
  const isWorkFlowImg = hasWorkFlowImg(message);
71
81
  const isBlock = hasBlocks(message);
72
82
  const isWorkFlowCustomerClickData = hasCustomerWorkFlowClickData(message);
73
83
  const isAuthForm = hasForm(message);
74
84
  const isRichForm = hasRichForm(message);
75
85
  const isFile = hasFileArray(message);
76
- // const isHasFile = hasFiles(message);
77
- // const isHasImage = hasImages(message);
86
+
78
87
  if (isFile) {
79
88
  return (
80
89
  <div className={`flex flex-col gap-[10px]`}>
@@ -90,6 +99,10 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
90
99
  </div>
91
100
  );
92
101
  }
102
+ //
103
+ // if (message.templateType === InquiryMessageTemplateType.WORK_FLOW_TEMPLATE_1) {
104
+ // } else if (message.templateType === InquiryMessageTemplateType.WORK_FLOW_TEMPLATE_1) {
105
+ // }
93
106
 
94
107
  if (isAuthForm) {
95
108
  return (
@@ -99,10 +112,18 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
99
112
  );
100
113
  }
101
114
  if (isWorkFlowCustomerClickData) {
102
- return <WorkFlowClickData message={message} />;
115
+ return (
116
+ <div className={`max-w-[80%]`}>
117
+ <WorkFlowClickData message={message} />
118
+ </div>
119
+ );
103
120
  }
104
121
  if (isWorkFlowImg) {
105
- return <WorkFlowImg message={message} />;
122
+ return (
123
+ <div className={``}>
124
+ <WorkFlowImg message={message} />
125
+ </div>
126
+ );
106
127
  }
107
128
  if (isRichForm) {
108
129
  return (
@@ -125,7 +146,6 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
125
146
  );
126
147
  };
127
148
 
128
- /** todo 메시지 내용 렌더링 추후 추가 될듯 */
129
149
  const renderMessageContent = () => {
130
150
  const objectFirstQuestionCheck = Array.isArray(object?.objectList)
131
151
  ? Object.values(ObjectNumber).every(enumValue =>
@@ -135,20 +155,6 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
135
155
 
136
156
  const objectIsBack = workFlowStack.length >= 3;
137
157
 
138
- // // PK없어서 이렇게
139
- // const fieldKeywords = [
140
- // '기업법무',
141
- // '지식재산권',
142
- // '공정거래',
143
- // '건설',
144
- // '이혼',
145
- // '상속',
146
- // '조세',
147
- // '형사',
148
- // '노동',
149
- // '금융'
150
- // ];
151
-
152
158
  const isAllFieldOfWork = !!object?.objectList && object?.objectList?.length > 20;
153
159
 
154
160
  return (
@@ -164,15 +170,13 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
164
170
  <div className={`mt-[10px] flex flex-col gap-[10px]`}>
165
171
  <div
166
172
  className={`
167
- ${
168
- WorkFlowButtonUiCode.TILE_BUTTON === object?.objectGroupUiCode
169
- ? 'flex flex-row flex-wrap gap-x-[4px] gap-y-[8px]'
170
- : 'flex flex-col gap-[8px]'
171
- }
172
-
173
- `}
173
+ ${
174
+ WorkFlowButtonUiCode.TILE_BUTTON === object?.objectGroupUiCode
175
+ ? 'flex flex-row flex-wrap gap-x-[4px] gap-y-[8px]'
176
+ : 'flex flex-col gap-[8px]'
177
+ }
178
+ `}
174
179
  >
175
- {/* 업무분야 리스트면 따로 빼자 */}
176
180
  {!isAllFieldOfWork
177
181
  ? object.objectList
178
182
  ?.sort((a, b) => a.sequence - b.sequence)
@@ -189,7 +193,7 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
189
193
  );
190
194
  })
191
195
  : null}
192
- {isAllFieldOfWork && (
196
+ {WorkFlowButtonUiCode.TILE_BUTTON === object?.objectGroupUiCode && (
193
197
  <FieldWorkObject
194
198
  object={object}
195
199
  message={message}
@@ -13,6 +13,7 @@ import { formatSecondsToMMSS, nameFilter, onlyNumbers, phoneCheck } from '../_li
13
13
  import Button2 from '../_ui/buttons/Button2';
14
14
  import { historyPhoneAuth, requestPhone } from '../_api';
15
15
  import { useDearyunTalkToast } from '../Toast/DaeryuntalkToastProvider';
16
+ import { AuthErrorCode } from '../_enums/error_code';
16
17
  const AuthForm = ({ goGetHistoryList }) => {
17
18
  const [name, setName] = useState({ value: '', isValid: false });
18
19
  const [phone, setPhone] = useState({ value: '', isValid: false });
@@ -20,11 +21,19 @@ const AuthForm = ({ goGetHistoryList }) => {
20
21
  const [isConfirmState, setIsConfirmState] = useState(false);
21
22
  const [timer, setTimer] = useState(180); // 3분(180초)
22
23
  const [timerId, setTimerId] = useState(null);
24
+ const [isLoading, setIsLoading] = useState(false);
23
25
  const toast = useDearyunTalkToast();
24
- // 3분 인증시간 start 필요
26
+ const resetTimerAndState = () => {
27
+ if (timerId)
28
+ clearInterval(timerId);
29
+ setTimer(180);
30
+ setIsConfirmState(false);
31
+ };
25
32
  const handleInput = (e) => {
26
33
  const { name: formName, value } = e.currentTarget;
27
34
  if (formName === 'name') {
35
+ if (isConfirmState)
36
+ resetTimerAndState();
28
37
  const { name: propsName, isValid } = nameFilter(value);
29
38
  setName(prev => {
30
39
  return {
@@ -34,6 +43,8 @@ const AuthForm = ({ goGetHistoryList }) => {
34
43
  });
35
44
  }
36
45
  if (formName === 'phone') {
46
+ if (isConfirmState)
47
+ resetTimerAndState();
37
48
  const { phoneNumber, isValid } = phoneCheck(value);
38
49
  setPhone(prev => {
39
50
  return {
@@ -49,9 +60,9 @@ const AuthForm = ({ goGetHistoryList }) => {
49
60
  // 인증번호 발송 클릭
50
61
  const handleSendAuth = () => __awaiter(void 0, void 0, void 0, function* () {
51
62
  try {
63
+ setIsLoading(true);
52
64
  const res = yield requestPhone({ name: name.value, cellPhoneNumber: phone.value });
53
65
  if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
54
- // 인증번호 발송 API 호출 등 처리
55
66
  setIsConfirmState(true);
56
67
  setAuthNumber('');
57
68
  setTimer(180);
@@ -61,7 +72,7 @@ const AuthForm = ({ goGetHistoryList }) => {
61
72
  setTimer(prev => {
62
73
  if (prev <= 1) {
63
74
  clearInterval(id);
64
- setIsConfirmState(false); // 타이머 종료시 인증상태 해제
75
+ setIsConfirmState(false);
65
76
  return 0;
66
77
  }
67
78
  return prev - 1;
@@ -69,11 +80,20 @@ const AuthForm = ({ goGetHistoryList }) => {
69
80
  }, 1000);
70
81
  setTimerId(id);
71
82
  }
83
+ else {
84
+ if (res.result_info.result_cd === AuthErrorCode.OWNERSHIP_DUPLICATE_REQUEST_ERROR) {
85
+ toast.warning('중복된 요청입니다.');
86
+ }
87
+ else {
88
+ toast.warning('다시 요청해주세요.');
89
+ }
90
+ }
72
91
  }
73
- catch (e) {
74
- console.error('e', e);
92
+ catch (err) {
93
+ console.error('인증번호 발송 실패', err);
75
94
  }
76
95
  finally {
96
+ setIsLoading(false);
77
97
  }
78
98
  });
79
99
  // 인증번호 확인
@@ -83,6 +103,7 @@ const AuthForm = ({ goGetHistoryList }) => {
83
103
  return;
84
104
  }
85
105
  try {
106
+ setIsLoading(true);
86
107
  const res = yield historyPhoneAuth({
87
108
  name: name.value,
88
109
  cellPhoneNumber: phone.value,
@@ -92,11 +113,23 @@ const AuthForm = ({ goGetHistoryList }) => {
92
113
  yield goGetHistoryList({});
93
114
  toast.success('인증이 완료되었습니다.');
94
115
  }
116
+ else {
117
+ if (res.result_info.result_cd === AuthErrorCode.OWNERSHIP_CODE_MISMATCH) {
118
+ toast.warning('잘못된 인증번호입니다.');
119
+ }
120
+ else if (res.result_info.result_cd === AuthErrorCode.OWNERSHIP_EXPIRED) {
121
+ toast.warning('인증번호가 만료되었습니다.');
122
+ }
123
+ else {
124
+ toast.warning('다시 시도해주세요.');
125
+ }
126
+ }
95
127
  }
96
128
  catch (e) {
97
129
  console.error('e', e);
98
130
  }
99
131
  finally {
132
+ setIsLoading(false);
100
133
  }
101
134
  });
102
135
  return (<div className={`
@@ -109,14 +142,14 @@ const AuthForm = ({ goGetHistoryList }) => {
109
142
  <div className={`flex flex-col`}>
110
143
  <div className={`mt-[40px] flex flex-col gap-[8px]`}>
111
144
  <div className={`text-[14px] font-[700] leading-[100%] tracking-[-4%]`}>이름</div>
112
- <Input2 onChange={handleInput} value={name.value} type="text" name="name" placeholder={'이름'} readOnly={isConfirmState}/>
145
+ <Input2 onChange={handleInput} value={name.value} type="text" name="name" placeholder={'이름'} readOnly={isLoading || (isConfirmState ? timer > 150 : false)}/>
113
146
  </div>
114
147
  <div className={`mt-[20px] flex flex-col gap-[8px]`}>
115
148
  <div className={`text-[14px] font-[700] leading-[100%] tracking-[-4%]`}>휴대폰 번호</div>
116
149
  <div className={`flex flex-row gap-[4px]`}>
117
- <Input2 onChange={handleInput} value={phone.value} type="text" name="phone" className={`!py-[12.5px]`} readOnly={isConfirmState} maxLength={11} placeholder="숫자만 입력"/>
118
- <Button2 isDisabled={isConfirmState || !name.isValid || !phone.isValid} onClick={handleSendAuth} type={'button'} className={`w-[120px]`}>
119
- 인증번호 발송
150
+ <Input2 onChange={handleInput} value={phone.value} type="text" name="phone" className={`!py-[12.5px]`} readOnly={isLoading || (isConfirmState ? timer > 150 : false)} maxLength={11} placeholder="숫자만 입력"/>
151
+ <Button2 isDisabled={isLoading || !name.isValid || !phone.isValid || (isConfirmState && timer > 150)} onClick={handleSendAuth} type={'button'} className={`w-[120px]`}>
152
+ {`${isConfirmState ? (timer > 150 ? `재전송(${timer - 150})` : '재전송') : '인증번호 발송'}`}
120
153
  </Button2>
121
154
  </div>
122
155
  </div>
@@ -125,7 +158,7 @@ const AuthForm = ({ goGetHistoryList }) => {
125
158
  </div>)}
126
159
 
127
160
  {isConfirmState && (<div className={`relative mt-[10px]`}>
128
- <Input2 onChange={handleInput} value={authNumber} type="text" name="authNumber" maxLength={6} placeholder={'인증 번호 입력'}/>
161
+ <Input2 onChange={handleInput} value={authNumber} type="text" readOnly={isLoading} name="authNumber" maxLength={6} placeholder={'인증 번호 입력'}/>
129
162
  <div className={`absolute right-[8px] top-[15px] text-[12px] font-[400] leading-[100%] tracking-[-4%] text-[#AA1D36] `}>
130
163
  {formatSecondsToMMSS(timer)}
131
164
  </div>
@@ -136,9 +169,10 @@ const AuthForm = ({ goGetHistoryList }) => {
136
169
  </div>)}
137
170
 
138
171
  {isConfirmState && (<div className="mt-[40px]">
139
- <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
140
- disabled:bg-[#D2D2D2]
141
- " onClick={handleSubmit}>
172
+ <button disabled={isLoading || authNumber.length < 5} className={`
173
+ flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B]
174
+ px-6 py-3 text-white disabled:bg-[#D2D2D2]
175
+ `} onClick={handleSubmit}>
142
176
  인증번호 확인
143
177
  </button>
144
178
  </div>)}
@@ -4,6 +4,8 @@ import { formatSecondsToMMSS, nameFilter, onlyNumbers, phoneCheck } from '../_li
4
4
  import Button2 from '../_ui/buttons/Button2';
5
5
  import { historyPhoneAuth, requestPhone } from '../_api';
6
6
  import { useDearyunTalkToast } from '../Toast/DaeryuntalkToastProvider';
7
+ import { isSetIterator } from 'util/types';
8
+ import { AuthErrorCode } from '../_enums/error_code';
7
9
 
8
10
  interface IProps {
9
11
  goGetHistoryList: (data: { version?: string }) => void;
@@ -15,13 +17,21 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
15
17
  const [isConfirmState, setIsConfirmState] = useState<boolean>(false);
16
18
  const [timer, setTimer] = useState<number>(180); // 3분(180초)
17
19
  const [timerId, setTimerId] = useState<NodeJS.Timeout | null>(null);
20
+ const [isLoading, setIsLoading] = useState(false);
21
+
18
22
  const toast = useDearyunTalkToast();
19
23
 
20
- // 3분 인증시간 start 필요
24
+ const resetTimerAndState = () => {
25
+ if (timerId) clearInterval(timerId);
26
+ setTimer(180);
27
+ setIsConfirmState(false);
28
+ };
21
29
 
22
30
  const handleInput = (e: React.FormEvent<HTMLInputElement>) => {
23
31
  const { name: formName, value } = e.currentTarget;
24
32
  if (formName === 'name') {
33
+ if (isConfirmState) resetTimerAndState();
34
+
25
35
  const { name: propsName, isValid } = nameFilter(value);
26
36
  setName(prev => {
27
37
  return {
@@ -31,6 +41,8 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
31
41
  });
32
42
  }
33
43
  if (formName === 'phone') {
44
+ if (isConfirmState) resetTimerAndState();
45
+
34
46
  const { phoneNumber, isValid } = phoneCheck(value);
35
47
  setPhone(prev => {
36
48
  return {
@@ -47,28 +59,38 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
47
59
  // 인증번호 발송 클릭
48
60
  const handleSendAuth = async () => {
49
61
  try {
62
+ setIsLoading(true);
50
63
  const res = await requestPhone({ name: name.value, cellPhoneNumber: phone.value });
51
64
  if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
52
- // 인증번호 발송 API 호출 등 처리
53
65
  setIsConfirmState(true);
54
66
  setAuthNumber('');
55
67
  setTimer(180);
68
+
56
69
  if (timerId) clearInterval(timerId);
70
+
57
71
  const id = setInterval(() => {
58
72
  setTimer(prev => {
59
73
  if (prev <= 1) {
60
74
  clearInterval(id);
61
- setIsConfirmState(false); // 타이머 종료시 인증상태 해제
75
+ setIsConfirmState(false);
62
76
  return 0;
63
77
  }
64
78
  return prev - 1;
65
79
  });
66
80
  }, 1000);
81
+
67
82
  setTimerId(id);
83
+ } else {
84
+ if (res.result_info.result_cd === AuthErrorCode.OWNERSHIP_DUPLICATE_REQUEST_ERROR) {
85
+ toast.warning('중복된 요청입니다.');
86
+ } else {
87
+ toast.warning('다시 요청해주세요.');
88
+ }
68
89
  }
69
- } catch (e) {
70
- console.error('e', e);
90
+ } catch (err) {
91
+ console.error('인증번호 발송 실패', err);
71
92
  } finally {
93
+ setIsLoading(false);
72
94
  }
73
95
  };
74
96
 
@@ -80,6 +102,7 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
80
102
  }
81
103
 
82
104
  try {
105
+ setIsLoading(true);
83
106
  const res = await historyPhoneAuth({
84
107
  name: name.value,
85
108
  cellPhoneNumber: phone.value,
@@ -88,10 +111,19 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
88
111
  if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
89
112
  await goGetHistoryList({});
90
113
  toast.success('인증이 완료되었습니다.');
114
+ } else {
115
+ if (res.result_info.result_cd === AuthErrorCode.OWNERSHIP_CODE_MISMATCH) {
116
+ toast.warning('잘못된 인증번호입니다.');
117
+ } else if (res.result_info.result_cd === AuthErrorCode.OWNERSHIP_EXPIRED) {
118
+ toast.warning('인증번호가 만료되었습니다.');
119
+ } else {
120
+ toast.warning('다시 시도해주세요.');
121
+ }
91
122
  }
92
123
  } catch (e) {
93
124
  console.error('e', e);
94
125
  } finally {
126
+ setIsLoading(false);
95
127
  }
96
128
  };
97
129
 
@@ -114,7 +146,7 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
114
146
  type="text"
115
147
  name="name"
116
148
  placeholder={'이름'}
117
- readOnly={isConfirmState}
149
+ readOnly={isLoading || (isConfirmState ? timer > 150 : false)}
118
150
  />
119
151
  </div>
120
152
  <div className={`mt-[20px] flex flex-col gap-[8px]`}>
@@ -126,17 +158,19 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
126
158
  type="text"
127
159
  name="phone"
128
160
  className={`!py-[12.5px]`}
129
- readOnly={isConfirmState}
161
+ readOnly={isLoading || (isConfirmState ? timer > 150 : false)}
130
162
  maxLength={11}
131
163
  placeholder="숫자만 입력"
132
164
  />
133
165
  <Button2
134
- isDisabled={isConfirmState || !name.isValid || !phone.isValid}
166
+ isDisabled={
167
+ isLoading || !name.isValid || !phone.isValid || (isConfirmState && timer > 150)
168
+ }
135
169
  onClick={handleSendAuth}
136
170
  type={'button'}
137
171
  className={`w-[120px]`}
138
172
  >
139
- 인증번호 발송
173
+ {`${isConfirmState ? (timer > 150 ? `재전송(${timer - 150})` : '재전송') : '인증번호 발송'}`}
140
174
  </Button2>
141
175
  </div>
142
176
  </div>
@@ -154,6 +188,7 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
154
188
  onChange={handleInput}
155
189
  value={authNumber}
156
190
  type="text"
191
+ readOnly={isLoading}
157
192
  name="authNumber"
158
193
  maxLength={6}
159
194
  placeholder={'인증 번호 입력'}
@@ -177,10 +212,11 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
177
212
  {isConfirmState && (
178
213
  <div className="mt-[40px]">
179
214
  <button
180
- disabled={authNumber.length < 5}
181
- className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white
182
- disabled:bg-[#D2D2D2]
183
- "
215
+ disabled={isLoading || authNumber.length < 5}
216
+ className={`
217
+ flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B]
218
+ px-6 py-3 text-white disabled:bg-[#D2D2D2]
219
+ `}
184
220
  onClick={handleSubmit}
185
221
  >
186
222
  인증번호 확인
@@ -1,6 +1,6 @@
1
- import { useEditor, EditorContent } from '@tiptap/react';
1
+ import { EditorContent, useEditor } from '@tiptap/react';
2
2
  import Placeholder from '@tiptap/extension-placeholder';
3
- import { useImperativeHandle, forwardRef, useEffect } from 'react';
3
+ import { forwardRef, useEffect, useImperativeHandle } from 'react';
4
4
  import Document from '@tiptap/extension-document';
5
5
  import Paragraph from '@tiptap/extension-paragraph';
6
6
  import Text from '@tiptap/extension-text';
@@ -24,16 +24,28 @@ const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세
24
24
  },
25
25
  editorProps: {
26
26
  attributes: {
27
- class: 'focus:outline-none min-h-[44px] max-h-[72px] overflow-y-auto resize-none px-[10px] py-[4px] flex items-center'
27
+ class: 'focus:outline-none min-h-[34px] max-h-[72px] overflow-y-auto resize-none px-[10px] mt-[4px] pt-[4px] pb-[4px] break-words whitespace-pre-wrap'
28
28
  },
29
29
  handleKeyDown: (view, event) => {
30
- if (event.key === 'Enter' && !event.shiftKey) {
31
- event.preventDefault();
32
- const content = editor === null || editor === void 0 ? void 0 : editor.getText();
33
- if (content && content.trim() && onEnterKeyPress) {
34
- onEnterKeyPress();
30
+ if (event.key === 'Enter') {
31
+ if (event.shiftKey) {
32
+ // 줄바꿈 이후 스크롤 이동 보장
33
+ requestAnimationFrame(() => {
34
+ if (view && view.dom) {
35
+ // 가장 아래에 스크롤되도록 처리
36
+ view.dom.scrollTop = view.dom.scrollHeight;
37
+ }
38
+ });
39
+ return false;
40
+ }
41
+ else {
42
+ event.preventDefault();
43
+ const content = editor === null || editor === void 0 ? void 0 : editor.getText();
44
+ if (content && content.trim() && onEnterKeyPress) {
45
+ onEnterKeyPress();
46
+ }
47
+ return true;
35
48
  }
36
- return true;
37
49
  }
38
50
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
39
51
  return false;
@@ -1,7 +1,6 @@
1
- import { useEditor, EditorContent } from '@tiptap/react';
2
- import StarterKit from '@tiptap/starter-kit';
1
+ import { EditorContent, useEditor } from '@tiptap/react';
3
2
  import Placeholder from '@tiptap/extension-placeholder';
4
- import { useImperativeHandle, forwardRef, useEffect } from 'react';
3
+ import { forwardRef, useEffect, useImperativeHandle } from 'react';
5
4
  import { JSONContent } from '@tiptap/core'; // 추가 필요
6
5
  import Document from '@tiptap/extension-document';
7
6
  import Paragraph from '@tiptap/extension-paragraph';
@@ -44,16 +43,27 @@ const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
44
43
  },
45
44
  editorProps: {
46
45
  attributes: {
47
- class: 'focus:outline-none min-h-[44px] max-h-[72px] overflow-y-auto resize-none px-[10px] py-[4px] flex items-center'
46
+ class: 'focus:outline-none min-h-[34px] max-h-[72px] overflow-y-auto resize-none px-[10px] mt-[4px] pt-[4px] pb-[4px] break-words whitespace-pre-wrap'
48
47
  },
49
48
  handleKeyDown: (view, event) => {
50
- if (event.key === 'Enter' && !event.shiftKey) {
51
- event.preventDefault();
52
- const content = editor?.getText();
53
- if (content && content.trim() && onEnterKeyPress) {
54
- onEnterKeyPress();
49
+ if (event.key === 'Enter') {
50
+ if (event.shiftKey) {
51
+ // 줄바꿈 이후 스크롤 이동 보장
52
+ requestAnimationFrame(() => {
53
+ if (view && view.dom) {
54
+ // 가장 아래에 스크롤되도록 처리
55
+ view.dom.scrollTop = view.dom.scrollHeight;
56
+ }
57
+ });
58
+ return false;
59
+ } else {
60
+ event.preventDefault();
61
+ const content = editor?.getText();
62
+ if (content && content.trim() && onEnterKeyPress) {
63
+ onEnterKeyPress();
64
+ }
65
+ return true;
55
66
  }
56
- return true;
57
67
  }
58
68
 
59
69
  onKeyDown?.(event as unknown as React.KeyboardEvent);