@daeryun/dr_components 1.3.52 → 1.3.54

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.
@@ -10,10 +10,11 @@ export interface IBlogListTypes {
10
10
  center_code?: string;
11
11
  domain?: string;
12
12
  }
13
- declare const BlogList: ({ list, currentPage, totalCount, isCenterBlogHas }: {
13
+ interface IBlogListProps {
14
14
  list: IBlogListTypes[];
15
15
  currentPage: number;
16
16
  totalCount: number;
17
17
  isCenterBlogHas: boolean;
18
- }) => React.JSX.Element;
19
- export default BlogList;
18
+ }
19
+ declare const BlogListView: ({ list, currentPage, totalCount, isCenterBlogHas }: IBlogListProps) => React.JSX.Element;
20
+ export default BlogListView;
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- import { useRouter } from 'next/router';
12
11
  import React, { useState } from 'react';
13
12
  import PageWrapper from '../../Layout/PageWrapper';
14
13
  import SearchBar from '../../SearchBar/SearchBar';
@@ -16,57 +15,50 @@ import Link from 'next/link';
16
15
  import Image from 'next/image';
17
16
  import PaginationForGroup from '../../PaginationForGroup/PaginationForGroup';
18
17
  import { htmlTagRemove } from '../../../lib';
19
- const BlogList = ({ list, currentPage, totalCount, isCenterBlogHas }) => {
18
+ import { useRouter, useSearchParams } from 'next/navigation';
19
+ const BlogListView = ({ list, currentPage, totalCount, isCenterBlogHas }) => {
20
20
  const router = useRouter();
21
- const [searchInput, setSearchInput] = useState('');
21
+ const searchParams = useSearchParams();
22
+ const [searchInput, setSearchInput] = useState(searchParams.get('search') || '');
22
23
  const handleInputChange = (e) => {
23
24
  setSearchInput(e.currentTarget.value);
24
25
  };
25
26
  const handleClick = () => __awaiter(void 0, void 0, void 0, function* () {
26
- yield router.push({
27
- pathname: '/blog',
28
- query: { page: 1, search: searchInput }
29
- });
27
+ router.push(`/blog?page=1&search=${encodeURIComponent(searchInput)}`);
30
28
  });
31
29
  const onPaginationChange = (pageNum) => __awaiter(void 0, void 0, void 0, function* () {
32
- yield router.push({
33
- pathname: '/blog',
34
- query: Object.assign(Object.assign({}, router.query), { page: pageNum })
35
- });
30
+ const params = new URLSearchParams(searchParams.toString());
31
+ params.set('page', String(pageNum));
32
+ router.push(`/blog?${params.toString()}`);
36
33
  });
37
- return (<>
38
- <PageWrapper>
39
- <div className="sticky top-[100px] z-[45] mb-[20px] bg-white pb-[2px] pt-4 max-md:top-[60px]">
40
- <SearchBar onChange={handleInputChange} onClick={handleClick} search={searchInput} placeholder={'검색어를 입력해주세요.'} isKeyPress={true} marginTop={[70, 50, 50]} marginBottom={0}/>
41
- </div>
42
- <section className={'column-section'}>
43
- {(list === null || list === void 0 ? void 0 : list.length) > 0 ? (<div className={'grid gap-[18px] sm:grid-cols-2 lg2:grid-cols-3'}>
44
- {list.map((card, idx) => (<Link href={card.center_code === process.env.NEXT_PUBLIC_CENTER_CODE || isCenterBlogHas
34
+ return (<PageWrapper>
35
+ <div className="sticky top-[100px] z-[45] mb-[20px] bg-white pb-[2px] pt-4 max-md:top-[60px]">
36
+ <SearchBar onChange={handleInputChange} onClick={handleClick} search={searchInput} placeholder={'검색어를 입력해주세요.'} isKeyPress={true} marginTop={[70, 50, 50]} marginBottom={0}/>
37
+ </div>
38
+
39
+ <section className="column-section">
40
+ {(list === null || list === void 0 ? void 0 : list.length) > 0 ? (<div className="grid gap-[18px] sm:grid-cols-2 lg2:grid-cols-3">
41
+ {list.map((card, idx) => (<Link href={card.center_code === process.env.NEXT_PUBLIC_CENTER_CODE || isCenterBlogHas
45
42
  ? `/blog/${card.type_idx}`
46
43
  : card.domain + `blog/${card.type_idx}`} key={idx} className="group flex flex-col overflow-hidden rounded-[30px] border border-solid border-transparent transition duration-300 ease-out hover:border-[#DDDDDD] max-xl:border-[#DDDDDD]" target={card.center_code === process.env.NEXT_PUBLIC_CENTER_CODE || isCenterBlogHas
47
44
  ? '_self'
48
45
  : '_blank'}>
49
- <div className="relative aspect-square w-full overflow-hidden">
50
- {card.save_file_name ? (<Image src={process.env.NEXT_PUBLIC_S3_URL +
46
+ <div className="relative aspect-square w-full overflow-hidden">
47
+ {card.save_file_name ? (<Image src={process.env.NEXT_PUBLIC_S3_URL +
51
48
  '/upload/seo/blog/' +
52
- card.save_file_name} alt={card.file_alt} fill sizes={'600px'} className="object-cover"/>) : (<Image src={`/images/column/column_list_${(idx % 6) + 1}.webp`} alt="" fill sizes={'600px'} className="object-cover"/>)}
53
- </div>
49
+ card.save_file_name} alt={card.file_alt} fill sizes="600px" className="object-cover"/>) : (<Image src={process.env.NEXT_PUBLIC_S3_URL +
50
+ `/column/column_list_${(idx % 6) + 1}.webp`} alt="" fill sizes="600px" className="object-cover"/>)}
51
+ </div>
54
52
 
55
- <div className="flex flex-col gap-3 bg-white px-4 py-6">
56
- <p className="line-clamp-2 text-xl font-extrabold md:text-2xl" dangerouslySetInnerHTML={{ __html: card.tag_title }}/>
57
- <p className="line-clamp-2 text-[16px] text-[#666] md:text-[18px]" dangerouslySetInnerHTML={{ __html: htmlTagRemove(card.description) }}></p>
58
- </div>
59
- </Link>))}
60
- </div>) : (<></>)}
61
- {(list === null || list === void 0 ? void 0 : list.length) < 1 ? (<>
62
- <div className={'h-[300px] text-center text-[20px] leading-[300px] '}>
63
- 검색 결과가 없습니다.
64
- </div>
65
- </>) : (<></>)}
66
- </section>
53
+ <div className="flex flex-col gap-3 bg-white px-4 py-6">
54
+ <p className="line-clamp-2 text-xl font-extrabold md:text-2xl" dangerouslySetInnerHTML={{ __html: card.tag_title }}/>
55
+ <p className="line-clamp-2 text-[16px] text-[#666] md:text-[18px]" dangerouslySetInnerHTML={{ __html: htmlTagRemove(card.description) }}/>
56
+ </div>
57
+ </Link>))}
58
+ </div>) : (<div className="h-[300px] text-center text-[20px] leading-[300px]">검색 결과가 없습니다.</div>)}
59
+ </section>
67
60
 
68
- <PaginationForGroup total={totalCount} currentPage={Number(currentPage)} size={12} className={'my-[100px]'} onChange={onPaginationChange}/>
69
- </PageWrapper>
70
- </>);
61
+ <PaginationForGroup total={totalCount} currentPage={Number(currentPage)} size={12} className="my-[100px]" onChange={onPaginationChange}/>
62
+ </PageWrapper>);
71
63
  };
72
- export default BlogList;
64
+ export default BlogListView;
@@ -1,6 +1,5 @@
1
1
  'use client';
2
2
 
3
- import { useRouter } from 'next/router';
4
3
  import React, { useState } from 'react';
5
4
  import PageWrapper from '../../Layout/PageWrapper';
6
5
  import SearchBar from '../../SearchBar/SearchBar';
@@ -8,6 +7,7 @@ import Link from 'next/link';
8
7
  import Image from 'next/image';
9
8
  import PaginationForGroup from '../../PaginationForGroup/PaginationForGroup';
10
9
  import { htmlTagRemove } from '../../../lib';
10
+ import { useRouter, useSearchParams } from 'next/navigation';
11
11
 
12
12
  export interface IBlogListTypes {
13
13
  tag_title: string;
@@ -21,132 +21,118 @@ export interface IBlogListTypes {
21
21
  domain?: string;
22
22
  }
23
23
 
24
- const BlogList = ({
25
- list,
26
- currentPage,
27
- totalCount,
28
- isCenterBlogHas
29
- }: {
24
+ interface IBlogListProps {
30
25
  list: IBlogListTypes[];
31
26
  currentPage: number;
32
27
  totalCount: number;
33
28
  isCenterBlogHas: boolean;
34
- }) => {
35
- const router = useRouter();
29
+ }
36
30
 
37
- const [searchInput, setSearchInput] = useState<string>('');
31
+ const BlogListView = ({ list, currentPage, totalCount, isCenterBlogHas }: IBlogListProps) => {
32
+ const router = useRouter();
33
+ const searchParams = useSearchParams();
34
+ const [searchInput, setSearchInput] = useState<string>(searchParams.get('search') || '');
38
35
 
39
36
  const handleInputChange = (e: React.FormEvent<HTMLInputElement>) => {
40
37
  setSearchInput(e.currentTarget.value);
41
38
  };
42
39
 
43
40
  const handleClick = async () => {
44
- await router.push({
45
- pathname: '/blog',
46
- query: { page: 1, search: searchInput }
47
- });
41
+ router.push(`/blog?page=1&search=${encodeURIComponent(searchInput)}`);
48
42
  };
49
43
 
50
44
  const onPaginationChange = async (pageNum: number) => {
51
- await router.push({
52
- pathname: '/blog',
53
- query: { ...router.query, page: pageNum }
54
- });
45
+ const params = new URLSearchParams(searchParams.toString());
46
+ params.set('page', String(pageNum));
47
+ router.push(`/blog?${params.toString()}`);
55
48
  };
56
49
 
57
50
  return (
58
- <>
59
- <PageWrapper>
60
- <div className="sticky top-[100px] z-[45] mb-[20px] bg-white pb-[2px] pt-4 max-md:top-[60px]">
61
- <SearchBar
62
- onChange={handleInputChange}
63
- onClick={handleClick}
64
- search={searchInput}
65
- placeholder={'검색어를 입력해주세요.'}
66
- isKeyPress={true}
67
- marginTop={[70, 50, 50]}
68
- marginBottom={0}
69
- />
70
- </div>
71
- <section className={'column-section'}>
72
- {list?.length > 0 ? (
73
- <div className={'grid gap-[18px] sm:grid-cols-2 lg2:grid-cols-3'}>
74
- {list.map((card, idx) => (
75
- <Link
76
- href={
77
- card.center_code === process.env.NEXT_PUBLIC_CENTER_CODE || isCenterBlogHas
78
- ? `/blog/${card.type_idx}`
79
- : card.domain + `blog/${card.type_idx}`
80
- }
81
- key={idx}
82
- className="group flex flex-col overflow-hidden rounded-[30px] border border-solid border-transparent transition duration-300 ease-out hover:border-[#DDDDDD] max-xl:border-[#DDDDDD]"
83
- target={
84
- card.center_code === process.env.NEXT_PUBLIC_CENTER_CODE || isCenterBlogHas
85
- ? '_self'
86
- : '_blank'
87
- }
88
- >
89
- <div className="relative aspect-square w-full overflow-hidden">
90
- {card.save_file_name ? (
91
- <Image
92
- src={
93
- process.env.NEXT_PUBLIC_S3_URL +
94
- '/upload/seo/blog/' +
95
- card.save_file_name
96
- }
97
- alt={card.file_alt}
98
- fill
99
- sizes={'600px'}
100
- className="object-cover"
101
- />
102
- ) : (
103
- <Image
104
- src={`/images/column/column_list_${(idx % 6) + 1}.webp`}
105
- alt=""
106
- fill
107
- sizes={'600px'}
108
- className="object-cover"
109
- />
110
- )}
111
- </div>
51
+ <PageWrapper>
52
+ <div className="sticky top-[100px] z-[45] mb-[20px] bg-white pb-[2px] pt-4 max-md:top-[60px]">
53
+ <SearchBar
54
+ onChange={handleInputChange}
55
+ onClick={handleClick}
56
+ search={searchInput}
57
+ placeholder={'검색어를 입력해주세요.'}
58
+ isKeyPress={true}
59
+ marginTop={[70, 50, 50]}
60
+ marginBottom={0}
61
+ />
62
+ </div>
112
63
 
113
- <div className="flex flex-col gap-3 bg-white px-4 py-6">
114
- <p
115
- className="line-clamp-2 text-xl font-extrabold md:text-2xl"
116
- dangerouslySetInnerHTML={{ __html: card.tag_title }}
64
+ <section className="column-section">
65
+ {list?.length > 0 ? (
66
+ <div className="grid gap-[18px] sm:grid-cols-2 lg2:grid-cols-3">
67
+ {list.map((card, idx) => (
68
+ <Link
69
+ href={
70
+ card.center_code === process.env.NEXT_PUBLIC_CENTER_CODE || isCenterBlogHas
71
+ ? `/blog/${card.type_idx}`
72
+ : card.domain + `blog/${card.type_idx}`
73
+ }
74
+ key={idx}
75
+ className="group flex flex-col overflow-hidden rounded-[30px] border border-solid border-transparent transition duration-300 ease-out hover:border-[#DDDDDD] max-xl:border-[#DDDDDD]"
76
+ target={
77
+ card.center_code === process.env.NEXT_PUBLIC_CENTER_CODE || isCenterBlogHas
78
+ ? '_self'
79
+ : '_blank'
80
+ }
81
+ >
82
+ <div className="relative aspect-square w-full overflow-hidden">
83
+ {card.save_file_name ? (
84
+ <Image
85
+ src={
86
+ process.env.NEXT_PUBLIC_S3_URL +
87
+ '/upload/seo/blog/' +
88
+ card.save_file_name
89
+ }
90
+ alt={card.file_alt}
91
+ fill
92
+ sizes="600px"
93
+ className="object-cover"
117
94
  />
118
- <p
119
- className="line-clamp-2 text-[16px] text-[#666] md:text-[18px]"
120
- dangerouslySetInnerHTML={{ __html: htmlTagRemove(card.description) }}
121
- ></p>
122
- </div>
123
- </Link>
124
- ))}
125
- </div>
126
- ) : (
127
- <></>
128
- )}
129
- {list?.length < 1 ? (
130
- <>
131
- <div className={'h-[300px] text-center text-[20px] leading-[300px] '}>
132
- 검색 결과가 없습니다.
133
- </div>
134
- </>
135
- ) : (
136
- <></>
137
- )}
138
- </section>
95
+ ) : (
96
+ <Image
97
+ src={
98
+ process.env.NEXT_PUBLIC_S3_URL +
99
+ `/column/column_list_${(idx % 6) + 1}.webp`
100
+ }
101
+ alt=""
102
+ fill
103
+ sizes="600px"
104
+ className="object-cover"
105
+ />
106
+ )}
107
+ </div>
139
108
 
140
- <PaginationForGroup
141
- total={totalCount}
142
- currentPage={Number(currentPage)}
143
- size={12}
144
- className={'my-[100px]'}
145
- onChange={onPaginationChange}
146
- />
147
- </PageWrapper>
148
- </>
109
+ <div className="flex flex-col gap-3 bg-white px-4 py-6">
110
+ <p
111
+ className="line-clamp-2 text-xl font-extrabold md:text-2xl"
112
+ dangerouslySetInnerHTML={{ __html: card.tag_title }}
113
+ />
114
+ <p
115
+ className="line-clamp-2 text-[16px] text-[#666] md:text-[18px]"
116
+ dangerouslySetInnerHTML={{ __html: htmlTagRemove(card.description) }}
117
+ />
118
+ </div>
119
+ </Link>
120
+ ))}
121
+ </div>
122
+ ) : (
123
+ <div className="h-[300px] text-center text-[20px] leading-[300px]">검색 결과가 없습니다.</div>
124
+ )}
125
+ </section>
126
+
127
+ <PaginationForGroup
128
+ total={totalCount}
129
+ currentPage={Number(currentPage)}
130
+ size={12}
131
+ className="my-[100px]"
132
+ onChange={onPaginationChange}
133
+ />
134
+ </PageWrapper>
149
135
  );
150
136
  };
151
137
 
152
- export default BlogList;
138
+ export default BlogListView;