From a63e31d982174822374e544be1f3fb0b9289fcc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=97=A4=EC=9D=B8?= Date: Mon, 5 Aug 2024 17:41:09 +0900 Subject: [PATCH 01/42] =?UTF-8?q?refactor(style):=20color=20dark=20<=3D>?= =?UTF-8?q?=20light=20=EB=B3=80=EC=88=98=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/style/color.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/style/color.ts b/frontend/src/style/color.ts index 5a746c9c5..3069030c0 100644 --- a/frontend/src/style/color.ts +++ b/frontend/src/style/color.ts @@ -1,4 +1,4 @@ -export const light = { +export const dark = { white: '#ffffff', black: '#000000', @@ -91,7 +91,7 @@ export const light = { triadic_secondary_900: '#00955c', }; -export const dark = { +export const light = { white: '#ffffff', black: '#000000', From 51f82fa0db5e3e4d1f5a99dc307959d30285d25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=97=A4=EC=9D=B8?= Date: Mon, 5 Aug 2024 17:42:20 +0900 Subject: [PATCH 02/42] =?UTF-8?q?feat(types):=20Tag,=20Category=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=ED=85=9C=ED=94=8C?= =?UTF-8?q?=EB=A6=BF=20=ED=83=80=EC=9E=85=EC=97=90=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/types/category.d.ts | 12 ++++++++++++ frontend/src/types/tag.d.ts | 4 ++++ frontend/src/types/template.ts | 12 ++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 frontend/src/types/category.d.ts create mode 100644 frontend/src/types/tag.d.ts diff --git a/frontend/src/types/category.d.ts b/frontend/src/types/category.d.ts new file mode 100644 index 000000000..a9acf4e64 --- /dev/null +++ b/frontend/src/types/category.d.ts @@ -0,0 +1,12 @@ +export interface Category { + id: number; + name: string; +} + +export interface CategoryList { + categories: Category[]; +} + +export interface CategoryRequest { + name: string; +} diff --git a/frontend/src/types/tag.d.ts b/frontend/src/types/tag.d.ts new file mode 100644 index 000000000..21ec96d0e --- /dev/null +++ b/frontend/src/types/tag.d.ts @@ -0,0 +1,4 @@ +export interface Tag { + id: number; + name: string; +} diff --git a/frontend/src/types/template.ts b/frontend/src/types/template.ts index 6e0977802..b4885412e 100644 --- a/frontend/src/types/template.ts +++ b/frontend/src/types/template.ts @@ -1,3 +1,6 @@ +import { Category } from './category'; +import { Tag } from './tag'; + export interface Snippet { id?: number; filename: string; @@ -8,7 +11,10 @@ export interface Snippet { export interface Template { id: number; title: string; + description: string; snippets: Snippet[]; + category: Category; + tags: Tag[]; modifiedAt: string; } @@ -28,12 +34,18 @@ export interface TemplateListResponse { export interface TemplateUploadRequest { title: string; + description: string; snippets: Snippet[]; + categoryId: number; + tags: string[]; } export interface TemplateEditRequest { title: string; + description: string; createSnippets: Snippet[]; updateSnippets: Snippet[]; deleteSnippetIds: number[]; + categoryId: number; + tags: string[]; } From 589f15ddbec6eb8fad3d7b90c880ea79e1b82120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=97=A4=EC=9D=B8?= Date: Mon, 5 Aug 2024 17:43:31 +0900 Subject: [PATCH 03/42] =?UTF-8?q?refactor(mocks):=20=ED=85=9C=ED=94=8C?= =?UTF-8?q?=EB=A6=BF=20mock=20data=20=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC,?= =?UTF-8?q?=20=ED=83=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/mocks/template.json | 33 +++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/frontend/src/mocks/template.json b/frontend/src/mocks/template.json index 538d7733c..de4c02f14 100644 --- a/frontend/src/mocks/template.json +++ b/frontend/src/mocks/template.json @@ -1,19 +1,38 @@ { "id": 2024, - "title": "회원가입 유효성 검증", + "title": "React 컴포넌트 기본 구조", + "description": "React 함수형 컴포넌트의 기본 구조와 props 타이핑", "snippets": [ { - "id": 305, - "filename": "filename1.txt", - "content": "import { Flex } from '@/components/Flex';\nimport { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport { monokaiSublime } from 'react-syntax-highlighter/dist/esm/styles/hljs';\n\nconst Template = () => {\n const content = '';\n return (\n <>\n \n

회원 가입 검증

\n CodeZap\n\n \n {content}\n \n
\n \n );\n};\n\nexport default Template", + "id": 101, + "filename": "MyComponent.tsx", + "content": "import React from 'react';\n\ninterface MyComponentProps {\n name: string;\n age: number;\n}\n\nconst MyComponent: React.FC = ({ name, age }) => {\n return (\n
\n

Hello, {name}!

\n

You are {age} years old.

\n
\n );\n};\n\nexport default MyComponent;", "ordinal": 1 }, { - "id": 306, - "filename": "filename2.java", - "content": "import { Flex } from '@/components/Flex';\nimport { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport { monokaiSublime } from 'react-syntax-highlighter/dist/esm/styles/hljs';\n\nconst Template = () => {\n const content = '';\n return (\n <>\n \n

회원 가입 검증

\n CodeZap\n\n \n {content}\n \n
\n \n );\n};\n\nexport default Template", + "id": 102, + "filename": "App.tsx", + "content": "import React from 'react';\nimport MyComponent from './MyComponent';\n\nconst App: React.FC = () => {\n return (\n
\n \n
\n );\n};\n\nexport default App;", "ordinal": 2 } ], + "category": { + "id": 2, + "name": "React" + }, + "tags": [ + { + "id": 1, + "name": "typescript" + }, + { + "id": 2, + "name": "component" + }, + { + "id": 3, + "name": "functional" + } + ], "modifiedAt": "2024-07-11 12:34" } From f2c54d124b92201b04ee3311cdab6900dfc3a78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=97=A4=EC=9D=B8?= Date: Mon, 5 Aug 2024 17:43:51 +0900 Subject: [PATCH 04/42] =?UTF-8?q?feat(mocks):=20=EC=B9=B4=ED=85=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=20mock=20data=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/mocks/categoryList.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 frontend/src/mocks/categoryList.json diff --git a/frontend/src/mocks/categoryList.json b/frontend/src/mocks/categoryList.json new file mode 100644 index 000000000..3c50e747d --- /dev/null +++ b/frontend/src/mocks/categoryList.json @@ -0,0 +1,20 @@ +{ + "categories": [ + { + "id": 1, + "name": "카테고리 없음" + }, + { + "id": 2, + "name": "카테고리1" + }, + { + "id": 3, + "name": "카테고리2" + }, + { + "id": 4, + "name": "카테고리3" + } + ] +} From 80a4be29000eaa36b7da76218b3620e55cca48f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=97=A4=EC=9D=B8?= Date: Mon, 5 Aug 2024 17:45:31 +0900 Subject: [PATCH 05/42] =?UTF-8?q?refactor(api):=20customFetch=20console.er?= =?UTF-8?q?ror(error)=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/customFetch.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/api/customFetch.ts b/frontend/src/api/customFetch.ts index 848578e8f..11f3e880f 100644 --- a/frontend/src/api/customFetch.ts +++ b/frontend/src/api/customFetch.ts @@ -35,6 +35,7 @@ export const customFetch = async ({ return data; } catch (error) { + console.error(error); throw new Error(errorMessage); } }; From 7d8ec71a306b6dc6e8e7a98d9eb347f8fe622853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=97=A4=EC=9D=B8?= Date: Mon, 5 Aug 2024 17:46:40 +0900 Subject: [PATCH 06/42] =?UTF-8?q?feat(api):=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20api=20=EC=97=B0=EA=B2=B0=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/category.ts | 18 ++++++++++++++++++ frontend/src/api/index.ts | 1 + frontend/src/api/queryKeys.ts | 1 + 3 files changed, 20 insertions(+) create mode 100644 frontend/src/api/category.ts diff --git a/frontend/src/api/category.ts b/frontend/src/api/category.ts new file mode 100644 index 000000000..f8cf8b650 --- /dev/null +++ b/frontend/src/api/category.ts @@ -0,0 +1,18 @@ +import { CategoryList, CategoryRequest } from '@/types/category'; +import { customFetch } from './customFetch'; + +const API_URL = process.env.REACT_APP_API_URL; + +export const CATEGORY_API_URL = `${API_URL}/categories`; + +export const getCategoryList = async (): Promise => + await customFetch({ + url: `${CATEGORY_API_URL}`, + }); + +export const postCategory = async (newCategory: CategoryRequest) => + await customFetch({ + method: 'POST', + url: `${CATEGORY_API_URL}`, + body: JSON.stringify(newCategory), + }); diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index b23ac44fe..94277e752 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -1,3 +1,4 @@ export { customFetch } from './customFetch'; export { QUERY_KEY } from './queryKeys'; export { TEMPLATE_API_URL, getTemplateList, getTemplate, postTemplate } from './templates'; +export { CATEGORY_API_URL, getCategoryList, postCategory } from './category'; diff --git a/frontend/src/api/queryKeys.ts b/frontend/src/api/queryKeys.ts index 59c59a78e..3c4bffd41 100644 --- a/frontend/src/api/queryKeys.ts +++ b/frontend/src/api/queryKeys.ts @@ -1,4 +1,5 @@ export const QUERY_KEY = { TEMPLATE: 'template', TEMPLATE_LIST: 'templateList', + CATEGORY: 'category', }; From 401166582f51a71d8e6df34bb6026f2cd3314e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=97=A4=EC=9D=B8?= Date: Mon, 5 Aug 2024 17:49:34 +0900 Subject: [PATCH 07/42] =?UTF-8?q?refactor(api):=20=ED=85=9C=ED=94=8C?= =?UTF-8?q?=EB=A6=BF=20=EB=93=B1=EB=A1=9D=20=ED=9B=84=20=EB=B0=94=EB=A1=9C?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9D=B4=EB=8F=99=EC=9D=84=20?= =?UTF-8?q?=EC=9C=84=ED=95=B4=20postTemplate=20return=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/templates.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/api/templates.ts b/frontend/src/api/templates.ts index 5909a4f1d..f570253a0 100644 --- a/frontend/src/api/templates.ts +++ b/frontend/src/api/templates.ts @@ -15,13 +15,12 @@ export const getTemplate = async (id: number): Promise