@daeryun/dr_components 0.9.22 → 0.9.24
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/page/Login/LoginComp/SignContainer.jsx +59 -64
- package/dist/components/page/Login/LoginComp/SignContainer.tsx +63 -63
- package/dist/components/page/Login/StepOne.jsx +83 -4
- package/dist/components/page/Login/StepOne.tsx +101 -5
- package/dist/components/page/Login/StepTwo.jsx +114 -5
- package/dist/components/page/Login/StepTwo.tsx +131 -6
- package/dist/components/page/index.d.ts +2 -0
- package/dist/components/page/index.js +2 -0
- package/dist/components/page/index.ts +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -10,11 +10,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
import React, { useEffect, useRef, useState } from 'react';
|
|
12
12
|
import Image from 'next/image';
|
|
13
|
+
import { useMutation } from '@tanstack/react-query';
|
|
14
|
+
import { getCookie } from '../../../lib';
|
|
13
15
|
const Box = ({ type_idx, tag_title, selected, selectedList, setSelectedList, activeTooltipId, setActiveTooltipId, tooltipTimeoutRef }) => {
|
|
14
16
|
const [tooltipStyle, setTooltipStyle] = useState({});
|
|
15
17
|
const buttonRef = useRef(null);
|
|
16
18
|
const tooltipRef = useRef(null);
|
|
17
19
|
const [tooltipArrowLeft, setTooltipArrowLeft] = useState('50%');
|
|
20
|
+
// sessionStorage 업데이트 함수
|
|
21
|
+
const updateSessionStorage = (newSelectedList) => {
|
|
22
|
+
try {
|
|
23
|
+
const existingLogin = sessionStorage.getItem('login');
|
|
24
|
+
if (existingLogin) {
|
|
25
|
+
const loginData = JSON.parse(existingLogin);
|
|
26
|
+
loginData.selectedFields = newSelectedList.map(String);
|
|
27
|
+
sessionStorage.setItem('login', JSON.stringify(loginData));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error('SessionStorage 업데이트 실패:', error);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
18
34
|
// 외부 클릭 시 툴팁 닫기
|
|
19
35
|
useEffect(() => {
|
|
20
36
|
if (activeTooltipId !== type_idx)
|
|
@@ -53,7 +69,9 @@ const Box = ({ type_idx, tag_title, selected, selectedList, setSelectedList, act
|
|
|
53
69
|
}
|
|
54
70
|
};
|
|
55
71
|
if (selected) {
|
|
56
|
-
|
|
72
|
+
const newSelectedList = selectedList.filter(item => item !== type_idx);
|
|
73
|
+
setSelectedList(newSelectedList);
|
|
74
|
+
updateSessionStorage(newSelectedList);
|
|
57
75
|
setActiveTooltipId(null);
|
|
58
76
|
clearTooltipTimer();
|
|
59
77
|
}
|
|
@@ -94,7 +112,9 @@ const Box = ({ type_idx, tag_title, selected, selectedList, setSelectedList, act
|
|
|
94
112
|
}, 3000000);
|
|
95
113
|
return;
|
|
96
114
|
}
|
|
97
|
-
|
|
115
|
+
const newSelectedList = [...selectedList, type_idx];
|
|
116
|
+
setSelectedList(newSelectedList);
|
|
117
|
+
updateSessionStorage(newSelectedList);
|
|
98
118
|
setActiveTooltipId(null);
|
|
99
119
|
clearTooltipTimer();
|
|
100
120
|
}
|
|
@@ -447,7 +467,96 @@ const StepTwo = () => {
|
|
|
447
467
|
}
|
|
448
468
|
]
|
|
449
469
|
};
|
|
450
|
-
|
|
470
|
+
const doneMutation = useMutation({
|
|
471
|
+
mutationFn: (bodyData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
472
|
+
const marketingResponse = yield fetch(`/api/lawfirm/app/user/agree`, {
|
|
473
|
+
method: 'POST',
|
|
474
|
+
headers: { 'Content-Type': 'application/json' },
|
|
475
|
+
body: JSON.stringify({ marketing_agree: bodyData.marketing_agree })
|
|
476
|
+
});
|
|
477
|
+
if (!marketingResponse.ok) {
|
|
478
|
+
throw new Error('마케팅 동의 API 호출 실패');
|
|
479
|
+
}
|
|
480
|
+
const userResponse = yield fetch(`/api/lawfirm/app/user`, {
|
|
481
|
+
method: 'PATCH',
|
|
482
|
+
headers: { 'Content-Type': 'application/json' },
|
|
483
|
+
body: JSON.stringify({
|
|
484
|
+
name: bodyData.name,
|
|
485
|
+
phoneNumber: bodyData.phoneNumber,
|
|
486
|
+
uuid: bodyData.uuid,
|
|
487
|
+
categoryAndField: {
|
|
488
|
+
categories: bodyData.categoryAndField.categories,
|
|
489
|
+
fields: bodyData.categoryAndField.fields
|
|
490
|
+
}
|
|
491
|
+
})
|
|
492
|
+
});
|
|
493
|
+
if (!userResponse.ok) {
|
|
494
|
+
throw new Error('사용자 정보 API 호출 실패');
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
marketing: yield marketingResponse.json(),
|
|
498
|
+
user: yield userResponse.json()
|
|
499
|
+
};
|
|
500
|
+
}),
|
|
501
|
+
onSuccess: () => {
|
|
502
|
+
const redirect = decodeURIComponent(getCookie('redirect')) || '/';
|
|
503
|
+
window.location.href = redirect;
|
|
504
|
+
},
|
|
505
|
+
onError: error => {
|
|
506
|
+
console.error('Skip API 호출 실패:', error);
|
|
507
|
+
// 필요시 에러 처리 로직 추가
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
const handlePrev = () => {
|
|
511
|
+
window.location.href = '/login/sign/step_one';
|
|
512
|
+
};
|
|
513
|
+
const handleDone = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
514
|
+
try {
|
|
515
|
+
// session storage에서 login 정보 가져오기
|
|
516
|
+
const existingLogin = sessionStorage.getItem('login');
|
|
517
|
+
if (!existingLogin) {
|
|
518
|
+
console.error('로그인 정보가 없습니다.');
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
const loginData = JSON.parse(existingLogin);
|
|
522
|
+
// 필수 정보 확인
|
|
523
|
+
if (!loginData.name || !loginData.phoneNumber || !loginData.uuid) {
|
|
524
|
+
console.error('필수 정보가 부족합니다.');
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const categories = loginData.selectedCategories;
|
|
528
|
+
const fields = selectedList.map(String);
|
|
529
|
+
// API 호출
|
|
530
|
+
doneMutation.mutate({
|
|
531
|
+
name: loginData.name,
|
|
532
|
+
phoneNumber: loginData.phoneNumber,
|
|
533
|
+
uuid: loginData.uuid,
|
|
534
|
+
categoryAndField: { categories, fields },
|
|
535
|
+
marketing_agree: loginData.marketing_agree
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
catch (error) {
|
|
539
|
+
console.error('Session storage parsing error:', error);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
// 페이지 로드 시 세션 스토리지에서 기존 선택값 복원
|
|
543
|
+
useEffect(() => {
|
|
544
|
+
try {
|
|
545
|
+
const existingLogin = sessionStorage.getItem('login');
|
|
546
|
+
if (existingLogin) {
|
|
547
|
+
const loginData = JSON.parse(existingLogin);
|
|
548
|
+
if (loginData.selectedFields && Array.isArray(loginData.selectedFields)) {
|
|
549
|
+
// 문자열 배열을 숫자 배열로 변환
|
|
550
|
+
const restoredList = loginData.selectedFields.map((field) => parseInt(field, 10));
|
|
551
|
+
setSelectedList(restoredList);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
catch (error) {
|
|
556
|
+
console.error('SessionStorage에서 선택된 필드 복원 실패:', error);
|
|
557
|
+
}
|
|
558
|
+
}, []);
|
|
559
|
+
console.log('selectedList:', selectedList);
|
|
451
560
|
return (<>
|
|
452
561
|
<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] ">
|
|
453
562
|
<div className="">
|
|
@@ -495,13 +604,13 @@ const StepTwo = () => {
|
|
|
495
604
|
</div>
|
|
496
605
|
<div className="mb-[56px] mt-[40px] flex flex-col items-center justify-center sm:mt-[60px] lg:mt-[79px]">
|
|
497
606
|
<div className="flex w-full flex-row items-center justify-center gap-[8px]">
|
|
498
|
-
<button type={'button'} onClick={
|
|
607
|
+
<button type={'button'} onClick={handlePrev} className={` bg-[#EDEDED] text-grayScale3` +
|
|
499
608
|
' title_small h-[72px] w-[740px] rounded-[36px] ' +
|
|
500
609
|
' max-lg:body_medium2 max-lg:h-[60px] max-lg:w-[620px] ' +
|
|
501
610
|
' max-sm:body_large2_mo max-sm:h-[48px] max-sm:w-full '}>
|
|
502
611
|
이전
|
|
503
612
|
</button>
|
|
504
|
-
<button type={'button'} onClick={
|
|
613
|
+
<button type={'button'} onClick={handleDone} className={` ${selectedList.length > 0 ? ' bg-[#AE0E36] text-white ' : ' bg-[#EDEDED] text-grayScale3 '} ` +
|
|
505
614
|
' title_small h-[72px] w-[740px] rounded-[36px] ' +
|
|
506
615
|
' max-lg:body_medium2 max-lg:h-[60px] max-lg:w-[620px] ' +
|
|
507
616
|
' max-sm:body_large2_mo max-sm:h-[48px] max-sm:w-full '}>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import React, { useEffect, useRef, useState } from 'react';
|
|
4
|
-
|
|
5
4
|
import Image from 'next/image';
|
|
5
|
+
import { useMutation } from '@tanstack/react-query';
|
|
6
|
+
import { getCookie } from '../../../lib';
|
|
6
7
|
|
|
7
8
|
const Box = ({
|
|
8
9
|
type_idx,
|
|
@@ -29,6 +30,20 @@ const Box = ({
|
|
|
29
30
|
|
|
30
31
|
const [tooltipArrowLeft, setTooltipArrowLeft] = useState('50%');
|
|
31
32
|
|
|
33
|
+
// sessionStorage 업데이트 함수
|
|
34
|
+
const updateSessionStorage = (newSelectedList: number[]) => {
|
|
35
|
+
try {
|
|
36
|
+
const existingLogin = sessionStorage.getItem('login');
|
|
37
|
+
if (existingLogin) {
|
|
38
|
+
const loginData = JSON.parse(existingLogin);
|
|
39
|
+
loginData.selectedFields = newSelectedList.map(String);
|
|
40
|
+
sessionStorage.setItem('login', JSON.stringify(loginData));
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('SessionStorage 업데이트 실패:', error);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
32
47
|
// 외부 클릭 시 툴팁 닫기
|
|
33
48
|
useEffect(() => {
|
|
34
49
|
if (activeTooltipId !== type_idx) return;
|
|
@@ -72,7 +87,9 @@ const Box = ({
|
|
|
72
87
|
};
|
|
73
88
|
|
|
74
89
|
if (selected) {
|
|
75
|
-
|
|
90
|
+
const newSelectedList = selectedList.filter(item => item !== type_idx);
|
|
91
|
+
setSelectedList(newSelectedList);
|
|
92
|
+
updateSessionStorage(newSelectedList);
|
|
76
93
|
setActiveTooltipId(null);
|
|
77
94
|
clearTooltipTimer();
|
|
78
95
|
} else {
|
|
@@ -121,7 +138,9 @@ const Box = ({
|
|
|
121
138
|
return;
|
|
122
139
|
}
|
|
123
140
|
|
|
124
|
-
|
|
141
|
+
const newSelectedList = [...selectedList, type_idx];
|
|
142
|
+
setSelectedList(newSelectedList);
|
|
143
|
+
updateSessionStorage(newSelectedList);
|
|
125
144
|
setActiveTooltipId(null);
|
|
126
145
|
clearTooltipTimer();
|
|
127
146
|
}
|
|
@@ -497,7 +516,113 @@ const StepTwo = () => {
|
|
|
497
516
|
]
|
|
498
517
|
};
|
|
499
518
|
|
|
500
|
-
|
|
519
|
+
const doneMutation = useMutation({
|
|
520
|
+
mutationFn: async (bodyData: {
|
|
521
|
+
name: string;
|
|
522
|
+
phoneNumber: string;
|
|
523
|
+
uuid: string;
|
|
524
|
+
marketing_agree: number;
|
|
525
|
+
categoryAndField: { categories: string[]; fields: string[] };
|
|
526
|
+
}) => {
|
|
527
|
+
const marketingResponse = await fetch(`/api/lawfirm/app/user/agree`, {
|
|
528
|
+
method: 'POST',
|
|
529
|
+
headers: { 'Content-Type': 'application/json' },
|
|
530
|
+
body: JSON.stringify({ marketing_agree: bodyData.marketing_agree })
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
if (!marketingResponse.ok) {
|
|
534
|
+
throw new Error('마케팅 동의 API 호출 실패');
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const userResponse = await fetch(`/api/lawfirm/app/user`, {
|
|
538
|
+
method: 'PATCH',
|
|
539
|
+
headers: { 'Content-Type': 'application/json' },
|
|
540
|
+
body: JSON.stringify({
|
|
541
|
+
name: bodyData.name,
|
|
542
|
+
phoneNumber: bodyData.phoneNumber,
|
|
543
|
+
uuid: bodyData.uuid,
|
|
544
|
+
categoryAndField: {
|
|
545
|
+
categories: bodyData.categoryAndField.categories,
|
|
546
|
+
fields: bodyData.categoryAndField.fields
|
|
547
|
+
}
|
|
548
|
+
})
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
if (!userResponse.ok) {
|
|
552
|
+
throw new Error('사용자 정보 API 호출 실패');
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
return {
|
|
556
|
+
marketing: await marketingResponse.json(),
|
|
557
|
+
user: await userResponse.json()
|
|
558
|
+
};
|
|
559
|
+
},
|
|
560
|
+
onSuccess: () => {
|
|
561
|
+
const redirect = decodeURIComponent(getCookie('redirect')) || '/';
|
|
562
|
+
window.location.href = redirect;
|
|
563
|
+
},
|
|
564
|
+
onError: error => {
|
|
565
|
+
console.error('Skip API 호출 실패:', error);
|
|
566
|
+
// 필요시 에러 처리 로직 추가
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
const handlePrev = () => {
|
|
571
|
+
window.location.href = '/login/sign/step_one';
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
const handleDone = async () => {
|
|
575
|
+
try {
|
|
576
|
+
// session storage에서 login 정보 가져오기
|
|
577
|
+
const existingLogin = sessionStorage.getItem('login');
|
|
578
|
+
|
|
579
|
+
if (!existingLogin) {
|
|
580
|
+
console.error('로그인 정보가 없습니다.');
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
const loginData = JSON.parse(existingLogin);
|
|
585
|
+
|
|
586
|
+
// 필수 정보 확인
|
|
587
|
+
if (!loginData.name || !loginData.phoneNumber || !loginData.uuid) {
|
|
588
|
+
console.error('필수 정보가 부족합니다.');
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const categories = loginData.selectedCategories;
|
|
593
|
+
const fields = selectedList.map(String);
|
|
594
|
+
|
|
595
|
+
// API 호출
|
|
596
|
+
doneMutation.mutate({
|
|
597
|
+
name: loginData.name,
|
|
598
|
+
phoneNumber: loginData.phoneNumber,
|
|
599
|
+
uuid: loginData.uuid,
|
|
600
|
+
categoryAndField: { categories, fields },
|
|
601
|
+
marketing_agree: loginData.marketing_agree
|
|
602
|
+
});
|
|
603
|
+
} catch (error) {
|
|
604
|
+
console.error('Session storage parsing error:', error);
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
// 페이지 로드 시 세션 스토리지에서 기존 선택값 복원
|
|
609
|
+
useEffect(() => {
|
|
610
|
+
try {
|
|
611
|
+
const existingLogin = sessionStorage.getItem('login');
|
|
612
|
+
if (existingLogin) {
|
|
613
|
+
const loginData = JSON.parse(existingLogin);
|
|
614
|
+
if (loginData.selectedFields && Array.isArray(loginData.selectedFields)) {
|
|
615
|
+
// 문자열 배열을 숫자 배열로 변환
|
|
616
|
+
const restoredList = loginData.selectedFields.map((field: string) => parseInt(field, 10));
|
|
617
|
+
setSelectedList(restoredList);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
} catch (error) {
|
|
621
|
+
console.error('SessionStorage에서 선택된 필드 복원 실패:', error);
|
|
622
|
+
}
|
|
623
|
+
}, []);
|
|
624
|
+
|
|
625
|
+
console.log('selectedList:', selectedList);
|
|
501
626
|
|
|
502
627
|
return (
|
|
503
628
|
<>
|
|
@@ -583,7 +708,7 @@ const StepTwo = () => {
|
|
|
583
708
|
<div className="flex w-full flex-row items-center justify-center gap-[8px]">
|
|
584
709
|
<button
|
|
585
710
|
type={'button'}
|
|
586
|
-
onClick={
|
|
711
|
+
onClick={handlePrev}
|
|
587
712
|
className={
|
|
588
713
|
` bg-[#EDEDED] text-grayScale3` +
|
|
589
714
|
' title_small h-[72px] w-[740px] rounded-[36px] ' +
|
|
@@ -595,7 +720,7 @@ const StepTwo = () => {
|
|
|
595
720
|
</button>
|
|
596
721
|
<button
|
|
597
722
|
type={'button'}
|
|
598
|
-
onClick={
|
|
723
|
+
onClick={handleDone}
|
|
599
724
|
className={
|
|
600
725
|
` ${selectedList.length > 0 ? ' bg-[#AE0E36] text-white ' : ' bg-[#EDEDED] text-grayScale3 '} ` +
|
|
601
726
|
' title_small h-[72px] w-[740px] rounded-[36px] ' +
|
|
@@ -8,6 +8,8 @@ export { default as MyCasePage } from './MyCase/MyCasePage';
|
|
|
8
8
|
export { default as MyCaseDetailPage } from './MyCase/[id]/MyCaseDetailPage';
|
|
9
9
|
export { default as Login } from './Login/Login';
|
|
10
10
|
export { default as Sign } from './Login/Sign';
|
|
11
|
+
export { default as StepOne } from './Login/StepOne';
|
|
12
|
+
export { default as StepTwo } from './Login/StepTwo';
|
|
11
13
|
export { default as logout } from './Login/_api/logout';
|
|
12
14
|
export { default as goToAIDaeryun } from './Login/_lib/goToAIDaeryun';
|
|
13
15
|
export { default as FaqList } from './Faq/FaqList';
|
|
@@ -10,6 +10,8 @@ export { default as MyCasePage } from './MyCase/MyCasePage';
|
|
|
10
10
|
export { default as MyCaseDetailPage } from './MyCase/[id]/MyCaseDetailPage';
|
|
11
11
|
export { default as Login } from './Login/Login';
|
|
12
12
|
export { default as Sign } from './Login/Sign';
|
|
13
|
+
export { default as StepOne } from './Login/StepOne';
|
|
14
|
+
export { default as StepTwo } from './Login/StepTwo';
|
|
13
15
|
export { default as logout } from './Login/_api/logout';
|
|
14
16
|
export { default as goToAIDaeryun } from './Login/_lib/goToAIDaeryun';
|
|
15
17
|
export { default as FaqList } from './Faq/FaqList';
|
|
@@ -10,6 +10,8 @@ export { default as MyCasePage } from './MyCase/MyCasePage';
|
|
|
10
10
|
export { default as MyCaseDetailPage } from './MyCase/[id]/MyCaseDetailPage';
|
|
11
11
|
export { default as Login } from './Login/Login';
|
|
12
12
|
export { default as Sign } from './Login/Sign';
|
|
13
|
+
export { default as StepOne } from './Login/StepOne';
|
|
14
|
+
export { default as StepTwo } from './Login/StepTwo';
|
|
13
15
|
export { default as logout } from './Login/_api/logout';
|
|
14
16
|
export { default as goToAIDaeryun } from './Login/_lib/goToAIDaeryun';
|
|
15
17
|
export { default as FaqList } from './Faq/FaqList';
|