@daeryun/dr_components 0.9.12 → 0.9.14
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/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +4 -4
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +4 -4
- package/dist/components/Daeryuntalk/HomeView.jsx +2 -4
- package/dist/components/Daeryuntalk/HomeView.tsx +8 -5
- package/dist/components/page/Login/LoginComp/SignContainer.jsx +107 -57
- package/dist/components/page/Login/LoginComp/SignContainer.tsx +113 -62
- package/dist/components/page/Login/StepOne.d.ts +3 -0
- package/dist/components/page/Login/StepOne.jsx +209 -0
- package/dist/components/page/Login/StepOne.tsx +300 -0
- package/dist/components/page/Login/StepTwo.d.ts +3 -0
- package/dist/components/page/Login/StepTwo.jsx +515 -0
- package/dist/components/page/Login/StepTwo.tsx +615 -0
- package/dist/styles/daeryuntalk.css +6 -0
- package/dist/styles/globals.css +358 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -11,11 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
import React, { Suspense, useCallback, useEffect, useRef, useState } from 'react';
|
|
12
12
|
import { useRouter } from 'next/navigation';
|
|
13
13
|
import { formatPhoneNumber, formatTime, getCookie, getNameValue, getPhoneValue, onlyNumberFilter } from '../../../../lib';
|
|
14
|
-
import {
|
|
14
|
+
import { getToken } from '../_api/token';
|
|
15
15
|
import { jwtDecode } from 'jwt-decode';
|
|
16
16
|
import { sendNumber } from '../_api/sendNumber';
|
|
17
17
|
import { confirmNumber } from '../_api/confirmNumber';
|
|
18
|
-
import { completeUserSign } from '../_api/completeUser';
|
|
19
18
|
import PageWrapper from '../../../Layout/PageWrapper';
|
|
20
19
|
import LoginBreadCrumb from './LoginBreadCrumb';
|
|
21
20
|
import ConfirmModal from './Modal/ConfirmModal';
|
|
@@ -27,7 +26,6 @@ import Image from 'next/image';
|
|
|
27
26
|
import { useQuery } from '@tanstack/react-query';
|
|
28
27
|
import Loader from '../../../Loader/Loader';
|
|
29
28
|
import OptionalCheckBox from './Sign/OptionalCheckBox';
|
|
30
|
-
import { optionalTermAgree } from '../_api/optionalTermAgree';
|
|
31
29
|
const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px] max-lg:py-[112px] max-sm:mt-[28px] max-sm:py-[100px]`, setUser }) => {
|
|
32
30
|
var _a, _b;
|
|
33
31
|
const session_key = process.env.NEXT_PUBLIC_USER_SESSION_STORAGE_KEY || 'loginUser';
|
|
@@ -394,61 +392,111 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
|
|
|
394
392
|
setIsModal(true);
|
|
395
393
|
}
|
|
396
394
|
});
|
|
397
|
-
const completeUser =
|
|
398
|
-
|
|
395
|
+
// const completeUser = async ({
|
|
396
|
+
// completeBodyData,
|
|
397
|
+
// termBodyData
|
|
398
|
+
// }: {
|
|
399
|
+
// completeBodyData: { name: string; phoneNumber: string; uuid: string };
|
|
400
|
+
// termBodyData: {
|
|
401
|
+
// marketing_agree: number;
|
|
402
|
+
// };
|
|
403
|
+
// }) => {
|
|
404
|
+
// // 이름 설정
|
|
405
|
+
// if (!userValidObj.nameValid) {
|
|
406
|
+
// const { title, subTitle, key } = modalValueSet[modalValueSetKey.nameError];
|
|
407
|
+
// setModalObj({ title: title, subTitle: subTitle, key });
|
|
408
|
+
// setIsModal(true);
|
|
409
|
+
// return;
|
|
410
|
+
// }
|
|
411
|
+
// // 전화번호 인증 완료 여부
|
|
412
|
+
// if (!userValidObj.codeValid || !userObj.uuid) {
|
|
413
|
+
// const { title, subTitle, key } = modalValueSet[modalValueSetKey.sendNumberComplete];
|
|
414
|
+
// setModalObj({ title: title, subTitle: subTitle, key });
|
|
415
|
+
// setIsModal(true);
|
|
416
|
+
// return;
|
|
417
|
+
// }
|
|
418
|
+
// // 약관
|
|
419
|
+
// if (!requiredTermItems.slice(1).every(item => item.checked)) {
|
|
420
|
+
// const { title, subTitle, key } = modalValueSet[modalValueSetKey.termRequiredError];
|
|
421
|
+
// setModalObj({ title: title, subTitle: subTitle, key });
|
|
422
|
+
// setIsModal(true);
|
|
423
|
+
// return;
|
|
424
|
+
// }
|
|
425
|
+
// // 약관 저장
|
|
426
|
+
// const termResult = await optionalTermAgree({
|
|
427
|
+
// bodyData: termBodyData
|
|
428
|
+
// });
|
|
429
|
+
// if (!termResult.result) {
|
|
430
|
+
// // alert('회원가입 실패');
|
|
431
|
+
// return;
|
|
432
|
+
// }
|
|
433
|
+
// // 회원가입 완료
|
|
434
|
+
// const result = await completeUserSign({
|
|
435
|
+
// bodyData: completeBodyData
|
|
436
|
+
// });
|
|
437
|
+
// // 가입 성공여부
|
|
438
|
+
// if (result.result) {
|
|
439
|
+
// setIsUserSignedUp(true);
|
|
440
|
+
// const userData = {
|
|
441
|
+
// email: userJwtObj.email,
|
|
442
|
+
// name: completeBodyData.name,
|
|
443
|
+
// provider: userJwtObj.provider,
|
|
444
|
+
// isLogin: true
|
|
445
|
+
// };
|
|
446
|
+
// setUser && sessionStorage.setItem(session_key || '', JSON.stringify(userData));
|
|
447
|
+
// setUser && setUser(userData);
|
|
448
|
+
// // await signRedirect(redirect);
|
|
449
|
+
// // await createToken(jwtToken);
|
|
450
|
+
// // router.push(redirect);
|
|
451
|
+
// window.location.href = redirect;
|
|
452
|
+
// // window.location.href = `/api/auth/redirect?redirect=${encodeURIComponent(redirect)}`;
|
|
453
|
+
// } else {
|
|
454
|
+
// await deleteToken();
|
|
455
|
+
// }
|
|
456
|
+
// };
|
|
457
|
+
// 다음 버튼 클릭 시 전역변수 설정 및 Step1으로 이동
|
|
458
|
+
const handleNext = () => {
|
|
459
|
+
// 이름 설정 체크
|
|
399
460
|
if (!userValidObj.nameValid) {
|
|
400
461
|
const { title, subTitle, key } = modalValueSet[modalValueSetKey.nameError];
|
|
401
462
|
setModalObj({ title: title, subTitle: subTitle, key });
|
|
402
463
|
setIsModal(true);
|
|
403
464
|
return;
|
|
404
465
|
}
|
|
405
|
-
// 전화번호 인증 완료 여부
|
|
466
|
+
// 전화번호 인증 완료 여부 체크
|
|
406
467
|
if (!userValidObj.codeValid || !userObj.uuid) {
|
|
407
468
|
const { title, subTitle, key } = modalValueSet[modalValueSetKey.sendNumberComplete];
|
|
408
469
|
setModalObj({ title: title, subTitle: subTitle, key });
|
|
409
470
|
setIsModal(true);
|
|
410
471
|
return;
|
|
411
472
|
}
|
|
412
|
-
// 약관
|
|
473
|
+
// 약관 동의 체크
|
|
413
474
|
if (!requiredTermItems.slice(1).every(item => item.checked)) {
|
|
414
475
|
const { title, subTitle, key } = modalValueSet[modalValueSetKey.termRequiredError];
|
|
415
476
|
setModalObj({ title: title, subTitle: subTitle, key });
|
|
416
477
|
setIsModal(true);
|
|
417
478
|
return;
|
|
418
479
|
}
|
|
419
|
-
//
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
};
|
|
440
|
-
setUser && sessionStorage.setItem(session_key || '', JSON.stringify(userData));
|
|
441
|
-
setUser && setUser(userData);
|
|
442
|
-
// await signRedirect(redirect);
|
|
443
|
-
// await createToken(jwtToken);
|
|
444
|
-
// router.push(redirect);
|
|
445
|
-
window.location.href = redirect;
|
|
446
|
-
// window.location.href = `/api/auth/redirect?redirect=${encodeURIComponent(redirect)}`;
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
yield deleteToken();
|
|
450
|
-
}
|
|
451
|
-
});
|
|
480
|
+
// marketing_agree 값 계산
|
|
481
|
+
const marketingAgree = optionalTermItems[0].alarmTypeList
|
|
482
|
+
.filter(item => item.checked)
|
|
483
|
+
.reduce((sum, item) => sum + item.value, 0);
|
|
484
|
+
// setUser를 통해 전역 상태에 저장
|
|
485
|
+
const userData = {
|
|
486
|
+
email: userJwtObj.email,
|
|
487
|
+
name: userObj.name,
|
|
488
|
+
provider: userJwtObj.provider,
|
|
489
|
+
phoneNumber: formatPhoneNumber(userObj.phoneNumber) || '',
|
|
490
|
+
uuid: userObj.uuid,
|
|
491
|
+
marketing_agree: marketingAgree,
|
|
492
|
+
category: [],
|
|
493
|
+
field: [],
|
|
494
|
+
isLogin: true
|
|
495
|
+
};
|
|
496
|
+
setUser && setUser(userData);
|
|
497
|
+
setUser && sessionStorage.setItem(session_key || '', JSON.stringify(userData));
|
|
498
|
+
window.location.href = '/login/sign/step_one';
|
|
499
|
+
};
|
|
452
500
|
const modalHandleClose = () => {
|
|
453
501
|
setIsModal(false);
|
|
454
502
|
setModalObj({ title: '', subTitle: '', key: '' });
|
|
@@ -640,23 +688,25 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
|
|
|
640
688
|
<div className={' mt-[80px] flex items-center justify-center ' +
|
|
641
689
|
' max-lg:mt-[72px] ' +
|
|
642
690
|
' max-sm:mt-[40px] '}>
|
|
643
|
-
<button type={'button'}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
691
|
+
<button type={'button'}
|
|
692
|
+
// onClick={async () => {
|
|
693
|
+
// await completeUser({
|
|
694
|
+
// completeBodyData: {
|
|
695
|
+
// name: userObj.name,
|
|
696
|
+
// phoneNumber: formatPhoneNumber(userObj.phoneNumber) || '',
|
|
697
|
+
// uuid: userObj.uuid
|
|
698
|
+
// },
|
|
699
|
+
// termBodyData: {
|
|
700
|
+
// // alert_agree: optionalTermItems[0].alarmTypeList
|
|
701
|
+
// // .filter(item => item.checked)
|
|
702
|
+
// // .reduce((sum, item) => sum + item.value, 0), // checked된 항목들의 value 합산
|
|
703
|
+
// marketing_agree: optionalTermItems[0].alarmTypeList
|
|
704
|
+
// .filter(item => item.checked)
|
|
705
|
+
// .reduce((sum, item) => sum + item.value, 0) // 마케팅 관련 동의 값 합산
|
|
706
|
+
// }
|
|
707
|
+
// });
|
|
708
|
+
// }}
|
|
709
|
+
onClick={handleNext} className={` ${checkAll ? ' bg-[#AE0E36] text-white ' : ' bg-[#EDEDED] text-[#909090] '} ` +
|
|
660
710
|
' title_small h-[72px] w-[740px] rounded-[36px] ' +
|
|
661
711
|
' max-lg:body_medium2 max-lg:h-[60px] max-lg:w-[620px] ' +
|
|
662
712
|
' max-sm:body_large2_mo max-sm:h-[48px] max-sm:w-full '}>
|
|
@@ -494,16 +494,78 @@ const SignContainer = ({
|
|
|
494
494
|
}
|
|
495
495
|
};
|
|
496
496
|
|
|
497
|
-
const completeUser = async ({
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}: {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}) => {
|
|
506
|
-
|
|
497
|
+
// const completeUser = async ({
|
|
498
|
+
// completeBodyData,
|
|
499
|
+
// termBodyData
|
|
500
|
+
// }: {
|
|
501
|
+
// completeBodyData: { name: string; phoneNumber: string; uuid: string };
|
|
502
|
+
// termBodyData: {
|
|
503
|
+
// marketing_agree: number;
|
|
504
|
+
// };
|
|
505
|
+
// }) => {
|
|
506
|
+
// // 이름 설정
|
|
507
|
+
// if (!userValidObj.nameValid) {
|
|
508
|
+
// const { title, subTitle, key } = modalValueSet[modalValueSetKey.nameError];
|
|
509
|
+
// setModalObj({ title: title, subTitle: subTitle, key });
|
|
510
|
+
// setIsModal(true);
|
|
511
|
+
// return;
|
|
512
|
+
// }
|
|
513
|
+
|
|
514
|
+
// // 전화번호 인증 완료 여부
|
|
515
|
+
// if (!userValidObj.codeValid || !userObj.uuid) {
|
|
516
|
+
// const { title, subTitle, key } = modalValueSet[modalValueSetKey.sendNumberComplete];
|
|
517
|
+
// setModalObj({ title: title, subTitle: subTitle, key });
|
|
518
|
+
// setIsModal(true);
|
|
519
|
+
// return;
|
|
520
|
+
// }
|
|
521
|
+
|
|
522
|
+
// // 약관
|
|
523
|
+
// if (!requiredTermItems.slice(1).every(item => item.checked)) {
|
|
524
|
+
// const { title, subTitle, key } = modalValueSet[modalValueSetKey.termRequiredError];
|
|
525
|
+
// setModalObj({ title: title, subTitle: subTitle, key });
|
|
526
|
+
// setIsModal(true);
|
|
527
|
+
// return;
|
|
528
|
+
// }
|
|
529
|
+
|
|
530
|
+
// // 약관 저장
|
|
531
|
+
// const termResult = await optionalTermAgree({
|
|
532
|
+
// bodyData: termBodyData
|
|
533
|
+
// });
|
|
534
|
+
// if (!termResult.result) {
|
|
535
|
+
// // alert('회원가입 실패');
|
|
536
|
+
// return;
|
|
537
|
+
// }
|
|
538
|
+
|
|
539
|
+
// // 회원가입 완료
|
|
540
|
+
// const result = await completeUserSign({
|
|
541
|
+
// bodyData: completeBodyData
|
|
542
|
+
// });
|
|
543
|
+
// // 가입 성공여부
|
|
544
|
+
// if (result.result) {
|
|
545
|
+
// setIsUserSignedUp(true);
|
|
546
|
+
|
|
547
|
+
// const userData = {
|
|
548
|
+
// email: userJwtObj.email,
|
|
549
|
+
// name: completeBodyData.name,
|
|
550
|
+
// provider: userJwtObj.provider,
|
|
551
|
+
// isLogin: true
|
|
552
|
+
// };
|
|
553
|
+
// setUser && sessionStorage.setItem(session_key || '', JSON.stringify(userData));
|
|
554
|
+
// setUser && setUser(userData);
|
|
555
|
+
// // await signRedirect(redirect);
|
|
556
|
+
|
|
557
|
+
// // await createToken(jwtToken);
|
|
558
|
+
// // router.push(redirect);
|
|
559
|
+
// window.location.href = redirect;
|
|
560
|
+
// // window.location.href = `/api/auth/redirect?redirect=${encodeURIComponent(redirect)}`;
|
|
561
|
+
// } else {
|
|
562
|
+
// await deleteToken();
|
|
563
|
+
// }
|
|
564
|
+
// };
|
|
565
|
+
|
|
566
|
+
// 다음 버튼 클릭 시 전역변수 설정 및 Step1으로 이동
|
|
567
|
+
const handleNext = () => {
|
|
568
|
+
// 이름 설정 체크
|
|
507
569
|
if (!userValidObj.nameValid) {
|
|
508
570
|
const { title, subTitle, key } = modalValueSet[modalValueSetKey.nameError];
|
|
509
571
|
setModalObj({ title: title, subTitle: subTitle, key });
|
|
@@ -511,7 +573,7 @@ const SignContainer = ({
|
|
|
511
573
|
return;
|
|
512
574
|
}
|
|
513
575
|
|
|
514
|
-
// 전화번호 인증 완료 여부
|
|
576
|
+
// 전화번호 인증 완료 여부 체크
|
|
515
577
|
if (!userValidObj.codeValid || !userObj.uuid) {
|
|
516
578
|
const { title, subTitle, key } = modalValueSet[modalValueSetKey.sendNumberComplete];
|
|
517
579
|
setModalObj({ title: title, subTitle: subTitle, key });
|
|
@@ -519,7 +581,7 @@ const SignContainer = ({
|
|
|
519
581
|
return;
|
|
520
582
|
}
|
|
521
583
|
|
|
522
|
-
// 약관
|
|
584
|
+
// 약관 동의 체크
|
|
523
585
|
if (!requiredTermItems.slice(1).every(item => item.checked)) {
|
|
524
586
|
const { title, subTitle, key } = modalValueSet[modalValueSetKey.termRequiredError];
|
|
525
587
|
setModalObj({ title: title, subTitle: subTitle, key });
|
|
@@ -527,40 +589,28 @@ const SignContainer = ({
|
|
|
527
589
|
return;
|
|
528
590
|
}
|
|
529
591
|
|
|
530
|
-
//
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
if (!termResult.result) {
|
|
535
|
-
// alert('회원가입 실패');
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
592
|
+
// marketing_agree 값 계산
|
|
593
|
+
const marketingAgree = optionalTermItems[0].alarmTypeList
|
|
594
|
+
.filter(item => item.checked)
|
|
595
|
+
.reduce((sum, item) => sum + item.value, 0);
|
|
538
596
|
|
|
539
|
-
//
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
// await createToken(jwtToken);
|
|
558
|
-
// router.push(redirect);
|
|
559
|
-
window.location.href = redirect;
|
|
560
|
-
// window.location.href = `/api/auth/redirect?redirect=${encodeURIComponent(redirect)}`;
|
|
561
|
-
} else {
|
|
562
|
-
await deleteToken();
|
|
563
|
-
}
|
|
597
|
+
// setUser를 통해 전역 상태에 저장
|
|
598
|
+
const userData = {
|
|
599
|
+
email: userJwtObj.email,
|
|
600
|
+
name: userObj.name,
|
|
601
|
+
provider: userJwtObj.provider,
|
|
602
|
+
phoneNumber: formatPhoneNumber(userObj.phoneNumber) || '',
|
|
603
|
+
uuid: userObj.uuid,
|
|
604
|
+
marketing_agree: marketingAgree,
|
|
605
|
+
category: [],
|
|
606
|
+
field: [],
|
|
607
|
+
isLogin: true
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
setUser && setUser(userData);
|
|
611
|
+
setUser && sessionStorage.setItem(session_key || '', JSON.stringify(userData));
|
|
612
|
+
|
|
613
|
+
window.location.href = '/login/sign/step_one';
|
|
564
614
|
};
|
|
565
615
|
|
|
566
616
|
const modalHandleClose = () => {
|
|
@@ -963,23 +1013,24 @@ const SignContainer = ({
|
|
|
963
1013
|
>
|
|
964
1014
|
<button
|
|
965
1015
|
type={'button'}
|
|
966
|
-
onClick={async () => {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
}}
|
|
1016
|
+
// onClick={async () => {
|
|
1017
|
+
// await completeUser({
|
|
1018
|
+
// completeBodyData: {
|
|
1019
|
+
// name: userObj.name,
|
|
1020
|
+
// phoneNumber: formatPhoneNumber(userObj.phoneNumber) || '',
|
|
1021
|
+
// uuid: userObj.uuid
|
|
1022
|
+
// },
|
|
1023
|
+
// termBodyData: {
|
|
1024
|
+
// // alert_agree: optionalTermItems[0].alarmTypeList
|
|
1025
|
+
// // .filter(item => item.checked)
|
|
1026
|
+
// // .reduce((sum, item) => sum + item.value, 0), // checked된 항목들의 value 합산
|
|
1027
|
+
// marketing_agree: optionalTermItems[0].alarmTypeList
|
|
1028
|
+
// .filter(item => item.checked)
|
|
1029
|
+
// .reduce((sum, item) => sum + item.value, 0) // 마케팅 관련 동의 값 합산
|
|
1030
|
+
// }
|
|
1031
|
+
// });
|
|
1032
|
+
// }}
|
|
1033
|
+
onClick={handleNext}
|
|
983
1034
|
className={
|
|
984
1035
|
` ${checkAll ? ' bg-[#AE0E36] text-white ' : ' bg-[#EDEDED] text-[#909090] '} ` +
|
|
985
1036
|
' title_small h-[72px] w-[740px] rounded-[36px] ' +
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
12
|
+
import Image from 'next/image';
|
|
13
|
+
const Box = ({ code, code_name, selected, selectedList, setSelectedList, activeTooltipId, setActiveTooltipId, tooltipTimeoutRef }) => {
|
|
14
|
+
const [tooltipStyle, setTooltipStyle] = useState({});
|
|
15
|
+
const buttonRef = useRef(null);
|
|
16
|
+
const tooltipRef = useRef(null);
|
|
17
|
+
const [tooltipArrowLeft, setTooltipArrowLeft] = useState('50%');
|
|
18
|
+
// 외부 클릭 시 툴팁 닫기
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (activeTooltipId !== code)
|
|
21
|
+
return;
|
|
22
|
+
const handleClickOutside = (e) => {
|
|
23
|
+
if (tooltipRef.current &&
|
|
24
|
+
!tooltipRef.current.contains(e.target) &&
|
|
25
|
+
buttonRef.current &&
|
|
26
|
+
!buttonRef.current.contains(e.target)) {
|
|
27
|
+
setActiveTooltipId(null);
|
|
28
|
+
if (tooltipTimeoutRef.current) {
|
|
29
|
+
clearTimeout(tooltipTimeoutRef.current);
|
|
30
|
+
tooltipTimeoutRef.current = null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const handleResize = () => {
|
|
35
|
+
setActiveTooltipId(null);
|
|
36
|
+
if (tooltipTimeoutRef.current) {
|
|
37
|
+
clearTimeout(tooltipTimeoutRef.current);
|
|
38
|
+
tooltipTimeoutRef.current = null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
window.addEventListener('resize', handleResize);
|
|
42
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
43
|
+
return () => {
|
|
44
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
45
|
+
window.removeEventListener('resize', handleResize);
|
|
46
|
+
};
|
|
47
|
+
}, [activeTooltipId, code]);
|
|
48
|
+
const handleClick = () => {
|
|
49
|
+
const clearTooltipTimer = () => {
|
|
50
|
+
if (tooltipTimeoutRef.current) {
|
|
51
|
+
clearTimeout(tooltipTimeoutRef.current);
|
|
52
|
+
tooltipTimeoutRef.current = null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
if (selected) {
|
|
56
|
+
setSelectedList(prev => prev.filter(item => item !== code));
|
|
57
|
+
setActiveTooltipId(null);
|
|
58
|
+
clearTooltipTimer();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (selectedList.length >= 2) {
|
|
62
|
+
const button = buttonRef.current;
|
|
63
|
+
if (button) {
|
|
64
|
+
const rect = button.getBoundingClientRect();
|
|
65
|
+
const viewportWidth = window.innerWidth;
|
|
66
|
+
const TOOLTIP_WIDTH = window.innerWidth >= 1024 ? 271 : window.innerWidth >= 640 ? 240 : 177;
|
|
67
|
+
const SCREEN_PADDING = 8;
|
|
68
|
+
const NUDGE_X = 20;
|
|
69
|
+
const TOOLTIP_OFFSET_Y = window.innerWidth >= 1024 ? 68 : window.innerWidth >= 640 ? 58 : 44;
|
|
70
|
+
const centerLeft = rect.width / 2 - TOOLTIP_WIDTH / 2;
|
|
71
|
+
let left = centerLeft;
|
|
72
|
+
const absoluteLeft = rect.left + centerLeft;
|
|
73
|
+
const absoluteRight = rect.left + centerLeft + TOOLTIP_WIDTH;
|
|
74
|
+
if (absoluteLeft < SCREEN_PADDING) {
|
|
75
|
+
left += SCREEN_PADDING - absoluteLeft + NUDGE_X;
|
|
76
|
+
}
|
|
77
|
+
else if (absoluteRight > viewportWidth - SCREEN_PADDING) {
|
|
78
|
+
left -= absoluteRight - (viewportWidth - SCREEN_PADDING) + NUDGE_X;
|
|
79
|
+
}
|
|
80
|
+
const tooltipArrowX = rect.left + rect.width / 2 - (rect.left + left);
|
|
81
|
+
setTooltipArrowLeft(`${tooltipArrowX}px`);
|
|
82
|
+
setTooltipStyle({
|
|
83
|
+
position: 'absolute',
|
|
84
|
+
top: -TOOLTIP_OFFSET_Y,
|
|
85
|
+
left,
|
|
86
|
+
width: TOOLTIP_WIDTH
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
clearTooltipTimer();
|
|
90
|
+
setActiveTooltipId(code);
|
|
91
|
+
tooltipTimeoutRef.current = setTimeout(() => {
|
|
92
|
+
setActiveTooltipId(null);
|
|
93
|
+
tooltipTimeoutRef.current = null;
|
|
94
|
+
}, 3000000);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
setSelectedList(prev => [...prev, code]);
|
|
98
|
+
setActiveTooltipId(null);
|
|
99
|
+
clearTooltipTimer();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return (<div className="relative inline-block">
|
|
103
|
+
{activeTooltipId === code && (<div ref={tooltipRef} style={tooltipStyle} className="z-10">
|
|
104
|
+
<div className="relative w-full rounded-[4px] bg-[#7B2238] p-[6px] text-white shadow-md sm:rounded-[8px] sm:px-[14px] sm:py-[10px] lg:px-[16px] lg:py-[12px]">
|
|
105
|
+
<div className="flex items-center justify-center gap-[4px] sm:gap-[6px] lg:gap-[8px]">
|
|
106
|
+
<Image src="https://d1tgonli21s4df.cloudfront.net/common-login/mark2.webp" alt="warning" width={24} height={24} className="h-[13.82px] w-[16px] sm:h-[17.27px] sm:w-[20px] lg:h-[20.73px] lg:w-[24px]"/>
|
|
107
|
+
<p className="label_large2_mo sm:label_large2_tb lg:label_large2">
|
|
108
|
+
선택은 2개까지만 가능해요.
|
|
109
|
+
</p>
|
|
110
|
+
</div>
|
|
111
|
+
{/* 꼬리 */}
|
|
112
|
+
<div style={{
|
|
113
|
+
position: 'absolute',
|
|
114
|
+
top: '100%',
|
|
115
|
+
left: tooltipArrowLeft,
|
|
116
|
+
transform: 'translateX(-50%)',
|
|
117
|
+
width: 0,
|
|
118
|
+
height: 0,
|
|
119
|
+
borderLeft: '4.8px solid transparent',
|
|
120
|
+
borderRight: '4.8px solid transparent',
|
|
121
|
+
borderTop: '8px solid #7B2238'
|
|
122
|
+
}}/>
|
|
123
|
+
</div>
|
|
124
|
+
</div>)}
|
|
125
|
+
|
|
126
|
+
<button ref={buttonRef} onClick={handleClick} className={`flex flex-row items-center gap-[4px] rounded-[26px] border border-solid ${selected ? 'border-transparent bg-grayScale1' : 'border-grayScale5'} px-[10px] py-[4px] sm:gap-[8px] sm:px-[16px] sm:py-[6px] lg:gap-[12px] lg:px-[20px] lg:py-[8px]`}>
|
|
127
|
+
<div className={`flex h-[16px] w-[16px] items-center justify-center border border-solid sm:h-[20px] sm:w-[20px] lg:h-[28px] lg:w-[28px] ${selected ? 'border-transparent bg-white' : 'border-grayScale5 bg-white'}`}>
|
|
128
|
+
{selected && (<img src="https://d1tgonli21s4df.cloudfront.net/common-login/check box_4.webp" alt="check" width={28} height={28} className="h-[16px] w-[16px] sm:h-[20px] sm:w-[20px] lg:h-[28px] lg:w-[28px]"/>)}
|
|
129
|
+
</div>
|
|
130
|
+
<p className={`body_medium2_mo sm:body_large2_tb lg:body_large2 leading-[20px] sm:leading-[30px] lg:leading-[35px] ${selected ? 'text-grayScale8' : 'text-grayScale2'}`}>
|
|
131
|
+
{code_name}
|
|
132
|
+
</p>
|
|
133
|
+
</button>
|
|
134
|
+
</div>);
|
|
135
|
+
};
|
|
136
|
+
const StepOne = () => {
|
|
137
|
+
const [selectedList, setSelectedList] = useState([]);
|
|
138
|
+
const [activeTooltipId, setActiveTooltipId] = useState(null);
|
|
139
|
+
const tooltipTimeoutRef = useRef(null);
|
|
140
|
+
const categories = [
|
|
141
|
+
{ code: 'CT0004', code_name: '기업법무' },
|
|
142
|
+
{ code: 'CT0014', code_name: '지식재산권' },
|
|
143
|
+
{ code: 'CT0026', code_name: '공정거래' },
|
|
144
|
+
{ code: 'CT0021', code_name: '관세·국제통상·이민' },
|
|
145
|
+
{ code: 'CT0007', code_name: '건설·부동산' },
|
|
146
|
+
{ code: 'CT0005', code_name: '이혼' },
|
|
147
|
+
{ code: 'CT0006', code_name: '상속·가사' },
|
|
148
|
+
{ code: 'CT0012', code_name: '조세' },
|
|
149
|
+
{ code: 'CT0024', code_name: '회계감리' },
|
|
150
|
+
{ code: 'CT0001', code_name: '형사' },
|
|
151
|
+
{ code: 'CT0019', code_name: '음주교통사고' },
|
|
152
|
+
{ code: 'CT0017', code_name: '국방군사' },
|
|
153
|
+
{ code: 'CT0002', code_name: '성범죄' },
|
|
154
|
+
{ code: 'CT0013', code_name: '마약' },
|
|
155
|
+
{ code: 'CT0008', code_name: '민사·중재' },
|
|
156
|
+
{ code: 'CT0003', code_name: '학교폭력' },
|
|
157
|
+
{ code: 'CT0009', code_name: '헌법행정' },
|
|
158
|
+
{ code: 'CT0011', code_name: '금융·보험' },
|
|
159
|
+
{ code: 'CT0018', code_name: '의료제약' },
|
|
160
|
+
{ code: 'CT0027', code_name: '산업안전·중대재해' },
|
|
161
|
+
{ code: 'CT0016', code_name: '노동·산재' },
|
|
162
|
+
{ code: 'CT0025', code_name: '엔터테인먼트·스포츠' },
|
|
163
|
+
{ code: 'CT0015', code_name: '증거조사' },
|
|
164
|
+
{ code: 'CT0029', code_name: '디지털포렌식' },
|
|
165
|
+
{ code: 'CT0030', code_name: '경호' }
|
|
166
|
+
];
|
|
167
|
+
return (<>
|
|
168
|
+
<div className="relative mx-[200px] mt-[150px] max-[1498px]:mx-[120px] max-lg:mx-[60px] max-sm:mx-[20px] sm:mt-[240px] lg:mt-[200px] ">
|
|
169
|
+
<div className="">
|
|
170
|
+
<p className="title_large_mo sm:title_large_tb lg:title_large">STEP 1</p>
|
|
171
|
+
<div className="xxl:flex xxl:flex-row xxl:items-center xxl:justify-between">
|
|
172
|
+
<div className="mt-[8px] flex flex-col gap-[4px] sm:mt-[12px] md:flex-row md:items-center md:gap-[8px] lg:mt-[12px] lg:flex-col lg:items-start 5xl:flex-row 5xl:items-center 5xl:gap-[8px]">
|
|
173
|
+
<p className="title_small_mo sm:title_small_tb lg:title_small">
|
|
174
|
+
어떤 법률도움이 필요하신가요?
|
|
175
|
+
</p>
|
|
176
|
+
<p className="body_small2_mo sm:body_medium2_tb lg:body_medium2">
|
|
177
|
+
(최대 2개까지 선택할 수 있어요.)
|
|
178
|
+
</p>
|
|
179
|
+
</div>
|
|
180
|
+
<div className="mt-[12px] flex flex-row gap-[8px] rounded-[8px] bg-grayScale7 p-[8px] sm:mt-[40px] sm:w-[513px] sm:gap-[12px] sm:px-[20px] sm:py-[12px] lg:w-[590px] lg:rounded-[12px] lg:px-[28px] lg:py-[16px] xxl:mt-0">
|
|
181
|
+
<Image src="https://d1tgonli21s4df.cloudfront.net/common-login/mark.webp" alt="물음표" width={28} height={28} className="mt-[1px] h-[16px] w-[16px] sm:mt-[2px] sm:h-[20px] sm:w-[20px] lg:mt-0 lg:h-[28px] lg:w-[28px]"/>
|
|
182
|
+
<p className="body_small2_mo sm:body_small2_tb lg:body_small2">
|
|
183
|
+
관심 분야 및 유형은 모바일 앱에서 맞춤 콘텐츠 제공에 사용됩니다. 설정해두시면 앱에서
|
|
184
|
+
더욱 편리하게 이용하실 수 있어요.
|
|
185
|
+
</p>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<div className="mt-[28px] flex flex-row flex-wrap gap-x-[8px] gap-y-[12px] sm:mt-[60px] sm:gap-[28px] lg:mt-[66px] lg:gap-x-[32px] lg:gap-y-[40px]">
|
|
191
|
+
{categories.map(item => (<Box key={item.code} code={item.code} code_name={item.code_name} selected={selectedList.includes(item.code)} selectedList={selectedList} setSelectedList={setSelectedList} activeTooltipId={activeTooltipId} setActiveTooltipId={setActiveTooltipId} tooltipTimeoutRef={tooltipTimeoutRef}/>))}
|
|
192
|
+
</div>
|
|
193
|
+
<div className="mb-[56px] mt-[40px] flex flex-col items-center justify-center sm:mt-[60px] lg:mt-[218px]">
|
|
194
|
+
<button type={'button'} onClick={() => __awaiter(void 0, void 0, void 0, function* () { })} className={` ${selectedList.length > 0 ? ' bg-[#AE0E36] text-white ' : ' bg-[#EDEDED] text-grayScale3 '} ` +
|
|
195
|
+
' title_small h-[72px] w-[740px] rounded-[36px] ' +
|
|
196
|
+
' max-lg:body_medium2 max-lg:h-[60px] max-lg:w-[620px] ' +
|
|
197
|
+
' max-sm:body_large2_mo max-sm:h-[48px] max-sm:w-full '}>
|
|
198
|
+
다음
|
|
199
|
+
</button>
|
|
200
|
+
<button type={'button'} onClick={() => __awaiter(void 0, void 0, void 0, function* () {
|
|
201
|
+
//추가해야함
|
|
202
|
+
})} className="body_small2_mo sm:body_small2_tb lg:body_small2 mt-[12px] text-grayScale2 underline sm:mt-[20px] lg:mt-[40px]">
|
|
203
|
+
건너뛰기
|
|
204
|
+
</button>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
</>);
|
|
208
|
+
};
|
|
209
|
+
export default StepOne;
|