@daeryun/dr_components 1.3.47 → 1.3.48

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.
@@ -18,8 +18,8 @@ const FieldNew = ({ data, tel }) => {
18
18
  const { template, contentsList, h2List, lawyerData, fieldData, successData, groupTopTenLawyerList, referenceLinkList, newsLinkList, shortsLinkList, youtubeLinkList, initialData, faqElementMaxCountInContents } = data;
19
19
  const { width } = useBrowser(true);
20
20
  const [relatedCaseLawyerList, setRelatedCaseLawyerList] = useState(lawyerData);
21
- const [isFaqActive, setIsFaqActive] = useState(false);
22
21
  const printRef = useRef(null);
22
+ const faqPageCountInContents = faqElementMaxCountInContents !== null && faqElementMaxCountInContents !== void 0 ? faqElementMaxCountInContents : 0;
23
23
  const idxNum = template && template[0].type_idx;
24
24
  const filteredFieldDataList = fieldData.filter(data => data.idx !== idxNum);
25
25
  const h1Title = template
@@ -42,31 +42,29 @@ const FieldNew = ({ data, tel }) => {
42
42
  }
43
43
  }
44
44
  };
45
- const handleFaqItemType = (isFaqActive, faqElementMaxCountInContents) => {
46
- if (isFaqActive && faqElementMaxCountInContents === 0) {
47
- return 'https://schema.org/FAQPage';
48
- }
49
- if (isFaqActive && faqElementMaxCountInContents >= 2) {
45
+ const handleFaqItemType = () => {
46
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
47
+ if (faqPageCountInContents === 1) {
50
48
  return undefined;
51
49
  }
52
50
  return 'https://schema.org/FAQPage';
53
51
  };
54
- const handleFaqItemScope = (isFaqActive, faqElementMaxCountInContents) => {
55
- if (isFaqActive && faqElementMaxCountInContents === 0) {
56
- return true;
57
- }
58
- if (isFaqActive && faqElementMaxCountInContents >= 2) {
52
+ const handleFaqItemScope = () => {
53
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
54
+ if (faqPageCountInContents === 1) {
59
55
  return undefined;
60
56
  }
61
57
  return true;
62
58
  };
63
59
  const convertFaqItemType = (template) => {
64
- if (faqElementMaxCountInContents >= 2) {
65
- // faqElementMaxCountInContents가 두 개 이상일 경우, template 내부에 FAQPage itemtype을 지운다. FAQPage 중복 이슈로 인한 코드임
66
- template.description = template.description.replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>');
67
- return template;
60
+ // 작성자 FAQPage가 2개 이상이면 내부 FAQPage를 지우고 루트 FAQPage 1개만 유지한다.
61
+ if (faqPageCountInContents >= 2) {
62
+ const convertedDescription = template.description
63
+ .replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>')
64
+ .replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>');
65
+ return Object.assign(Object.assign({}, template), { description: convertedDescription });
68
66
  }
69
- return template;
67
+ return Object.assign({}, template);
70
68
  };
71
69
  // 변호사 6명 맞추기
72
70
  useEffect(() => {
@@ -86,20 +84,8 @@ const FieldNew = ({ data, tel }) => {
86
84
  setRelatedCaseLawyerList(lawyerData.slice(0, maxCount));
87
85
  }
88
86
  }, [lawyerData, groupTopTenLawyerList]);
89
- useEffect(() => {
90
- if (template) {
91
- // 초기화
92
- setIsFaqActive(false);
93
- for (const data of template) {
94
- // console.log("faq 활성화: ", data['active_faq']);
95
- if (data['active_faq']) {
96
- setIsFaqActive(true);
97
- }
98
- }
99
- }
100
- }, [template]);
101
87
  return (<>
102
- <div itemScope={handleFaqItemScope(isFaqActive, faqElementMaxCountInContents)} itemType={handleFaqItemType(isFaqActive, faqElementMaxCountInContents)} ref={printRef}>
88
+ <div itemScope={handleFaqItemScope()} itemType={handleFaqItemType()} ref={printRef}>
103
89
  <div id={'sub_contents'} ref={printRef}>
104
90
  <div className="relative m-auto mb-[100px] w-[90%] max-w-screen-2xl max-md2:mb-[40px] max-xs:mb-[30px] ">
105
91
  <div className={'m-auto mt-[100px] flex gap-[120px] ' +
@@ -34,8 +34,8 @@ const FieldNew = ({ data, tel }: IFieldNewPageTypes) => {
34
34
  } = data;
35
35
  const { width } = useBrowser(true);
36
36
  const [relatedCaseLawyerList, setRelatedCaseLawyerList] = useState<ILawyerTypes[]>(lawyerData);
37
- const [isFaqActive, setIsFaqActive] = useState<boolean>(false);
38
37
  const printRef = useRef<HTMLDivElement>(null);
38
+ const faqPageCountInContents = faqElementMaxCountInContents ?? 0;
39
39
  const idxNum: number | null = template && (template[0].type_idx as number);
40
40
  const filteredFieldDataList: IFieldTypes[] = fieldData.filter(data => data.idx !== idxNum);
41
41
  const h1Title: string = template
@@ -60,24 +60,18 @@ const FieldNew = ({ data, tel }: IFieldNewPageTypes) => {
60
60
  }
61
61
  };
62
62
 
63
- const handleFaqItemType = (isFaqActive: boolean, faqElementMaxCountInContents?: number): string | undefined => {
64
- if (isFaqActive && faqElementMaxCountInContents === 0) {
65
- return 'https://schema.org/FAQPage';
66
- }
67
-
68
- if (isFaqActive && (faqElementMaxCountInContents as number) >= 2) {
63
+ const handleFaqItemType = (): string | undefined => {
64
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
65
+ if (faqPageCountInContents === 1) {
69
66
  return undefined;
70
67
  }
71
68
 
72
69
  return 'https://schema.org/FAQPage';
73
70
  };
74
71
 
75
- const handleFaqItemScope = (isFaqActive: boolean, faqElementMaxCountInContents?: number): true | undefined => {
76
- if (isFaqActive && faqElementMaxCountInContents === 0) {
77
- return true;
78
- }
79
-
80
- if (isFaqActive && (faqElementMaxCountInContents as number) >= 2) {
72
+ const handleFaqItemScope = (): true | undefined => {
73
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
74
+ if (faqPageCountInContents === 1) {
81
75
  return undefined;
82
76
  }
83
77
 
@@ -85,17 +79,22 @@ const FieldNew = ({ data, tel }: IFieldNewPageTypes) => {
85
79
  };
86
80
 
87
81
  const convertFaqItemType = (template: ISeoTemplateTypes): ISeoTemplateTypes => {
88
- if ((faqElementMaxCountInContents as number) >= 2) {
89
- // faqElementMaxCountInContents가 두 개 이상일 경우, template 내부에 FAQPage itemtype을 지운다. FAQPage 중복 이슈로 인한 코드임
90
- template.description = template.description.replaceAll(
91
- '&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;',
92
- '&lt;div&gt;'
93
- );
82
+ // 작성자 FAQPage가 2개 이상이면 내부 FAQPage를 지우고 루트 FAQPage 1개만 유지한다.
83
+ if (faqPageCountInContents >= 2) {
84
+ const convertedDescription = template.description
85
+ .replaceAll(
86
+ '&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;',
87
+ '&lt;div&gt;'
88
+ )
89
+ .replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>');
94
90
 
95
- return template;
91
+ return {
92
+ ...template,
93
+ description: convertedDescription
94
+ };
96
95
  }
97
96
 
98
- return template;
97
+ return { ...template };
99
98
  };
100
99
 
101
100
  // 변호사 6명 맞추기
@@ -118,25 +117,11 @@ const FieldNew = ({ data, tel }: IFieldNewPageTypes) => {
118
117
  }
119
118
  }, [lawyerData, groupTopTenLawyerList]);
120
119
 
121
- useEffect(() => {
122
- if (template) {
123
- // 초기화
124
- setIsFaqActive(false);
125
-
126
- for (const data of template) {
127
- // console.log("faq 활성화: ", data['active_faq']);
128
- if (data['active_faq']) {
129
- setIsFaqActive(true);
130
- }
131
- }
132
- }
133
- }, [template]);
134
-
135
120
  return (
136
121
  <>
137
122
  <div
138
- itemScope={handleFaqItemScope(isFaqActive, faqElementMaxCountInContents as number)}
139
- itemType={handleFaqItemType(isFaqActive, faqElementMaxCountInContents as number)}
123
+ itemScope={handleFaqItemScope()}
124
+ itemType={handleFaqItemType()}
140
125
  ref={printRef}
141
126
  >
142
127
  <div id={'sub_contents'} ref={printRef}>
@@ -23,8 +23,8 @@ const SuccessNew = ({ data, tel }) => {
23
23
  const { template, contentsList, h2List, imgData, lawyerData, fieldData, successData, groupTopTenLawyerList, referenceLinkList, newsLinkList, shortsLinkList, youtubeLinkList, pn, initialData, faqElementMaxCountInContents } = data;
24
24
  const { width } = useBrowser(true);
25
25
  const [relatedCaseLawyerList, setRelatedCaseLawyerList] = useState(lawyerData);
26
- const [isFaqActive, setIsFaqActive] = useState(false);
27
26
  const printRef = useRef(null);
27
+ const faqPageCountInContents = faqElementMaxCountInContents !== null && faqElementMaxCountInContents !== void 0 ? faqElementMaxCountInContents : 0;
28
28
  const typeIdxNum = template && template[0].type_idx;
29
29
  const successDataFiltered = successData.filter(data => Number(data.type_idx) !== typeIdxNum);
30
30
  const legalDocumentImageObject = imgData && imgData.length > 0 ? imgData[0] : null;
@@ -55,31 +55,29 @@ const SuccessNew = ({ data, tel }) => {
55
55
  const imgLocation = (_b = (_a = document.getElementById('img_wrap')) === null || _a === void 0 ? void 0 : _a.offsetTop) !== null && _b !== void 0 ? _b : 0;
56
56
  window.scrollTo({ top: imgLocation + (width > 680 ? 300 : 200), behavior: 'smooth' });
57
57
  };
58
- const handleFaqItemType = (isFaqActive, faqElementMaxCountInContents) => {
59
- if (isFaqActive && faqElementMaxCountInContents === 0) {
60
- return 'https://schema.org/FAQPage';
61
- }
62
- if (isFaqActive && faqElementMaxCountInContents >= 2) {
58
+ const handleFaqItemType = () => {
59
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
60
+ if (faqPageCountInContents === 1) {
63
61
  return undefined;
64
62
  }
65
63
  return 'https://schema.org/FAQPage';
66
64
  };
67
- const handleFaqItemScope = (isFaqActive, faqElementMaxCountInContents) => {
68
- if (isFaqActive && faqElementMaxCountInContents === 0) {
69
- return true;
70
- }
71
- if (isFaqActive && faqElementMaxCountInContents >= 2) {
65
+ const handleFaqItemScope = () => {
66
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
67
+ if (faqPageCountInContents === 1) {
72
68
  return undefined;
73
69
  }
74
70
  return true;
75
71
  };
76
72
  const convertFaqItemType = (template) => {
77
- if (faqElementMaxCountInContents >= 2) {
78
- // faqElementMaxCountInContents가 두 개 이상일 경우, template 내부에 FAQPage itemtype을 지운다. FAQPage 중복 이슈로 인한 코드임
79
- template.description = template.description.replaceAll('&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;', '&lt;div&gt;');
80
- return template;
73
+ // 작성자 FAQPage가 2개 이상이면 내부 FAQPage를 지우고 루트 FAQPage 1개만 유지한다.
74
+ if (faqPageCountInContents >= 2) {
75
+ const convertedDescription = template.description
76
+ .replaceAll('&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;', '&lt;div&gt;')
77
+ .replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>');
78
+ return Object.assign(Object.assign({}, template), { description: convertedDescription });
81
79
  }
82
- return template;
80
+ return Object.assign({}, template);
83
81
  };
84
82
  // 변호사 6명 맞추기
85
83
  useEffect(() => {
@@ -99,19 +97,7 @@ const SuccessNew = ({ data, tel }) => {
99
97
  setRelatedCaseLawyerList(lawyerData.slice(0, maxCount));
100
98
  }
101
99
  }, [lawyerData, groupTopTenLawyerList]);
102
- useEffect(() => {
103
- if (template) {
104
- // 초기화
105
- setIsFaqActive(false);
106
- for (const data of template) {
107
- // console.log("faq 활성화: ", data['active_faq']);
108
- if (data['active_faq']) {
109
- setIsFaqActive(true);
110
- }
111
- }
112
- }
113
- }, [template]);
114
- return (<div itemScope={handleFaqItemScope(isFaqActive, faqElementMaxCountInContents)} itemType={handleFaqItemType(isFaqActive, faqElementMaxCountInContents)} ref={printRef}>
100
+ return (<div itemScope={handleFaqItemScope()} itemType={handleFaqItemType()} ref={printRef}>
115
101
  <div className="relative m-auto mb-[100px] w-[90%] max-w-screen-2xl max-md2:mb-[40px] max-xs:mb-[30px]">
116
102
  <div className={'m-auto mt-[100px] flex gap-[120px] ' +
117
103
  //1700px
@@ -46,8 +46,8 @@ const SuccessNew = ({ data, tel }: ISuccessNewPageTypes) => {
46
46
  } = data;
47
47
  const { width } = useBrowser(true);
48
48
  const [relatedCaseLawyerList, setRelatedCaseLawyerList] = useState<ILawyerTypes[]>(lawyerData);
49
- const [isFaqActive, setIsFaqActive] = useState<boolean>(false);
50
49
  const printRef = useRef<HTMLDivElement>(null);
50
+ const faqPageCountInContents = faqElementMaxCountInContents ?? 0;
51
51
  const typeIdxNum: number | null = template && (template[0].type_idx as number);
52
52
  const successDataFiltered: ISuccessTypes[] = successData.filter(data => Number(data.type_idx) !== typeIdxNum);
53
53
 
@@ -85,24 +85,18 @@ const SuccessNew = ({ data, tel }: ISuccessNewPageTypes) => {
85
85
  window.scrollTo({ top: imgLocation + (width > 680 ? 300 : 200), behavior: 'smooth' });
86
86
  };
87
87
 
88
- const handleFaqItemType = (isFaqActive: boolean, faqElementMaxCountInContents?: number): string | undefined => {
89
- if (isFaqActive && faqElementMaxCountInContents === 0) {
90
- return 'https://schema.org/FAQPage';
91
- }
92
-
93
- if (isFaqActive && (faqElementMaxCountInContents as number) >= 2) {
88
+ const handleFaqItemType = (): string | undefined => {
89
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
90
+ if (faqPageCountInContents === 1) {
94
91
  return undefined;
95
92
  }
96
93
 
97
94
  return 'https://schema.org/FAQPage';
98
95
  };
99
96
 
100
- const handleFaqItemScope = (isFaqActive: boolean, faqElementMaxCountInContents?: number): true | undefined => {
101
- if (isFaqActive && faqElementMaxCountInContents === 0) {
102
- return true;
103
- }
104
-
105
- if (isFaqActive && (faqElementMaxCountInContents as number) >= 2) {
97
+ const handleFaqItemScope = (): true | undefined => {
98
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
99
+ if (faqPageCountInContents === 1) {
106
100
  return undefined;
107
101
  }
108
102
 
@@ -110,17 +104,22 @@ const SuccessNew = ({ data, tel }: ISuccessNewPageTypes) => {
110
104
  };
111
105
 
112
106
  const convertFaqItemType = (template: ISeoTemplateTypes): ISeoTemplateTypes => {
113
- if ((faqElementMaxCountInContents as number) >= 2) {
114
- // faqElementMaxCountInContents가 두 개 이상일 경우, template 내부에 FAQPage itemtype을 지운다. FAQPage 중복 이슈로 인한 코드임
115
- template.description = template.description.replaceAll(
116
- '&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;',
117
- '&lt;div&gt;'
118
- );
119
-
120
- return template;
107
+ // 작성자 FAQPage가 2개 이상이면 내부 FAQPage를 지우고 루트 FAQPage 1개만 유지한다.
108
+ if (faqPageCountInContents >= 2) {
109
+ const convertedDescription = template.description
110
+ .replaceAll(
111
+ '&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;',
112
+ '&lt;div&gt;'
113
+ )
114
+ .replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>');
115
+
116
+ return {
117
+ ...template,
118
+ description: convertedDescription
119
+ };
121
120
  }
122
121
 
123
- return template;
122
+ return { ...template };
124
123
  };
125
124
 
126
125
  // 변호사 6명 맞추기
@@ -143,24 +142,10 @@ const SuccessNew = ({ data, tel }: ISuccessNewPageTypes) => {
143
142
  }
144
143
  }, [lawyerData, groupTopTenLawyerList]);
145
144
 
146
- useEffect(() => {
147
- if (template) {
148
- // 초기화
149
- setIsFaqActive(false);
150
-
151
- for (const data of template) {
152
- // console.log("faq 활성화: ", data['active_faq']);
153
- if (data['active_faq']) {
154
- setIsFaqActive(true);
155
- }
156
- }
157
- }
158
- }, [template]);
159
-
160
145
  return (
161
146
  <div
162
- itemScope={handleFaqItemScope(isFaqActive, faqElementMaxCountInContents as number)}
163
- itemType={handleFaqItemType(isFaqActive, faqElementMaxCountInContents as number)}
147
+ itemScope={handleFaqItemScope()}
148
+ itemType={handleFaqItemType()}
164
149
  ref={printRef}
165
150
  >
166
151
  <div className="relative m-auto mb-[100px] w-[90%] max-w-screen-2xl max-md2:mb-[40px] max-xs:mb-[30px]">