From 95a9a24d74549f8622e2e29c6a82bb2409646001 Mon Sep 17 00:00:00 2001
From: NaveOWO <87578512+NaveOWO@users.noreply.github.com>
Date: Wed, 27 Dec 2023 00:45:44 +0900
Subject: [PATCH 01/12] =?UTF-8?q?chore:=20ck-util-component=20=EB=9D=BC?=
=?UTF-8?q?=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EC=84=A4=EC=B9=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
client/package.json | 1 +
client/tsconfig.json | 6 +++++-
client/webpack.common.js | 4 ++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/client/package.json b/client/package.json
index a636936de..13d5e694d 100644
--- a/client/package.json
+++ b/client/package.json
@@ -34,6 +34,7 @@
"ajv": "^8.12.0",
"axios": "^1.4.0",
"babel-plugin-transform-builtin-extend": "^1.1.2",
+ "ck-util-components": "^1.3.12",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-lightweight-form": "^1.2.5",
diff --git a/client/tsconfig.json b/client/tsconfig.json
index bd5cb3eec..90145f077 100644
--- a/client/tsconfig.json
+++ b/client/tsconfig.json
@@ -6,9 +6,10 @@
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
+
"allowSyntheticDefaultImports": true,
"strict": true,
- "forceConsistentCasingInFileNames": true,
+ "forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
@@ -35,5 +36,8 @@
"@icons/*": ["src/icons/*"]
}
},
+ "paths": {
+ "ck-util-components/*": ["node_modules/ck-util-components/dist/lib/*"]
+ },
"include": ["./src"]
}
diff --git a/client/webpack.common.js b/client/webpack.common.js
index 0844bcd8b..f405eaaff 100644
--- a/client/webpack.common.js
+++ b/client/webpack.common.js
@@ -32,6 +32,10 @@ module.exports = {
'@styles': path.resolve(__dirname, 'src/styles'),
'@myTypes': path.resolve(__dirname, 'src/myTypes'),
'@utils': path.resolve(__dirname, 'src/utils'),
+ 'ck-util-components': path.resolve(
+ __dirname,
+ 'node_modules/ck-util-components/dist/lib'
+ ),
},
},
From 94d4c585c487074f6da4df8c413249e9ac047416 Mon Sep 17 00:00:00 2001
From: NaveOWO <87578512+NaveOWO@users.noreply.github.com>
Date: Wed, 27 Dec 2023 00:47:02 +0900
Subject: [PATCH 02/12] =?UTF-8?q?refactor:=20roadmap=20create=20select?=
=?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=9C=A0=ED=8B=B8=20?=
=?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EC=A0=81?=
=?UTF-8?q?=EC=9A=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../roadmapCreatePage/category/Category.tsx | 41 +++++++++----------
client/src/constants/roadmap/category.ts | 5 ---
.../hooks/roadmap/useCollectRoadmapData.ts | 6 +--
client/src/myTypes/roadmap/internal.ts | 2 +-
4 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/client/src/components/roadmapCreatePage/category/Category.tsx b/client/src/components/roadmapCreatePage/category/Category.tsx
index 7b8efca2e..9ea30272c 100644
--- a/client/src/components/roadmapCreatePage/category/Category.tsx
+++ b/client/src/components/roadmapCreatePage/category/Category.tsx
@@ -2,49 +2,46 @@ import { CategoriesInfo } from '@/constants/roadmap/category';
import { useSelect } from '@/hooks/_common/useSelect';
import { getInvariantObjectKeys, invariantOf } from '@/utils/_common/invariantType';
import { useEffect } from 'react';
-import { Select, SelectBox } from '../selector/SelectBox';
+import { Select } from 'ck-util-components';
import { S } from './category.styles';
-// 임시 더미데이터
-export type DummyCategoryType = {
- [key: number]: string;
-};
-
type CategoryProps = {
- getSelectedCategoryId: (category: keyof DummyCategoryType | null) => void;
+ getSelectedCategoryId: (category: keyof typeof CategoriesInfo) => void;
};
const Category = ({ getSelectedCategoryId }: CategoryProps) => {
- const { selectOption, selectedOption } = useSelect();
+ const { selectOption, selectedOption } = useSelect();
useEffect(() => {
- getSelectedCategoryId(selectedOption);
+ if (selectedOption !== null) {
+ getSelectedCategoryId(selectedOption);
+ }
}, [selectedOption]);
return (
-
-
-
- 카테고리*
-
-
-
-
- 컨텐츠에 어울리는 카테고리를 선택해주세요.
-
-
+
+
);
};
diff --git a/client/src/constants/roadmap/category.ts b/client/src/constants/roadmap/category.ts
index cc93773e0..c60c2b875 100644
--- a/client/src/constants/roadmap/category.ts
+++ b/client/src/constants/roadmap/category.ts
@@ -1,9 +1,4 @@
export const CategoriesInfo = {
- // 0: {
- // id: 0,
- // name: '전체',
- // iconName: 'AllCategoryIcon',
- // },
1: {
id: 1,
name: '어학',
diff --git a/client/src/hooks/roadmap/useCollectRoadmapData.ts b/client/src/hooks/roadmap/useCollectRoadmapData.ts
index d5b1658f1..9505a6d4f 100644
--- a/client/src/hooks/roadmap/useCollectRoadmapData.ts
+++ b/client/src/hooks/roadmap/useCollectRoadmapData.ts
@@ -1,4 +1,4 @@
-import { DummyCategoryType } from '@/components/roadmapCreatePage/category/Category';
+import { CategoriesInfo } from '@/constants/roadmap/category';
import {
DifficultyKeyType,
NodeImagesType,
@@ -23,10 +23,10 @@ export const useCollectRoadmapData = () => {
const [isSumbited, setIsSubmited] = useState(false);
const { createRoadmap } = useCreateRoadmap();
- const getSelectedCategoryId = (category: keyof DummyCategoryType | null) => {
+ const getSelectedCategoryId = (category: keyof typeof CategoriesInfo) => {
setRoadmapValue((prev) => ({
...prev,
- categoryId: category,
+ categoryId: CategoriesInfo[category].id,
}));
};
diff --git a/client/src/myTypes/roadmap/internal.ts b/client/src/myTypes/roadmap/internal.ts
index 833f88e3c..c40030197 100644
--- a/client/src/myTypes/roadmap/internal.ts
+++ b/client/src/myTypes/roadmap/internal.ts
@@ -71,7 +71,7 @@ export type RoadmapNodes = {
};
export type RoadmapValueType = {
- categoryId: null | number;
+ categoryId: number | null;
title: null | string;
introduction: null | string;
content: null | string;
From e2fd3476f93b34b9b1e4e530c8967a2d47dda216 Mon Sep 17 00:00:00 2001
From: NaveOWO <87578512+NaveOWO@users.noreply.github.com>
Date: Wed, 27 Dec 2023 00:48:46 +0900
Subject: [PATCH 03/12] =?UTF-8?q?refactor:=20goalroom=20filter=20select?=
=?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=9C=A0=ED=8B=B8=20?=
=?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EC=A0=81?=
=?UTF-8?q?=EC=9A=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../goalRoomList/GoalRoomFilter.tsx | 52 ++++++++++++-------
.../goalRoomList/GoalRoomList.tsx | 26 +++-------
2 files changed, 40 insertions(+), 38 deletions(-)
diff --git a/client/src/components/goalRoomListPage/goalRoomList/GoalRoomFilter.tsx b/client/src/components/goalRoomListPage/goalRoomList/GoalRoomFilter.tsx
index 1a5876466..e9f47b266 100644
--- a/client/src/components/goalRoomListPage/goalRoomList/GoalRoomFilter.tsx
+++ b/client/src/components/goalRoomListPage/goalRoomList/GoalRoomFilter.tsx
@@ -1,33 +1,47 @@
-import { Select } from '@/components/roadmapCreatePage/selector/SelectBox';
+import { Select } from 'ck-util-components';
import { goalRoomFilter } from '@/constants/goalRoom/goalRoomFilter';
-import React, { useState } from 'react';
+import { useState } from 'react';
import * as S from './goalRoomList.styles';
+import { getInvariantObjectKeys, invariantOf } from '@/utils/_common/invariantType';
-const GoalRoomFilter = ({
- children,
-}: {
- children: (
- selectedOption: (typeof goalRoomFilter)[keyof typeof goalRoomFilter]
- ) => React.ReactNode;
-}) => {
- const [selectedOption, setSelectedOption] = useState<
- (typeof goalRoomFilter)[keyof typeof goalRoomFilter]
- >(goalRoomFilter['1']);
+interface GoalRoomFilterProps {
+ sortedOption: (typeof goalRoomFilter)[keyof typeof goalRoomFilter];
+ selectOption: (option: keyof typeof goalRoomFilter) => void;
+}
- const selectFilterOption = (id: number) => {
- // eslint-disable-next-line no-prototype-builtins
- if (goalRoomFilter.hasOwnProperty(id)) {
- setSelectedOption(goalRoomFilter[id as keyof typeof goalRoomFilter]);
+const GoalRoomFilter = ({ sortedOption, selectOption }: GoalRoomFilterProps) => {
+ const [filterOpen, setFilterOpen] = useState(false);
+
+ const toggleFilter = () => {
+ if (filterOpen) {
+ setFilterOpen(false);
+ } else {
+ setFilterOpen(true);
}
};
return (
-
);
diff --git a/client/src/components/goalRoomListPage/goalRoomList/GoalRoomList.tsx b/client/src/components/goalRoomListPage/goalRoomList/GoalRoomList.tsx
index fd49a3823..e5599c83d 100644
--- a/client/src/components/goalRoomListPage/goalRoomList/GoalRoomList.tsx
+++ b/client/src/components/goalRoomListPage/goalRoomList/GoalRoomList.tsx
@@ -2,19 +2,19 @@ import * as S from './goalRoomList.styles';
import GoalRoomItem from './GoalRoomItem';
import { useGoalRoomList } from '@/hooks/queries/goalRoom';
import useValidParams from '@/hooks/_common/useValidParams';
-import GoalRoomFilter from './GoalRoomFilter';
-import { Select } from '@/components/roadmapCreatePage/selector/SelectBox';
import { useState } from 'react';
import { FILTER_COND, goalRoomFilter } from '@/constants/goalRoom/goalRoomFilter';
import { useInfiniteScroll } from '@hooks/_common/useInfiniteScroll';
import WavyLoading from '@components/_common/wavyLoading/WavyLoading';
import { Link } from 'react-router-dom';
+import GoalRoomFilter from './GoalRoomFilter';
const GoalRoomList = () => {
const { id } = useValidParams<{ id: string }>();
const [sortedOption, setSortedOption] = useState<
(typeof goalRoomFilter)[keyof typeof goalRoomFilter]
>(goalRoomFilter['1']);
+
const {
goalRoomListResponse: { responses: goalRoomList, hasNext },
fetchNextPage,
@@ -33,6 +33,10 @@ const GoalRoomList = () => {
(goalRoomInfo) => goalRoomInfo.status === 'RECRUITING'
);
+ const selectOption = (option: keyof typeof goalRoomFilter) => {
+ setSortedOption(goalRoomFilter[option]);
+ };
+
return (
@@ -44,23 +48,7 @@ const GoalRoomList = () => {
}
개
-
- {(selectedOption) => {
- setSortedOption(selectedOption);
- return (
-
-
-
- {goalRoomFilter['1']}
-
-
- {goalRoomFilter['2']}
-
-
-
- );
- }}
-
+
{RecruitingGoalRoomList.length ? (
From 2cee9fdf5e10ffe7ebbe04200dcfbe16b7cda9ea Mon Sep 17 00:00:00 2001
From: NaveOWO <87578512+NaveOWO@users.noreply.github.com>
Date: Wed, 27 Dec 2023 00:50:03 +0900
Subject: [PATCH 04/12] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?=
=?UTF-8?q?=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../roadmapCreateForm/RoadmapCreateForm.tsx | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/client/src/components/roadmapCreatePage/roadmapCreateForm/RoadmapCreateForm.tsx b/client/src/components/roadmapCreatePage/roadmapCreateForm/RoadmapCreateForm.tsx
index 2c11169b6..ccfc66a3a 100644
--- a/client/src/components/roadmapCreatePage/roadmapCreateForm/RoadmapCreateForm.tsx
+++ b/client/src/components/roadmapCreatePage/roadmapCreateForm/RoadmapCreateForm.tsx
@@ -1,5 +1,4 @@
import { useCollectRoadmapData } from '@/hooks/roadmap/useCollectRoadmapData';
-import React, { createContext, PropsWithChildren, useRef } from 'react';
import Category from '../category/Category';
import Description from '../description/Description';
import Difficulty from '../difficulty/Difficulty';
@@ -11,18 +10,6 @@ import Tag from '../tag/Tag';
import Title from '../title/Title';
import * as S from './roadmapCreateForm.styles';
-// ref공유를 위한 context - 다음 브랜치에서 파일 옮길 예정
-const FormRefContext = createContext<{ ref: React.MutableRefObject | null }>({
- ref: null,
-});
-
-const RefProvider = ({ children }: PropsWithChildren) => {
- const ref = useRef();
-
- return {children};
-};
-//
-
const RoadmapCreateForm = () => {
const {
roadmapValue,
@@ -36,7 +23,7 @@ const RoadmapCreateForm = () => {
} = useCollectRoadmapData();
return (
-
+ <>
로드맵
을 생성해주세요
@@ -75,7 +62,7 @@ const RoadmapCreateForm = () => {
로드맵 생성완료
-
+ >
);
};
From db42b2ac711292e4fbda097c25d9bb89926f3592 Mon Sep 17 00:00:00 2001
From: NaveOWO <87578512+NaveOWO@users.noreply.github.com>
Date: Wed, 27 Dec 2023 03:23:18 +0900
Subject: [PATCH 05/12] =?UTF-8?q?refactor:=20roadmap=20create=20=EB=82=9C?=
=?UTF-8?q?=EC=9D=B4=EB=8F=84=20select=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8?=
=?UTF-8?q?=20=EC=9C=A0=ED=8B=B8=20=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC?=
=?UTF-8?q?=EB=A6=AC=20=EC=A0=81=EC=9A=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../difficulty/Difficulty.tsx | 62 ++++++++-----------
.../difficulty/difficulty.styles.ts | 6 ++
2 files changed, 33 insertions(+), 35 deletions(-)
diff --git a/client/src/components/roadmapCreatePage/difficulty/Difficulty.tsx b/client/src/components/roadmapCreatePage/difficulty/Difficulty.tsx
index c5b07ce0a..4e61e00c4 100644
--- a/client/src/components/roadmapCreatePage/difficulty/Difficulty.tsx
+++ b/client/src/components/roadmapCreatePage/difficulty/Difficulty.tsx
@@ -1,9 +1,13 @@
/* eslint-disable react/no-unused-prop-types */
import { useSelect } from '@/hooks/_common/useSelect';
import { DifficultiesType, DifficultyKeyType } from '@/myTypes/roadmap/internal';
-import { getInvariantObjectKeys, invariantOf } from '@/utils/_common/invariantType';
+import {
+ getInvariantObjectKeys,
+ getInvariantObjectValues,
+ invariantOf,
+} from '@/utils/_common/invariantType';
import { useEffect } from 'react';
-import { Select, SelectBox } from '../selector/SelectBox';
+import { Select } from 'ck-util-components';
import * as S from './difficulty.styles';
const Difficulties: DifficultiesType = {
@@ -19,54 +23,42 @@ type DifficultyProps = {
};
const Difficulty = ({ getSelectedDifficulty }: DifficultyProps) => {
- const { selectOption, selectedOption } = useSelect();
+ const { selectOption, selectedOption } = useSelect();
useEffect(() => {
if (selectedOption === null) return;
- getSelectedDifficulty(
- getInvariantObjectKeys(invariantOf(Difficulties))[selectedOption]
- );
+ getSelectedDifficulty(selectedOption);
}, [selectedOption]);
return (
-
-
-
- 난이도*
-
-
-
-
- 컨텐츠의 달성 난이도를 선택해주세요
-
-
+
+
+ 난이도*
+
+
+ 컨텐츠의 달성 난이도를 선택해주세요
+
-
-
- {({ selectedId }: { selectedId: number | null }) => {
- return (
-
- {selectedId === null
- ? '선택안함'
- : Difficulties[
- getInvariantObjectKeys(invariantOf(Difficulties))[selectedId]
- ]}
-
- );
- }}
-
+
+ {selectedOption ?? '선택안함'}
{getInvariantObjectKeys(invariantOf(Difficulties)).map((difficulty, idx) => {
return (
-
+
-
+
-
+
{Difficulties[difficulty]}
@@ -74,7 +66,7 @@ const Difficulty = ({ getSelectedDifficulty }: DifficultyProps) => {
})}
-
+
);
};
diff --git a/client/src/components/roadmapCreatePage/difficulty/difficulty.styles.ts b/client/src/components/roadmapCreatePage/difficulty/difficulty.styles.ts
index 7d6684b0b..7089b6992 100644
--- a/client/src/components/roadmapCreatePage/difficulty/difficulty.styles.ts
+++ b/client/src/components/roadmapCreatePage/difficulty/difficulty.styles.ts
@@ -34,6 +34,12 @@ export const Wrapper = styled.ul`
`;
export const TriggerButton = styled.button`
+ cursor: pointer;
+
+ display: flex;
+ align-items: center;
+ justify-content: center;
+
width: 15.4rem;
height: 4rem;
From 0044a56f0c3101a6882f89deb91fbf91dab13b5f Mon Sep 17 00:00:00 2001
From: NaveOWO <87578512+NaveOWO@users.noreply.github.com>
Date: Wed, 27 Dec 2023 03:24:05 +0900
Subject: [PATCH 06/12] =?UTF-8?q?feat:=20invariantType=20=ED=95=A8?=
=?UTF-8?q?=EC=88=98=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
client/src/utils/_common/invariantType.ts | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/client/src/utils/_common/invariantType.ts b/client/src/utils/_common/invariantType.ts
index 7a59183fc..3238c1e3f 100644
--- a/client/src/utils/_common/invariantType.ts
+++ b/client/src/utils/_common/invariantType.ts
@@ -23,3 +23,13 @@ export function invariantOf(value: T): InvariantOf {
export function getInvariantObjectKeys(arg: InvariantOf): (keyof T)[] {
return Object.keys(arg) as unknown as (keyof T)[];
}
+
+export function getInvariantObjectValues(arg: InvariantOf): T[keyof T][] {
+ return Object.values(arg) as unknown as T[keyof T][];
+}
+
+export function getInvariantObjectEntries(
+ arg: InvariantOf
+): [keyof T, T[keyof T]][] {
+ return Object.entries(arg) as unknown as [keyof T, T[keyof T]][];
+}
From aebf1f2aa802eac7bf0e78aff5197d492b79d7c0 Mon Sep 17 00:00:00 2001
From: NaveOWO <87578512+NaveOWO@users.noreply.github.com>
Date: Wed, 27 Dec 2023 03:50:01 +0900
Subject: [PATCH 07/12] =?UTF-8?q?refactor:=20roadmap=20search=20select?=
=?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=9C=A0=ED=8B=B8=20?=
=?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EC=A0=81?=
=?UTF-8?q?=EC=9A=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../roadmapSearch/RoadmapSearch.tsx | 53 +++++++++++--------
1 file changed, 31 insertions(+), 22 deletions(-)
diff --git a/client/src/components/roadmapListPage/roadmapSearch/RoadmapSearch.tsx b/client/src/components/roadmapListPage/roadmapSearch/RoadmapSearch.tsx
index 1bded6fbb..b0cceeb2b 100644
--- a/client/src/components/roadmapListPage/roadmapSearch/RoadmapSearch.tsx
+++ b/client/src/components/roadmapListPage/roadmapSearch/RoadmapSearch.tsx
@@ -1,15 +1,10 @@
import { SearchIcon } from '@/components/icons/svgIcons';
-import { Select } from '@/components/roadmapCreatePage/selector/SelectBox';
+import { getInvariantObjectKeys, invariantOf } from '@/utils/_common/invariantType';
+import { Select } from 'ck-util-components';
import { FormEvent, useRef, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import * as S from './roadmapSearch.styles';
-const searchCategoryKeyword = {
- 1: 'tagName',
- 2: 'roadmapTitle',
- 3: 'creatorName',
-} as const;
-
const searchCategorySelection = {
tagName: '태그',
roadmapTitle: '로드맵 제목',
@@ -22,12 +17,15 @@ const RoadmapSearch = () => {
const [searchCategory, setSearchCategory] = useState<
'tagName' | 'roadmapTitle' | 'creatorName'
>('roadmapTitle');
+ const [categoryOpen, setCategoryOpen] = useState(false);
+
+ const selectSearchCategory = (option: keyof typeof searchCategorySelection) => {
+ setSearchCategory(option);
+ };
- const selectSearchCategory = (id: number) => {
- // eslint-disable-next-line no-prototype-builtins
- if (searchCategory.hasOwnProperty(id)) {
- setSearchCategory(searchCategoryKeyword[id as keyof typeof searchCategoryKeyword]);
- }
+ const toggleSearchCategory = () => {
+ // eslint-disable-next-line no-unused-expressions
+ categoryOpen ? setCategoryOpen(false) : setCategoryOpen(true);
};
const searchRoadmap = (e: FormEvent) => {
@@ -42,7 +40,12 @@ const RoadmapSearch = () => {