@daeryun/dr_components 0.1.17 → 0.1.19

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.
@@ -2,74 +2,58 @@ import Image from 'next/image';
2
2
  import React, { useEffect, useRef, useState } from 'react';
3
3
  import * as gtag from '../../lib/gtag';
4
4
  import Link from 'next/link';
5
- import { insert } from '../../lib';
5
+ import { getDomainHandler, insert } from '../../lib';
6
6
  import { savePowerLinkConversion } from '../../lib';
7
- import { paramFetch } from '../../lib';
8
- import { useQuery } from 'react-query';
9
- import TopBtn from './TopBtn';
10
7
  import Wrapper from '../Layout/Wrapper';
8
+ import TopBtn from './TopBtn';
9
+ import { useRouter } from 'next/router';
10
+ import { IGroupsData, INewFooterTypes } from './IFooterTypes';
11
+ import sns01 from '/public/images/footer/sns_01.webp';
12
+ import sns02 from '/public/images/footer/sns_02.webp';
13
+ import sns03 from '/public/images/footer/sns_03.webp';
14
+ import sns04 from '/public/images/footer/sns_04.webp';
15
+ import sns05 from '/public/images/footer/sns_05.webp';
11
16
 
12
- import ArrowIcon from '../../asset/images/footer/icon_arrow_gray.webp';
13
- import SNS1 from '../../asset/images/footer/sns_01.webp';
14
- import SNS2 from '../../asset/images/footer/sns_02.webp';
15
- import SNS3 from '../../asset/images/footer/sns_03.webp';
16
- import SNS4 from '../../asset/images/footer/sns_04.webp';
17
- import SNS5 from '../../asset/images/footer/sns_05.webp';
18
-
19
- interface IFooterTypes {
20
- tel: string;
21
- logoUrl: string;
22
- aceCountLink?: string;
17
+ interface GroupsProps {
18
+ list: IGroupsData[];
23
19
  }
24
20
 
25
- // tel: string -> 전화번호
26
- // logoUrl:string -> 로고 url
27
- // aceCountLink?: string -> 에이스 카운터 전환태그 주소, 안 넣을 경우 메인으로
28
- const Footer = (props: IFooterTypes) => {
21
+ const NewFooter = ({ groupsData, tel, logo, aceUrl }: INewFooterTypes) => {
22
+ const router = useRouter();
29
23
  const mobile = require('is-mobile');
30
24
  const snsClass =
31
25
  'w-[44px] h-auto mr-[5px] max-md:w-[40px] max-md:m-0 max-xs:w-[45px] max-xs:mr-[17px] max-2xs:w-[40px] max-3xs:w-[35px]';
26
+ const [isGroups, setIsGroups] = useState<GroupsProps[]>([]);
32
27
 
33
28
  const [isMobile, setIsMobile] = useState<boolean>(false);
34
- const [centerLink, setCenterLink] = useState<
35
- { code: string; codename: string; parent_code: string; etc: string; etc2: string }[]
36
- >([]);
37
29
  const [isOpen, setIsOpen] = useState(false);
38
30
  const wrapperRef = useRef(null);
39
31
 
40
- useQuery(
41
- 'centerList',
42
- () => {
43
- paramFetch(
44
- 'https://mng.daeryunlaw.com/api/center/list',
45
- { type: 'footer' },
46
- (obj: any) => {
47
- const data = obj.list
48
- .filter((i: any) => i.code != 'CT0020')
49
- .map((l: any) => {
50
- return {
51
- codename: l.code_name.replace('전문', '') + '그룹',
52
- code:
53
- l.code === 'CT0000'
54
- ? 'https://www.daeryunlaw.com/'
55
- : l.parent_code === 'center'
56
- ? `https://www.daeryunlaw-${l.code_desc}.com`
57
- : l.etc2,
58
- code_num: l.code,
59
- etc: l.etc,
60
- code_name2: l.code_name2,
61
- parent_code: l.parent_code,
62
- etc2: l.etc2
63
- };
64
- });
32
+ const routeLocation: boolean = router.asPath === '/';
65
33
 
66
- setCenterLink(data);
67
- },
68
- 'GET'
69
- );
70
- },
71
- { refetchOnWindowFocus: false, refetchInterval: undefined }
72
- );
34
+ const fetchData = async () => {
35
+ try {
36
+ const req = await fetch('/api/center/list');
37
+ return await req.json();
38
+ } catch (error) {
39
+ console.error(`fetch groupsData error : ${error} `);
40
+ }
41
+ };
42
+
43
+ useEffect(() => {
44
+ const fetchGroupsData = async () => {
45
+ if (router.asPath !== '/') {
46
+ try {
47
+ const data: GroupsProps[] = await fetchData();
48
+ setIsGroups(data); // data를 setIsGroups로 설정
49
+ } catch (error) {
50
+ console.error(`fetch groupsData useEffect error: ${error}`);
51
+ }
52
+ }
53
+ };
54
+
55
+ fetchGroupsData();
56
+ }, [router.asPath]);
73
57
 
74
58
  const onClickTel = () => {
75
59
  insert('call', isMobile);
@@ -115,7 +99,7 @@ const Footer = (props: IFooterTypes) => {
115
99
  const ace_pcTelClick = () => {
116
100
  try {
117
101
  // @ts-ignore
118
- _PL(props.aceCountLink ? props.aceCountLink : 'www.daeryunlaw.com/tel');
102
+ _PL(aceUrl ? aceUrl : 'www.daeryunlaw.com/tel');
119
103
  } catch (e) {}
120
104
  };
121
105
 
@@ -140,19 +124,19 @@ const Footer = (props: IFooterTypes) => {
140
124
  return (
141
125
  <footer
142
126
  className={
143
- 'relative flex h-[550px] w-full items-center justify-center border-t border-solid border-[#A8A8A8] bg-white font-[SUIT] text-[18px] ' +
127
+ 'relative mb-[30px] flex h-[550px] w-full items-center justify-center border-t border-solid border-[#A8A8A8] bg-white font-[SUIT] text-[18px] ' +
144
128
  'max-xs:h-[800px] ' +
145
129
  'max-lg:mb-[70px] ' +
146
130
  'max-2xs:h-[730px]'
147
131
  }
148
132
  >
149
133
  {/*top button*/}
150
- {/*<Wrapper className={'!absolute top-0'}>*/}
151
- {/* <div className={'relative z-20'}>*/}
152
- {/* <TopBtn className={'absolute right-0 top-[-50%] translate-y-[-50%]'} />*/}
153
- {/* </div>*/}
154
- {/*</Wrapper>*/}
155
- <Wrapper>
134
+ <Wrapper id={'footer'} className={'!absolute top-0'}>
135
+ <div className={'relative z-20'}>
136
+ <TopBtn className={'absolute right-0 top-[-50%] translate-y-[-50%]'} />
137
+ </div>
138
+ </Wrapper>
139
+ <Wrapper id={'footer'}>
156
140
  <div className={'w-full'}>
157
141
  <div
158
142
  className={
@@ -162,7 +146,7 @@ const Footer = (props: IFooterTypes) => {
162
146
  >
163
147
  <Link href={'/'}>
164
148
  <Image
165
- src={props.logoUrl}
149
+ src={logo}
166
150
  alt="대륜 로고"
167
151
  width={216}
168
152
  height={33}
@@ -204,62 +188,116 @@ const Footer = (props: IFooterTypes) => {
204
188
  법무법인 대륜 그룹 바로가기
205
189
  </button>
206
190
 
207
- {isOpen && (
208
- <ul
209
- className="absolute right-0 mt-2 h-[340px] w-full origin-top-right overflow-y-auto rounded-md bg-white pt-3 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none"
210
- role="listbox"
211
- aria-orientation="vertical"
212
- aria-labelledby="listbox-label"
213
- aria-expanded="true"
214
- aria-hidden="false"
215
- >
216
- {centerLink.map(
217
- (item: any, index: number) =>
218
- item.parent_code === 'center' && (
219
- <li
220
- key={index}
221
- value={item.code}
222
- className="cursor-pointer px-5 py-[5px] text-[17px] font-[500]"
223
- >
224
- <Link
225
- href={item.code}
226
- key={index}
227
- target="_blank"
228
- title={'새창열기'}
229
- onClick={() => {
230
- setIsOpen(!isOpen);
231
- }}
232
- >
233
- {item.code_num === 'CT0000'
234
- ? '법무법인 대륜 변호사 대표사이트'
235
- : item.codename}
236
- </Link>
237
- {centerLink.map((items, index2) => {
238
- return (
239
- items.parent_code === 'in_center' &&
240
- item.code_num === items.etc && (
241
- <Link
242
- href={items.code}
243
- key={index2}
244
- target="_blank"
245
- title={'새창열기'}
246
- >
247
- <p>
248
- &nbsp;&nbsp;{' '}
249
- {items.codename.replace('그룹', '센터')}
250
- </p>
251
- </Link>
252
- )
253
- );
254
- })}
255
- </li>
256
- )
257
- )}
258
- </ul>
259
- )}
191
+ <ul
192
+ className={`absolute right-0 mt-2 h-[340px] w-full origin-top-right overflow-y-auto rounded-md bg-white pt-3 shadow-lg ring-1 ring-black ring-opacity-5 transition-all duration-150 focus:outline-none ${
193
+ isOpen ? 'visible opacity-100' : 'invisible opacity-0'
194
+ }`}
195
+ style={{
196
+ zIndex: isOpen ? 50 : -9999,
197
+ pointerEvents: isOpen ? 'auto' : 'none'
198
+ }}
199
+ role="listbox"
200
+ aria-orientation="vertical"
201
+ aria-labelledby="listbox-label"
202
+ aria-expanded="true"
203
+ aria-hidden="false"
204
+ >
205
+ {routeLocation
206
+ ? groupsData?.map((item: any, index: number) => (
207
+ // 메인페이지로 접근했을 때, 서버사이드에서 가져온 데이터로 색인
208
+ <>
209
+ <li
210
+ key={index}
211
+ value={item.code_name}
212
+ className="cursor-pointer px-5 py-[5px] text-[17px] font-[500] duration-150 hover:bg-gray-100"
213
+ >
214
+ <Link
215
+ href={getDomainHandler(item.code, item.code_desc)}
216
+ key={index}
217
+ target="_blank"
218
+ title={item.code_name}
219
+ onClick={() => {
220
+ setIsOpen(!isOpen);
221
+ }}
222
+ >
223
+ {item.code === 'CT0000'
224
+ ? item.code_name
225
+ : `${item.code_name} 그룹`}
226
+ </Link>
227
+ </li>
228
+ {item.children.length > 0 &&
229
+ item.children.map((childGroup: any) => (
230
+ <li
231
+ key={childGroup.code}
232
+ value={childGroup.code_name}
233
+ className="cursor-pointer px-9 py-[5px] text-[15px] font-[500] duration-150 hover:bg-gray-100"
234
+ >
235
+ <Link
236
+ href={childGroup.etc2}
237
+ key={index}
238
+ target="_blank"
239
+ title={childGroup.codename}
240
+ onClick={() => {
241
+ setIsOpen(!isOpen);
242
+ }}
243
+ >
244
+ {childGroup.code_name} 센터
245
+ </Link>
246
+ </li>
247
+ ))}
248
+ </>
249
+ ))
250
+ : (isGroups as unknown as { list: any[] }).list?.map(
251
+ (item: any, index: number) => (
252
+ // 메인페이지가 아닌 경로로 유입되었을 때, api 호출하여 받은 데이터. 색인 x
253
+ <>
254
+ <li
255
+ key={index}
256
+ value={item.code_name}
257
+ className="cursor-pointer px-5 py-[5px] text-[17px] font-[500] duration-150 hover:bg-gray-100"
258
+ >
259
+ <Link
260
+ href={getDomainHandler(item.code, item.code_desc)}
261
+ key={index}
262
+ target="_blank"
263
+ title={item.code_name}
264
+ onClick={() => {
265
+ setIsOpen(!isOpen);
266
+ }}
267
+ >
268
+ {item.code === 'CT0000'
269
+ ? item.code_name
270
+ : `${item.code_name} 그룹`}
271
+ </Link>
272
+ </li>
273
+ {item.children.length > 0 &&
274
+ item.children.map((childGroup: any) => (
275
+ <li
276
+ key={childGroup.code}
277
+ value={childGroup.code_name}
278
+ className="cursor-pointer px-9 py-[5px] text-[15px] font-[500] duration-150 hover:bg-gray-100"
279
+ >
280
+ <Link
281
+ href={childGroup.etc2}
282
+ key={index}
283
+ target="_blank"
284
+ title={childGroup.codename}
285
+ onClick={() => {
286
+ setIsOpen(!isOpen);
287
+ }}
288
+ >
289
+ {childGroup.code_name} 센터
290
+ </Link>
291
+ </li>
292
+ ))}
293
+ </>
294
+ )
295
+ )}
296
+ </ul>
297
+
260
298
  <Image
261
299
  draggable={false}
262
- src={ArrowIcon}
300
+ src={process.env.NEXT_PUBLIC_S3_URL + '/comp-asset/section10/icon_arrow_gray.webp'}
263
301
  alt={'select icon'}
264
302
  width={28}
265
303
  height={15}
@@ -308,12 +346,12 @@ const Footer = (props: IFooterTypes) => {
308
346
  <p className={'border-solid max-xs:my-[11px] xs:border-r xs:px-[11px] xs:text-center'}>
309
347
  <span className="font-[800]">법률상담접수 </span>{' '}
310
348
  <Link
311
- href={`tel:${props.tel}`}
349
+ href={tel}
312
350
  onClick={onClickTel}
313
- aria-label={'법률상담접수 ' + props.tel}
351
+ aria-label={'법률상담접수 ' + tel}
314
352
  className={'inline-block'}
315
353
  >
316
- <span className={'inline-block'}>{props.tel}</span>
354
+ <span className={'inline-block'}>{tel}</span>
317
355
  </Link>
318
356
  </p>
319
357
  <p className={'break-keep xs:pl-[11px] xs:text-center'}>
@@ -334,12 +372,12 @@ const Footer = (props: IFooterTypes) => {
334
372
  target="_blank"
335
373
  rel="noopener noreferrer"
336
374
  >
337
- <Image src={SNS1} alt="나의 사건 검색" width={66} height={66} className={snsClass} />
375
+ <Image src={sns01} alt="나의 사건 검색" width={66} height={66} className={snsClass} />
338
376
  </Link>
339
377
 
340
378
  <Link href="https://blog.naver.com/lawfirmdaeryun" target="_blank" rel="noopener noreferrer">
341
379
  <Image
342
- src={SNS2}
380
+ src={sns02}
343
381
  alt="법무법인(유한) 대륜 공식블로그"
344
382
  width={37}
345
383
  height={31}
@@ -359,7 +397,7 @@ const Footer = (props: IFooterTypes) => {
359
397
  }}
360
398
  >
361
399
  <Image
362
- src={SNS3}
400
+ src={sns03}
363
401
  alt="법무법인(유한) 대륜 카카오톡채널"
364
402
  width={66}
365
403
  height={66}
@@ -374,7 +412,7 @@ const Footer = (props: IFooterTypes) => {
374
412
  >
375
413
  <Image
376
414
  draggable={false}
377
- src={SNS4}
415
+ src={sns04}
378
416
  alt="법무법인(유한) 대륜 유투브"
379
417
  width={66}
380
418
  height={66}
@@ -389,7 +427,7 @@ const Footer = (props: IFooterTypes) => {
389
427
  >
390
428
  <Image
391
429
  draggable={false}
392
- src={SNS5}
430
+ src={sns05}
393
431
  alt="법무법인(유한) 대륜 인스타그램"
394
432
  width={66}
395
433
  height={66}
@@ -403,7 +441,7 @@ const Footer = (props: IFooterTypes) => {
403
441
  );
404
442
  };
405
443
 
406
- export default Footer;
444
+ export default NewFooter;
407
445
 
408
446
  const FooterLinkList = () => {
409
447
  return (
@@ -544,6 +544,14 @@ video {
544
544
  pointer-events: none;
545
545
  }
546
546
 
547
+ .visible {
548
+ visibility: visible;
549
+ }
550
+
551
+ .invisible {
552
+ visibility: hidden;
553
+ }
554
+
547
555
  .fixed {
548
556
  position: fixed;
549
557
  }
@@ -633,6 +641,10 @@ video {
633
641
  margin-bottom: 20px;
634
642
  }
635
643
 
644
+ .mb-\[30px\] {
645
+ margin-bottom: 30px;
646
+ }
647
+
636
648
  .mb-\[4px\] {
637
649
  margin-bottom: 4px;
638
650
  }
@@ -1195,6 +1207,11 @@ video {
1195
1207
  padding-right: 1.25rem;
1196
1208
  }
1197
1209
 
1210
+ .px-9 {
1211
+ padding-left: 2.25rem;
1212
+ padding-right: 2.25rem;
1213
+ }
1214
+
1198
1215
  .px-\[140px\] {
1199
1216
  padding-left: 140px;
1200
1217
  padding-right: 140px;
@@ -1303,6 +1320,10 @@ video {
1303
1320
  font-size: 14px;
1304
1321
  }
1305
1322
 
1323
+ .text-\[15px\] {
1324
+ font-size: 15px;
1325
+ }
1326
+
1306
1327
  .text-\[16px\] {
1307
1328
  font-size: 16px;
1308
1329
  }
@@ -1529,6 +1550,10 @@ video {
1529
1550
  transition-duration: 150ms;
1530
1551
  }
1531
1552
 
1553
+ .duration-150 {
1554
+ transition-duration: 150ms;
1555
+ }
1556
+
1532
1557
  .duration-700 {
1533
1558
  transition-duration: 700ms;
1534
1559
  }
@@ -1590,6 +1615,11 @@ body {
1590
1615
  background-color: #b99c6e1a;
1591
1616
  }
1592
1617
 
1618
+ .hover\:bg-gray-100:hover {
1619
+ --tw-bg-opacity: 1;
1620
+ background-color: rgb(243 244 246 / var(--tw-bg-opacity));
1621
+ }
1622
+
1593
1623
  .focus\:outline-none:focus {
1594
1624
  outline: 2px solid transparent;
1595
1625
  outline-offset: 2px;