@daeryun/dr_components 0.1.13 → 0.1.15
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/components/MapFix/MapFix.stories.d.ts +7 -0
- package/dist/components/MapFix/MapFix.stories.jsx +19 -0
- package/dist/components/MapFix/MapFix.stories.tsx +29 -0
- package/dist/components/banner/TopBanner.stories.d.ts +11 -0
- package/dist/components/banner/TopBanner.stories.jsx +18 -0
- package/dist/components/banner/TopBanner.stories.tsx +25 -0
- package/dist/components/categoryView/CategoryComponent.d.ts +12 -0
- package/dist/components/categoryView/CategoryComponent.jsx +90 -0
- package/dist/components/categoryView/CategoryComponent.tsx +190 -0
- package/dist/components/categoryView/CategoryView.d.ts +8 -0
- package/dist/components/categoryView/CategoryView.jsx +103 -0
- package/dist/components/categoryView/CategoryView.tsx +129 -0
- package/dist/components/categoryView/CenterComponent.d.ts +10 -0
- package/dist/components/categoryView/CenterComponent.jsx +113 -0
- package/dist/components/categoryView/CenterComponent.tsx +189 -0
- package/dist/components/categoryView/ICategoryViewTypes.d.ts +12 -0
- package/dist/components/categoryView/ICategoryViewTypes.js +1 -0
- package/dist/components/categoryView/ICategoryViewTypes.ts +12 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.ts +1 -0
- package/dist/styles/globals.css +458 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import '../../styles/globals.css';
|
|
3
|
+
import { MapFix } from '../index';
|
|
4
|
+
declare const meta: Meta<typeof MapFix>;
|
|
5
|
+
export default meta;
|
|
6
|
+
type Story = StoryObj<typeof meta>;
|
|
7
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import '../../styles/globals.css';
|
|
2
|
+
import { MapFix } from '../index';
|
|
3
|
+
const meta = {
|
|
4
|
+
component: MapFix,
|
|
5
|
+
title: 'MapFix'
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
export const Default = {
|
|
9
|
+
render: args => {
|
|
10
|
+
return (<div className={'relative h-[1000px] w-full'}>
|
|
11
|
+
<MapFix {...args}/>
|
|
12
|
+
</div>);
|
|
13
|
+
},
|
|
14
|
+
args: {
|
|
15
|
+
selectRegion: '서울',
|
|
16
|
+
mapFixOpen: true,
|
|
17
|
+
onClose: () => { }
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import '../../styles/globals.css';
|
|
3
|
+
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
4
|
+
import Logo from '../../asset/images/footer/logo_b.webp';
|
|
5
|
+
import { MapFix } from '../index';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof MapFix> = {
|
|
8
|
+
component: MapFix,
|
|
9
|
+
title: 'MapFix'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
render: args => {
|
|
18
|
+
return (
|
|
19
|
+
<div className={'relative h-[1000px] w-full'}>
|
|
20
|
+
<MapFix {...args} />
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
},
|
|
24
|
+
args: {
|
|
25
|
+
selectRegion: '서울',
|
|
26
|
+
mapFixOpen: true,
|
|
27
|
+
onClose: () => {}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import TopBanner from './TopBanner';
|
|
3
|
+
import type { StoryObj } from '@storybook/react';
|
|
4
|
+
import '../../styles/globals.css';
|
|
5
|
+
declare const meta: {
|
|
6
|
+
component: () => import("react").JSX.Element;
|
|
7
|
+
title: string;
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof TopBanner>;
|
|
11
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import TopBanner from './TopBanner';
|
|
2
|
+
import '../../styles/globals.css';
|
|
3
|
+
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
4
|
+
const meta = {
|
|
5
|
+
component: TopBanner, //컴포넌트
|
|
6
|
+
title: 'TopBanner' //스토리 이름
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
export const Default = {
|
|
10
|
+
render: args => {
|
|
11
|
+
const queryClient = new QueryClient();
|
|
12
|
+
return (<QueryClientProvider client={queryClient}>
|
|
13
|
+
<div className={'relative h-[500px] w-full'}>
|
|
14
|
+
<TopBanner />
|
|
15
|
+
</div>
|
|
16
|
+
</QueryClientProvider>);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import TopBanner from './TopBanner';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import '../../styles/globals.css';
|
|
4
|
+
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
component: TopBanner, //컴포넌트
|
|
8
|
+
title: 'TopBanner' //스토리 이름
|
|
9
|
+
} satisfies Meta<typeof TopBanner>;
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof TopBanner>;
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
render: args => {
|
|
16
|
+
const queryClient = new QueryClient();
|
|
17
|
+
return (
|
|
18
|
+
<QueryClientProvider client={queryClient}>
|
|
19
|
+
<div className={'relative h-[500px] w-full'}>
|
|
20
|
+
<TopBanner />
|
|
21
|
+
</div>
|
|
22
|
+
</QueryClientProvider>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ICategory, ICenter } from './ICategoryViewTypes';
|
|
3
|
+
declare const CategoryComponent: (props: {
|
|
4
|
+
showCategory: ICategory[];
|
|
5
|
+
onClickPage: (num: number) => void;
|
|
6
|
+
currentPage: number;
|
|
7
|
+
maxPageNum: number;
|
|
8
|
+
selectedCenter: ICenter;
|
|
9
|
+
currentCenterTitle: string;
|
|
10
|
+
allMainCenterTargetBlank?: boolean | undefined;
|
|
11
|
+
}) => React.JSX.Element;
|
|
12
|
+
export default CategoryComponent;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import Link from 'next/link';
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
const CategoryComponent = (props) => {
|
|
5
|
+
const { showCategory, onClickPage, currentPage, maxPageNum, selectedCenter, currentCenterTitle, allMainCenterTargetBlank } = props;
|
|
6
|
+
const linkString = (id, pathname) => {
|
|
7
|
+
let link = '';
|
|
8
|
+
if (selectedCenter.code_desc === currentCenterTitle && !allMainCenterTargetBlank) {
|
|
9
|
+
link = `/${pathname}`;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
link = `https://www.daeryunlaw-${selectedCenter.code_desc}.com/${pathname}`;
|
|
13
|
+
}
|
|
14
|
+
return link + '/' + id;
|
|
15
|
+
};
|
|
16
|
+
return (<div className={'flex h-auto w-full flex-col justify-between bg-[#FAFAFA] px-[30px] py-[20px] ' +
|
|
17
|
+
//1280px
|
|
18
|
+
'max-xl:p-[25px] ' +
|
|
19
|
+
//520px
|
|
20
|
+
'max-2sm:p-[12px]'}>
|
|
21
|
+
<span className={'mt-[20px] grid h-auto w-full auto-cols-[minmax(150px,auto)] auto-rows-[minmax(0,80px)] grid-cols-5 gap-[12px] ' +
|
|
22
|
+
//1920px
|
|
23
|
+
'max-full:grid-cols-4 ' +
|
|
24
|
+
//1280px
|
|
25
|
+
'max-4xl:grid-cols-3 max-4xl:gap-[5px] ' +
|
|
26
|
+
//1280px
|
|
27
|
+
'max-xl:mt-0 max-xl:grid-cols-2 ' +
|
|
28
|
+
//900px
|
|
29
|
+
'max-md2:auto-rows-[minmax(0,60px)] max-md2:grid-cols-1 ' +
|
|
30
|
+
//520px
|
|
31
|
+
'max-2sm:auto-rows-[minmax(0,50px)]'}>
|
|
32
|
+
{showCategory.map((item, index) => (<Link href={linkString(item.idx, item.pathname)} key={index} className={'group/category flex h-full w-full items-center justify-between rounded-[10px] border-[1px] border-solid border-[#D9D9D9] bg-[#fff] px-[20px] ' +
|
|
33
|
+
//900px
|
|
34
|
+
'max-md2:rounded-none max-md2:border-0' +
|
|
35
|
+
//520px
|
|
36
|
+
'max-2sm:px-[10px] '} target={selectedCenter.code_desc === currentCenterTitle && !allMainCenterTargetBlank
|
|
37
|
+
? '_self'
|
|
38
|
+
: '_blank'}>
|
|
39
|
+
<p className={'text-left text-[18px] tracking-[-1px] text-[#4B4B4B] ' +
|
|
40
|
+
//900px
|
|
41
|
+
'max-md2:text-[16px] ' +
|
|
42
|
+
//520px
|
|
43
|
+
'max-2sm:text-[13px]'}>
|
|
44
|
+
{item.title}
|
|
45
|
+
</p>
|
|
46
|
+
<Image src={'/images/categoryView/section9_arrow_03.webp'} alt={'arrow'} width={43} height={36} className={'h-auto w-[20px] transition-all group-hover/category:translate-x-[5px] ' +
|
|
47
|
+
//520px
|
|
48
|
+
'max-md2:w-[16px] ' +
|
|
49
|
+
//520px
|
|
50
|
+
'max-2sm:w-[13px]'}/>
|
|
51
|
+
</Link>))}
|
|
52
|
+
</span>
|
|
53
|
+
<span className={'mt-[18px] flex items-center gap-[20px] ' +
|
|
54
|
+
//900px
|
|
55
|
+
'max-md2:mb-[5px] max-md2:mt-[30px] max-md2:justify-center max-md2:gap-[30px] ' +
|
|
56
|
+
//520px
|
|
57
|
+
'max-2sm:mt-[15px]'}>
|
|
58
|
+
<div className={'h-[2px] flex-grow bg-[#DBDBDB] ' +
|
|
59
|
+
//900px
|
|
60
|
+
'max-md2:hidden'}></div>
|
|
61
|
+
<p className={'text-[18px] font-medium tracking-[3.6px] text-[#4B4B4B] ' +
|
|
62
|
+
//520px
|
|
63
|
+
'max-2sm:text-[14px]'}>
|
|
64
|
+
<span className={'font-[800]'}>{currentPage}</span>/{maxPageNum}
|
|
65
|
+
</p>
|
|
66
|
+
<span className={'flex items-center gap-[12px] ' +
|
|
67
|
+
//900px
|
|
68
|
+
'max-md2:w-[40%] max-md2:justify-between'}>
|
|
69
|
+
<button className={`${currentPage <= 1 && 'pointer-events-none opacity-30'}`} onClick={() => {
|
|
70
|
+
onClickPage(currentPage - 1);
|
|
71
|
+
}}>
|
|
72
|
+
<Image src={'/images/categoryView/section9_arrow_05.webp'} alt={'section9 next button'} width={22} height={39} className={'h-[19px] w-auto rotate-180 ' +
|
|
73
|
+
//520px
|
|
74
|
+
'max-2sm:h-[15px]'}/>
|
|
75
|
+
</button>
|
|
76
|
+
<Image src={'/images/categoryView/section9_icon.webp'} alt={'section9'} width={12} height={32} className={'h-[16px] w-auto ' +
|
|
77
|
+
//520px
|
|
78
|
+
'max-2sm:h-[12px]'}/>
|
|
79
|
+
<button className={`${currentPage >= maxPageNum && 'pointer-events-none opacity-30'}`} onClick={() => {
|
|
80
|
+
onClickPage(currentPage + 1);
|
|
81
|
+
}}>
|
|
82
|
+
<Image src={'/images/categoryView/section9_arrow_05.webp'} alt={'section9 next button'} width={22} height={39} className={'h-[19px] w-auto ' +
|
|
83
|
+
//520px
|
|
84
|
+
'max-2sm:h-[15px]'}/>
|
|
85
|
+
</button>
|
|
86
|
+
</span>
|
|
87
|
+
</span>
|
|
88
|
+
</div>);
|
|
89
|
+
};
|
|
90
|
+
export default CategoryComponent;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import Link from 'next/link';
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ICategory, ICenter } from './ICategoryViewTypes';
|
|
5
|
+
|
|
6
|
+
const CategoryComponent = (props: {
|
|
7
|
+
showCategory: ICategory[];
|
|
8
|
+
onClickPage: (num: number) => void;
|
|
9
|
+
currentPage: number;
|
|
10
|
+
maxPageNum: number;
|
|
11
|
+
selectedCenter: ICenter;
|
|
12
|
+
currentCenterTitle: string;
|
|
13
|
+
allMainCenterTargetBlank?: boolean;
|
|
14
|
+
}) => {
|
|
15
|
+
const {
|
|
16
|
+
showCategory,
|
|
17
|
+
onClickPage,
|
|
18
|
+
currentPage,
|
|
19
|
+
maxPageNum,
|
|
20
|
+
selectedCenter,
|
|
21
|
+
currentCenterTitle,
|
|
22
|
+
allMainCenterTargetBlank
|
|
23
|
+
} = props;
|
|
24
|
+
|
|
25
|
+
const linkString = (id: number, pathname: string) => {
|
|
26
|
+
let link = '';
|
|
27
|
+
|
|
28
|
+
if (selectedCenter.code_desc === currentCenterTitle && !allMainCenterTargetBlank) {
|
|
29
|
+
link = `/${pathname}`;
|
|
30
|
+
} else {
|
|
31
|
+
link = `https://www.daeryunlaw-${selectedCenter.code_desc}.com/${pathname}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return link + '/' + id;
|
|
35
|
+
};
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
className={
|
|
39
|
+
'flex h-auto w-full flex-col justify-between bg-[#FAFAFA] px-[30px] py-[20px] ' +
|
|
40
|
+
//1280px
|
|
41
|
+
'max-xl:p-[25px] ' +
|
|
42
|
+
//520px
|
|
43
|
+
'max-2sm:p-[12px]'
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
<span
|
|
47
|
+
className={
|
|
48
|
+
'mt-[20px] grid h-auto w-full auto-cols-[minmax(150px,auto)] auto-rows-[minmax(0,80px)] grid-cols-5 gap-[12px] ' +
|
|
49
|
+
//1920px
|
|
50
|
+
'max-full:grid-cols-4 ' +
|
|
51
|
+
//1280px
|
|
52
|
+
'max-4xl:grid-cols-3 max-4xl:gap-[5px] ' +
|
|
53
|
+
//1280px
|
|
54
|
+
'max-xl:mt-0 max-xl:grid-cols-2 ' +
|
|
55
|
+
//900px
|
|
56
|
+
'max-md2:auto-rows-[minmax(0,60px)] max-md2:grid-cols-1 ' +
|
|
57
|
+
//520px
|
|
58
|
+
'max-2sm:auto-rows-[minmax(0,50px)]'
|
|
59
|
+
}
|
|
60
|
+
>
|
|
61
|
+
{showCategory.map((item, index) => (
|
|
62
|
+
<Link
|
|
63
|
+
href={linkString(item.idx, item.pathname)}
|
|
64
|
+
key={index}
|
|
65
|
+
className={
|
|
66
|
+
'group/category flex h-full w-full items-center justify-between rounded-[10px] border-[1px] border-solid border-[#D9D9D9] bg-[#fff] px-[20px] ' +
|
|
67
|
+
//900px
|
|
68
|
+
'max-md2:rounded-none max-md2:border-0' +
|
|
69
|
+
//520px
|
|
70
|
+
'max-2sm:px-[10px] '
|
|
71
|
+
}
|
|
72
|
+
target={
|
|
73
|
+
selectedCenter.code_desc === currentCenterTitle && !allMainCenterTargetBlank
|
|
74
|
+
? '_self'
|
|
75
|
+
: '_blank'
|
|
76
|
+
}
|
|
77
|
+
>
|
|
78
|
+
<p
|
|
79
|
+
className={
|
|
80
|
+
'text-left text-[18px] tracking-[-1px] text-[#4B4B4B] ' +
|
|
81
|
+
//900px
|
|
82
|
+
'max-md2:text-[16px] ' +
|
|
83
|
+
//520px
|
|
84
|
+
'max-2sm:text-[13px]'
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
{item.title}
|
|
88
|
+
</p>
|
|
89
|
+
<Image
|
|
90
|
+
src={'/images/categoryView/section9_arrow_03.webp'}
|
|
91
|
+
alt={'arrow'}
|
|
92
|
+
width={43}
|
|
93
|
+
height={36}
|
|
94
|
+
className={
|
|
95
|
+
'h-auto w-[20px] transition-all group-hover/category:translate-x-[5px] ' +
|
|
96
|
+
//520px
|
|
97
|
+
'max-md2:w-[16px] ' +
|
|
98
|
+
//520px
|
|
99
|
+
'max-2sm:w-[13px]'
|
|
100
|
+
}
|
|
101
|
+
/>
|
|
102
|
+
</Link>
|
|
103
|
+
))}
|
|
104
|
+
</span>
|
|
105
|
+
<span
|
|
106
|
+
className={
|
|
107
|
+
'mt-[18px] flex items-center gap-[20px] ' +
|
|
108
|
+
//900px
|
|
109
|
+
'max-md2:mb-[5px] max-md2:mt-[30px] max-md2:justify-center max-md2:gap-[30px] ' +
|
|
110
|
+
//520px
|
|
111
|
+
'max-2sm:mt-[15px]'
|
|
112
|
+
}
|
|
113
|
+
>
|
|
114
|
+
<div
|
|
115
|
+
className={
|
|
116
|
+
'h-[2px] flex-grow bg-[#DBDBDB] ' +
|
|
117
|
+
//900px
|
|
118
|
+
'max-md2:hidden'
|
|
119
|
+
}
|
|
120
|
+
></div>
|
|
121
|
+
<p
|
|
122
|
+
className={
|
|
123
|
+
'text-[18px] font-medium tracking-[3.6px] text-[#4B4B4B] ' +
|
|
124
|
+
//520px
|
|
125
|
+
'max-2sm:text-[14px]'
|
|
126
|
+
}
|
|
127
|
+
>
|
|
128
|
+
<span className={'font-[800]'}>{currentPage}</span>/{maxPageNum}
|
|
129
|
+
</p>
|
|
130
|
+
<span
|
|
131
|
+
className={
|
|
132
|
+
'flex items-center gap-[12px] ' +
|
|
133
|
+
//900px
|
|
134
|
+
'max-md2:w-[40%] max-md2:justify-between'
|
|
135
|
+
}
|
|
136
|
+
>
|
|
137
|
+
<button
|
|
138
|
+
className={`${currentPage <= 1 && 'pointer-events-none opacity-30'}`}
|
|
139
|
+
onClick={() => {
|
|
140
|
+
onClickPage(currentPage - 1);
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
<Image
|
|
144
|
+
src={'/images/categoryView/section9_arrow_05.webp'}
|
|
145
|
+
alt={'section9 next button'}
|
|
146
|
+
width={22}
|
|
147
|
+
height={39}
|
|
148
|
+
className={
|
|
149
|
+
'h-[19px] w-auto rotate-180 ' +
|
|
150
|
+
//520px
|
|
151
|
+
'max-2sm:h-[15px]'
|
|
152
|
+
}
|
|
153
|
+
/>
|
|
154
|
+
</button>
|
|
155
|
+
<Image
|
|
156
|
+
src={'/images/categoryView/section9_icon.webp'}
|
|
157
|
+
alt={'section9'}
|
|
158
|
+
width={12}
|
|
159
|
+
height={32}
|
|
160
|
+
className={
|
|
161
|
+
'h-[16px] w-auto ' +
|
|
162
|
+
//520px
|
|
163
|
+
'max-2sm:h-[12px]'
|
|
164
|
+
}
|
|
165
|
+
/>
|
|
166
|
+
<button
|
|
167
|
+
className={`${currentPage >= maxPageNum && 'pointer-events-none opacity-30'}`}
|
|
168
|
+
onClick={() => {
|
|
169
|
+
onClickPage(currentPage + 1);
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
<Image
|
|
173
|
+
src={'/images/categoryView/section9_arrow_05.webp'}
|
|
174
|
+
alt={'section9 next button'}
|
|
175
|
+
width={22}
|
|
176
|
+
height={39}
|
|
177
|
+
className={
|
|
178
|
+
'h-[19px] w-auto ' +
|
|
179
|
+
//520px
|
|
180
|
+
'max-2sm:h-[15px]'
|
|
181
|
+
}
|
|
182
|
+
/>
|
|
183
|
+
</button>
|
|
184
|
+
</span>
|
|
185
|
+
</span>
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export default CategoryComponent;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React, { useEffect, useState } from 'react';
|
|
11
|
+
import CenterComponent from './CenterComponent';
|
|
12
|
+
import CategoryComponent from './CategoryComponent';
|
|
13
|
+
import axios from 'axios';
|
|
14
|
+
const CategoryView = (props) => {
|
|
15
|
+
//센터, 분야정보
|
|
16
|
+
const [centerList, setCenterList] = useState([]);
|
|
17
|
+
const [categoryList, setCategoryList] = useState([]);
|
|
18
|
+
const [selectedCenter, setSelectedCenter] = useState({ code: '', code_name: '', code_desc: '' });
|
|
19
|
+
const [filterCategory, setFilterCategory] = useState([]);
|
|
20
|
+
// 페이지 관련
|
|
21
|
+
const [showCategory, setShowCategory] = useState([]);
|
|
22
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
23
|
+
const [maxPageNum, setMaxPageNum] = useState(0);
|
|
24
|
+
//보여지는 카테고리 수
|
|
25
|
+
const [itemsPerPage, setItemsPerPage] = useState(20);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const fetchCenterList = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
try {
|
|
29
|
+
const response = yield axios.get('/api/center/list?type=category');
|
|
30
|
+
// const centerArr = response.data.list;
|
|
31
|
+
//회계감리 삭제
|
|
32
|
+
const centerArr = response.data.list.filter((i) => i.code !== 'CT0024');
|
|
33
|
+
const selectedCenter = centerArr.find((i) => i.code_desc === props.currentCenterTitle);
|
|
34
|
+
if (selectedCenter) {
|
|
35
|
+
selectedCenter.isSelect = true;
|
|
36
|
+
setSelectedCenter(selectedCenter);
|
|
37
|
+
}
|
|
38
|
+
setCenterList(centerArr);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error('Error fetching center list', error);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const fetchCategoryList = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
try {
|
|
46
|
+
const response = yield axios.get('/api/category/list');
|
|
47
|
+
setCategoryList(response.data.list);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error('Error fetching category list', error);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
void fetchCenterList();
|
|
54
|
+
void fetchCategoryList();
|
|
55
|
+
const handleResize = () => {
|
|
56
|
+
const screenWidth = window.innerWidth;
|
|
57
|
+
if (screenWidth >= 1600) {
|
|
58
|
+
setItemsPerPage(20);
|
|
59
|
+
}
|
|
60
|
+
else if (screenWidth >= 900) {
|
|
61
|
+
setItemsPerPage(12);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
setItemsPerPage(9);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
window.addEventListener('resize', handleResize);
|
|
68
|
+
handleResize();
|
|
69
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
70
|
+
}, []);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (centerList.length > 0 && categoryList.length > 0) {
|
|
73
|
+
const selected = centerList.find(i => i.isSelect);
|
|
74
|
+
if (selected) {
|
|
75
|
+
setSelectedCenter(selected);
|
|
76
|
+
const selectedCategory = categoryList.filter(i => i.center_code === selected.code);
|
|
77
|
+
setFilterCategory(selectedCategory);
|
|
78
|
+
setShowCategory(selectedCategory.slice(0, itemsPerPage));
|
|
79
|
+
setCurrentPage(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, [centerList, categoryList]);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
setShowCategory(filterCategory.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage));
|
|
85
|
+
setMaxPageNum(Math.ceil(filterCategory.length / itemsPerPage));
|
|
86
|
+
}, [filterCategory, currentPage, itemsPerPage]);
|
|
87
|
+
return (<div className={'flex h-fit w-full gap-[65px] bg-[#fff] px-[50px] py-[70px] shadow-[0_3px_10px_#0000001A] ' +
|
|
88
|
+
//1280px
|
|
89
|
+
'max-xl:gap-[40px] ' +
|
|
90
|
+
//900px
|
|
91
|
+
'max-md2:gap-[10px] max-md2:px-[10px] max-md2:py-[20px] max-md2:shadow-none '}>
|
|
92
|
+
{/*센터*/}
|
|
93
|
+
<CenterComponent themeColor={props.themeColor} centerList={centerList} onClick={(list) => {
|
|
94
|
+
setCenterList(list);
|
|
95
|
+
}} hiddenTitle={props.hiddenTitle} currentCenterTitle={props.currentCenterTitle}/>
|
|
96
|
+
|
|
97
|
+
{/*분야*/}
|
|
98
|
+
<CategoryComponent showCategory={showCategory} onClickPage={(num) => {
|
|
99
|
+
setCurrentPage(num);
|
|
100
|
+
}} currentPage={currentPage} maxPageNum={maxPageNum} selectedCenter={selectedCenter} currentCenterTitle={props.currentCenterTitle} allMainCenterTargetBlank={props.allMainCenterTargetBlank}/>
|
|
101
|
+
</div>);
|
|
102
|
+
};
|
|
103
|
+
export default CategoryView;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { ICategory, ICenter } from './ICategoryViewTypes';
|
|
3
|
+
import CenterComponent from './CenterComponent';
|
|
4
|
+
import CategoryComponent from './CategoryComponent';
|
|
5
|
+
import axios from 'axios';
|
|
6
|
+
|
|
7
|
+
const CategoryView = (props: {
|
|
8
|
+
themeColor: string; // 테마색상
|
|
9
|
+
currentCenterTitle: string; // 기준이 되는 센터 영어이름 (설정 시, 센터 가장 상단위치, 기본값)
|
|
10
|
+
hiddenTitle?: boolean; // '1280px' 보다 클 시, 타이틀 숨김처리
|
|
11
|
+
allMainCenterTargetBlank?: boolean; // 카테고리 링크 전부 새창, 해당 센터 카테고리로 이동
|
|
12
|
+
}) => {
|
|
13
|
+
//센터, 분야정보
|
|
14
|
+
const [centerList, setCenterList] = useState<ICenter[]>([]);
|
|
15
|
+
const [categoryList, setCategoryList] = useState<ICategory[]>([]);
|
|
16
|
+
const [selectedCenter, setSelectedCenter] = useState<ICenter>({ code: '', code_name: '', code_desc: '' });
|
|
17
|
+
const [filterCategory, setFilterCategory] = useState<ICategory[]>([]);
|
|
18
|
+
|
|
19
|
+
// 페이지 관련
|
|
20
|
+
const [showCategory, setShowCategory] = useState<ICategory[]>([]);
|
|
21
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
22
|
+
const [maxPageNum, setMaxPageNum] = useState<number>(0);
|
|
23
|
+
|
|
24
|
+
//보여지는 카테고리 수
|
|
25
|
+
const [itemsPerPage, setItemsPerPage] = useState(20);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const fetchCenterList = async () => {
|
|
29
|
+
try {
|
|
30
|
+
const response = await axios.get('/api/center/list?type=category');
|
|
31
|
+
// const centerArr = response.data.list;
|
|
32
|
+
//회계감리 삭제
|
|
33
|
+
const centerArr = response.data.list.filter((i: ICenter) => i.code !== 'CT0024');
|
|
34
|
+
const selectedCenter = centerArr.find((i: ICenter) => i.code_desc === props.currentCenterTitle);
|
|
35
|
+
if (selectedCenter) {
|
|
36
|
+
selectedCenter.isSelect = true;
|
|
37
|
+
setSelectedCenter(selectedCenter);
|
|
38
|
+
}
|
|
39
|
+
setCenterList(centerArr);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('Error fetching center list', error);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const fetchCategoryList = async () => {
|
|
46
|
+
try {
|
|
47
|
+
const response = await axios.get('/api/category/list');
|
|
48
|
+
setCategoryList(response.data.list);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('Error fetching category list', error);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
void fetchCenterList();
|
|
55
|
+
void fetchCategoryList();
|
|
56
|
+
|
|
57
|
+
const handleResize = () => {
|
|
58
|
+
const screenWidth = window.innerWidth;
|
|
59
|
+
if (screenWidth >= 1600) {
|
|
60
|
+
setItemsPerPage(20);
|
|
61
|
+
} else if (screenWidth >= 900) {
|
|
62
|
+
setItemsPerPage(12);
|
|
63
|
+
} else {
|
|
64
|
+
setItemsPerPage(9);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
window.addEventListener('resize', handleResize);
|
|
69
|
+
handleResize();
|
|
70
|
+
|
|
71
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (centerList.length > 0 && categoryList.length > 0) {
|
|
76
|
+
const selected = centerList.find(i => i.isSelect);
|
|
77
|
+
if (selected) {
|
|
78
|
+
setSelectedCenter(selected);
|
|
79
|
+
const selectedCategory = categoryList.filter(i => i.center_code === selected.code);
|
|
80
|
+
setFilterCategory(selectedCategory);
|
|
81
|
+
setShowCategory(selectedCategory.slice(0, itemsPerPage));
|
|
82
|
+
setCurrentPage(1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, [centerList, categoryList]);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
setShowCategory(filterCategory.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage));
|
|
89
|
+
setMaxPageNum(Math.ceil(filterCategory.length / itemsPerPage));
|
|
90
|
+
}, [filterCategory, currentPage, itemsPerPage]);
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
className={
|
|
95
|
+
'flex h-fit w-full gap-[65px] bg-[#fff] px-[50px] py-[70px] shadow-[0_3px_10px_#0000001A] ' +
|
|
96
|
+
//1280px
|
|
97
|
+
'max-xl:gap-[40px] ' +
|
|
98
|
+
//900px
|
|
99
|
+
'max-md2:gap-[10px] max-md2:px-[10px] max-md2:py-[20px] max-md2:shadow-none '
|
|
100
|
+
}
|
|
101
|
+
>
|
|
102
|
+
{/*센터*/}
|
|
103
|
+
<CenterComponent
|
|
104
|
+
themeColor={props.themeColor}
|
|
105
|
+
centerList={centerList}
|
|
106
|
+
onClick={(list: ICenter[]) => {
|
|
107
|
+
setCenterList(list);
|
|
108
|
+
}}
|
|
109
|
+
hiddenTitle={props.hiddenTitle}
|
|
110
|
+
currentCenterTitle={props.currentCenterTitle}
|
|
111
|
+
/>
|
|
112
|
+
|
|
113
|
+
{/*분야*/}
|
|
114
|
+
<CategoryComponent
|
|
115
|
+
showCategory={showCategory}
|
|
116
|
+
onClickPage={(num: number) => {
|
|
117
|
+
setCurrentPage(num);
|
|
118
|
+
}}
|
|
119
|
+
currentPage={currentPage}
|
|
120
|
+
maxPageNum={maxPageNum}
|
|
121
|
+
selectedCenter={selectedCenter}
|
|
122
|
+
currentCenterTitle={props.currentCenterTitle}
|
|
123
|
+
allMainCenterTargetBlank={props.allMainCenterTargetBlank}
|
|
124
|
+
/>
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export default CategoryView;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ICenter } from './ICategoryViewTypes';
|
|
3
|
+
declare const CenterComponent: (props: {
|
|
4
|
+
themeColor: string;
|
|
5
|
+
centerList: ICenter[];
|
|
6
|
+
onClick: (list: ICenter[]) => void;
|
|
7
|
+
hiddenTitle: boolean | undefined;
|
|
8
|
+
currentCenterTitle: string;
|
|
9
|
+
}) => React.JSX.Element;
|
|
10
|
+
export default CenterComponent;
|