@daeryun/dr_components 0.6.83 → 0.6.85

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.
@@ -41,7 +41,6 @@ const CategoryView = (props: {
41
41
  );
42
42
  const selectedCenter = centerArr.find((i: ICenter) => i.code_desc === props.currentCenterTitle);
43
43
  if (selectedCenter) {
44
- selectedCenter.isSelect = true;
45
44
  setSelectedCenter(selectedCenter);
46
45
  }
47
46
  setCenterList(centerArr);
@@ -81,7 +80,7 @@ const CategoryView = (props: {
81
80
 
82
81
  useEffect(() => {
83
82
  if (centerList.length > 0 && categoryList.length > 0) {
84
- const selected = centerList.find(i => i.isSelect);
83
+ const selected = centerList.find(i => i === selectedCenter);
85
84
  if (selected) {
86
85
  setSelectedCenter(selected);
87
86
  const selectedCategory = categoryList.filter(i => i.center_code === selected.code);
@@ -90,7 +89,7 @@ const CategoryView = (props: {
90
89
  setCurrentPage(1);
91
90
  }
92
91
  }
93
- }, [centerList, categoryList]);
92
+ }, [selectedCenter, categoryList]);
94
93
 
95
94
  useEffect(() => {
96
95
  setShowCategory(filterCategory.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage));
@@ -110,10 +109,9 @@ const CategoryView = (props: {
110
109
  {/*센터*/}
111
110
  <CenterComponent
112
111
  themeColor={props.themeColor}
112
+ selectedCenter={selectedCenter}
113
113
  centerList={centerList}
114
- onClick={(list: ICenter[]) => {
115
- setCenterList(list);
116
- }}
114
+ onClick={setSelectedCenter}
117
115
  hiddenTitle={props.hiddenTitle}
118
116
  currentCenterTitle={props.currentCenterTitle}
119
117
  />
@@ -3,7 +3,8 @@ import { ICenter } from './ICategoryViewTypes';
3
3
  declare const CenterComponent: (props: {
4
4
  themeColor: string;
5
5
  centerList: ICenter[];
6
- onClick: (list: ICenter[]) => void;
6
+ selectedCenter: ICenter;
7
+ onClick: (center: ICenter) => void;
7
8
  hiddenTitle: boolean | undefined;
8
9
  currentCenterTitle: string;
9
10
  }) => React.JSX.Element;
@@ -4,22 +4,24 @@ import Image from 'next/image';
4
4
  import Arrow1 from '../../asset/images/categoryView/section9_arrow_01.webp';
5
5
  import Arrow2 from '../../asset/images/categoryView/section9_arrow_02.webp';
6
6
  const CenterComponent = (props) => {
7
- const { themeColor, centerList, onClick, hiddenTitle, currentCenterTitle } = props;
7
+ const { themeColor, centerList, selectedCenter, onClick, hiddenTitle, currentCenterTitle } = props;
8
8
  const currentCenter = props.centerList.filter(item => item.code_desc === currentCenterTitle);
9
9
  const CenterCon = (props) => {
10
10
  const { item } = props;
11
11
  return (<>
12
12
  <button type="button" onClick={() => {
13
- const newCenters = centerList.map(i => (Object.assign(Object.assign({}, i), { isSelect: i.code === item.code })));
14
- onClick(newCenters);
15
- }} style={{ direction: 'ltr', backgroundColor: item.isSelect ? themeColor : themeColor + '00' }} className={'relative block h-fit w-full bg-amber-200 py-[15px] text-left ' +
16
- `${item.isSelect
13
+ onClick(item);
14
+ }} style={{
15
+ direction: 'ltr',
16
+ backgroundColor: item === selectedCenter ? themeColor : themeColor + '00'
17
+ }} className={'relative block h-fit w-full bg-amber-200 py-[15px] text-left ' +
18
+ `${item === selectedCenter
17
19
  ? 'rounded-[15px] text-[#fff] max-2sm:rounded-[10px] '
18
20
  : 'hover:bg-[#b99c6e1a] '}`} onMouseOver={e => {
19
- if (!item.isSelect)
21
+ if (item !== selectedCenter)
20
22
  e.currentTarget.style.backgroundColor = themeColor + '15';
21
23
  }} onMouseOut={e => {
22
- if (!item.isSelect)
24
+ if (item !== selectedCenter)
23
25
  e.currentTarget.style.backgroundColor = themeColor + '00';
24
26
  }}>
25
27
  <span className={'flex h-full w-full items-center justify-between gap-[10px] px-[20px] ' +
@@ -35,13 +37,13 @@ const CenterComponent = (props) => {
35
37
  {item.code_name}
36
38
  </p>
37
39
  <Image src={Arrow1} alt={'arrow'} width={24} height={43} className={'mr-[10px] h-auto w-[12px] ' +
38
- `${item.isSelect ? 'block ' : 'hidden '}` +
40
+ `${item === selectedCenter ? 'block ' : 'hidden '}` +
39
41
  //1280px
40
42
  'max-xl:w-[9px] ' +
41
43
  //520px
42
44
  'max-2sm:w-[6px]'}/>
43
45
  <Image src={Arrow2} alt={'arrow'} width={24} height={43} className={'mr-[10px] h-auto w-[12px] ' +
44
- `${item.isSelect ? 'hidden ' : 'block '}` +
46
+ `${item === selectedCenter ? 'hidden ' : 'block '}` +
45
47
  //1280px
46
48
  'max-xl:w-[9px] ' +
47
49
  //520px
@@ -9,11 +9,12 @@ import Arrow2 from '../../asset/images/categoryView/section9_arrow_02.webp';
9
9
  const CenterComponent = (props: {
10
10
  themeColor: string;
11
11
  centerList: ICenter[];
12
- onClick: (list: ICenter[]) => void;
12
+ selectedCenter: ICenter;
13
+ onClick: (center: ICenter) => void;
13
14
  hiddenTitle: boolean | undefined;
14
15
  currentCenterTitle: string;
15
16
  }) => {
16
- const { themeColor, centerList, onClick, hiddenTitle, currentCenterTitle } = props;
17
+ const { themeColor, centerList, selectedCenter, onClick, hiddenTitle, currentCenterTitle } = props;
17
18
  const currentCenter = props.centerList.filter(item => item.code_desc === currentCenterTitle);
18
19
 
19
20
  const CenterCon = (props: { item: ICenter }) => {
@@ -23,26 +24,25 @@ const CenterComponent = (props: {
23
24
  <button
24
25
  type="button"
25
26
  onClick={() => {
26
- const newCenters = centerList.map(i => ({
27
- ...i,
28
- isSelect: i.code === item.code
29
- }));
30
- onClick(newCenters);
27
+ onClick(item);
28
+ }}
29
+ style={{
30
+ direction: 'ltr',
31
+ backgroundColor: item === selectedCenter ? themeColor : themeColor + '00'
31
32
  }}
32
- style={{ direction: 'ltr', backgroundColor: item.isSelect ? themeColor : themeColor + '00' }}
33
33
  className={
34
34
  'relative block h-fit w-full bg-amber-200 py-[15px] text-left ' +
35
35
  `${
36
- item.isSelect
36
+ item === selectedCenter
37
37
  ? 'rounded-[15px] text-[#fff] max-2sm:rounded-[10px] '
38
38
  : 'hover:bg-[#b99c6e1a] '
39
39
  }`
40
40
  }
41
41
  onMouseOver={e => {
42
- if (!item.isSelect) e.currentTarget.style.backgroundColor = themeColor + '15';
42
+ if (item !== selectedCenter) e.currentTarget.style.backgroundColor = themeColor + '15';
43
43
  }}
44
44
  onMouseOut={e => {
45
- if (!item.isSelect) e.currentTarget.style.backgroundColor = themeColor + '00';
45
+ if (item !== selectedCenter) e.currentTarget.style.backgroundColor = themeColor + '00';
46
46
  }}
47
47
  >
48
48
  <span
@@ -72,7 +72,7 @@ const CenterComponent = (props: {
72
72
  height={43}
73
73
  className={
74
74
  'mr-[10px] h-auto w-[12px] ' +
75
- `${item.isSelect ? 'block ' : 'hidden '}` +
75
+ `${item === selectedCenter ? 'block ' : 'hidden '}` +
76
76
  //1280px
77
77
  'max-xl:w-[9px] ' +
78
78
  //520px
@@ -86,7 +86,7 @@ const CenterComponent = (props: {
86
86
  height={43}
87
87
  className={
88
88
  'mr-[10px] h-auto w-[12px] ' +
89
- `${item.isSelect ? 'hidden ' : 'block '}` +
89
+ `${item === selectedCenter ? 'hidden ' : 'block '}` +
90
90
  //1280px
91
91
  'max-xl:w-[9px] ' +
92
92
  //520px
@@ -2,7 +2,6 @@ export interface ICenter {
2
2
  code: string;
3
3
  code_name: string | null;
4
4
  code_desc: string | null;
5
- isSelect?: boolean;
6
5
  }
7
6
  export interface ICategory {
8
7
  idx: number;
@@ -2,7 +2,6 @@ export interface ICenter {
2
2
  code: string;
3
3
  code_name: string | null; //한글이름
4
4
  code_desc: string | null; //영어이름
5
- isSelect?: boolean;
6
5
  }
7
6
  export interface ICategory {
8
7
  idx: number;