File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed
Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -95,12 +95,17 @@ const Purchase = () => {
9595 }
9696 } , [ name ] ) ;
9797
98+ // useEffect(() => {
99+ // if (phone.length > 0 && phone.trim() !== "") {
100+ // setPhoneValid(true);
101+ // } else {
102+ // setPhoneValid(false);
103+ // }
104+ // }, [phone]);
105+
98106 useEffect ( ( ) => {
99- if ( phone . length > 0 && phone . trim ( ) !== "" ) {
100- setPhoneValid ( true ) ;
101- } else {
102- setPhoneValid ( false ) ;
103- }
107+ const PHONE_REGEX = / ^ 0 1 0 - \d { 4 } - \d { 4 } $ / ;
108+ setPhoneValid ( PHONE_REGEX . test ( phone ) ) ;
104109 } , [ phone ] ) ;
105110
106111 useEffect ( ( ) => {
@@ -183,8 +188,14 @@ const Purchase = () => {
183188 setIsLoading ( true ) ;
184189
185190 // 1) 사용자 입력 검증
186- if ( buyPerform && ( ! nameValid || ! phoneValid || ! addressValid ) ) {
187- alert ( "신청자 정보를 다시 확인해주세요." ) ;
191+ // if (buyPerform && (!nameValid || !addressValid)) {
192+ // alert("신청자 정보를 다시 확인해주세요.");
193+ // setIsLoading(false);
194+ // return;
195+ // }
196+
197+ if ( buyPerform && ! phoneValid ) {
198+ alert ( "전화번호 입력 형식을 다시 확인해 주세요 (010-****-****)" ) ;
188199 setIsLoading ( false ) ;
189200 return ;
190201 }
@@ -268,7 +279,6 @@ const Purchase = () => {
268279 JSON . stringify ( requestBody )
269280 ) ;
270281
271-
272282 requestPay ( {
273283 clientId : import . meta. env . VITE_NICEPAY_CLIENT_KEY ,
274284 method : nicepayMethod , // 'card' | 'bank' | 'vbank'
You can’t perform that action at this time.
0 commit comments