@daeryun/dr_components 0.9.21 → 0.9.23
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/page/Login/LoginComp/SignContainer.jsx +58 -63
- package/dist/components/page/Login/LoginComp/SignContainer.tsx +62 -62
- 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/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -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] ' +
|