@daeryun/dr_components 0.9.34 → 0.9.35
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/StepOne.jsx +3 -0
- package/dist/components/page/Login/StepOne.tsx +4 -0
- package/dist/components/page/Login/StepTwo.jsx +118 -33
- package/dist/components/page/Login/StepTwo.tsx +110 -15
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -210,6 +210,11 @@ const StepTwo = () => {
|
|
|
210
210
|
subTitle: ''
|
|
211
211
|
});
|
|
212
212
|
|
|
213
|
+
const [centerCodes, setCenterCodes] = useState<string[]>([]);
|
|
214
|
+
const [fieldData, setFieldData] = useState<{
|
|
215
|
+
[key: string]: { result: boolean; data: { type_idx: number; tag_title: string }[] };
|
|
216
|
+
}>({});
|
|
217
|
+
|
|
213
218
|
const center_code = 'CT0001';
|
|
214
219
|
const center_code2 = 'CT0025';
|
|
215
220
|
const categories = [
|
|
@@ -239,6 +244,26 @@ const StepTwo = () => {
|
|
|
239
244
|
{ code: 'CT0029', code_name: '디지털포렌식' },
|
|
240
245
|
{ code: 'CT0030', code_name: '경호' }
|
|
241
246
|
];
|
|
247
|
+
|
|
248
|
+
// API 호출 함수
|
|
249
|
+
const fetchFieldData = async (centerCode: string) => {
|
|
250
|
+
try {
|
|
251
|
+
const response = await fetch(
|
|
252
|
+
`https://mng.daeryunlaw.com/api/app/seo-template/field/list-by-center?center_code=${centerCode}`
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
if (!response.ok) {
|
|
256
|
+
throw new Error(`API 호출 실패: ${response.status}`);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const data = await response.json();
|
|
260
|
+
return data;
|
|
261
|
+
} catch (error) {
|
|
262
|
+
console.error(`Center code ${centerCode} API 호출 실패:`, error);
|
|
263
|
+
return { result: false, data: [] };
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
242
267
|
const data1 = {
|
|
243
268
|
result: true,
|
|
244
269
|
data: [
|
|
@@ -588,6 +613,10 @@ const StepTwo = () => {
|
|
|
588
613
|
};
|
|
589
614
|
|
|
590
615
|
const handleDone = async () => {
|
|
616
|
+
if (selectedList.length === 0) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
|
|
591
620
|
try {
|
|
592
621
|
// session storage에서 login 정보 가져오기
|
|
593
622
|
const existingLogin = sessionStorage.getItem('login');
|
|
@@ -621,21 +650,49 @@ const StepTwo = () => {
|
|
|
621
650
|
}
|
|
622
651
|
};
|
|
623
652
|
|
|
624
|
-
// 페이지 로드 시
|
|
653
|
+
// 페이지 로드 시 sessionStorage에서 선택된 카테고리를 읽어서 API 호출
|
|
625
654
|
useEffect(() => {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
if (
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
655
|
+
const initializeData = async () => {
|
|
656
|
+
try {
|
|
657
|
+
const existingLogin = sessionStorage.getItem('login');
|
|
658
|
+
|
|
659
|
+
if (existingLogin) {
|
|
660
|
+
const loginData = JSON.parse(existingLogin);
|
|
661
|
+
|
|
662
|
+
// 선택된 필드 복원
|
|
663
|
+
if (loginData.selectedFields && Array.isArray(loginData.selectedFields)) {
|
|
664
|
+
const restoredList = loginData.selectedFields.map((field: string) => parseInt(field, 10));
|
|
665
|
+
setSelectedList(restoredList);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// 선택된 카테고리에서 center_code 가져오기
|
|
669
|
+
if (loginData.selectedCategories && Array.isArray(loginData.selectedCategories)) {
|
|
670
|
+
const codes = loginData.selectedCategories;
|
|
671
|
+
setCenterCodes(codes);
|
|
672
|
+
|
|
673
|
+
// 각 center_code별로 API 호출
|
|
674
|
+
const fieldDataPromises = codes.map(async (centerCode: string) => {
|
|
675
|
+
const data = await fetchFieldData(centerCode);
|
|
676
|
+
return { centerCode, data };
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
const results = await Promise.all(fieldDataPromises);
|
|
680
|
+
|
|
681
|
+
// 결과를 fieldData state에 저장
|
|
682
|
+
const newFieldData: { [key: string]: any } = {};
|
|
683
|
+
results.forEach(({ centerCode, data }) => {
|
|
684
|
+
newFieldData[centerCode] = data;
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
setFieldData(newFieldData);
|
|
688
|
+
}
|
|
634
689
|
}
|
|
690
|
+
} catch (error) {
|
|
691
|
+
console.error('데이터 초기화 실패:', error);
|
|
635
692
|
}
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
initializeData();
|
|
639
696
|
}, []);
|
|
640
697
|
|
|
641
698
|
return (
|
|
@@ -669,7 +726,7 @@ const StepTwo = () => {
|
|
|
669
726
|
</div>
|
|
670
727
|
|
|
671
728
|
<div className="mt-[28px] flex flex-col gap-[40px] sm:mt-[61px] lg:mt-[66px] ">
|
|
672
|
-
{data1?.data?.length > 0 && (
|
|
729
|
+
{/* {data1?.data?.length > 0 && (
|
|
673
730
|
<div className="sm:flex sm:flex-row sm:rounded-[16px] sm:border sm:border-solid sm:border-grayScale5 sm:p-[40px] lg:rounded-[20px]">
|
|
674
731
|
<p className="body_large1_mo sm:body_large1_tb lg:body_large1 sm:w-[150px] sm:sm:flex-shrink-0">
|
|
675
732
|
{categories.find(item => item.code === center_code)?.code_name}
|
|
@@ -716,7 +773,45 @@ const StepTwo = () => {
|
|
|
716
773
|
))}
|
|
717
774
|
</div>
|
|
718
775
|
</div>
|
|
719
|
-
)}
|
|
776
|
+
)} */}
|
|
777
|
+
{centerCodes.map((centerCode, index) => {
|
|
778
|
+
const currentFieldData = fieldData[centerCode];
|
|
779
|
+
const categoryName = categories.find(item => item.code === centerCode)?.code_name;
|
|
780
|
+
|
|
781
|
+
if (!currentFieldData?.data?.length) {
|
|
782
|
+
return null;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
return (
|
|
786
|
+
<div
|
|
787
|
+
key={centerCode}
|
|
788
|
+
className="sm:flex sm:flex-row sm:rounded-[16px] sm:border sm:border-solid sm:border-grayScale5 sm:p-[40px] lg:rounded-[20px]"
|
|
789
|
+
>
|
|
790
|
+
<p className="body_large1_mo sm:body_large1_tb lg:body_large1 sm:w-[150px] sm:flex-shrink-0">
|
|
791
|
+
{categoryName}
|
|
792
|
+
</p>
|
|
793
|
+
<div className="my-[12px] w-full bg-grayScale5 max-sm:h-[1px] sm:mx-[44px] sm:my-0 sm:h-auto sm:w-[1px] sm:flex-shrink-0 lg:gap-[80px]" />
|
|
794
|
+
|
|
795
|
+
<div
|
|
796
|
+
className={`flex flex-row flex-wrap gap-x-[8px] gap-y-[12px] sm:gap-[20px] lg:gap-x-[24px] ${index === 1 ? 'lg:gap-y-[32px]' : 'lg:gap-y-[24px]'}`}
|
|
797
|
+
>
|
|
798
|
+
{currentFieldData.data.map(item => (
|
|
799
|
+
<Box
|
|
800
|
+
key={item.type_idx}
|
|
801
|
+
type_idx={item.type_idx}
|
|
802
|
+
tag_title={item.tag_title}
|
|
803
|
+
selected={selectedList.includes(item.type_idx)}
|
|
804
|
+
selectedList={selectedList}
|
|
805
|
+
setSelectedList={setSelectedList}
|
|
806
|
+
activeTooltipId={activeTooltipId}
|
|
807
|
+
setActiveTooltipId={setActiveTooltipId}
|
|
808
|
+
tooltipTimeoutRef={tooltipTimeoutRef}
|
|
809
|
+
/>
|
|
810
|
+
))}
|
|
811
|
+
</div>
|
|
812
|
+
</div>
|
|
813
|
+
);
|
|
814
|
+
})}
|
|
720
815
|
</div>
|
|
721
816
|
<div className="mb-[56px] mt-[40px] flex flex-col items-center justify-center sm:mt-[60px] lg:mt-[79px]">
|
|
722
817
|
<div className="flex w-full flex-row items-center justify-center gap-[8px]">
|
|
@@ -737,7 +832,7 @@ const StepTwo = () => {
|
|
|
737
832
|
onClick={handleDone}
|
|
738
833
|
className={
|
|
739
834
|
` ${selectedList.length > 0 ? ' bg-[#AE0E36] text-white ' : ' bg-[#EDEDED] text-grayScale3 '} ` +
|
|
740
|
-
' title_small h-[72px] w-[740px]
|
|
835
|
+
' title_small h-[72px] w-[740px] rounded-[36px] ' +
|
|
741
836
|
' max-lg:body_medium2 max-lg:h-[60px] max-lg:w-[620px] ' +
|
|
742
837
|
' max-sm:body_large2_mo max-sm:h-[48px] max-sm:w-full '
|
|
743
838
|
}
|