From 3afe009abdb038de5cba03cc76bfaa3ecfddf014 Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:11:53 +0900 Subject: [PATCH 01/18] =?UTF-8?q?chore(getPost):=20getPost=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=9E=84=EC=8B=9C=EB=A1=9C=20=EC=84=A0?= =?UTF-8?q?=EC=96=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/httpClient/httpClient.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/apis/httpClient/httpClient.ts b/src/apis/httpClient/httpClient.ts index 08d07333..54678343 100644 --- a/src/apis/httpClient/httpClient.ts +++ b/src/apis/httpClient/httpClient.ts @@ -4,6 +4,9 @@ import Storage from "@/apis/storage"; import refreshToken from "@/apis/token/refreshToken"; import TOKEN from "@/global/constants/token.constant"; import IClassLevel from "@/global/types/classLevel.type"; +import KEY from "@/global/constants/key.constant"; +import { QueryClient } from "react-query"; +import IPostQuery from "@/global/types/postQuery.type"; export interface HttpClientConfig { baseURL?: string; @@ -61,6 +64,20 @@ export class HttpClient { }); } + getPost(postConfig: IPostQuery, requestConfig?: AxiosRequestConfig) { + const { postType, category } = postConfig; + const postRenderLimit = Storage.getItem(TOKEN.POST_RENDER_LIMIT); + + const query = `https://bssm.kro.kr/api/post/${ + postType === "free" ? "board" : postType + }/recent?startPostId=-1&limit=${postRenderLimit}&category=${category}`; + + return this.api.get(query, { + ...HttpClient.clientConfig, + ...requestConfig, + }); + } + post(data: unknown, requestConfig?: AxiosRequestConfig) { return this.api.post("", data, { ...HttpClient.clientConfig, @@ -109,12 +126,12 @@ export class HttpClient { private setting() { HttpClient.setCommonInterceptors(this.api); - // const queryClient = new QueryClient(); + const queryClient = new QueryClient(); this.api.interceptors.response.use( (response) => response, (error) => { - // queryClient.invalidateQueries("getUser"); + queryClient.invalidateQueries(KEY.USER); refreshToken(); return Promise.reject(error); }, @@ -148,4 +165,5 @@ export default { oauth: new HttpClient("api/auth/oauth/bsm", axiosConfig), user: new HttpClient("api/user", axiosConfig), timetable: new HttpClient("api/timetable", axiosConfig), + post: new HttpClient("api/post/", axiosConfig), }; From 5d72fae7af8b8f2592aec0fb888647251fff3a37 Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:12:05 +0900 Subject: [PATCH 02/18] =?UTF-8?q?chore(LocalStorageKey):=20post=20render?= =?UTF-8?q?=20limit=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/storage/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apis/storage/index.ts b/src/apis/storage/index.ts index 741aa481..6bc1f4b5 100644 --- a/src/apis/storage/index.ts +++ b/src/apis/storage/index.ts @@ -1,4 +1,4 @@ -type LocalStorageKey = "access_token" | "refresh_token"; +type LocalStorageKey = "access_token" | "refresh_token" | "post_render_limit"; export default class Storage { static getItem(key: LocalStorageKey) { From 1142591a33ccbe6e08832a629b8288bee396d7b8 Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:12:31 +0900 Subject: [PATCH 03/18] =?UTF-8?q?refactor(import):=20forum=20import=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global/assets/data/categories.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/global/assets/data/categories.ts b/src/global/assets/data/categories.ts index 34aa9631..74cf995e 100644 --- a/src/global/assets/data/categories.ts +++ b/src/global/assets/data/categories.ts @@ -1,4 +1,4 @@ -import forum from "@/page/forum/constants/forum.constant"; +import forum from "@/global/constants/forum.constant"; const categories = [ { From b8aa461ede028b35a38326c27c8d49aa8193d75e Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:12:43 +0900 Subject: [PATCH 04/18] =?UTF-8?q?refactor(forum):=20forum=20type=20?= =?UTF-8?q?=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global/constants/forum.constant.ts | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/global/constants/forum.constant.ts diff --git a/src/global/constants/forum.constant.ts b/src/global/constants/forum.constant.ts new file mode 100644 index 00000000..d09ec832 --- /dev/null +++ b/src/global/constants/forum.constant.ts @@ -0,0 +1,53 @@ +import PostCategoryType from "../types/postCategory.type"; + +interface IForum { + free: { + name: string; + type: string; + }; + student: { + name: string; + type: string; + }; + name: string; + type: string; + category: { + [categoryName: string]: { + name: string; + type: PostCategoryType; + }; + }; +} + +const forum: IForum = { + free: { + name: "자유", + type: "free", + }, + student: { + name: "학생", + type: "student", + }, + name: "forum", + type: "radio", + category: { + all: { + name: "전체", + type: "all", + }, + complain: { + name: "불만", + type: "complain", + }, + humor: { + name: "유머", + type: "humor", + }, + infomation: { + name: "정보", + type: "information", + }, + }, +}; + +export default forum; From 21798eefd092cea377078be626ff198b2fbbe793 Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:12:51 +0900 Subject: [PATCH 05/18] =?UTF-8?q?chore(key):=20POST=20key=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global/constants/key.constant.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/global/constants/key.constant.ts b/src/global/constants/key.constant.ts index c8b00322..462c694e 100644 --- a/src/global/constants/key.constant.ts +++ b/src/global/constants/key.constant.ts @@ -1,6 +1,7 @@ const KEY = { USER: "useUser", TIMETABLE: "useTimetable", + POST: "usePost", } as const; export default KEY; From b616425c93235c04f55cc0fd613986820f6bda4b Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:13:25 +0900 Subject: [PATCH 06/18] =?UTF-8?q?chore(constant):=20IToken=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global/constants/lostfound.constant.ts | 12 ++++++++++++ src/global/constants/token.constant.ts | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 src/global/constants/lostfound.constant.ts diff --git a/src/global/constants/lostfound.constant.ts b/src/global/constants/lostfound.constant.ts new file mode 100644 index 00000000..69bfa25c --- /dev/null +++ b/src/global/constants/lostfound.constant.ts @@ -0,0 +1,12 @@ +const lostfound = { + lost: { + name: "분실", + type: "lost", + }, + found: { + name: "습득", + type: "found", + }, +}; + +export default lostfound; diff --git a/src/global/constants/token.constant.ts b/src/global/constants/token.constant.ts index 375544d7..2b2354b4 100644 --- a/src/global/constants/token.constant.ts +++ b/src/global/constants/token.constant.ts @@ -1,6 +1,11 @@ +export interface IToken { + [TOKEN: string]: "access_token" | "refresh_token" | "post_render_limit"; +} + const TOKEN = { ACCESS: "access_token", REFRESH: "refresh_token", + POST_RENDER_LIMIT: "post_render_limit", } as const; export default TOKEN; From e299a2a27e9deddec9c9a5f0c03a357339843c76 Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:13:42 +0900 Subject: [PATCH 07/18] =?UTF-8?q?chore(type):=20IPost=20=ED=83=80=EC=9E=85?= =?UTF-8?q?=20=EC=84=A0=EC=96=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global/types/post.type.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/global/types/post.type.ts diff --git a/src/global/types/post.type.ts b/src/global/types/post.type.ts new file mode 100644 index 00000000..17a3c34f --- /dev/null +++ b/src/global/types/post.type.ts @@ -0,0 +1,15 @@ +import PostCategoryType from "./postCategory.type"; + +export default interface IPost { + id: string; + user: { + code: number; + nickname: string; + }; + category: PostCategoryType; + title: string; + createdAt: string; + view: number; + totalComments: number; + totalLikes: number; +} From 77d0471e12214869cbebff6afbccf467a7e153ed Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:13:54 +0900 Subject: [PATCH 08/18] =?UTF-8?q?chore(type):=20postCategoryType=20?= =?UTF-8?q?=EC=84=A0=EC=96=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global/types/postCategory.type.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/global/types/postCategory.type.ts diff --git a/src/global/types/postCategory.type.ts b/src/global/types/postCategory.type.ts new file mode 100644 index 00000000..fb09a2ac --- /dev/null +++ b/src/global/types/postCategory.type.ts @@ -0,0 +1,3 @@ +type PostCategoryType = "all" | "complain" | "humor" | "information"; + +export default PostCategoryType; From 27fa39fb97a658d0bf228e5983e9b5e7bcba25cd Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:14:00 +0900 Subject: [PATCH 09/18] =?UTF-8?q?chore(type):=20postQuery=20=EC=84=A0?= =?UTF-8?q?=EC=96=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global/types/postQuery.type.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/global/types/postQuery.type.ts diff --git a/src/global/types/postQuery.type.ts b/src/global/types/postQuery.type.ts new file mode 100644 index 00000000..2aef4b56 --- /dev/null +++ b/src/global/types/postQuery.type.ts @@ -0,0 +1,6 @@ +import PostCategoryType from "./postCategory.type"; + +export default interface IPostQuery { + postType: string; + category: PostCategoryType; +} From 192eb2e69d26812fbb66c03b2fbeb4554ea24e88 Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:14:12 +0900 Subject: [PATCH 10/18] =?UTF-8?q?refactor(timetable):=20IClassInfo?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global/types/timetable.type.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/global/types/timetable.type.ts b/src/global/types/timetable.type.ts index 9f29da8d..f1681445 100644 --- a/src/global/types/timetable.type.ts +++ b/src/global/types/timetable.type.ts @@ -1,5 +1,5 @@ -import IClass from "./classInfo.type"; +import IClassInfo from "./classInfo.type"; export default interface ITimetable { - [day: string]: IClass[]; + [day: string]: IClassInfo[]; } From 01a034b68ed201b3a0b3282066874b9b13f49b7d Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:14:34 +0900 Subject: [PATCH 11/18] =?UTF-8?q?chore(post):=20api=20=EC=97=B0=EA=B2=B0?= =?UTF-8?q?=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/forum/constants/forum.constant.ts | 32 ---------------------- src/page/forum/layouts/Categories.tsx | 3 +- src/page/forum/layouts/Forum.tsx | 14 ++++++++++ src/page/forum/layouts/ForumFilter.tsx | 2 +- 4 files changed, 17 insertions(+), 34 deletions(-) delete mode 100644 src/page/forum/constants/forum.constant.ts diff --git a/src/page/forum/constants/forum.constant.ts b/src/page/forum/constants/forum.constant.ts deleted file mode 100644 index d63f6833..00000000 --- a/src/page/forum/constants/forum.constant.ts +++ /dev/null @@ -1,32 +0,0 @@ -const forum = { - free: { - name: "자유", - type: "free", - }, - student: { - name: "학생", - type: "student", - }, - name: "forum", - type: "radio", - category: { - all: { - name: "전체", - type: "all", - }, - complain: { - name: "불만", - type: "complain", - }, - humor: { - name: "유머", - type: "humor", - }, - infomation: { - name: "정보", - type: "infomation", - }, - }, -}; - -export default forum; diff --git a/src/page/forum/layouts/Categories.tsx b/src/page/forum/layouts/Categories.tsx index 588dce56..e65a5f93 100644 --- a/src/page/forum/layouts/Categories.tsx +++ b/src/page/forum/layouts/Categories.tsx @@ -4,12 +4,13 @@ import React from "react"; import { useRecoilState } from "recoil"; import Category from "@/components/atoms/Category"; import categories from "@/global/assets/data/categories"; +import PostCategoryType from "@/global/types/postCategory.type"; const Categories = () => { const [checked, setChecked] = useRecoilState(categoriesStore); const onCheckCategory = (e: React.ChangeEvent) => { - setChecked(e.target.id); + setChecked(e.target.id as PostCategoryType); }; return ( diff --git a/src/page/forum/layouts/Forum.tsx b/src/page/forum/layouts/Forum.tsx index 8e0e7877..4b045baf 100644 --- a/src/page/forum/layouts/Forum.tsx +++ b/src/page/forum/layouts/Forum.tsx @@ -1,10 +1,24 @@ import React from "react"; import styled from "styled-components"; +import { useRecoilValue } from "recoil"; +import { categoriesStore } from "@/store/categories.store"; +import { forumFilterStore } from "@/store/forumType.store"; +import { useQueryClient } from "react-query"; +import KEY from "@/global/constants/key.constant"; import ForumFilter from "./ForumFilter"; import Categories from "./Categories"; import PostList from "./PostList"; +import { usePostListQuery } from "../services/query.service"; const Forum = () => { + const queryClient = useQueryClient(); + const postType = useRecoilValue(forumFilterStore); + const category = useRecoilValue(categoriesStore); + + React.useEffect(() => { + queryClient.invalidateQueries(KEY.POST); + }, [postType, category, queryClient]); + return ( diff --git a/src/page/forum/layouts/ForumFilter.tsx b/src/page/forum/layouts/ForumFilter.tsx index 964202a0..6ac6cd8d 100644 --- a/src/page/forum/layouts/ForumFilter.tsx +++ b/src/page/forum/layouts/ForumFilter.tsx @@ -2,7 +2,7 @@ import Row from "@/components/Flex/Row"; import { forumFilterStore } from "@/store/forumType.store"; import color from "@/styles/color"; import { font } from "@/styles/font"; -import forum from "@/page/forum/constants/forum.constant"; +import forum from "@/global/constants/forum.constant"; import React from "react"; import { useRecoilState } from "recoil"; import styled, { css, keyframes } from "styled-components"; From 31a2abf3996d3d8485f20d8f66703e33962bb2bf Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:14:48 +0900 Subject: [PATCH 12/18] =?UTF-8?q?feat(api):=20post=20list=20api=20?= =?UTF-8?q?=EC=84=A0=EC=96=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/forum/services/.gitkeep | 0 src/page/forum/services/api.service.ts | 11 +++++++++++ src/page/forum/services/query.service.ts | 9 +++++++++ 3 files changed, 20 insertions(+) delete mode 100644 src/page/forum/services/.gitkeep create mode 100644 src/page/forum/services/api.service.ts create mode 100644 src/page/forum/services/query.service.ts diff --git a/src/page/forum/services/.gitkeep b/src/page/forum/services/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/page/forum/services/api.service.ts b/src/page/forum/services/api.service.ts new file mode 100644 index 00000000..808ef13c --- /dev/null +++ b/src/page/forum/services/api.service.ts @@ -0,0 +1,11 @@ +import httpClient from "@/apis/httpClient"; +import IPostQuery from "@/global/types/postQuery.type"; + +export const getPostList = async (postConfig: IPostQuery) => { + try { + const { data } = await httpClient.post.getPost(postConfig); + return data.postList; + } catch (err) { + return err; + } +}; diff --git a/src/page/forum/services/query.service.ts b/src/page/forum/services/query.service.ts new file mode 100644 index 00000000..cc09d40e --- /dev/null +++ b/src/page/forum/services/query.service.ts @@ -0,0 +1,9 @@ +import KEY from "@/global/constants/key.constant"; +import IPost from "@/global/types/post.type"; +import { useQuery } from "react-query"; +import IPostQuery from "@/global/types/postQuery.type"; +import { getPostList } from "./api.service"; + +export const usePostListQuery = (postConfig: IPostQuery) => { + return useQuery([KEY.POST], async () => getPostList(postConfig)); +}; From 82f80179b1e45492655db371e719e99ee56554bc Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 17:15:07 +0900 Subject: [PATCH 13/18] =?UTF-8?q?refactor(import):=20global=EB=A1=9C=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/lostfound-write/layouts/InputBox.tsx | 2 +- src/page/lostfound-write/layouts/StateBox.tsx | 2 +- src/page/lostfound/constants/lostfound.constant.ts | 12 ------------ src/page/lostfound/layouts/LostFoundFIlter.tsx | 4 ++-- src/page/timetable/layouts/TimeTableBox.tsx | 7 ++----- src/store/categories.store.ts | 5 +++-- src/store/forumType.store.ts | 2 +- 7 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 src/page/lostfound/constants/lostfound.constant.ts diff --git a/src/page/lostfound-write/layouts/InputBox.tsx b/src/page/lostfound-write/layouts/InputBox.tsx index 776c0010..092f5445 100644 --- a/src/page/lostfound-write/layouts/InputBox.tsx +++ b/src/page/lostfound-write/layouts/InputBox.tsx @@ -1,7 +1,7 @@ import AnonymousBox from "@/components/atoms/AnonymousBox"; import CustomEditor from "@/components/atoms/CustomEditor"; import Input from "@/components/atoms/Input"; -import lostfound from "@/page/lostfound/constants/lostfound.constant"; +import lostfound from "@/global/constants/lostfound.constant"; import color from "@/styles/color"; import { font } from "@/styles/font"; import React from "react"; diff --git a/src/page/lostfound-write/layouts/StateBox.tsx b/src/page/lostfound-write/layouts/StateBox.tsx index 7bf9790b..d19d5f4b 100644 --- a/src/page/lostfound-write/layouts/StateBox.tsx +++ b/src/page/lostfound-write/layouts/StateBox.tsx @@ -1,7 +1,7 @@ import Column from "@/components/Flex/Column"; import Row from "@/components/Flex/Row"; import React from "react"; -import lostfoundKey from "@/page/lostfound/constants/lostfound.constant"; +import lostfoundKey from "@/global/constants/lostfound.constant"; import Category from "@/components/atoms/Category"; import styled from "styled-components"; import { font } from "@/styles/font"; diff --git a/src/page/lostfound/constants/lostfound.constant.ts b/src/page/lostfound/constants/lostfound.constant.ts deleted file mode 100644 index 69bfa25c..00000000 --- a/src/page/lostfound/constants/lostfound.constant.ts +++ /dev/null @@ -1,12 +0,0 @@ -const lostfound = { - lost: { - name: "분실", - type: "lost", - }, - found: { - name: "습득", - type: "found", - }, -}; - -export default lostfound; diff --git a/src/page/lostfound/layouts/LostFoundFIlter.tsx b/src/page/lostfound/layouts/LostFoundFIlter.tsx index 7b2f2cd9..d2edb425 100644 --- a/src/page/lostfound/layouts/LostFoundFIlter.tsx +++ b/src/page/lostfound/layouts/LostFoundFIlter.tsx @@ -1,10 +1,10 @@ import Row from "@/components/Flex/Row"; import color from "@/styles/color"; import { font } from "@/styles/font"; -import forum from "@/page/forum/constants/forum.constant"; +import forum from "@/global/constants/forum.constant"; import React from "react"; import styled, { css, keyframes } from "styled-components"; -import lostfound from "../constants/lostfound.constant"; +import lostfound from "../../../global/constants/lostfound.constant"; const filters = [ { diff --git a/src/page/timetable/layouts/TimeTableBox.tsx b/src/page/timetable/layouts/TimeTableBox.tsx index 86c5c341..d58bef87 100644 --- a/src/page/timetable/layouts/TimeTableBox.tsx +++ b/src/page/timetable/layouts/TimeTableBox.tsx @@ -3,7 +3,6 @@ import styled from "styled-components"; import useDate from "@/hooks/useDate"; import { useQueryClient } from "react-query"; import KEY from "@/global/constants/key.constant"; -import IClassLevel from "@/global/types/classLevel.type"; import TimeTableBar from "./TimeTableBar"; import { useTimetableListQuery } from "../services/queries.service"; import TimeTableCategory from "./TimeTableCategory"; @@ -11,16 +10,14 @@ import emptyTimetable from "../data/emptyTimetable"; import emptyClassLevel from "../data/emptyClassLevel"; const TimeTableBox = () => { + const queryClient = useQueryClient(); const { weekdaysKOR: weekdays, getNowWeekDay, translateDay } = useDate(); const [selectedDay, setSelectedDay] = React.useState( getNowWeekDay({ type: "KOR" }), ); - const [classLevel, setClassLevel] = - React.useState(emptyClassLevel); + const [classLevel, setClassLevel] = React.useState(emptyClassLevel); const [dayTimeTable, setDayTimeTable] = React.useState(emptyTimetable); - - const queryClient = useQueryClient(); const { data } = useTimetableListQuery(classLevel); React.useEffect(() => { diff --git a/src/store/categories.store.ts b/src/store/categories.store.ts index 59ebdbe5..aace29e2 100644 --- a/src/store/categories.store.ts +++ b/src/store/categories.store.ts @@ -1,7 +1,8 @@ -import forum from "@/page/forum/constants/forum.constant"; +import forum from "@/global/constants/forum.constant"; +import PostCategoryType from "@/global/types/postCategory.type"; import { atom } from "recoil"; -export const categoriesStore = atom({ +export const categoriesStore = atom({ key: "categoriesStore", default: forum.category.all.type, }); diff --git a/src/store/forumType.store.ts b/src/store/forumType.store.ts index 68fcefc2..21733ef7 100644 --- a/src/store/forumType.store.ts +++ b/src/store/forumType.store.ts @@ -1,4 +1,4 @@ -import forum from "@/page/forum/constants/forum.constant"; +import forum from "@/global/constants/forum.constant"; import { atom } from "recoil"; export const forumFilterStore = atom({ From 25e622cdd378b97a76b528130f6f6953edf2d09a Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 20:24:56 +0900 Subject: [PATCH 14/18] =?UTF-8?q?feat(msw):=20msw=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 + public/mockServiceWorker.js | 303 ++++++++++++++++++++++++++++++++++++ src/app/page.tsx | 3 + src/mocks/browser.ts | 4 + src/mocks/handlers/post.ts | 24 +++ src/mocks/index.ts | 11 ++ src/mocks/server.ts | 4 + tsconfig.json | 2 +- yarn.lock | 286 ++++++++++++++++++++++++++++++++-- 9 files changed, 631 insertions(+), 10 deletions(-) create mode 100644 public/mockServiceWorker.js create mode 100644 src/mocks/browser.ts create mode 100644 src/mocks/handlers/post.ts create mode 100644 src/mocks/index.ts create mode 100644 src/mocks/server.ts diff --git a/package.json b/package.json index 9519840c..d9fd8850 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "eslint-config-next": "13.0.0", "eslint-plugin-prettier": "^4.2.1", "jest": "^29.3.1", + "msw": "^1.2.3", "next": "13.4.4", "prettier": "^2.8.8", "react": "18.2.0", @@ -73,5 +74,8 @@ "commitizen": { "path": "./node_modules/cz-conventional-changelog" } + }, + "msw": { + "workerDirectory": "public" } } diff --git a/public/mockServiceWorker.js b/public/mockServiceWorker.js new file mode 100644 index 00000000..36a99274 --- /dev/null +++ b/public/mockServiceWorker.js @@ -0,0 +1,303 @@ +/* eslint-disable */ +/* tslint:disable */ + +/** + * Mock Service Worker (1.2.3). + * @see https://github.com/mswjs/msw + * - Please do NOT modify this file. + * - Please do NOT serve this file on production. + */ + +const INTEGRITY_CHECKSUM = '3d6b9f06410d179a7f7404d4bf4c3c70' +const activeClientIds = new Set() + +self.addEventListener('install', function () { + self.skipWaiting() +}) + +self.addEventListener('activate', function (event) { + event.waitUntil(self.clients.claim()) +}) + +self.addEventListener('message', async function (event) { + const clientId = event.source.id + + if (!clientId || !self.clients) { + return + } + + const client = await self.clients.get(clientId) + + if (!client) { + return + } + + const allClients = await self.clients.matchAll({ + type: 'window', + }) + + switch (event.data) { + case 'KEEPALIVE_REQUEST': { + sendToClient(client, { + type: 'KEEPALIVE_RESPONSE', + }) + break + } + + case 'INTEGRITY_CHECK_REQUEST': { + sendToClient(client, { + type: 'INTEGRITY_CHECK_RESPONSE', + payload: INTEGRITY_CHECKSUM, + }) + break + } + + case 'MOCK_ACTIVATE': { + activeClientIds.add(clientId) + + sendToClient(client, { + type: 'MOCKING_ENABLED', + payload: true, + }) + break + } + + case 'MOCK_DEACTIVATE': { + activeClientIds.delete(clientId) + break + } + + case 'CLIENT_CLOSED': { + activeClientIds.delete(clientId) + + const remainingClients = allClients.filter((client) => { + return client.id !== clientId + }) + + // Unregister itself when there are no more clients + if (remainingClients.length === 0) { + self.registration.unregister() + } + + break + } + } +}) + +self.addEventListener('fetch', function (event) { + const { request } = event + const accept = request.headers.get('accept') || '' + + // Bypass server-sent events. + if (accept.includes('text/event-stream')) { + return + } + + // Bypass navigation requests. + if (request.mode === 'navigate') { + return + } + + // Opening the DevTools triggers the "only-if-cached" request + // that cannot be handled by the worker. Bypass such requests. + if (request.cache === 'only-if-cached' && request.mode !== 'same-origin') { + return + } + + // Bypass all requests when there are no active clients. + // Prevents the self-unregistered worked from handling requests + // after it's been deleted (still remains active until the next reload). + if (activeClientIds.size === 0) { + return + } + + // Generate unique request ID. + const requestId = Math.random().toString(16).slice(2) + + event.respondWith( + handleRequest(event, requestId).catch((error) => { + if (error.name === 'NetworkError') { + console.warn( + '[MSW] Successfully emulated a network error for the "%s %s" request.', + request.method, + request.url, + ) + return + } + + // At this point, any exception indicates an issue with the original request/response. + console.error( + `\ +[MSW] Caught an exception from the "%s %s" request (%s). This is probably not a problem with Mock Service Worker. There is likely an additional logging output above.`, + request.method, + request.url, + `${error.name}: ${error.message}`, + ) + }), + ) +}) + +async function handleRequest(event, requestId) { + const client = await resolveMainClient(event) + const response = await getResponse(event, client, requestId) + + // Send back the response clone for the "response:*" life-cycle events. + // Ensure MSW is active and ready to handle the message, otherwise + // this message will pend indefinitely. + if (client && activeClientIds.has(client.id)) { + ;(async function () { + const clonedResponse = response.clone() + sendToClient(client, { + type: 'RESPONSE', + payload: { + requestId, + type: clonedResponse.type, + ok: clonedResponse.ok, + status: clonedResponse.status, + statusText: clonedResponse.statusText, + body: + clonedResponse.body === null ? null : await clonedResponse.text(), + headers: Object.fromEntries(clonedResponse.headers.entries()), + redirected: clonedResponse.redirected, + }, + }) + })() + } + + return response +} + +// Resolve the main client for the given event. +// Client that issues a request doesn't necessarily equal the client +// that registered the worker. It's with the latter the worker should +// communicate with during the response resolving phase. +async function resolveMainClient(event) { + const client = await self.clients.get(event.clientId) + + if (client?.frameType === 'top-level') { + return client + } + + const allClients = await self.clients.matchAll({ + type: 'window', + }) + + return allClients + .filter((client) => { + // Get only those clients that are currently visible. + return client.visibilityState === 'visible' + }) + .find((client) => { + // Find the client ID that's recorded in the + // set of clients that have registered the worker. + return activeClientIds.has(client.id) + }) +} + +async function getResponse(event, client, requestId) { + const { request } = event + const clonedRequest = request.clone() + + function passthrough() { + // Clone the request because it might've been already used + // (i.e. its body has been read and sent to the client). + const headers = Object.fromEntries(clonedRequest.headers.entries()) + + // Remove MSW-specific request headers so the bypassed requests + // comply with the server's CORS preflight check. + // Operate with the headers as an object because request "Headers" + // are immutable. + delete headers['x-msw-bypass'] + + return fetch(clonedRequest, { headers }) + } + + // Bypass mocking when the client is not active. + if (!client) { + return passthrough() + } + + // Bypass initial page load requests (i.e. static assets). + // The absence of the immediate/parent client in the map of the active clients + // means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet + // and is not ready to handle requests. + if (!activeClientIds.has(client.id)) { + return passthrough() + } + + // Bypass requests with the explicit bypass header. + // Such requests can be issued by "ctx.fetch()". + if (request.headers.get('x-msw-bypass') === 'true') { + return passthrough() + } + + // Notify the client that a request has been intercepted. + const clientMessage = await sendToClient(client, { + type: 'REQUEST', + payload: { + id: requestId, + url: request.url, + method: request.method, + headers: Object.fromEntries(request.headers.entries()), + cache: request.cache, + mode: request.mode, + credentials: request.credentials, + destination: request.destination, + integrity: request.integrity, + redirect: request.redirect, + referrer: request.referrer, + referrerPolicy: request.referrerPolicy, + body: await request.text(), + bodyUsed: request.bodyUsed, + keepalive: request.keepalive, + }, + }) + + switch (clientMessage.type) { + case 'MOCK_RESPONSE': { + return respondWithMock(clientMessage.data) + } + + case 'MOCK_NOT_FOUND': { + return passthrough() + } + + case 'NETWORK_ERROR': { + const { name, message } = clientMessage.data + const networkError = new Error(message) + networkError.name = name + + // Rejecting a "respondWith" promise emulates a network error. + throw networkError + } + } + + return passthrough() +} + +function sendToClient(client, message) { + return new Promise((resolve, reject) => { + const channel = new MessageChannel() + + channel.port1.onmessage = (event) => { + if (event.data && event.data.error) { + return reject(event.data.error) + } + + resolve(event.data) + } + + client.postMessage(message, [channel.port2]) + }) +} + +function sleep(timeMs) { + return new Promise((resolve) => { + setTimeout(resolve, timeMs) + }) +} + +async function respondWithMock(response) { + await sleep(response.delay) + return new Response(response.body, response) +} diff --git a/src/app/page.tsx b/src/app/page.tsx index 77cfff68..1f8dd329 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,7 +1,10 @@ "use client"; +import initMockAPI from "@/mocks"; import HomePage from "@/page/home"; +if (process.env.NODE_ENV === "development") initMockAPI(); + const Home = () => { return ; }; diff --git a/src/mocks/browser.ts b/src/mocks/browser.ts new file mode 100644 index 00000000..74df1dbe --- /dev/null +++ b/src/mocks/browser.ts @@ -0,0 +1,4 @@ +import { setupWorker } from "msw"; +import { handlers } from "./handlers"; + +export const worker = setupWorker(...handlers); diff --git a/src/mocks/handlers/post.ts b/src/mocks/handlers/post.ts new file mode 100644 index 00000000..06cd7dc3 --- /dev/null +++ b/src/mocks/handlers/post.ts @@ -0,0 +1,24 @@ +import { rest } from "msw"; + +export const MOCK_API_BASE_URL = "http://localhost:3000"; + +const PostListData = [ + { + id: 1, + title: "테스트입니다", + }, + { + id: 2, + title: "테스트입니다", + }, + { + id: 3, + title: "테스트입니다", + }, +]; + +export const handlers = [ + rest.get(`${MOCK_API_BASE_URL}/main/notice/list`, (req, res, ctx) => { + return res(ctx.status(200), ctx.json(PostListData)); + }), +]; diff --git a/src/mocks/index.ts b/src/mocks/index.ts new file mode 100644 index 00000000..d2b2ead5 --- /dev/null +++ b/src/mocks/index.ts @@ -0,0 +1,11 @@ +const initMockAPI = async (): Promise => { + if (typeof window === "undefined") { + const { server } = await import("@/mocks/server"); + server.listen(); + } else { + const { worker } = await import("@/mocks/browser"); + worker.start(); + } +}; + +export default initMockAPI; diff --git a/src/mocks/server.ts b/src/mocks/server.ts new file mode 100644 index 00000000..7b37f2ac --- /dev/null +++ b/src/mocks/server.ts @@ -0,0 +1,4 @@ +import { setupServer } from "msw/node"; +import { handlers } from "./handlers"; + +export const server = setupServer(...handlers); diff --git a/tsconfig.json b/tsconfig.json index d3bbeb43..3673dbea 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,6 +31,6 @@ "tailwind.config.js", ".eslintrc.js", ".next/types/**/*.ts" - ], +, "public/mockServiceWorker.js" ], "exclude": ["node_modules"] } diff --git a/yarn.lock b/yarn.lock index f81de83a..1dcfffaa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -844,6 +844,28 @@ "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" +"@mswjs/cookies@^0.2.2": + version "0.2.2" + resolved "https://registry.yarnpkg.com/@mswjs/cookies/-/cookies-0.2.2.tgz#b4e207bf6989e5d5427539c2443380a33ebb922b" + integrity sha512-mlN83YSrcFgk7Dm1Mys40DLssI1KdJji2CMKN8eOlBqsTADYzj2+jWzsANsUTFbxDMWPD5e9bfA1RGqBpS3O1g== + dependencies: + "@types/set-cookie-parser" "^2.4.0" + set-cookie-parser "^2.4.6" + +"@mswjs/interceptors@^0.17.5": + version "0.17.9" + resolved "https://registry.yarnpkg.com/@mswjs/interceptors/-/interceptors-0.17.9.tgz#0096fc88fea63ee42e36836acae8f4ae33651c04" + integrity sha512-4LVGt03RobMH/7ZrbHqRxQrS9cc2uh+iNKSj8UWr8M26A2i793ju+csaB5zaqYltqJmA2jUq4VeYfKmVqvsXQg== + dependencies: + "@open-draft/until" "^1.0.3" + "@types/debug" "^4.1.7" + "@xmldom/xmldom" "^0.8.3" + debug "^4.3.3" + headers-polyfill "^3.1.0" + outvariant "^1.2.1" + strict-event-emitter "^0.2.4" + web-encoding "^1.1.5" + "@next/env@13.4.4": version "13.4.4" resolved "https://registry.npmjs.org/@next/env/-/env-13.4.4.tgz" @@ -1101,6 +1123,11 @@ read-package-json-fast "^2.0.3" which "^2.0.2" +"@open-draft/until@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@open-draft/until/-/until-1.0.3.tgz#db9cc719191a62e7d9200f6e7bab21c5b848adca" + integrity sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q== + "@pkgjs/parseargs@^0.11.0": version "0.11.0" resolved "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz" @@ -1327,6 +1354,18 @@ dependencies: "@babel/types" "^7.20.7" +"@types/cookie@^0.4.1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d" + integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q== + +"@types/debug@^4.1.7": + version "4.1.8" + resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.8.tgz#cef723a5d0a90990313faec2d1e22aee5eecb317" + integrity sha512-/vPO1EPOs306Cvhwv7KfVfYvOJqA/S/AXjaHQiJboCZzcNDb+TIJFN9/2C9DZ//ijSKWioNyUxD792QmDJ+HKQ== + dependencies: + "@types/ms" "*" + "@types/graceful-fs@^4.1.3": version "4.1.6" resolved "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz" @@ -1376,6 +1415,11 @@ dependencies: "@types/sizzle" "*" +"@types/js-levenshtein@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@types/js-levenshtein/-/js-levenshtein-1.1.1.tgz#ba05426a43f9e4e30b631941e0aa17bf0c890ed5" + integrity sha512-qC4bCqYGy1y/NP7dDVr7KJarn+PbX1nSpwA7JXdu0HxT3QYjO8MJ+cntENtHFVy2dRAyBV23OZ6MxsW1AM1L8g== + "@types/jsdom@^20.0.0": version "20.0.1" resolved "https://registry.npmjs.org/@types/jsdom/-/jsdom-20.0.1.tgz" @@ -1400,6 +1444,11 @@ resolved "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz" integrity sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ== +"@types/ms@*": + version "0.7.31" + resolved "https://registry.yarnpkg.com/@types/ms/-/ms-0.7.31.tgz#31b7ca6407128a3d2bbc27fe2d21b345397f6197" + integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA== + "@types/node@*": version "20.3.3" resolved "https://registry.npmjs.org/@types/node/-/node-20.3.3.tgz" @@ -1465,6 +1514,13 @@ resolved "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz" integrity sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw== +"@types/set-cookie-parser@^2.4.0": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@types/set-cookie-parser/-/set-cookie-parser-2.4.3.tgz#963a7437ed026c6adec2a71478ed6e3df2837160" + integrity sha512-7QhnH7bi+6KAhBB+Auejz1uV9DHiopZqu7LfR/5gZZTkejJV5nYeZZpgfFoE0N8aDsXuiYpfKyfyMatCwQhyTQ== + dependencies: + "@types/node" "*" + "@types/sizzle@*": version "2.3.3" resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.3.tgz#ff5e2f1902969d305225a047c8a0fd5c915cebef" @@ -1592,6 +1648,16 @@ "@typescript-eslint/types" "5.60.1" eslint-visitor-keys "^3.3.0" +"@xmldom/xmldom@^0.8.3": + version "0.8.10" + resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.8.10.tgz#a1337ca426aa61cef9fe15b5b28e340a72f6fa99" + integrity sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw== + +"@zxing/text-encoding@0.9.0": + version "0.9.0" + resolved "https://registry.yarnpkg.com/@zxing/text-encoding/-/text-encoding-0.9.0.tgz#fb50ffabc6c7c66a0c96b4c03e3d9be74864b70b" + integrity sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA== + JSONStream@^1.0.4: version "1.3.5" resolved "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz" @@ -1733,7 +1799,7 @@ ansi-styles@^6.1.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== -anymatch@^3.0.3: +anymatch@^3.0.3, anymatch@~3.1.2: version "3.1.3" resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz" integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== @@ -2004,7 +2070,7 @@ bin-links@^3.0.3: rimraf "^3.0.0" write-file-atomic "^4.0.0" -binary-extensions@^2.2.0: +binary-extensions@^2.0.0, binary-extensions@^2.2.0: version "2.2.0" resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== @@ -2033,7 +2099,7 @@ brace-expansion@^2.0.1: dependencies: balanced-match "^1.0.0" -braces@^3.0.2: +braces@^3.0.2, braces@~3.0.2: version "3.0.2" resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== @@ -2187,6 +2253,14 @@ caniuse-lite@^1.0.30001406, caniuse-lite@^1.0.30001464, caniuse-lite@^1.0.300015 resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001509.tgz" integrity sha512-2uDDk+TRiTX5hMcUYT/7CSyzMZxjfGu0vAUjS2g0LSD8UoXOv0LtpH4LxGMemsiPq6LCVIUjNwVM0erkOkGCDA== +chalk@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.1.tgz#c80b3fab28bf6371e6863325eee67e618b77e6ad" + integrity sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + chalk@^2.0.0, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz" @@ -2214,6 +2288,21 @@ chardet@^0.7.0: resolved "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz" integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== +chokidar@^3.4.2: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + chownr@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz" @@ -2500,6 +2589,11 @@ convert-source-map@^2.0.0: resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz" integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== +cookie@^0.4.2: + version "0.4.2" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" + integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== + copy-anything@^3.0.2: version "3.0.5" resolved "https://registry.npmjs.org/copy-anything/-/copy-anything-3.0.5.tgz" @@ -3249,6 +3343,11 @@ esutils@^2.0.2: resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== +events@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== + execa@^5.0.0: version "5.1.1" resolved "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz" @@ -3518,7 +3617,7 @@ fs.realpath@^1.0.0: resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@2.3.2, fsevents@^2.3.2: +fsevents@2.3.2, fsevents@^2.3.2, fsevents@~2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== @@ -3606,7 +3705,7 @@ git-raw-commits@^2.0.11: split2 "^3.0.0" through2 "^4.0.0" -glob-parent@^5.1.2: +glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== @@ -3751,6 +3850,11 @@ graphemer@^1.4.0: resolved "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz" integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== +"graphql@^15.0.0 || ^16.0.0": + version "16.7.1" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.7.1.tgz#11475b74a7bff2aefd4691df52a0eca0abd9b642" + integrity sha512-DRYR9tf+UGU0KOsMcKAlXeFfX89UiiIZ0dRU3mR0yJfu6OjZqUcp68NnFLnqQU5RexygFoDy1EW+ccOYcPfmHg== + hamt_plus@1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/hamt_plus/-/hamt_plus-1.0.2.tgz" @@ -3824,6 +3928,11 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" +headers-polyfill@^3.1.0, headers-polyfill@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/headers-polyfill/-/headers-polyfill-3.1.2.tgz#9a4dcb545c5b95d9569592ef7ec0708aab763fbe" + integrity sha512-tWCK4biJ6hcLqTviLXVR9DTRfYGQMXEIUj3gwJ2rZ5wO/at3XtkI4g8mCvFdUF9l1KMBNCfmNAdnahm1cgavQA== + hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.3.0: version "3.3.2" resolved "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz" @@ -4011,7 +4120,7 @@ init-package-json@^3.0.2: validate-npm-package-license "^3.0.4" validate-npm-package-name "^4.0.0" -inquirer@8.2.5: +inquirer@8.2.5, inquirer@^8.2.0: version "8.2.5" resolved "https://registry.npmjs.org/inquirer/-/inquirer-8.2.5.tgz" integrity sha512-QAgPDQMEgrDssk1XiwwHoOGYF9BAbUcc1+j+FhEvaOt8/cKRqyLn0U5qA6F74fGhTMGxf92pOvPBeh29jQJDTQ== @@ -4078,6 +4187,14 @@ ip@^2.0.0: resolved "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz" integrity sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ== +is-arguments@^1.0.4: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" + integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== + dependencies: + call-bind "^1.0.2" + has-tostringtag "^1.0.0" + is-array-buffer@^3.0.1, is-array-buffer@^3.0.2: version "3.0.2" resolved "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz" @@ -4099,6 +4216,13 @@ is-bigint@^1.0.1: dependencies: has-bigints "^1.0.1" +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + is-boolean-object@^1.1.0: version "1.1.2" resolved "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz" @@ -4153,7 +4277,14 @@ is-generator-fn@^2.0.0: resolved "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz" integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== -is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3: +is-generator-function@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.10.tgz#f1558baf1ac17e0deea7c0415c438351ff2b3c72" + integrity sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A== + dependencies: + has-tostringtag "^1.0.0" + +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: version "4.0.3" resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== @@ -4175,6 +4306,11 @@ is-negative-zero@^2.0.2: resolved "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz" integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== +is-node-process@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-node-process/-/is-node-process-1.2.0.tgz#ea02a1b90ddb3934a19aea414e88edef7e11d134" + integrity sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw== + is-number-object@^1.0.4: version "1.0.7" resolved "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz" @@ -4264,6 +4400,13 @@ is-typed-array@^1.1.10, is-typed-array@^1.1.9: gopd "^1.0.1" has-tostringtag "^1.0.0" +is-typed-array@^1.1.3: + version "1.1.12" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.12.tgz#d0bab5686ef4a76f7a73097b95470ab199c57d4a" + integrity sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg== + dependencies: + which-typed-array "^1.1.11" + is-unicode-supported@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz" @@ -4727,6 +4870,11 @@ jest@^29.3.1: import-local "^3.0.2" jest-cli "^29.5.0" +js-levenshtein@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d" + integrity sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g== + js-sha3@0.8.0: version "0.8.0" resolved "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz" @@ -5464,6 +5612,31 @@ ms@^2.0.0, ms@^2.1.1, ms@^2.1.2: resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== +msw@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/msw/-/msw-1.2.3.tgz#750d6c53ac611732b243c82a87dad960ed832a37" + integrity sha512-Fqy/TaLKR32x4IkMwudJHJysBzVM/v/lSoMPS9f3QaHLOmb3xHN9YurSUnRt+2eEvNXLjVPij1wMBQtLmTbKsg== + dependencies: + "@mswjs/cookies" "^0.2.2" + "@mswjs/interceptors" "^0.17.5" + "@open-draft/until" "^1.0.3" + "@types/cookie" "^0.4.1" + "@types/js-levenshtein" "^1.1.1" + chalk "4.1.1" + chokidar "^3.4.2" + cookie "^0.4.2" + graphql "^15.0.0 || ^16.0.0" + headers-polyfill "^3.1.2" + inquirer "^8.2.0" + is-node-process "^1.2.0" + js-levenshtein "^1.1.6" + node-fetch "^2.6.7" + outvariant "^1.4.0" + path-to-regexp "^6.2.0" + strict-event-emitter "^0.4.3" + type-fest "^2.19.0" + yargs "^17.3.1" + mute-stream@0.0.7: version "0.0.7" resolved "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz" @@ -5534,6 +5707,13 @@ next@13.4.4: "@next/swc-win32-ia32-msvc" "13.4.4" "@next/swc-win32-x64-msvc" "13.4.4" +node-fetch@^2.6.7: + version "2.6.12" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" + integrity sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g== + dependencies: + whatwg-url "^5.0.0" + node-gyp@^9.0.0, node-gyp@^9.1.0: version "9.4.0" resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-9.4.0.tgz#2a7a91c7cba4eccfd95e949369f27c9ba704f369" @@ -5598,7 +5778,7 @@ normalize-package-data@^4.0.0: semver "^7.3.5" validate-npm-package-license "^3.0.4" -normalize-path@^3.0.0: +normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== @@ -5936,6 +6116,11 @@ os-tmpdir@~1.0.2: resolved "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz" integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== +outvariant@^1.2.1, outvariant@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/outvariant/-/outvariant-1.4.0.tgz#e742e4bda77692da3eca698ef5bfac62d9fba06e" + integrity sha512-AlWY719RF02ujitly7Kk/0QlV+pXGFDHrHf9O2OKqyqgBieaPOIeuSkL8sRK6j2WK+/ZAURq2kZsY0d8JapUiw== + p-is-promise@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/p-is-promise/-/p-is-promise-3.0.0.tgz" @@ -6079,6 +6264,11 @@ path-scurry@^1.10.1: lru-cache "^9.1.1 || ^10.0.0" minipass "^5.0.0 || ^6.0.2 || ^7.0.0" +path-to-regexp@^6.2.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.2.1.tgz#d54934d6798eb9e5ef14e7af7962c945906918e5" + integrity sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw== + path-type@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz" @@ -6089,7 +6279,7 @@ picocolors@^1.0.0: resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.1: +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -6409,6 +6599,13 @@ readdir-scoped-modules@^1.1.0: graceful-fs "^4.1.2" once "^1.3.0" +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + recoil@^0.7.7: version "0.7.7" resolved "https://registry.npmjs.org/recoil/-/recoil-0.7.7.tgz" @@ -6665,6 +6862,11 @@ set-blocking@^2.0.0: resolved "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz" integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw== +set-cookie-parser@^2.4.6: + version "2.6.0" + resolved "https://registry.yarnpkg.com/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz#131921e50f62ff1a66a461d7d62d7b21d5d15a51" + integrity sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ== + shallowequal@^1.1.0: version "1.1.0" resolved "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz" @@ -6827,6 +7029,18 @@ streamsearch@^1.1.0: resolved "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz" integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== +strict-event-emitter@^0.2.4: + version "0.2.8" + resolved "https://registry.yarnpkg.com/strict-event-emitter/-/strict-event-emitter-0.2.8.tgz#b4e768927c67273c14c13d20e19d5e6c934b47ca" + integrity sha512-KDf/ujU8Zud3YaLtMCcTI4xkZlZVIYxTLr+XIULexP+77EEVWixeXroLUXQXiVtH4XH2W7jr/3PT1v3zBuvc3A== + dependencies: + events "^3.3.0" + +strict-event-emitter@^0.4.3: + version "0.4.6" + resolved "https://registry.yarnpkg.com/strict-event-emitter/-/strict-event-emitter-0.4.6.tgz#ff347c8162b3e931e3ff5f02cfce6772c3b07eb3" + integrity sha512-12KWeb+wixJohmnwNFerbyiBrAlq5qJLwIt38etRtKtmmHyDSoGlIqFE9wx+4IwG0aDjI7GV8tc8ZccjWZZtTg== + string-convert@^0.2.0: version "0.2.1" resolved "https://registry.npmjs.org/string-convert/-/string-convert-0.2.1.tgz" @@ -7165,6 +7379,11 @@ tr46@^3.0.0: dependencies: punycode "^2.1.1" +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + treeverse@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/treeverse/-/treeverse-2.0.0.tgz" @@ -7263,6 +7482,11 @@ type-fest@^0.8.1: resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== +type-fest@^2.19.0: + version "2.19.0" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.19.0.tgz#88068015bb33036a598b952e55e9311a60fd3a9b" + integrity sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA== + typed-array-length@^1.0.4: version "1.0.4" resolved "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz" @@ -7390,6 +7614,17 @@ util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== +util@^0.12.3: + version "0.12.5" + resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc" + integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA== + dependencies: + inherits "^2.0.3" + is-arguments "^1.0.4" + is-generator-function "^1.0.7" + is-typed-array "^1.1.3" + which-typed-array "^1.1.2" + v8-compile-cache-lib@^3.0.1: version "3.0.1" resolved "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz" @@ -7445,6 +7680,20 @@ wcwidth@^1.0.0, wcwidth@^1.0.1: dependencies: defaults "^1.0.3" +web-encoding@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/web-encoding/-/web-encoding-1.1.5.tgz#fc810cf7667364a6335c939913f5051d3e0c4864" + integrity sha512-HYLeVCdJ0+lBYV2FvNZmv3HJ2Nt0QYXqZojk3d9FJOLkwnuhzM9tmamh8d7HPM8QqjKH8DeHkFTx+CFlWpZZDA== + dependencies: + util "^0.12.3" + optionalDependencies: + "@zxing/text-encoding" "0.9.0" + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + webidl-conversions@^7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz" @@ -7470,6 +7719,14 @@ whatwg-url@^11.0.0: tr46 "^3.0.0" webidl-conversions "^7.0.0" +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + which-boxed-primitive@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz" @@ -7481,6 +7738,17 @@ which-boxed-primitive@^1.0.2: is-string "^1.0.5" is-symbol "^1.0.3" +which-typed-array@^1.1.11, which-typed-array@^1.1.2: + version "1.1.11" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.11.tgz#99d691f23c72aab6768680805a271b69761ed61a" + integrity sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + gopd "^1.0.1" + has-tostringtag "^1.0.0" + which-typed-array@^1.1.9: version "1.1.9" resolved "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz" From cb5b44a7357d3fc6d05143f65f364ac4d828dbc8 Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Mon, 31 Jul 2023 21:04:22 +0900 Subject: [PATCH 15/18] =?UTF-8?q?refactor(httpClient):=20httpClient=20api?= =?UTF-8?q?=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=84=B8=ED=8C=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/httpClient/httpClient.ts | 48 ++++++---------------- src/mocks/handlers/{post.ts => index.ts} | 8 ++-- src/page/forum/layouts/Forum.tsx | 1 - src/page/forum/services/api.service.ts | 6 ++- src/page/oauth/services/api.service.ts | 2 +- src/page/timetable/services/api.service.ts | 6 ++- 6 files changed, 25 insertions(+), 46 deletions(-) rename src/mocks/handlers/{post.ts => index.ts} (60%) diff --git a/src/apis/httpClient/httpClient.ts b/src/apis/httpClient/httpClient.ts index 54678343..5cb26828 100644 --- a/src/apis/httpClient/httpClient.ts +++ b/src/apis/httpClient/httpClient.ts @@ -3,10 +3,8 @@ import { requestInterceptors, responseInterceptors } from "@/apis/interceptor"; import Storage from "@/apis/storage"; import refreshToken from "@/apis/token/refreshToken"; import TOKEN from "@/global/constants/token.constant"; -import IClassLevel from "@/global/types/classLevel.type"; import KEY from "@/global/constants/key.constant"; import { QueryClient } from "react-query"; -import IPostQuery from "@/global/types/postQuery.type"; export interface HttpClientConfig { baseURL?: string; @@ -39,40 +37,22 @@ export class HttpClient { }); } - getTimetable(classLevel: IClassLevel, requestConfig?: AxiosRequestConfig) { - return this.api.get(`/${classLevel.grade}/${classLevel.class}`, { + getByTitle(requestConfig?: AxiosRequestConfig) { + return this.api.get("/:title", { ...HttpClient.clientConfig, ...requestConfig, }); } - getByTitle(url: string, requestConfig?: AxiosRequestConfig) { - return this.api.get(`/${url}`, { + getTimetable(requestConfig?: AxiosRequestConfig) { + return this.api.get("/:grade/:class", { ...HttpClient.clientConfig, ...requestConfig, }); } - getInQuery( - param: string, - data: string | number, - requestConfig?: AxiosRequestConfig, - ) { - return this.api.get(`?${param}=${data}`, { - ...HttpClient.clientConfig, - ...requestConfig, - }); - } - - getPost(postConfig: IPostQuery, requestConfig?: AxiosRequestConfig) { - const { postType, category } = postConfig; - const postRenderLimit = Storage.getItem(TOKEN.POST_RENDER_LIMIT); - - const query = `https://bssm.kro.kr/api/post/${ - postType === "free" ? "board" : postType - }/recent?startPostId=-1&limit=${postRenderLimit}&category=${category}`; - - return this.api.get(query, { + getPost(requestConfig?: AxiosRequestConfig) { + return this.api.get("", { ...HttpClient.clientConfig, ...requestConfig, }); @@ -85,12 +65,8 @@ export class HttpClient { }); } - postInQuery( - param: string, - data: unknown, - requestConfig?: AxiosRequestConfig, - ) { - return this.api.post(`?${param}=${data}`, { + postOAuth(data: unknown, requestConfig?: AxiosRequestConfig) { + return this.api.post(`?code=${data}`, { ...HttpClient.clientConfig, ...requestConfig, }); @@ -103,8 +79,8 @@ export class HttpClient { }); } - putByTitle(title: string, data: unknown, requestConfig?: AxiosRequestConfig) { - return this.api.put(`/${title}`, data, { + putByTitle(data: unknown, requestConfig?: AxiosRequestConfig) { + return this.api.put("/:title", data, { ...HttpClient.clientConfig, ...requestConfig, }); @@ -117,8 +93,8 @@ export class HttpClient { }); } - deleteById(id: number, requestConfig?: AxiosRequestConfig) { - return this.api.delete(`/${id}`, { + deleteById(requestConfig?: AxiosRequestConfig) { + return this.api.delete("/:id", { ...HttpClient.clientConfig, ...requestConfig, }); diff --git a/src/mocks/handlers/post.ts b/src/mocks/handlers/index.ts similarity index 60% rename from src/mocks/handlers/post.ts rename to src/mocks/handlers/index.ts index 06cd7dc3..22c30ae4 100644 --- a/src/mocks/handlers/post.ts +++ b/src/mocks/handlers/index.ts @@ -5,20 +5,20 @@ export const MOCK_API_BASE_URL = "http://localhost:3000"; const PostListData = [ { id: 1, - title: "테스트입니다", + title: "test", }, { id: 2, - title: "테스트입니다", + title: "test", }, { id: 3, - title: "테스트입니다", + title: "test", }, ]; export const handlers = [ - rest.get(`${MOCK_API_BASE_URL}/main/notice/list`, (req, res, ctx) => { + rest.get(`${MOCK_API_BASE_URL}/`, (req, res, ctx) => { return res(ctx.status(200), ctx.json(PostListData)); }), ]; diff --git a/src/page/forum/layouts/Forum.tsx b/src/page/forum/layouts/Forum.tsx index 4b045baf..0539510b 100644 --- a/src/page/forum/layouts/Forum.tsx +++ b/src/page/forum/layouts/Forum.tsx @@ -8,7 +8,6 @@ import KEY from "@/global/constants/key.constant"; import ForumFilter from "./ForumFilter"; import Categories from "./Categories"; import PostList from "./PostList"; -import { usePostListQuery } from "../services/query.service"; const Forum = () => { const queryClient = useQueryClient(); diff --git a/src/page/forum/services/api.service.ts b/src/page/forum/services/api.service.ts index 808ef13c..8d26ace6 100644 --- a/src/page/forum/services/api.service.ts +++ b/src/page/forum/services/api.service.ts @@ -3,8 +3,10 @@ import IPostQuery from "@/global/types/postQuery.type"; export const getPostList = async (postConfig: IPostQuery) => { try { - const { data } = await httpClient.post.getPost(postConfig); - return data.postList; + const { data } = await httpClient.post.getPost({ + params: postConfig, + }); + return data; } catch (err) { return err; } diff --git a/src/page/oauth/services/api.service.ts b/src/page/oauth/services/api.service.ts index 1dc61f28..65deb672 100644 --- a/src/page/oauth/services/api.service.ts +++ b/src/page/oauth/services/api.service.ts @@ -7,6 +7,6 @@ export interface ILoginParams { export const login = async ({ authCode }: ILoginParams) => { if (!authCode) return; - const { data } = await httpClient.oauth.postInQuery("code", authCode); + const { data } = await httpClient.oauth.postOAuth(authCode); return data; }; diff --git a/src/page/timetable/services/api.service.ts b/src/page/timetable/services/api.service.ts index 3d78d4f7..930d57cc 100644 --- a/src/page/timetable/services/api.service.ts +++ b/src/page/timetable/services/api.service.ts @@ -2,7 +2,9 @@ import httpClient from "@/apis/httpClient"; import IClassLevel from "@/global/types/classLevel.type"; export const getTimetable = async (classLevel: IClassLevel) => { - const { data } = await httpClient.timetable.getTimetable(classLevel); + const { data } = await httpClient.timetable.getTimetable({ + params: classLevel, + }); - return data.timetableList; + return data; }; From c96d9f26d4b15b4a0904a7e2aeb4474e4b320af3 Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Tue, 1 Aug 2023 15:52:22 +0900 Subject: [PATCH 16/18] =?UTF-8?q?refactor(import):=20index=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 ++++- src/apis/httpClient/httpClient.ts | 18 +----- src/apis/interceptor/index.ts | 13 ---- src/apis/storage/index.ts | 8 +-- src/apis/token/refreshToken.ts | 19 ------ src/app/layout.tsx | 5 +- src/assets/data/emptyCategories.ts | 22 +++++++ .../data/emptyClassInfo.ts | 2 +- .../data/emptyClassLevel.ts | 0 .../data/emptyTimetable.ts | 2 +- src/assets/data/index.ts | 4 ++ .../assets/svgs => assets/icons}/Arrow.tsx | 3 +- .../assets => assets/icons}/CategoryArrow.tsx | 3 +- .../assets/svgs => assets/icons}/Check.tsx | 3 +- .../assets => assets/icons}/CommentIcon.tsx | 3 +- .../assets/svgs => assets/icons}/Emoji.tsx | 2 +- .../assets => assets/icons}/Like.tsx | 3 +- .../icons/LikeIcon.tsx} | 7 +-- .../assets => assets/icons}/LinkArrow.tsx | 3 +- .../assets/svgs => assets/icons}/Logo.tsx | 3 +- .../assets/svgs => assets/icons}/Setting.tsx | 3 +- .../assets => assets/icons}/Time.tsx | 3 +- .../assets => assets/icons}/View.tsx | 3 +- .../assets/svgs => assets/icons}/XIcon.tsx | 2 - .../svgs => assets/icons}/emojis/Grinning.tsx | 3 +- .../icons}/emojis/HoldingBackTears.tsx | 3 +- .../svgs => assets/icons}/emojis/Kissing.tsx | 3 +- .../svgs => assets/icons}/emojis/Laughing.tsx | 3 +- .../svgs => assets/icons}/emojis/Relaxed.tsx | 3 +- .../icons}/emojis/StyledEmoji.tsx | 0 src/assets/icons/index.ts | 18 ++++++ .../Footer/assets => assets/images}/QR.png | Bin .../icons => assets/images}/emoticon.png | Bin .../images/emptyImage.png} | Bin src/assets/images/index.ts | 5 ++ .../icons => assets/images}/loading.gif | Bin .../images}/profile_default.png | Bin src/components/Flex/index.ts | 2 + src/components/atoms/AnonymousBox.tsx | 6 +- src/components/atoms/Category.tsx | 6 +- src/components/atoms/CommentBox.tsx | 9 ++- src/components/atoms/CustomEditor.tsx | 6 +- src/components/atoms/ImageWithFallback.tsx | 4 +- src/components/atoms/Input.tsx | 3 +- src/components/atoms/Select.tsx | 5 +- src/components/atoms/Switch.tsx | 2 +- src/components/atoms/index.ts | 8 +++ src/components/common/Aside/InfomationBox.tsx | 18 +++--- src/components/common/Aside/JoinCheckBox.tsx | 4 +- src/components/common/Aside/MeisterBox.tsx | 8 +-- src/components/common/Aside/assets/Check.tsx | 41 ------------ src/components/common/Aside/index.tsx | 3 +- src/components/common/Footer/Info.tsx | 10 +-- src/components/common/Footer/index.tsx | 3 +- src/components/common/Header/Navigation.tsx | 4 +- src/components/common/Header/index.tsx | 8 +-- .../common/Modal/EmojiModal/ModalHeader.tsx | 7 +-- .../common/Modal/EmojiModal/ModalList.tsx | 1 - .../common/Modal/EmojiModal/ModalListItem.tsx | 4 +- .../common/Modal/EmojiModal/index.tsx | 3 +- .../common/Modal/SettingModal/SettingBody.tsx | 5 +- .../Modal/SettingModal/SettingHeader.tsx | 6 +- .../common/Modal/SettingModal/index.tsx | 3 +- src/components/common/Modal/View.tsx | 2 +- src/components/common/Modal/index.tsx | 2 +- src/components/common/index.ts | 6 ++ src/constants/applications.constant.ts | 14 +++++ src/{global => }/constants/error.constant.ts | 0 src/constants/forum.constant.ts | 32 ++++++++++ src/constants/index.ts | 10 +++ src/{global => }/constants/key.constant.ts | 0 src/constants/lostfound.constant.ts | 12 ++++ src/constants/meal.constant.ts | 24 +++++++ src/{global => }/constants/router.constant.ts | 0 .../constants/service.constant.ts | 0 src/{global => }/constants/token.constant.ts | 0 src/{global => }/constants/user.constant.ts | 0 src/global/assets/data/categories.ts | 22 ------- src/global/constants/forum.constant.ts | 53 ---------------- src/global/constants/lostfound.constant.ts | 12 ---- src/global/helpers/getProfileUrl.helper.ts | 5 -- src/global/types/modal.type.ts | 8 --- src/helpers/getProfileUrl.helper.ts | 8 +++ src/{global => }/helpers/provider.helper.tsx | 8 +-- .../helpers/reactQueryProvider.helper.tsx | 4 +- src/hooks/useEmoji.ts | 8 +-- src/hooks/useModal.ts | 10 +-- src/hooks/useTimetableBar.ts | 6 +- src/hooks/useUser.ts | 38 +++++------ .../SVGAttribute.interface.ts} | 0 .../classInfo.interface.ts} | 0 .../classLevel.interface.ts} | 0 .../emoji.interface.ts} | 0 src/interfaces/index.ts | 11 ++++ src/interfaces/mealList.interface.ts | 3 + .../mealListItem.interface.ts} | 4 +- src/interfaces/modal.interface.ts | 8 +++ .../post.interface.ts} | 2 +- .../postQuery.interface.ts} | 2 +- .../timetable.interface.ts} | 2 +- .../user.interface.ts} | 0 .../constants/applications.constant.ts | 14 ----- src/page/applications/index.tsx | 5 +- src/page/applications/layouts/AppList.tsx | 3 +- .../applications/layouts/AppListFilter.tsx | 19 +++--- src/page/applications/layouts/AppListItem.tsx | 9 +-- src/page/calender/index.tsx | 3 +- src/page/calender/layouts/CalenderList.tsx | 3 +- .../calender/layouts/CalenderListItem.tsx | 4 +- src/page/calender/layouts/DateBox.tsx | 5 +- src/page/calender/layouts/ScheduleBox.tsx | 3 +- src/page/calender/layouts/WeekBox.tsx | 4 +- src/page/forum-post/layouts/Post.tsx | 3 +- .../forum-post/layouts/PostBody/CountBox.tsx | 10 ++- .../forum-post/layouts/PostBody/index.tsx | 5 +- .../forum-post/layouts/PostHead/Category.tsx | 7 +-- .../forum-post/layouts/PostHead/PostTitle.tsx | 10 ++- .../forum-post/layouts/PostHead/ReactBox.tsx | 12 ++-- .../forum-post/layouts/PostHead/index.tsx | 1 - src/page/forum-write/index.tsx | 3 +- src/page/forum-write/layouts/InputBox.tsx | 20 +++--- src/page/forum-write/layouts/WriteBox.tsx | 6 +- src/page/forum/index.tsx | 3 +- src/page/forum/layouts/Categories.tsx | 12 ++-- src/page/forum/layouts/Forum.tsx | 2 +- src/page/forum/layouts/ForumFilter.tsx | 23 ++++--- src/page/forum/layouts/PostList.tsx | 3 +- src/page/forum/layouts/PostListItem.tsx | 11 ++-- src/page/forum/services/api.service.ts | 2 +- src/page/forum/services/query.service.ts | 5 +- src/page/home/assets/.gitkeep | 0 src/page/home/index.tsx | 3 +- src/page/home/services/.gitkeep | 0 src/page/lostfound-post/index.tsx | 3 +- .../LostFoundBody/LostFoundInfoBox.tsx | 5 +- .../layouts/LostFoundBody/index.tsx | 6 +- .../layouts/LostFoundHead/Category.tsx | 7 +-- .../layouts/LostFoundHead/LostFoundTitle.tsx | 9 +-- .../layouts/LostFoundHead/index.tsx | 1 - .../layouts/LostFoundPostBox.tsx | 3 +- src/page/lostfound-write/index.tsx | 3 +- src/page/lostfound-write/layouts/InputBox.tsx | 13 ++-- .../layouts/LostFoundWriteBox.tsx | 6 +- src/page/lostfound-write/layouts/StateBox.tsx | 18 +++--- src/page/lostfound/index.tsx | 3 +- src/page/lostfound/layouts/LostFoundBox.tsx | 1 - .../lostfound/layouts/LostFoundFIlter.tsx | 20 +++--- src/page/lostfound/layouts/LostFoundList.tsx | 3 +- .../lostfound/layouts/LostFoundListItem.tsx | 12 ++-- src/page/lostfound/layouts/States.tsx | 4 +- src/page/meal/assets/.gitkeep | 0 src/page/meal/constants/meal.constant.ts | 24 ------- src/page/meal/index.tsx | 3 +- src/page/meal/layouts/ListSlider.tsx | 4 +- src/page/meal/layouts/Meal.tsx | 1 - src/page/meal/layouts/MealListItem.tsx | 27 ++++---- src/page/meal/layouts/SwipeArea.tsx | 1 - src/page/meal/types/mealList.type.ts | 5 -- src/page/oauth/index.tsx | 11 ++-- src/page/oauth/services/mutations.service.ts | 10 +-- src/page/timetable/index.tsx | 3 +- src/page/timetable/layouts/TimeTableBar.tsx | 6 +- src/page/timetable/layouts/TimeTableBox.tsx | 5 +- .../timetable/layouts/TimeTableCategory.tsx | 11 ++-- src/page/timetable/services/api.service.ts | 2 +- .../timetable/services/queries.service.ts | 5 +- src/store/categories.store.ts | 6 +- src/store/emoji.store.ts | 2 +- src/store/forumType.store.ts | 4 +- src/store/modal.store.ts | 2 +- src/store/user.store.ts | 8 +-- src/styles/GlobalStyle.ts | 59 ++++++++++++++++++ src/styles/font.ts | 4 +- src/styles/index.ts | 2 + src/styles/style.ts | 5 -- src/types/index.ts | 2 + src/{global => }/types/postCategory.type.ts | 0 src/types/storageSettingKey.type.ts | 3 + 178 files changed, 557 insertions(+), 671 deletions(-) delete mode 100644 src/apis/token/refreshToken.ts create mode 100644 src/assets/data/emptyCategories.ts rename src/{page/timetable => assets}/data/emptyClassInfo.ts (75%) rename src/{page/timetable => assets}/data/emptyClassLevel.ts (100%) rename src/{page/timetable => assets}/data/emptyTimetable.ts (95%) create mode 100644 src/assets/data/index.ts rename src/{global/assets/svgs => assets/icons}/Arrow.tsx (96%) rename src/{page/forum-post/assets => assets/icons}/CategoryArrow.tsx (92%) rename src/{global/assets/svgs => assets/icons}/Check.tsx (94%) rename src/{page/forum-post/assets => assets/icons}/CommentIcon.tsx (91%) rename src/{global/assets/svgs => assets/icons}/Emoji.tsx (92%) rename src/{page/forum-post/assets => assets/icons}/Like.tsx (94%) rename src/{page/forum/assets/LikeLogo.tsx => assets/icons/LikeIcon.tsx} (78%) rename src/{page/applications/assets => assets/icons}/LinkArrow.tsx (92%) rename src/{global/assets/svgs => assets/icons}/Logo.tsx (98%) rename src/{global/assets/svgs => assets/icons}/Setting.tsx (98%) rename src/{page/forum-post/assets => assets/icons}/Time.tsx (94%) rename src/{page/forum-post/assets => assets/icons}/View.tsx (96%) rename src/{global/assets/svgs => assets/icons}/XIcon.tsx (98%) rename src/{global/assets/svgs => assets/icons}/emojis/Grinning.tsx (93%) rename src/{global/assets/svgs => assets/icons}/emojis/HoldingBackTears.tsx (97%) rename src/{global/assets/svgs => assets/icons}/emojis/Kissing.tsx (97%) rename src/{global/assets/svgs => assets/icons}/emojis/Laughing.tsx (95%) rename src/{global/assets/svgs => assets/icons}/emojis/Relaxed.tsx (97%) rename src/{global/assets/svgs => assets/icons}/emojis/StyledEmoji.tsx (100%) create mode 100644 src/assets/icons/index.ts rename src/{components/common/Footer/assets => assets/images}/QR.png (100%) rename src/{global/assets/icons => assets/images}/emoticon.png (100%) rename src/{page/lostfound/assets/imageNotFound.png => assets/images/emptyImage.png} (100%) create mode 100644 src/assets/images/index.ts rename src/{global/assets/icons => assets/images}/loading.gif (100%) rename src/{global/assets/icons => assets/images}/profile_default.png (100%) create mode 100644 src/components/Flex/index.ts create mode 100644 src/components/atoms/index.ts delete mode 100644 src/components/common/Aside/assets/Check.tsx create mode 100644 src/components/common/index.ts create mode 100644 src/constants/applications.constant.ts rename src/{global => }/constants/error.constant.ts (100%) create mode 100644 src/constants/forum.constant.ts create mode 100644 src/constants/index.ts rename src/{global => }/constants/key.constant.ts (100%) create mode 100644 src/constants/lostfound.constant.ts create mode 100644 src/constants/meal.constant.ts rename src/{global => }/constants/router.constant.ts (100%) rename src/{global => }/constants/service.constant.ts (100%) rename src/{global => }/constants/token.constant.ts (100%) rename src/{global => }/constants/user.constant.ts (100%) delete mode 100644 src/global/assets/data/categories.ts delete mode 100644 src/global/constants/forum.constant.ts delete mode 100644 src/global/constants/lostfound.constant.ts delete mode 100644 src/global/helpers/getProfileUrl.helper.ts delete mode 100644 src/global/types/modal.type.ts create mode 100644 src/helpers/getProfileUrl.helper.ts rename src/{global => }/helpers/provider.helper.tsx (69%) rename src/{global => }/helpers/reactQueryProvider.helper.tsx (75%) rename src/{global/types/SVGAttribute.type.ts => interfaces/SVGAttribute.interface.ts} (100%) rename src/{global/types/classInfo.type.ts => interfaces/classInfo.interface.ts} (100%) rename src/{global/types/classLevel.type.ts => interfaces/classLevel.interface.ts} (100%) rename src/{global/types/emoji.type.ts => interfaces/emoji.interface.ts} (100%) create mode 100644 src/interfaces/index.ts create mode 100644 src/interfaces/mealList.interface.ts rename src/{page/meal/types/mealListItem.type.ts => interfaces/mealListItem.interface.ts} (56%) create mode 100644 src/interfaces/modal.interface.ts rename src/{global/types/post.type.ts => interfaces/post.interface.ts} (81%) rename src/{global/types/postQuery.type.ts => interfaces/postQuery.interface.ts} (63%) rename src/{global/types/timetable.type.ts => interfaces/timetable.interface.ts} (62%) rename src/{global/types/user.type.ts => interfaces/user.interface.ts} (100%) delete mode 100644 src/page/applications/constants/applications.constant.ts delete mode 100644 src/page/home/assets/.gitkeep delete mode 100644 src/page/home/services/.gitkeep delete mode 100644 src/page/meal/assets/.gitkeep delete mode 100644 src/page/meal/constants/meal.constant.ts delete mode 100644 src/page/meal/types/mealList.type.ts create mode 100644 src/styles/GlobalStyle.ts create mode 100644 src/styles/index.ts delete mode 100644 src/styles/style.ts create mode 100644 src/types/index.ts rename src/{global => }/types/postCategory.type.ts (100%) create mode 100644 src/types/storageSettingKey.type.ts diff --git a/README.md b/README.md index 541db24f..69a63429 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ## BSM +## commit convention + feat : 새로운 기능 추가 fix : 버그 수정 docs : 문서 관련 @@ -9,4 +11,16 @@ test : 테스트 관련 코드 build : 빌드 관련 파일 수정 ci : CI 설정 파일 수정 perf : 성능 개선 -chore : 그 외 자잘한 수정 \ No newline at end of file +chore : 그 외 자잘한 수정 + +## import convention + +1. React +2. style +3. asset +4. constant +5. hook +6. store +7. type +8. interface +9. components diff --git a/src/apis/httpClient/httpClient.ts b/src/apis/httpClient/httpClient.ts index 5cb26828..449ad202 100644 --- a/src/apis/httpClient/httpClient.ts +++ b/src/apis/httpClient/httpClient.ts @@ -1,9 +1,6 @@ import axios, { AxiosInstance, AxiosRequestConfig } from "axios"; import { requestInterceptors, responseInterceptors } from "@/apis/interceptor"; -import Storage from "@/apis/storage"; -import refreshToken from "@/apis/token/refreshToken"; -import TOKEN from "@/global/constants/token.constant"; -import KEY from "@/global/constants/key.constant"; +import { KEY } from "@/constants/"; import { QueryClient } from "react-query"; export interface HttpClientConfig { @@ -108,24 +105,11 @@ export class HttpClient { (response) => response, (error) => { queryClient.invalidateQueries(KEY.USER); - refreshToken(); return Promise.reject(error); }, ); } - static setAccessToken() { - const accessToken = Storage.getItem(TOKEN.ACCESS); - HttpClient.clientConfig.headers = { - ...HttpClient.clientConfig.headers, - Authorization: accessToken || undefined, - }; - } - - static removeAccessToken() { - Storage.setItem(TOKEN.ACCESS, ""); - } - private static setCommonInterceptors(instance: AxiosInstance) { instance.interceptors.request.use(requestInterceptors as never); instance.interceptors.response.use(responseInterceptors); diff --git a/src/apis/interceptor/index.ts b/src/apis/interceptor/index.ts index c6a1882b..d23cfbad 100644 --- a/src/apis/interceptor/index.ts +++ b/src/apis/interceptor/index.ts @@ -1,17 +1,6 @@ -import Storage from "@/apis/storage"; import { AxiosRequestConfig, AxiosResponse } from "axios"; -import refreshToken from "@/apis/token/refreshToken"; -import ERROR from "@/global/constants/error.constant"; -import TOKEN from "@/global/constants/token.constant"; export const requestInterceptors = (requestConfig: AxiosRequestConfig) => { - if (!Storage.getItem(TOKEN.ACCESS) && Storage.getItem(TOKEN.REFRESH)) - refreshToken(); - - if (requestConfig.headers) { - requestConfig.headers.Authorization = Storage.getItem(TOKEN.ACCESS); - } - const urlParams = requestConfig.url?.split("/:") || []; if (urlParams.length < 2) return requestConfig; @@ -32,8 +21,6 @@ export const requestInterceptors = (requestConfig: AxiosRequestConfig) => { }; export const responseInterceptors = (originalResponse: AxiosResponse) => { - if (originalResponse.status !== ERROR.STATUS.SUCCESS) refreshToken(); - return { ...originalResponse, data: originalResponse.data, diff --git a/src/apis/storage/index.ts b/src/apis/storage/index.ts index 6bc1f4b5..21888371 100644 --- a/src/apis/storage/index.ts +++ b/src/apis/storage/index.ts @@ -1,16 +1,16 @@ -type LocalStorageKey = "access_token" | "refresh_token" | "post_render_limit"; +import { StorageSettingKey } from "@/types/"; export default class Storage { - static getItem(key: LocalStorageKey) { + static getItem(key: StorageSettingKey) { return typeof window !== "undefined" ? localStorage.getItem(key) : null; } - static setItem(key: LocalStorageKey, value: string) { + static setItem(key: StorageSettingKey, value: string) { if (typeof window === "undefined") return; localStorage.setItem(key, value); } - static delItem(key: LocalStorageKey) { + static delItem(key: StorageSettingKey) { if (typeof window === "undefined") return; localStorage.removeItem(key); } diff --git a/src/apis/token/refreshToken.ts b/src/apis/token/refreshToken.ts deleted file mode 100644 index ea49fd33..00000000 --- a/src/apis/token/refreshToken.ts +++ /dev/null @@ -1,19 +0,0 @@ -import axios from "axios"; -import Storage from "@/apis/storage"; -import TOKEN from "@/global/constants/token.constant"; - -const refreshToken = async () => { - // fix 필요 - try { - const res = ( - await axios.put("/auth/refresh/access", { - refresh_token: Storage.getItem(TOKEN.REFRESH), - }) - ).data; - Storage.setItem(TOKEN.ACCESS, res.accessToken); - } catch (err) { - Storage.delItem(TOKEN.REFRESH); - } -}; - -export default refreshToken; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index f189e420..a2e974a1 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,5 +1,5 @@ -import "@/styles/globals.css"; -import Provider from "@/global/helpers/provider.helper"; +import Provider from "@/helpers/provider.helper"; +import GlobalStyle from "@/styles/GlobalStyle"; export const metadata = { title: "BSM", @@ -14,6 +14,7 @@ export default function RootLayout({ return ( + {children} diff --git a/src/assets/data/emptyCategories.ts b/src/assets/data/emptyCategories.ts new file mode 100644 index 00000000..b22de56f --- /dev/null +++ b/src/assets/data/emptyCategories.ts @@ -0,0 +1,22 @@ +import { FORUM } from "@/constants"; + +const categories = [ + { + name: FORUM.CATEGORY.ALL.NAME, + type: FORUM.CATEGORY.ALL.TYPE, + }, + { + name: FORUM.CATEGORY.COMPLAIN.NAME, + type: FORUM.CATEGORY.COMPLAIN.TYPE, + }, + { + name: FORUM.CATEGORY.HUMOR.NAME, + type: FORUM.CATEGORY.HUMOR.TYPE, + }, + { + name: FORUM.CATEGORY.INFORMATION.NAME, + type: FORUM.CATEGORY.INFORMATION.TYPE, + }, +]; + +export default categories; diff --git a/src/page/timetable/data/emptyClassInfo.ts b/src/assets/data/emptyClassInfo.ts similarity index 75% rename from src/page/timetable/data/emptyClassInfo.ts rename to src/assets/data/emptyClassInfo.ts index 37373225..66caeb62 100644 --- a/src/page/timetable/data/emptyClassInfo.ts +++ b/src/assets/data/emptyClassInfo.ts @@ -1,4 +1,4 @@ -import IClassInfo from "@/global/types/classInfo.type"; +import { IClassInfo } from "@/interfaces"; const emptyClassInfo: IClassInfo = { className: "", diff --git a/src/page/timetable/data/emptyClassLevel.ts b/src/assets/data/emptyClassLevel.ts similarity index 100% rename from src/page/timetable/data/emptyClassLevel.ts rename to src/assets/data/emptyClassLevel.ts diff --git a/src/page/timetable/data/emptyTimetable.ts b/src/assets/data/emptyTimetable.ts similarity index 95% rename from src/page/timetable/data/emptyTimetable.ts rename to src/assets/data/emptyTimetable.ts index ba0407a5..f5611408 100644 --- a/src/page/timetable/data/emptyTimetable.ts +++ b/src/assets/data/emptyTimetable.ts @@ -1,4 +1,4 @@ -import ITimetable from "@/global/types/timetable.type"; +import { ITimetable } from "@/interfaces"; const emptyTimetable: ITimetable = { SUN: [ diff --git a/src/assets/data/index.ts b/src/assets/data/index.ts new file mode 100644 index 00000000..7bca69dc --- /dev/null +++ b/src/assets/data/index.ts @@ -0,0 +1,4 @@ +export { default as emptyCategories } from "./emptyCategories"; +export { default as emptyClassInfo } from "./emptyClassInfo"; +export { default as emptyClassLevel } from "./emptyClassLevel"; +export { default as emptyTimetable } from "./emptyTimetable"; diff --git a/src/global/assets/svgs/Arrow.tsx b/src/assets/icons/Arrow.tsx similarity index 96% rename from src/global/assets/svgs/Arrow.tsx rename to src/assets/icons/Arrow.tsx index 33ee15e5..af176f86 100644 --- a/src/global/assets/svgs/Arrow.tsx +++ b/src/assets/icons/Arrow.tsx @@ -1,5 +1,4 @@ -import SVGAttribute from "@/global/types/SVGAttribute.type"; -import React from "react"; +import { SVGAttribute } from "@/interfaces"; const path = { top: "M1.66419 23.4679C2.24222 24.0457 3.02609 24.3703 3.84342 24.3703C4.66075 24.3703 5.44462 24.0457 6.02265 23.4679L21.2803 8.21018L36.538 23.4679C37.1193 24.0293 37.898 24.34 38.7061 24.333C39.5143 24.326 40.2874 24.0018 40.8589 23.4303C41.4304 22.8588 41.7546 22.0857 41.7616 21.2775C41.7686 20.4694 41.4579 19.6907 40.8965 19.1094L23.4596 1.67249C22.8815 1.09464 22.0977 0.77002 21.2803 0.77002C20.463 0.77002 19.6791 1.09464 19.1011 1.67249L1.66419 19.1094C1.08634 19.6874 0.761719 20.4713 0.761719 21.2886C0.761719 22.106 1.08634 22.8898 1.66419 23.4679Z", diff --git a/src/page/forum-post/assets/CategoryArrow.tsx b/src/assets/icons/CategoryArrow.tsx similarity index 92% rename from src/page/forum-post/assets/CategoryArrow.tsx rename to src/assets/icons/CategoryArrow.tsx index ab189677..e6052696 100644 --- a/src/page/forum-post/assets/CategoryArrow.tsx +++ b/src/assets/icons/CategoryArrow.tsx @@ -1,5 +1,4 @@ -import SVGAttribute from "@/global/types/SVGAttribute.type"; -import React from "react"; +import { SVGAttribute } from "@/interfaces"; const CategoryArrow = ({ width = 12, diff --git a/src/global/assets/svgs/Check.tsx b/src/assets/icons/Check.tsx similarity index 94% rename from src/global/assets/svgs/Check.tsx rename to src/assets/icons/Check.tsx index 21a4f691..913252f3 100644 --- a/src/global/assets/svgs/Check.tsx +++ b/src/assets/icons/Check.tsx @@ -1,5 +1,4 @@ -import SVGAttribute from "@/global/types/SVGAttribute.type"; -import React from "react"; +import { SVGAttribute } from "@/interfaces"; const Check = ({ width = 24, height = 24, isPointable }: SVGAttribute) => { return ( diff --git a/src/page/forum-post/assets/CommentIcon.tsx b/src/assets/icons/CommentIcon.tsx similarity index 91% rename from src/page/forum-post/assets/CommentIcon.tsx rename to src/assets/icons/CommentIcon.tsx index 584f6c27..955454eb 100644 --- a/src/page/forum-post/assets/CommentIcon.tsx +++ b/src/assets/icons/CommentIcon.tsx @@ -1,5 +1,4 @@ -import SVGAttribute from "@/global/types/SVGAttribute.type"; -import React from "react"; +import { SVGAttribute } from "@/interfaces"; const CommentIcon = ({ width = 22, diff --git a/src/global/assets/svgs/Emoji.tsx b/src/assets/icons/Emoji.tsx similarity index 92% rename from src/global/assets/svgs/Emoji.tsx rename to src/assets/icons/Emoji.tsx index d61be812..2be64c23 100644 --- a/src/global/assets/svgs/Emoji.tsx +++ b/src/assets/icons/Emoji.tsx @@ -1,5 +1,5 @@ import React from "react"; -import Kissing from "./emojis/Kissing"; +import { Kissing } from "./index"; const Emoji = ({ ...props }: React.ButtonHTMLAttributes) => { const [isHover, setIsHover] = React.useState(false); diff --git a/src/page/forum-post/assets/Like.tsx b/src/assets/icons/Like.tsx similarity index 94% rename from src/page/forum-post/assets/Like.tsx rename to src/assets/icons/Like.tsx index 8a0421f7..60ceb6ae 100644 --- a/src/page/forum-post/assets/Like.tsx +++ b/src/assets/icons/Like.tsx @@ -1,5 +1,4 @@ -import SVGAttribute from "@/global/types/SVGAttribute.type"; -import React from "react"; +import { SVGAttribute } from "@/interfaces"; const Like = ({ width = 50, height = 50, isPointable }: SVGAttribute) => { return ( diff --git a/src/page/forum/assets/LikeLogo.tsx b/src/assets/icons/LikeIcon.tsx similarity index 78% rename from src/page/forum/assets/LikeLogo.tsx rename to src/assets/icons/LikeIcon.tsx index eee7a81d..8bad7197 100644 --- a/src/page/forum/assets/LikeLogo.tsx +++ b/src/assets/icons/LikeIcon.tsx @@ -1,7 +1,6 @@ -import SVGAttribute from "@/global/types/SVGAttribute.type"; -import React from "react"; +import { SVGAttribute } from "@/interfaces"; -const LikeLogo = ({ width = 15, height = 13, isPointable }: SVGAttribute) => { +const LikeIcon = ({ width = 15, height = 13, isPointable }: SVGAttribute) => { return ( { ); }; -export default LikeLogo; +export default LikeIcon; diff --git a/src/page/applications/assets/LinkArrow.tsx b/src/assets/icons/LinkArrow.tsx similarity index 92% rename from src/page/applications/assets/LinkArrow.tsx rename to src/assets/icons/LinkArrow.tsx index 63c8d565..32ded025 100644 --- a/src/page/applications/assets/LinkArrow.tsx +++ b/src/assets/icons/LinkArrow.tsx @@ -1,5 +1,4 @@ -import SVGAttribute from "@/global/types/SVGAttribute.type"; -import React from "react"; +import { SVGAttribute } from "@/interfaces"; const LinkArrow = ({ width = 12, diff --git a/src/global/assets/svgs/Logo.tsx b/src/assets/icons/Logo.tsx similarity index 98% rename from src/global/assets/svgs/Logo.tsx rename to src/assets/icons/Logo.tsx index bd5dc7a7..29d80e16 100644 --- a/src/global/assets/svgs/Logo.tsx +++ b/src/assets/icons/Logo.tsx @@ -1,5 +1,4 @@ -import React from "react"; -import SVGAttribute from "../../types/SVGAttribute.type"; +import { SVGAttribute } from "@/interfaces"; const Logo = ({ width = 41, height = 40, isPointable }: SVGAttribute) => { return ( diff --git a/src/global/assets/svgs/Setting.tsx b/src/assets/icons/Setting.tsx similarity index 98% rename from src/global/assets/svgs/Setting.tsx rename to src/assets/icons/Setting.tsx index a7154718..9156d948 100644 --- a/src/global/assets/svgs/Setting.tsx +++ b/src/assets/icons/Setting.tsx @@ -1,5 +1,4 @@ -import color from "@/styles/color"; -import React from "react"; +import { color } from "@/styles"; interface ISettingProps extends React.SVGAttributes { width?: number; diff --git a/src/page/forum-post/assets/Time.tsx b/src/assets/icons/Time.tsx similarity index 94% rename from src/page/forum-post/assets/Time.tsx rename to src/assets/icons/Time.tsx index 7f627dbd..12a4352a 100644 --- a/src/page/forum-post/assets/Time.tsx +++ b/src/assets/icons/Time.tsx @@ -1,5 +1,4 @@ -import SVGAttribute from "@/global/types/SVGAttribute.type"; -import React from "react"; +import { SVGAttribute } from "@/interfaces"; const Time = ({ width = 21, height = 21, isPointable }: SVGAttribute) => { return ( diff --git a/src/page/forum-post/assets/View.tsx b/src/assets/icons/View.tsx similarity index 96% rename from src/page/forum-post/assets/View.tsx rename to src/assets/icons/View.tsx index d1b0d51c..b7fd3040 100644 --- a/src/page/forum-post/assets/View.tsx +++ b/src/assets/icons/View.tsx @@ -1,5 +1,4 @@ -import SVGAttribute from "@/global/types/SVGAttribute.type"; -import React from "react"; +import { SVGAttribute } from "@/interfaces"; const View = ({ width = 31, height = 23, isPointable }: SVGAttribute) => { return ( diff --git a/src/global/assets/svgs/XIcon.tsx b/src/assets/icons/XIcon.tsx similarity index 98% rename from src/global/assets/svgs/XIcon.tsx rename to src/assets/icons/XIcon.tsx index c64eac5b..516cfea1 100644 --- a/src/global/assets/svgs/XIcon.tsx +++ b/src/assets/icons/XIcon.tsx @@ -1,5 +1,3 @@ -import React from "react"; - const XIcon = ({ ...props }: React.SVGAttributes) => { return ( { diff --git a/src/global/assets/svgs/emojis/HoldingBackTears.tsx b/src/assets/icons/emojis/HoldingBackTears.tsx similarity index 97% rename from src/global/assets/svgs/emojis/HoldingBackTears.tsx rename to src/assets/icons/emojis/HoldingBackTears.tsx index 5a51e555..b8e450ca 100644 --- a/src/global/assets/svgs/emojis/HoldingBackTears.tsx +++ b/src/assets/icons/emojis/HoldingBackTears.tsx @@ -1,5 +1,4 @@ -import React from "react"; -import color from "@/styles/color"; +import { color } from "@/styles"; import StyledEmoji, { IStyledEmoji } from "./StyledEmoji"; const HoldingBackTears = ({ isHover, ...props }: IStyledEmoji) => { diff --git a/src/global/assets/svgs/emojis/Kissing.tsx b/src/assets/icons/emojis/Kissing.tsx similarity index 97% rename from src/global/assets/svgs/emojis/Kissing.tsx rename to src/assets/icons/emojis/Kissing.tsx index 42d46b8f..392b4a8e 100644 --- a/src/global/assets/svgs/emojis/Kissing.tsx +++ b/src/assets/icons/emojis/Kissing.tsx @@ -1,5 +1,4 @@ -import React from "react"; -import color from "@/styles/color"; +import { color } from "@/styles"; import StyledEmoji, { IStyledEmoji } from "./StyledEmoji"; const Kissing = ({ isHover, ...props }: IStyledEmoji) => { diff --git a/src/global/assets/svgs/emojis/Laughing.tsx b/src/assets/icons/emojis/Laughing.tsx similarity index 95% rename from src/global/assets/svgs/emojis/Laughing.tsx rename to src/assets/icons/emojis/Laughing.tsx index 2ad98c6e..c55e369d 100644 --- a/src/global/assets/svgs/emojis/Laughing.tsx +++ b/src/assets/icons/emojis/Laughing.tsx @@ -1,5 +1,4 @@ -import color from "@/styles/color"; -import React from "react"; +import { color } from "@/styles"; import StyledEmoji, { IStyledEmoji } from "./StyledEmoji"; const Laughing = ({ isHover, ...props }: IStyledEmoji) => { diff --git a/src/global/assets/svgs/emojis/Relaxed.tsx b/src/assets/icons/emojis/Relaxed.tsx similarity index 97% rename from src/global/assets/svgs/emojis/Relaxed.tsx rename to src/assets/icons/emojis/Relaxed.tsx index 1612d3be..c1c30bd8 100644 --- a/src/global/assets/svgs/emojis/Relaxed.tsx +++ b/src/assets/icons/emojis/Relaxed.tsx @@ -1,5 +1,4 @@ -import React from "react"; -import color from "@/styles/color"; +import { color } from "@/styles"; import StyledEmoji, { IStyledEmoji } from "./StyledEmoji"; const Relaxed = ({ isHover, ...props }: IStyledEmoji) => { diff --git a/src/global/assets/svgs/emojis/StyledEmoji.tsx b/src/assets/icons/emojis/StyledEmoji.tsx similarity index 100% rename from src/global/assets/svgs/emojis/StyledEmoji.tsx rename to src/assets/icons/emojis/StyledEmoji.tsx diff --git a/src/assets/icons/index.ts b/src/assets/icons/index.ts new file mode 100644 index 00000000..fc653bad --- /dev/null +++ b/src/assets/icons/index.ts @@ -0,0 +1,18 @@ +export { default as Arrow } from "./Arrow"; +export { default as CategoryArrow } from "./CategoryArrow"; +export { default as Check } from "./Check"; +export { default as CommentIcon } from "./CommentIcon"; +export { default as Emoji } from "./Emoji"; +export { default as Like } from "./Like"; +export { default as LikeIcon } from "./LikeIcon"; +export { default as LinkArrow } from "./LinkArrow"; +export { default as Logo } from "./Logo"; +export { default as Setting } from "./Setting"; +export { default as Time } from "./Time"; +export { default as View } from "./View"; +export { default as XIcon } from "./XIcon"; +export { default as Grinning } from "./emojis/Grinning"; +export { default as HoldingBackTears } from "./emojis/HoldingBackTears"; +export { default as Kissing } from "./emojis/Kissing"; +export { default as Laughing } from "./emojis/Laughing"; +export { default as Relaxed } from "./emojis/Relaxed"; diff --git a/src/components/common/Footer/assets/QR.png b/src/assets/images/QR.png similarity index 100% rename from src/components/common/Footer/assets/QR.png rename to src/assets/images/QR.png diff --git a/src/global/assets/icons/emoticon.png b/src/assets/images/emoticon.png similarity index 100% rename from src/global/assets/icons/emoticon.png rename to src/assets/images/emoticon.png diff --git a/src/page/lostfound/assets/imageNotFound.png b/src/assets/images/emptyImage.png similarity index 100% rename from src/page/lostfound/assets/imageNotFound.png rename to src/assets/images/emptyImage.png diff --git a/src/assets/images/index.ts b/src/assets/images/index.ts new file mode 100644 index 00000000..c728a9bf --- /dev/null +++ b/src/assets/images/index.ts @@ -0,0 +1,5 @@ +export { default as emoticon } from "./emoticon.png"; +export { default as emptyImage } from "./emptyImage.png"; +export { default as loading } from "./loading.gif"; +export { default as defaultProfile } from "./profile_default.png"; +export { default as QR } from "./QR.png"; diff --git a/src/global/assets/icons/loading.gif b/src/assets/images/loading.gif similarity index 100% rename from src/global/assets/icons/loading.gif rename to src/assets/images/loading.gif diff --git a/src/global/assets/icons/profile_default.png b/src/assets/images/profile_default.png similarity index 100% rename from src/global/assets/icons/profile_default.png rename to src/assets/images/profile_default.png diff --git a/src/components/Flex/index.ts b/src/components/Flex/index.ts new file mode 100644 index 00000000..12cd578f --- /dev/null +++ b/src/components/Flex/index.ts @@ -0,0 +1,2 @@ +export { default as Column } from "./Column"; +export { default as Row } from "./Row"; diff --git a/src/components/atoms/AnonymousBox.tsx b/src/components/atoms/AnonymousBox.tsx index 036153b5..4819252b 100644 --- a/src/components/atoms/AnonymousBox.tsx +++ b/src/components/atoms/AnonymousBox.tsx @@ -1,8 +1,6 @@ -import Check from "@/global/assets/svgs/Check"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; import styled, { css } from "styled-components"; +import { color, font } from "@/styles"; +import { Check } from "@/assets/icons"; interface IAnonymousBoxProps { clicked: boolean; diff --git a/src/components/atoms/Category.tsx b/src/components/atoms/Category.tsx index a81c76da..7eb2d359 100644 --- a/src/components/atoms/Category.tsx +++ b/src/components/atoms/Category.tsx @@ -1,8 +1,6 @@ -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; import styled, { css } from "styled-components"; -import Row from "../Flex/Row"; +import { color, font } from "@/styles"; +import { Row } from "@/components/Flex"; interface ICategoryProps extends React.InputHTMLAttributes { id?: string; diff --git a/src/components/atoms/CommentBox.tsx b/src/components/atoms/CommentBox.tsx index d0870721..c40c24d1 100644 --- a/src/components/atoms/CommentBox.tsx +++ b/src/components/atoms/CommentBox.tsx @@ -1,11 +1,10 @@ -import color from "@/styles/color"; import React from "react"; import styled from "styled-components"; -import { font } from "@/styles/font"; -import Emoji from "@/global/assets/svgs/Emoji"; +import { color, font } from "@/styles"; +import { Emoji } from "@/assets/icons"; import useEmoji from "@/hooks/useEmoji"; -import AnonymousBox from "@/components/atoms/AnonymousBox"; -import EmojiModal from "@/components/common/Modal/EmojiModal"; +import { AnonymousBox } from "@/components/atoms"; +import { EmojiModal } from "@/components/common"; const CommentBox = () => { const [isAnonymous, setIsAnonymous] = React.useState(false); diff --git a/src/components/atoms/CustomEditor.tsx b/src/components/atoms/CustomEditor.tsx index a3555f3a..e7aa2885 100644 --- a/src/components/atoms/CustomEditor.tsx +++ b/src/components/atoms/CustomEditor.tsx @@ -1,9 +1,9 @@ import React from "react"; -import { Editor as TinymcEditor } from "@tinymce/tinymce-react"; -import { font } from "@/styles/font"; import styled from "styled-components"; +import { Editor as TinymcEditor } from "@tinymce/tinymce-react"; +import { font } from "@/styles"; import useEmoji from "@/hooks/useEmoji"; -import EmojiModal from "../common/Modal/EmojiModal"; +import { EmojiModal } from "@/components/common"; interface IBlobInfo { id: () => string; diff --git a/src/components/atoms/ImageWithFallback.tsx b/src/components/atoms/ImageWithFallback.tsx index c11608f8..2b5ce77b 100644 --- a/src/components/atoms/ImageWithFallback.tsx +++ b/src/components/atoms/ImageWithFallback.tsx @@ -1,5 +1,5 @@ +import React from "react"; import Image, { ImageProps, StaticImageData } from "next/image"; -import { useState } from "react"; import styled, { css } from "styled-components"; interface ImageWithFallbackProps extends ImageProps { @@ -18,7 +18,7 @@ const ImageWithFallback = ({ isShouldHide, ...props }: ImageWithFallbackProps) => { - const [imgSrc, setImgSrc] = useState(src); + const [imgSrc, setImgSrc] = React.useState(src); return ( { width?: string; diff --git a/src/components/atoms/Select.tsx b/src/components/atoms/Select.tsx index d85ed24f..ab4bec5e 100644 --- a/src/components/atoms/Select.tsx +++ b/src/components/atoms/Select.tsx @@ -1,8 +1,7 @@ -import Arrow from "@/global/assets/svgs/Arrow"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; import React from "react"; import styled, { css } from "styled-components"; +import { color, font } from "@/styles"; +import { Arrow } from "@/assets/icons"; interface ISelectProps { options: string[]; diff --git a/src/components/atoms/Switch.tsx b/src/components/atoms/Switch.tsx index 1777f4a0..6493a085 100644 --- a/src/components/atoms/Switch.tsx +++ b/src/components/atoms/Switch.tsx @@ -1,6 +1,6 @@ -import color from "@/styles/color"; import React from "react"; import styled, { keyframes } from "styled-components"; +import { color } from "@/styles"; interface ISwitchProps { isSwitch: boolean; diff --git a/src/components/atoms/index.ts b/src/components/atoms/index.ts new file mode 100644 index 00000000..44bc0311 --- /dev/null +++ b/src/components/atoms/index.ts @@ -0,0 +1,8 @@ +export { default as AnonymousBox } from "./AnonymousBox"; +export { default as Category } from "./Category"; +export { default as CommentBox } from "./CommentBox"; +export { default as CustomEditor } from "./CustomEditor"; +export { default as ImageWithFallback } from "./ImageWithFallback"; +export { default as Input } from "./Input"; +export { default as Select } from "./Select"; +export { default as Switch } from "./Switch"; diff --git a/src/components/common/Aside/InfomationBox.tsx b/src/components/common/Aside/InfomationBox.tsx index 54967537..40194cb4 100644 --- a/src/components/common/Aside/InfomationBox.tsx +++ b/src/components/common/Aside/InfomationBox.tsx @@ -1,18 +1,14 @@ -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; import Image from "next/image"; -import DefaultProfile from "@/global/assets/icons/profile_default.png"; -import { Student } from "@/global/types/user.type"; import Link from "next/link"; -import ROUTER from "@/global/constants/router.constant"; -import USER from "@/global/constants/user.constant"; -import Column from "../../Flex/Column"; -import Row from "../../Flex/Row"; +import { color, font } from "@/styles"; +import { defaultProfile } from "@/assets/images"; +import { USER, ROUTER } from "@/constants"; +import { IUser } from "@/interfaces"; +import { Row, Column } from "@/components/Flex"; interface IInfomationBoxProps { - user: Student; + user: IUser; isLogined: boolean; } @@ -20,7 +16,7 @@ const InfomationBox = ({ user, isLogined }: IInfomationBoxProps) => { return ( { return ( diff --git a/src/components/common/Aside/MeisterBox.tsx b/src/components/common/Aside/MeisterBox.tsx index 52eda935..64800b73 100644 --- a/src/components/common/Aside/MeisterBox.tsx +++ b/src/components/common/Aside/MeisterBox.tsx @@ -1,9 +1,7 @@ -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; -import SERVICE from "@/global/constants/service.constant"; -import Row from "../../Flex/Row"; +import { color, font } from "@/styles"; +import { SERVICE } from "@/constants"; +import { Row } from "@/components/Flex"; const scores = [ { diff --git a/src/components/common/Aside/assets/Check.tsx b/src/components/common/Aside/assets/Check.tsx deleted file mode 100644 index e527ed30..00000000 --- a/src/components/common/Aside/assets/Check.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import SVGAttribute from "@/global/types/SVGAttribute.type"; -import React from "react"; - -const Check = ({ width, height, color }: SVGAttribute) => { - return ( - - - - - - - ); -}; - -export default Check; diff --git a/src/components/common/Aside/index.tsx b/src/components/common/Aside/index.tsx index 97e57d5a..71305405 100644 --- a/src/components/common/Aside/index.tsx +++ b/src/components/common/Aside/index.tsx @@ -1,7 +1,6 @@ -import React from "react"; import styled from "styled-components"; -import Row from "@/components/Flex/Row"; import useUser from "@/hooks/useUser"; +import { Row } from "@/components/Flex"; import InfomationBox from "./InfomationBox"; import MeisterBox from "./MeisterBox"; import JoinCheckBox from "./JoinCheckBox"; diff --git a/src/components/common/Footer/Info.tsx b/src/components/common/Footer/Info.tsx index 926749d7..da01dc12 100644 --- a/src/components/common/Footer/Info.tsx +++ b/src/components/common/Footer/Info.tsx @@ -1,12 +1,8 @@ -import React from "react"; import styled from "styled-components"; -import color from "@/styles/color"; import Image from "next/image"; -import { font } from "@/styles/font"; -import Column from "../../Flex/Column"; -import Row from "../../Flex/Row"; - -import QR from "./assets/QR.png"; +import { color, font } from "@/styles"; +import { QR } from "@/assets/images"; +import { Row, Column } from "@/components/Flex"; const Info = () => { const { name, service, headline, serviceInfo, policy, inquery, copyRight } = { diff --git a/src/components/common/Footer/index.tsx b/src/components/common/Footer/index.tsx index 6687ea1e..088bd647 100644 --- a/src/components/common/Footer/index.tsx +++ b/src/components/common/Footer/index.tsx @@ -1,6 +1,5 @@ -import React from "react"; import styled from "styled-components"; -import color from "@/styles/color"; +import { color } from "@/styles"; import Info from "./Info"; const Footer = () => { diff --git a/src/components/common/Header/Navigation.tsx b/src/components/common/Header/Navigation.tsx index 5e335f56..dc25826e 100644 --- a/src/components/common/Header/Navigation.tsx +++ b/src/components/common/Header/Navigation.tsx @@ -1,8 +1,6 @@ -import color from "@/styles/color"; -import { font } from "@/styles/font"; import Link from "next/link"; -import React from "react"; import styled from "styled-components"; +import { color, font } from "@/styles"; const navigations = [ { diff --git a/src/components/common/Header/index.tsx b/src/components/common/Header/index.tsx index 4fe2d2b2..dd1fe3f4 100644 --- a/src/components/common/Header/index.tsx +++ b/src/components/common/Header/index.tsx @@ -1,12 +1,10 @@ -import React from "react"; import styled from "styled-components"; -import Logo from "@/global/assets/svgs/Logo"; -import Setting from "@/global/assets/svgs/Setting"; -import color from "@/styles/color"; import Link from "next/link"; +import { color } from "@/styles"; +import { Logo, Setting } from "@/assets/icons"; import useModal from "@/hooks/useModal"; +import { SettingModal } from "@/components/common"; import Navigation from "./Navigation"; -import SettingModal from "../Modal/SettingModal"; const Header = () => { const { openModal } = useModal(); diff --git a/src/components/common/Modal/EmojiModal/ModalHeader.tsx b/src/components/common/Modal/EmojiModal/ModalHeader.tsx index 977e6698..20f056ea 100644 --- a/src/components/common/Modal/EmojiModal/ModalHeader.tsx +++ b/src/components/common/Modal/EmojiModal/ModalHeader.tsx @@ -1,9 +1,6 @@ -import XIcon from "@/global/assets/svgs/XIcon"; -import HoldingBackTears from "@/global/assets/svgs/emojis/HoldingBackTears"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; +import { color, font } from "@/styles"; +import { XIcon, HoldingBackTears } from "@/assets/icons"; interface IModalHeaderProps { handleClickCloseButton: () => void; diff --git a/src/components/common/Modal/EmojiModal/ModalList.tsx b/src/components/common/Modal/EmojiModal/ModalList.tsx index c229c074..89179e35 100644 --- a/src/components/common/Modal/EmojiModal/ModalList.tsx +++ b/src/components/common/Modal/EmojiModal/ModalList.tsx @@ -1,4 +1,3 @@ -import React from "react"; import styled from "styled-components"; import ModalListItem from "./ModalListItem"; diff --git a/src/components/common/Modal/EmojiModal/ModalListItem.tsx b/src/components/common/Modal/EmojiModal/ModalListItem.tsx index b10c79dd..109c3291 100644 --- a/src/components/common/Modal/EmojiModal/ModalListItem.tsx +++ b/src/components/common/Modal/EmojiModal/ModalListItem.tsx @@ -1,8 +1,6 @@ -import color from "@/styles/color"; -import { font } from "@/styles/font"; import Image from "next/image"; -import React from "react"; import styled from "styled-components"; +import { color, font } from "@/styles"; const ModalListItem = () => { return ( diff --git a/src/components/common/Modal/EmojiModal/index.tsx b/src/components/common/Modal/EmojiModal/index.tsx index 16dba693..b719adaa 100644 --- a/src/components/common/Modal/EmojiModal/index.tsx +++ b/src/components/common/Modal/EmojiModal/index.tsx @@ -1,6 +1,5 @@ -import color from "@/styles/color"; -import React from "react"; import styled, { css } from "styled-components"; +import { color } from "@/styles"; import ModalList from "./ModalList"; import ModalHeader from "./ModalHeader"; diff --git a/src/components/common/Modal/SettingModal/SettingBody.tsx b/src/components/common/Modal/SettingModal/SettingBody.tsx index cb3f0471..9e8222d5 100644 --- a/src/components/common/Modal/SettingModal/SettingBody.tsx +++ b/src/components/common/Modal/SettingModal/SettingBody.tsx @@ -1,8 +1,7 @@ -import Switch from "@/components/atoms/Switch"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; import React from "react"; import styled from "styled-components"; +import { color, font } from "@/styles"; +import { Switch } from "@/components/atoms"; const settingOptions = [ { diff --git a/src/components/common/Modal/SettingModal/SettingHeader.tsx b/src/components/common/Modal/SettingModal/SettingHeader.tsx index bd5541b4..86a8b928 100644 --- a/src/components/common/Modal/SettingModal/SettingHeader.tsx +++ b/src/components/common/Modal/SettingModal/SettingHeader.tsx @@ -1,8 +1,6 @@ -import Setting from "@/global/assets/svgs/Setting"; -import XIcon from "@/global/assets/svgs/XIcon"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; +import { font } from "@/styles"; +import { XIcon, Setting } from "@/assets/icons"; const SettingHeader = () => { return ( diff --git a/src/components/common/Modal/SettingModal/index.tsx b/src/components/common/Modal/SettingModal/index.tsx index a536670c..7c898568 100644 --- a/src/components/common/Modal/SettingModal/index.tsx +++ b/src/components/common/Modal/SettingModal/index.tsx @@ -1,6 +1,5 @@ -import color from "@/styles/color"; -import React from "react"; import styled from "styled-components"; +import { color } from "@/styles"; import SettingHeader from "./SettingHeader"; import SettingBody from "./SettingBody"; diff --git a/src/components/common/Modal/View.tsx b/src/components/common/Modal/View.tsx index a4f41303..f6068797 100644 --- a/src/components/common/Modal/View.tsx +++ b/src/components/common/Modal/View.tsx @@ -1,5 +1,5 @@ -import { IModalState } from "@/global/types/modal.type"; import styled, { css } from "styled-components"; +import { IModalState } from "@/interfaces"; interface ModalViewProps extends IModalState { onClose?: () => void; diff --git a/src/components/common/Modal/index.tsx b/src/components/common/Modal/index.tsx index 34aaa166..7e7e2dc4 100644 --- a/src/components/common/Modal/index.tsx +++ b/src/components/common/Modal/index.tsx @@ -1,5 +1,5 @@ -import useModal from "@/hooks/useModal"; import { useRecoilState } from "recoil"; +import useModal from "@/hooks/useModal"; import modalStore from "@/store/modal.store"; import ModalView from "./View"; diff --git a/src/components/common/index.ts b/src/components/common/index.ts new file mode 100644 index 00000000..cefbe583 --- /dev/null +++ b/src/components/common/index.ts @@ -0,0 +1,6 @@ +export { default as Aside } from "./Aside"; +export { default as Footer } from "./Footer"; +export { default as Header } from "./Header"; +export { default as Modal } from "./Modal"; +export { default as SettingModal } from "./Modal/SettingModal"; +export { default as EmojiModal } from "./Modal/EmojiModal"; diff --git a/src/constants/applications.constant.ts b/src/constants/applications.constant.ts new file mode 100644 index 00000000..e2c04842 --- /dev/null +++ b/src/constants/applications.constant.ts @@ -0,0 +1,14 @@ +const APPLICATIONS = { + BSM: { + NAME: "BSM", + TYPE: "bsm_service", + }, + OTHER: { + NAME: "외부", + TYPE: "other_service", + }, + NAME: "applications", + TYPE: "radio", +} as const; + +export default APPLICATIONS; diff --git a/src/global/constants/error.constant.ts b/src/constants/error.constant.ts similarity index 100% rename from src/global/constants/error.constant.ts rename to src/constants/error.constant.ts diff --git a/src/constants/forum.constant.ts b/src/constants/forum.constant.ts new file mode 100644 index 00000000..83bf2ded --- /dev/null +++ b/src/constants/forum.constant.ts @@ -0,0 +1,32 @@ +const FORUM = { + FREE: { + NAME: "자유", + TYPE: "free", + }, + STUDENT: { + NAME: "학생", + TYPE: "student", + }, + NAME: "forum", + TYPE: "radio", + CATEGORY: { + ALL: { + NAME: "전체", + TYPE: "all", + }, + COMPLAIN: { + NAME: "불만", + TYPE: "complain", + }, + HUMOR: { + NAME: "유머", + TYPE: "humor", + }, + INFORMATION: { + NAME: "정보", + TYPE: "information", + }, + }, +} as const; + +export default FORUM; diff --git a/src/constants/index.ts b/src/constants/index.ts new file mode 100644 index 00000000..dfcccb77 --- /dev/null +++ b/src/constants/index.ts @@ -0,0 +1,10 @@ +export { default as APPLICATIONS } from "./applications.constant"; +export { default as ERROR } from "./error.constant"; +export { default as FORUM } from "./forum.constant"; +export { default as KEY } from "./key.constant"; +export { default as LOSTFOUND } from "./lostfound.constant"; +export { default as MEAL } from "./meal.constant"; +export { default as ROUTER } from "./router.constant"; +export { default as SERVICE } from "./service.constant"; +export { default as TOKEN } from "./token.constant"; +export { default as USER } from "./user.constant"; diff --git a/src/global/constants/key.constant.ts b/src/constants/key.constant.ts similarity index 100% rename from src/global/constants/key.constant.ts rename to src/constants/key.constant.ts diff --git a/src/constants/lostfound.constant.ts b/src/constants/lostfound.constant.ts new file mode 100644 index 00000000..54bfdb74 --- /dev/null +++ b/src/constants/lostfound.constant.ts @@ -0,0 +1,12 @@ +const LOSTFOUND = { + LOST: { + NAME: "분실", + TYPE: "lost", + }, + FOUND: { + NAME: "습득", + TYPE: "found", + }, +}; + +export default LOSTFOUND; diff --git a/src/constants/meal.constant.ts b/src/constants/meal.constant.ts new file mode 100644 index 00000000..deccbe9a --- /dev/null +++ b/src/constants/meal.constant.ts @@ -0,0 +1,24 @@ +const MEAL = { + PREV: { + NAME: "이전", + TYPE: "prev", + }, + FIRST: { + NAME: "첫번째", + TYPE: "first", + }, + SECOND: { + NAME: "두번째", + TYPE: "second", + }, + THIRD: { + NAME: "세번째", + TYPE: "third", + }, + NEXT: { + NAME: "다음", + TYPE: "next", + }, +}; + +export default MEAL; diff --git a/src/global/constants/router.constant.ts b/src/constants/router.constant.ts similarity index 100% rename from src/global/constants/router.constant.ts rename to src/constants/router.constant.ts diff --git a/src/global/constants/service.constant.ts b/src/constants/service.constant.ts similarity index 100% rename from src/global/constants/service.constant.ts rename to src/constants/service.constant.ts diff --git a/src/global/constants/token.constant.ts b/src/constants/token.constant.ts similarity index 100% rename from src/global/constants/token.constant.ts rename to src/constants/token.constant.ts diff --git a/src/global/constants/user.constant.ts b/src/constants/user.constant.ts similarity index 100% rename from src/global/constants/user.constant.ts rename to src/constants/user.constant.ts diff --git a/src/global/assets/data/categories.ts b/src/global/assets/data/categories.ts deleted file mode 100644 index 74cf995e..00000000 --- a/src/global/assets/data/categories.ts +++ /dev/null @@ -1,22 +0,0 @@ -import forum from "@/global/constants/forum.constant"; - -const categories = [ - { - name: forum.category.all.name, - type: forum.category.all.type, - }, - { - name: forum.category.complain.name, - type: forum.category.complain.type, - }, - { - name: forum.category.humor.name, - type: forum.category.humor.type, - }, - { - name: forum.category.infomation.name, - type: forum.category.infomation.type, - }, -]; - -export default categories; diff --git a/src/global/constants/forum.constant.ts b/src/global/constants/forum.constant.ts deleted file mode 100644 index d09ec832..00000000 --- a/src/global/constants/forum.constant.ts +++ /dev/null @@ -1,53 +0,0 @@ -import PostCategoryType from "../types/postCategory.type"; - -interface IForum { - free: { - name: string; - type: string; - }; - student: { - name: string; - type: string; - }; - name: string; - type: string; - category: { - [categoryName: string]: { - name: string; - type: PostCategoryType; - }; - }; -} - -const forum: IForum = { - free: { - name: "자유", - type: "free", - }, - student: { - name: "학생", - type: "student", - }, - name: "forum", - type: "radio", - category: { - all: { - name: "전체", - type: "all", - }, - complain: { - name: "불만", - type: "complain", - }, - humor: { - name: "유머", - type: "humor", - }, - infomation: { - name: "정보", - type: "information", - }, - }, -}; - -export default forum; diff --git a/src/global/constants/lostfound.constant.ts b/src/global/constants/lostfound.constant.ts deleted file mode 100644 index 69bfa25c..00000000 --- a/src/global/constants/lostfound.constant.ts +++ /dev/null @@ -1,12 +0,0 @@ -const lostfound = { - lost: { - name: "분실", - type: "lost", - }, - found: { - name: "습득", - type: "found", - }, -}; - -export default lostfound; diff --git a/src/global/helpers/getProfileUrl.helper.ts b/src/global/helpers/getProfileUrl.helper.ts deleted file mode 100644 index 06e05dc3..00000000 --- a/src/global/helpers/getProfileUrl.helper.ts +++ /dev/null @@ -1,5 +0,0 @@ -const getProfileUrl = (userCode: number) => { - return `https://bssm.kro.kr/_next/image?url=https://auth.bssm.kro.kr/resource/user/profile/${userCode}.png&w=256&q=75`; -}; - -export default getProfileUrl; diff --git a/src/global/types/modal.type.ts b/src/global/types/modal.type.ts deleted file mode 100644 index deffab05..00000000 --- a/src/global/types/modal.type.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ReactNode } from "react"; - -export interface IModalState { - component: ReactNode; - visible?: boolean; - menualClose?: boolean; - onClose?: () => void; -} diff --git a/src/helpers/getProfileUrl.helper.ts b/src/helpers/getProfileUrl.helper.ts new file mode 100644 index 00000000..9143abda --- /dev/null +++ b/src/helpers/getProfileUrl.helper.ts @@ -0,0 +1,8 @@ +const getProfileUrl = (userCode: number) => { + const BASE_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/_next/image`; + const IMAGE_URL = `${process.env.NEXT_PUBLIC_USER_IMAGE_URL}/${userCode}.png&w=256&q=75`; + + return `${BASE_URL}?url=${IMAGE_URL}`; +}; + +export default getProfileUrl; diff --git a/src/global/helpers/provider.helper.tsx b/src/helpers/provider.helper.tsx similarity index 69% rename from src/global/helpers/provider.helper.tsx rename to src/helpers/provider.helper.tsx index 89dbe834..e635ff61 100644 --- a/src/global/helpers/provider.helper.tsx +++ b/src/helpers/provider.helper.tsx @@ -1,15 +1,13 @@ "use client"; -import Header from "@/components/common/Header"; -import Footer from "@/components/common/Footer"; -import Modal from "@/components/common/Modal"; -import React, { PropsWithChildren } from "react"; +import React from "react"; import { ToastContainer, toast } from "react-toastify"; import { RecoilRoot } from "recoil"; +import { Header, Footer, Modal } from "@/components/common"; import Column from "@/components/Flex/Column"; import ReactQueryProvider from "./reactQueryProvider.helper"; -const Provider = ({ children }: PropsWithChildren) => { +const Provider = ({ children }: React.PropsWithChildren) => { return ( diff --git a/src/global/helpers/reactQueryProvider.helper.tsx b/src/helpers/reactQueryProvider.helper.tsx similarity index 75% rename from src/global/helpers/reactQueryProvider.helper.tsx rename to src/helpers/reactQueryProvider.helper.tsx index 209f10dc..f839f9de 100644 --- a/src/global/helpers/reactQueryProvider.helper.tsx +++ b/src/helpers/reactQueryProvider.helper.tsx @@ -1,6 +1,6 @@ "use client"; -import React, { PropsWithChildren } from "react"; +import React from "react"; import { QueryClient, QueryClientProvider } from "react-query"; const queryClient = new QueryClient({ @@ -12,7 +12,7 @@ const queryClient = new QueryClient({ }, }); -const ReactQueryProvider = ({ children }: PropsWithChildren) => { +const ReactQueryProvider = ({ children }: React.PropsWithChildren) => { return ( {children} ); diff --git a/src/hooks/useEmoji.ts b/src/hooks/useEmoji.ts index 0fab24b6..875ba053 100644 --- a/src/hooks/useEmoji.ts +++ b/src/hooks/useEmoji.ts @@ -1,15 +1,15 @@ -import emojiStore from "@/store/emoji.store"; -import { useCallback } from "react"; +import React from "react"; import { useRecoilState } from "recoil"; +import emojiStore from "@/store/emoji.store"; const useEmoji = () => { const [emoji, setEmoji] = useRecoilState(emojiStore); - const openEmoji = useCallback(() => { + const openEmoji = React.useCallback(() => { setEmoji({ visible: true }); }, [setEmoji]); - const closeEmoji = useCallback(() => { + const closeEmoji = React.useCallback(() => { setEmoji({ visible: false }); }, [setEmoji]); diff --git a/src/hooks/useModal.ts b/src/hooks/useModal.ts index 310b65db..37f6eff1 100644 --- a/src/hooks/useModal.ts +++ b/src/hooks/useModal.ts @@ -1,12 +1,12 @@ -import { IModalState } from "@/global/types/modal.type"; -import modalStore from "@/store/modal.store"; -import { useCallback } from "react"; +import React from "react"; import { useRecoilState } from "recoil"; +import { IModalState } from "@/interfaces"; +import modalStore from "@/store/modal.store"; const useModal = () => { const [modal, setModal] = useRecoilState(modalStore); - const openModal = useCallback( + const openModal = React.useCallback( (modalData: IModalState) => { setModal({ ...modalData, @@ -16,7 +16,7 @@ const useModal = () => { [setModal], ); - const closeModal = useCallback(() => { + const closeModal = React.useCallback(() => { setModal({ component: null, visible: false, diff --git a/src/hooks/useTimetableBar.ts b/src/hooks/useTimetableBar.ts index 9f39380f..0e291e47 100644 --- a/src/hooks/useTimetableBar.ts +++ b/src/hooks/useTimetableBar.ts @@ -1,11 +1,11 @@ import React from "react"; -import emptyClass from "@/page/timetable/data/emptyClassInfo"; -import useDate from "./useDate"; +import { emptyClassInfo } from "@/assets/data"; +import useDate from "@/hooks/useDate"; const useTimetableBar = () => { const date = useDate(); const [nowDate, setNowDate] = React.useState(""); - const [currentClass, setCurrentClass] = React.useState(emptyClass); + const [currentClass, setCurrentClass] = React.useState(emptyClassInfo); const [isScrollBox, setIsScrollBox] = React.useState(false); const scrollRef = React.useRef(null); diff --git a/src/hooks/useUser.ts b/src/hooks/useUser.ts index b4fa9256..c48ca512 100644 --- a/src/hooks/useUser.ts +++ b/src/hooks/useUser.ts @@ -1,16 +1,14 @@ -import httpClient, { HttpClient } from "@/apis/httpClient/httpClient"; -import Storage from "@/apis/storage"; import React from "react"; -import KEY from "@/global/constants/key.constant"; -import TOKEN from "@/global/constants/token.constant"; -import { Student } from "@/global/types/user.type"; -import { emptyUser, userStore } from "@/store/user.store"; import { useRouter } from "next/navigation"; import { useQuery } from "react-query"; -import getProfileUrl from "@/global/helpers/getProfileUrl.helper"; import { useRecoilState } from "recoil"; -import useWindow from "./useWindow"; -import useModal from "./useModal"; +import httpClient from "@/apis/httpClient/httpClient"; +import KEY from "@/constants/key.constant"; +import { IUser } from "@/interfaces"; +import { emptyUser, userStore } from "@/store/user.store"; +import getProfileUrl from "@/helpers/getProfileUrl.helper"; +import useWindow from "@/hooks/useWindow"; +import useModal from "@/hooks/useModal"; interface UseUserOptions { authorizedPage?: boolean; @@ -26,22 +24,16 @@ const useUser = (options?: UseUserOptions) => { data: userInfo, remove, isLoading, - } = useQuery( - [KEY.USER], - async () => { - HttpClient.setAccessToken(); - const { data } = await httpClient.user.get(); - const profile = getProfileUrl(data.code); - return { - ...data, - profile, - }; - }, - { enabled: !!Storage.getItem(TOKEN.ACCESS) }, - ); + } = useQuery([KEY.USER], async () => { + const { data } = await httpClient.user.get(); + const profile = getProfileUrl(data.code); + return { + ...data, + profile, + }; + }); const logout = () => { - HttpClient.removeAccessToken(); setUser(emptyUser); remove(); }; diff --git a/src/global/types/SVGAttribute.type.ts b/src/interfaces/SVGAttribute.interface.ts similarity index 100% rename from src/global/types/SVGAttribute.type.ts rename to src/interfaces/SVGAttribute.interface.ts diff --git a/src/global/types/classInfo.type.ts b/src/interfaces/classInfo.interface.ts similarity index 100% rename from src/global/types/classInfo.type.ts rename to src/interfaces/classInfo.interface.ts diff --git a/src/global/types/classLevel.type.ts b/src/interfaces/classLevel.interface.ts similarity index 100% rename from src/global/types/classLevel.type.ts rename to src/interfaces/classLevel.interface.ts diff --git a/src/global/types/emoji.type.ts b/src/interfaces/emoji.interface.ts similarity index 100% rename from src/global/types/emoji.type.ts rename to src/interfaces/emoji.interface.ts diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts new file mode 100644 index 00000000..e13b30cb --- /dev/null +++ b/src/interfaces/index.ts @@ -0,0 +1,11 @@ +export type { default as SVGAttribute } from "./SVGAttribute.interface"; +export type { default as IClassInfo } from "./classInfo.interface"; +export type { default as IClassLevel } from "./classLevel.interface"; +export type { default as IEmojiState } from "./emoji.interface"; +export type { default as IMealList } from "./mealList.interface"; +export type { default as IMealListItem } from "./mealListItem.interface"; +export type { default as IModalState } from "./modal.interface"; +export type { default as IPost } from "./post.interface"; +export type { default as IPostQuery } from "./postQuery.interface"; +export type { default as ITimetable } from "./timetable.interface"; +export type { Student as IUser } from "./user.interface"; diff --git a/src/interfaces/mealList.interface.ts b/src/interfaces/mealList.interface.ts new file mode 100644 index 00000000..321e63e0 --- /dev/null +++ b/src/interfaces/mealList.interface.ts @@ -0,0 +1,3 @@ +export default interface MealListType { + mealList: Array; +} diff --git a/src/page/meal/types/mealListItem.type.ts b/src/interfaces/mealListItem.interface.ts similarity index 56% rename from src/page/meal/types/mealListItem.type.ts rename to src/interfaces/mealListItem.interface.ts index 0fa6dbea..f4e5793e 100644 --- a/src/page/meal/types/mealListItem.type.ts +++ b/src/interfaces/mealListItem.interface.ts @@ -1,8 +1,6 @@ -interface MealListItemsType { +export default interface MealListItemsType { key: number; date: number; menu: Array; currentSlideIndex: number; } - -export default MealListItemsType; diff --git a/src/interfaces/modal.interface.ts b/src/interfaces/modal.interface.ts new file mode 100644 index 00000000..89d26a67 --- /dev/null +++ b/src/interfaces/modal.interface.ts @@ -0,0 +1,8 @@ +import React from "react"; + +export default interface IModalState { + component: React.ReactNode; + visible?: boolean; + menualClose?: boolean; + onClose?: () => void; +} diff --git a/src/global/types/post.type.ts b/src/interfaces/post.interface.ts similarity index 81% rename from src/global/types/post.type.ts rename to src/interfaces/post.interface.ts index 17a3c34f..828d8464 100644 --- a/src/global/types/post.type.ts +++ b/src/interfaces/post.interface.ts @@ -1,4 +1,4 @@ -import PostCategoryType from "./postCategory.type"; +import { PostCategoryType } from "@/types"; export default interface IPost { id: string; diff --git a/src/global/types/postQuery.type.ts b/src/interfaces/postQuery.interface.ts similarity index 63% rename from src/global/types/postQuery.type.ts rename to src/interfaces/postQuery.interface.ts index 2aef4b56..792bba9d 100644 --- a/src/global/types/postQuery.type.ts +++ b/src/interfaces/postQuery.interface.ts @@ -1,4 +1,4 @@ -import PostCategoryType from "./postCategory.type"; +import { PostCategoryType } from "@/types"; export default interface IPostQuery { postType: string; diff --git a/src/global/types/timetable.type.ts b/src/interfaces/timetable.interface.ts similarity index 62% rename from src/global/types/timetable.type.ts rename to src/interfaces/timetable.interface.ts index f1681445..96192cf5 100644 --- a/src/global/types/timetable.type.ts +++ b/src/interfaces/timetable.interface.ts @@ -1,4 +1,4 @@ -import IClassInfo from "./classInfo.type"; +import { IClassInfo } from "@/interfaces"; export default interface ITimetable { [day: string]: IClassInfo[]; diff --git a/src/global/types/user.type.ts b/src/interfaces/user.interface.ts similarity index 100% rename from src/global/types/user.type.ts rename to src/interfaces/user.interface.ts diff --git a/src/page/applications/constants/applications.constant.ts b/src/page/applications/constants/applications.constant.ts deleted file mode 100644 index 2bb12fdb..00000000 --- a/src/page/applications/constants/applications.constant.ts +++ /dev/null @@ -1,14 +0,0 @@ -const applications = { - bsm: { - name: "BSM", - type: "bsm_service", - }, - other: { - name: "외부", - type: "other_service", - }, - name: "applications", - type: "radio", -}; - -export default applications; diff --git a/src/page/applications/index.tsx b/src/page/applications/index.tsx index bf7dca64..1c34cb48 100644 --- a/src/page/applications/index.tsx +++ b/src/page/applications/index.tsx @@ -1,7 +1,6 @@ -import Aside from "@/components/common/Aside"; -import Column from "@/components/Flex/Column"; -import React from "react"; import styled from "styled-components"; +import { Aside } from "@/components/common"; +import { Column } from "@/components/Flex"; import AppList from "./layouts/AppList"; import AppListFilter from "./layouts/AppListFilter"; diff --git a/src/page/applications/layouts/AppList.tsx b/src/page/applications/layouts/AppList.tsx index f6f3b73a..3dfbee79 100644 --- a/src/page/applications/layouts/AppList.tsx +++ b/src/page/applications/layouts/AppList.tsx @@ -1,11 +1,10 @@ -import React from "react"; import styled from "styled-components"; import AppListItem from "./AppListItem"; const AppList = () => { return ( - {[1, 2, 3, 4, 5, 6, 7].map((x) => ( + {Array.from({ length: 7 }).map((_, x) => ( ))} diff --git a/src/page/applications/layouts/AppListFilter.tsx b/src/page/applications/layouts/AppListFilter.tsx index 3fa14e03..dde61cfc 100644 --- a/src/page/applications/layouts/AppListFilter.tsx +++ b/src/page/applications/layouts/AppListFilter.tsx @@ -1,18 +1,17 @@ -import Row from "@/components/Flex/Row"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import applications from "@/page/applications/constants/applications.constant"; +import { Row } from "@/components/Flex"; +import { color, font } from "@/styles"; +import { APPLICATIONS } from "@/constants"; import React from "react"; import styled, { css, keyframes } from "styled-components"; const filters = [ { - type: applications.bsm.type, - name: applications.bsm.name, + type: APPLICATIONS.BSM.TYPE, + name: APPLICATIONS.BSM.NAME, }, { - type: applications.other.type, - name: applications.other.name, + type: APPLICATIONS.OTHER.TYPE, + name: APPLICATIONS.OTHER.NAME, }, ]; @@ -32,9 +31,9 @@ const AppListFilter = () => { ))} diff --git a/src/page/applications/layouts/AppListItem.tsx b/src/page/applications/layouts/AppListItem.tsx index d733b584..515000c7 100644 --- a/src/page/applications/layouts/AppListItem.tsx +++ b/src/page/applications/layouts/AppListItem.tsx @@ -1,11 +1,8 @@ -import Column from "@/components/Flex/Column"; -import Row from "@/components/Flex/Row"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; import Link from "next/link"; -import React from "react"; import styled from "styled-components"; -import LinkArrow from "@/page/applications/assets/LinkArrow"; +import { Row, Column } from "@/components/Flex"; +import { color, font } from "@/styles"; +import { LinkArrow } from "@/assets/icons"; const AppListItem = () => { return ( diff --git a/src/page/calender/index.tsx b/src/page/calender/index.tsx index d54c482f..285f64e7 100644 --- a/src/page/calender/index.tsx +++ b/src/page/calender/index.tsx @@ -1,6 +1,5 @@ -import Aside from "@/components/common/Aside"; -import React from "react"; import styled from "styled-components"; +import { Aside } from "@/components/common"; import ScheduleBox from "./layouts/ScheduleBox"; const CalenderPage = () => { diff --git a/src/page/calender/layouts/CalenderList.tsx b/src/page/calender/layouts/CalenderList.tsx index f5141355..279ba082 100644 --- a/src/page/calender/layouts/CalenderList.tsx +++ b/src/page/calender/layouts/CalenderList.tsx @@ -1,11 +1,10 @@ -import React from "react"; import styled from "styled-components"; import CalenderListItem from "./CalenderListItem"; const CalenderList = () => { return ( - {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((index) => ( + {Array.from({ length: 10 }).map((_, index) => ( ))} diff --git a/src/page/calender/layouts/CalenderListItem.tsx b/src/page/calender/layouts/CalenderListItem.tsx index 0db405e5..e0565f54 100644 --- a/src/page/calender/layouts/CalenderListItem.tsx +++ b/src/page/calender/layouts/CalenderListItem.tsx @@ -1,6 +1,4 @@ -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; +import { color, font } from "@/styles"; import styled from "styled-components"; const CalenderListItem = () => { diff --git a/src/page/calender/layouts/DateBox.tsx b/src/page/calender/layouts/DateBox.tsx index 75dee3a3..7d976673 100644 --- a/src/page/calender/layouts/DateBox.tsx +++ b/src/page/calender/layouts/DateBox.tsx @@ -1,7 +1,6 @@ -import Row from "@/components/Flex/Row"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; +import { Row } from "@/components/Flex"; +import { font } from "@/styles"; const DateBox = () => { const date = new Date(); diff --git a/src/page/calender/layouts/ScheduleBox.tsx b/src/page/calender/layouts/ScheduleBox.tsx index 2331a422..d9d0648b 100644 --- a/src/page/calender/layouts/ScheduleBox.tsx +++ b/src/page/calender/layouts/ScheduleBox.tsx @@ -1,6 +1,5 @@ -import color from "@/styles/color"; -import React from "react"; import styled from "styled-components"; +import { color } from "@/styles"; import DateBox from "./DateBox"; import WeekBox from "./WeekBox"; import CalenderList from "./CalenderList"; diff --git a/src/page/calender/layouts/WeekBox.tsx b/src/page/calender/layouts/WeekBox.tsx index 183ace8b..12bd1755 100644 --- a/src/page/calender/layouts/WeekBox.tsx +++ b/src/page/calender/layouts/WeekBox.tsx @@ -1,7 +1,5 @@ -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; +import { color, font } from "@/styles"; const weeks = ["월", "화", "수", "목", "금"]; diff --git a/src/page/forum-post/layouts/Post.tsx b/src/page/forum-post/layouts/Post.tsx index dd4737fa..1f2fe392 100644 --- a/src/page/forum-post/layouts/Post.tsx +++ b/src/page/forum-post/layouts/Post.tsx @@ -1,6 +1,5 @@ -import color from "@/styles/color"; -import React from "react"; import styled from "styled-components"; +import { color } from "@/styles"; import PostBody from "./PostBody"; import PostHead from "./PostHead"; diff --git a/src/page/forum-post/layouts/PostBody/CountBox.tsx b/src/page/forum-post/layouts/PostBody/CountBox.tsx index 47d60f69..17c0f660 100644 --- a/src/page/forum-post/layouts/PostBody/CountBox.tsx +++ b/src/page/forum-post/layouts/PostBody/CountBox.tsx @@ -1,9 +1,7 @@ -import Row from "@/components/Flex/Row"; -import React from "react"; -import Like from "@/page/forum-post/assets/Like"; -import Comment from "@/page/forum-post/assets/CommentIcon"; import styled from "styled-components"; -import { font } from "@/styles/font"; +import { Row } from "@/components/Flex"; +import { font } from "@/styles"; +import { CommentIcon, Like } from "@/assets/icons"; const CountBox = () => { return ( @@ -13,7 +11,7 @@ const CountBox = () => { 18 - + 4 diff --git a/src/page/forum-post/layouts/PostBody/index.tsx b/src/page/forum-post/layouts/PostBody/index.tsx index 74034332..e1c2da1e 100644 --- a/src/page/forum-post/layouts/PostBody/index.tsx +++ b/src/page/forum-post/layouts/PostBody/index.tsx @@ -1,7 +1,6 @@ -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; -import CommentBox from "@/components/atoms/CommentBox"; +import { font } from "@/styles"; +import { CommentBox } from "@/components/atoms"; import CountBox from "./CountBox"; const PostBody = () => { diff --git a/src/page/forum-post/layouts/PostHead/Category.tsx b/src/page/forum-post/layouts/PostHead/Category.tsx index 7ecba7d1..b5473ba5 100644 --- a/src/page/forum-post/layouts/PostHead/Category.tsx +++ b/src/page/forum-post/layouts/PostHead/Category.tsx @@ -1,13 +1,12 @@ -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; -import Arrow from "@/page/forum-post/assets/CategoryArrow"; +import { font } from "@/styles"; +import { CategoryArrow } from "@/assets/icons"; const Category = () => { return ( 학생 - + 자유 diff --git a/src/page/forum-post/layouts/PostHead/PostTitle.tsx b/src/page/forum-post/layouts/PostHead/PostTitle.tsx index cbd9da73..ff0e0733 100644 --- a/src/page/forum-post/layouts/PostHead/PostTitle.tsx +++ b/src/page/forum-post/layouts/PostHead/PostTitle.tsx @@ -1,12 +1,10 @@ -import Column from "@/components/Flex/Column"; -import Row from "@/components/Flex/Row"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; import Image from "next/image"; -import React from "react"; import styled from "styled-components"; -import Time from "@/page/forum-post/assets/Time"; +import { Column, Row } from "@/components/Flex"; +import color from "@/styles/color"; +import { font } from "@/styles"; import Link from "next/link"; +import { Time } from "@/assets/icons"; const PostTitle = () => { return ( diff --git a/src/page/forum-post/layouts/PostHead/ReactBox.tsx b/src/page/forum-post/layouts/PostHead/ReactBox.tsx index 6bf65c5b..00eb41af 100644 --- a/src/page/forum-post/layouts/PostHead/ReactBox.tsx +++ b/src/page/forum-post/layouts/PostHead/ReactBox.tsx @@ -1,11 +1,7 @@ -import Row from "@/components/Flex/Row"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; -import View from "@/page/forum-post/assets/View"; -import Like from "@/page/forum-post/assets/Like"; -import Comment from "@/page/forum-post/assets/CommentIcon"; +import { CommentIcon, Like, View } from "@/assets/icons"; +import { Row } from "@/components/Flex"; +import { color, font } from "@/styles"; const ReactBox = () => { return ( @@ -19,7 +15,7 @@ const ReactBox = () => { 8 - + 3 diff --git a/src/page/forum-post/layouts/PostHead/index.tsx b/src/page/forum-post/layouts/PostHead/index.tsx index 85f19914..91314d72 100644 --- a/src/page/forum-post/layouts/PostHead/index.tsx +++ b/src/page/forum-post/layouts/PostHead/index.tsx @@ -1,4 +1,3 @@ -import React from "react"; import styled from "styled-components"; import Category from "./Category"; import PostTitle from "./PostTitle"; diff --git a/src/page/forum-write/index.tsx b/src/page/forum-write/index.tsx index 0c978d03..719bd1d9 100644 --- a/src/page/forum-write/index.tsx +++ b/src/page/forum-write/index.tsx @@ -1,6 +1,5 @@ -import Aside from "@/components/common/Aside"; -import React from "react"; import styled from "styled-components"; +import { Aside } from "@/components/common"; import WriteBox from "./layouts/WriteBox"; const WritePage = () => { diff --git a/src/page/forum-write/layouts/InputBox.tsx b/src/page/forum-write/layouts/InputBox.tsx index 94725c1b..065fe036 100644 --- a/src/page/forum-write/layouts/InputBox.tsx +++ b/src/page/forum-write/layouts/InputBox.tsx @@ -1,14 +1,14 @@ -import AnonymousBox from "@/components/atoms/AnonymousBox"; -import Category from "@/components/atoms/Category"; -import CustomEditor from "@/components/atoms/CustomEditor"; -import Input from "@/components/atoms/Input"; -import Column from "@/components/Flex/Column"; -import Row from "@/components/Flex/Row"; -import categories from "@/global/assets/data/categories"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; import React from "react"; import styled from "styled-components"; +import { + Category, + AnonymousBox, + CustomEditor, + Input, +} from "@/components/atoms"; +import { Column, Row } from "@/components/Flex"; +import { emptyCategories } from "@/assets/data"; +import { color, font } from "@/styles"; const InputBox = () => { const [checked, setChecked] = React.useState("all"); @@ -23,7 +23,7 @@ const InputBox = () => { - {categories.map((category) => ( + {emptyCategories.map((category) => ( { diff --git a/src/page/forum/index.tsx b/src/page/forum/index.tsx index f8a4cf2b..d84de644 100644 --- a/src/page/forum/index.tsx +++ b/src/page/forum/index.tsx @@ -1,6 +1,5 @@ -import Aside from "@/components/common/Aside"; -import React from "react"; import styled from "styled-components"; +import { Aside } from "@/components/common"; import Forum from "./layouts/Forum"; const ForumPage = () => { diff --git a/src/page/forum/layouts/Categories.tsx b/src/page/forum/layouts/Categories.tsx index e65a5f93..3a7e97d7 100644 --- a/src/page/forum/layouts/Categories.tsx +++ b/src/page/forum/layouts/Categories.tsx @@ -1,10 +1,10 @@ -import Row from "@/components/Flex/Row"; -import { categoriesStore } from "@/store/categories.store"; import React from "react"; import { useRecoilState } from "recoil"; -import Category from "@/components/atoms/Category"; -import categories from "@/global/assets/data/categories"; -import PostCategoryType from "@/global/types/postCategory.type"; +import { Row } from "@/components/Flex"; +import { categoriesStore } from "@/store/categories.store"; +import { Category } from "@/components/atoms"; +import { emptyCategories } from "@/assets/data"; +import { PostCategoryType } from "@/types"; const Categories = () => { const [checked, setChecked] = useRecoilState(categoriesStore); @@ -15,7 +15,7 @@ const Categories = () => { return ( - {categories.map((category) => ( + {emptyCategories.map((category) => ( { ))} diff --git a/src/page/forum/layouts/PostList.tsx b/src/page/forum/layouts/PostList.tsx index e32475d3..ad79d8fb 100644 --- a/src/page/forum/layouts/PostList.tsx +++ b/src/page/forum/layouts/PostList.tsx @@ -1,5 +1,4 @@ -import Column from "@/components/Flex/Column"; -import React from "react"; +import { Column } from "@/components/Flex"; import PostListItem from "./PostListItem"; const PostList = () => { diff --git a/src/page/forum/layouts/PostListItem.tsx b/src/page/forum/layouts/PostListItem.tsx index bac9e162..caa91ace 100644 --- a/src/page/forum/layouts/PostListItem.tsx +++ b/src/page/forum/layouts/PostListItem.tsx @@ -1,10 +1,7 @@ -import Column from "@/components/Flex/Column"; -import Row from "@/components/Flex/Row"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; -import LikeLogo from "@/page/forum/assets/LikeLogo"; +import { Column, Row } from "@/components/Flex"; +import { color, font } from "@/styles"; +import { LikeIcon } from "@/assets/icons"; const PostListItem = () => { return ( @@ -15,7 +12,7 @@ const PostListItem = () => { 83 - + 30 diff --git a/src/page/forum/services/api.service.ts b/src/page/forum/services/api.service.ts index 8d26ace6..18539195 100644 --- a/src/page/forum/services/api.service.ts +++ b/src/page/forum/services/api.service.ts @@ -1,5 +1,5 @@ import httpClient from "@/apis/httpClient"; -import IPostQuery from "@/global/types/postQuery.type"; +import { IPostQuery } from "@/interfaces"; export const getPostList = async (postConfig: IPostQuery) => { try { diff --git a/src/page/forum/services/query.service.ts b/src/page/forum/services/query.service.ts index cc09d40e..91b59178 100644 --- a/src/page/forum/services/query.service.ts +++ b/src/page/forum/services/query.service.ts @@ -1,7 +1,6 @@ -import KEY from "@/global/constants/key.constant"; -import IPost from "@/global/types/post.type"; +import { KEY } from "@/constants"; import { useQuery } from "react-query"; -import IPostQuery from "@/global/types/postQuery.type"; +import { IPost, IPostQuery } from "@/interfaces"; import { getPostList } from "./api.service"; export const usePostListQuery = (postConfig: IPostQuery) => { diff --git a/src/page/home/assets/.gitkeep b/src/page/home/assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/page/home/index.tsx b/src/page/home/index.tsx index 7a40aea4..17032fe9 100644 --- a/src/page/home/index.tsx +++ b/src/page/home/index.tsx @@ -1,6 +1,5 @@ -import Aside from "@/components/common/Aside"; -import React from "react"; import styled from "styled-components"; +import { Aside } from "@/components/common"; const HomePage = () => { return ( diff --git a/src/page/home/services/.gitkeep b/src/page/home/services/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/page/lostfound-post/index.tsx b/src/page/lostfound-post/index.tsx index 43609b52..c0347d5d 100644 --- a/src/page/lostfound-post/index.tsx +++ b/src/page/lostfound-post/index.tsx @@ -1,6 +1,5 @@ -import Aside from "@/components/common/Aside"; -import React from "react"; import styled from "styled-components"; +import { Aside } from "@/components/common/"; import LostFoundPostBox from "./layouts/LostFoundPostBox"; const LostFoundPostPage = () => { diff --git a/src/page/lostfound-post/layouts/LostFoundBody/LostFoundInfoBox.tsx b/src/page/lostfound-post/layouts/LostFoundBody/LostFoundInfoBox.tsx index c1d8f04a..b3b8490a 100644 --- a/src/page/lostfound-post/layouts/LostFoundBody/LostFoundInfoBox.tsx +++ b/src/page/lostfound-post/layouts/LostFoundBody/LostFoundInfoBox.tsx @@ -1,7 +1,6 @@ -import React from "react"; import styled from "styled-components"; -import { font } from "@/styles/font"; -import Column from "@/components/Flex/Column"; +import { font } from "@/styles"; +import { Column } from "@/components/Flex"; const LostFoundInfoBox = () => { return ( diff --git a/src/page/lostfound-post/layouts/LostFoundBody/index.tsx b/src/page/lostfound-post/layouts/LostFoundBody/index.tsx index 1e4ca3ad..e51c2708 100644 --- a/src/page/lostfound-post/layouts/LostFoundBody/index.tsx +++ b/src/page/lostfound-post/layouts/LostFoundBody/index.tsx @@ -1,8 +1,6 @@ -import ImageWithFallback from "@/components/atoms/ImageWithFallback"; -import CommentBox from "@/components/atoms/CommentBox"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; +import { CommentBox, ImageWithFallback } from "@/components/atoms"; +import { font } from "@/styles"; import LostFoundInfoBox from "./LostFoundInfoBox"; const LostFoundBody = () => { diff --git a/src/page/lostfound-post/layouts/LostFoundHead/Category.tsx b/src/page/lostfound-post/layouts/LostFoundHead/Category.tsx index ee4bd46d..73caa4bc 100644 --- a/src/page/lostfound-post/layouts/LostFoundHead/Category.tsx +++ b/src/page/lostfound-post/layouts/LostFoundHead/Category.tsx @@ -1,13 +1,12 @@ -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; -import Arrow from "@/page/forum-post/assets/CategoryArrow"; +import { font } from "@/styles"; +import { CategoryArrow } from "@/assets/icons"; const Category = () => { return ( 분실물 - + 습득 ); diff --git a/src/page/lostfound-post/layouts/LostFoundHead/LostFoundTitle.tsx b/src/page/lostfound-post/layouts/LostFoundHead/LostFoundTitle.tsx index a46e2fe6..0c7f3e36 100644 --- a/src/page/lostfound-post/layouts/LostFoundHead/LostFoundTitle.tsx +++ b/src/page/lostfound-post/layouts/LostFoundHead/LostFoundTitle.tsx @@ -1,12 +1,9 @@ -import Column from "@/components/Flex/Column"; -import Row from "@/components/Flex/Row"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; import Image from "next/image"; -import React from "react"; import styled from "styled-components"; -import Time from "@/page/forum-post/assets/Time"; import Link from "next/link"; +import { Row, Column } from "@/components/Flex"; +import { color, font } from "@/styles"; +import { Time } from "@/assets/icons"; const LostFoundTitle = () => { return ( diff --git a/src/page/lostfound-post/layouts/LostFoundHead/index.tsx b/src/page/lostfound-post/layouts/LostFoundHead/index.tsx index de3665f8..739668d4 100644 --- a/src/page/lostfound-post/layouts/LostFoundHead/index.tsx +++ b/src/page/lostfound-post/layouts/LostFoundHead/index.tsx @@ -1,4 +1,3 @@ -import React from "react"; import styled from "styled-components"; import Category from "./Category"; import LostFoundTitle from "./LostFoundTitle"; diff --git a/src/page/lostfound-post/layouts/LostFoundPostBox.tsx b/src/page/lostfound-post/layouts/LostFoundPostBox.tsx index 9ba793da..3567a193 100644 --- a/src/page/lostfound-post/layouts/LostFoundPostBox.tsx +++ b/src/page/lostfound-post/layouts/LostFoundPostBox.tsx @@ -1,6 +1,5 @@ -import color from "@/styles/color"; -import React from "react"; import styled from "styled-components"; +import { color } from "@/styles"; import LostFoundBody from "./LostFoundBody"; import LostFoundHead from "./LostFoundHead"; diff --git a/src/page/lostfound-write/index.tsx b/src/page/lostfound-write/index.tsx index 701eccea..7f81eede 100644 --- a/src/page/lostfound-write/index.tsx +++ b/src/page/lostfound-write/index.tsx @@ -1,6 +1,5 @@ -import Aside from "@/components/common/Aside"; -import React from "react"; import styled from "styled-components"; +import { Aside } from "@/components/common"; import LostFoundWriteBox from "./layouts/LostFoundWriteBox"; const LostFoundWritePage = () => { diff --git a/src/page/lostfound-write/layouts/InputBox.tsx b/src/page/lostfound-write/layouts/InputBox.tsx index 092f5445..66e2c180 100644 --- a/src/page/lostfound-write/layouts/InputBox.tsx +++ b/src/page/lostfound-write/layouts/InputBox.tsx @@ -1,11 +1,8 @@ -import AnonymousBox from "@/components/atoms/AnonymousBox"; -import CustomEditor from "@/components/atoms/CustomEditor"; -import Input from "@/components/atoms/Input"; -import lostfound from "@/global/constants/lostfound.constant"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; import React from "react"; import styled from "styled-components"; +import { AnonymousBox, CustomEditor, Input } from "@/components/atoms"; +import { LOSTFOUND } from "@/constants"; +import { color, font } from "@/styles"; import StateBox from "./StateBox"; const InputBox = () => { @@ -21,10 +18,10 @@ const InputBox = () => { - {checked === lostfound.lost.type && ( + {checked === LOSTFOUND.LOST.TYPE && ( )} - {checked === lostfound.found.type && ( + {checked === LOSTFOUND.FOUND.TYPE && ( <> diff --git a/src/page/lostfound-write/layouts/LostFoundWriteBox.tsx b/src/page/lostfound-write/layouts/LostFoundWriteBox.tsx index 876da62e..3ba7a188 100644 --- a/src/page/lostfound-write/layouts/LostFoundWriteBox.tsx +++ b/src/page/lostfound-write/layouts/LostFoundWriteBox.tsx @@ -1,8 +1,6 @@ -import Column from "@/components/Flex/Column"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; +import { Column } from "@/components/Flex"; +import { color, font } from "@/styles"; import InputBox from "./InputBox"; const LostFoundWriteBox = () => { diff --git a/src/page/lostfound-write/layouts/StateBox.tsx b/src/page/lostfound-write/layouts/StateBox.tsx index d19d5f4b..af71176d 100644 --- a/src/page/lostfound-write/layouts/StateBox.tsx +++ b/src/page/lostfound-write/layouts/StateBox.tsx @@ -1,19 +1,17 @@ -import Column from "@/components/Flex/Column"; -import Row from "@/components/Flex/Row"; -import React from "react"; -import lostfoundKey from "@/global/constants/lostfound.constant"; -import Category from "@/components/atoms/Category"; +import { Row, Column } from "@/components/Flex"; +import { LOSTFOUND } from "@/constants"; +import { Category } from "@/components/atoms"; import styled from "styled-components"; -import { font } from "@/styles/font"; +import { font } from "@/styles"; const lostfounds = [ { - type: lostfoundKey.lost.type, - name: lostfoundKey.lost.name, + type: LOSTFOUND.LOST.TYPE, + name: LOSTFOUND.LOST.NAME, }, { - type: lostfoundKey.found.type, - name: lostfoundKey.found.name, + type: LOSTFOUND.FOUND.TYPE, + name: LOSTFOUND.FOUND.NAME, }, ]; diff --git a/src/page/lostfound/index.tsx b/src/page/lostfound/index.tsx index ff0d8f92..b807c239 100644 --- a/src/page/lostfound/index.tsx +++ b/src/page/lostfound/index.tsx @@ -1,6 +1,5 @@ -import Aside from "@/components/common/Aside"; -import React from "react"; import styled from "styled-components"; +import { Aside } from "@/components/common"; import LostFoundBox from "./layouts/LostFoundBox"; const LostFoundPage = () => { diff --git a/src/page/lostfound/layouts/LostFoundBox.tsx b/src/page/lostfound/layouts/LostFoundBox.tsx index ec65cf02..ef127e0b 100644 --- a/src/page/lostfound/layouts/LostFoundBox.tsx +++ b/src/page/lostfound/layouts/LostFoundBox.tsx @@ -1,4 +1,3 @@ -import React from "react"; import styled from "styled-components"; import LostFoundFilter from "./LostFoundFIlter"; import LostFoundList from "./LostFoundList"; diff --git a/src/page/lostfound/layouts/LostFoundFIlter.tsx b/src/page/lostfound/layouts/LostFoundFIlter.tsx index d2edb425..564daa3d 100644 --- a/src/page/lostfound/layouts/LostFoundFIlter.tsx +++ b/src/page/lostfound/layouts/LostFoundFIlter.tsx @@ -1,19 +1,17 @@ -import Row from "@/components/Flex/Row"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import forum from "@/global/constants/forum.constant"; import React from "react"; import styled, { css, keyframes } from "styled-components"; -import lostfound from "../../../global/constants/lostfound.constant"; +import { Row } from "@/components/Flex"; +import { color, font } from "@/styles"; +import { LOSTFOUND, FORUM } from "@/constants"; const filters = [ { - type: lostfound.lost.type, - name: lostfound.lost.name, + type: LOSTFOUND.LOST.TYPE, + name: LOSTFOUND.LOST.NAME, }, { - type: lostfound.found.type, - name: lostfound.found.name, + type: LOSTFOUND.FOUND.TYPE, + name: LOSTFOUND.FOUND.NAME, }, ]; @@ -33,9 +31,9 @@ const LostFoundFilter = () => { ))} diff --git a/src/page/lostfound/layouts/LostFoundList.tsx b/src/page/lostfound/layouts/LostFoundList.tsx index e8155163..284f7863 100644 --- a/src/page/lostfound/layouts/LostFoundList.tsx +++ b/src/page/lostfound/layouts/LostFoundList.tsx @@ -1,5 +1,4 @@ -import Column from "@/components/Flex/Column"; -import React from "react"; +import { Column } from "@/components/Flex"; import LostFoundListItem from "./LostFoundListItem"; const LostFoundList = () => { diff --git a/src/page/lostfound/layouts/LostFoundListItem.tsx b/src/page/lostfound/layouts/LostFoundListItem.tsx index 0e396b60..3361f124 100644 --- a/src/page/lostfound/layouts/LostFoundListItem.tsx +++ b/src/page/lostfound/layouts/LostFoundListItem.tsx @@ -1,17 +1,15 @@ -import Column from "@/components/Flex/Column"; -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; -import ImageWithFallback from "@/components/atoms/ImageWithFallback"; -import NotFoundImage from "@/page/lostfound/assets/imageNotFound.png"; +import { Column } from "@/components/Flex"; +import { color, font } from "@/styles"; +import { ImageWithFallback } from "@/components/atoms"; +import { emptyImage } from "@/assets/images"; const LostFoundListItem = () => { return ( diff --git a/src/page/lostfound/layouts/States.tsx b/src/page/lostfound/layouts/States.tsx index 433b8590..b705cd08 100644 --- a/src/page/lostfound/layouts/States.tsx +++ b/src/page/lostfound/layouts/States.tsx @@ -1,6 +1,6 @@ -import Category from "@/components/atoms/Category"; -import Row from "@/components/Flex/Row"; import React from "react"; +import { Category } from "@/components/atoms"; +import { Row } from "@/components/Flex"; const states = [ { diff --git a/src/page/meal/assets/.gitkeep b/src/page/meal/assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/page/meal/constants/meal.constant.ts b/src/page/meal/constants/meal.constant.ts deleted file mode 100644 index facb62e0..00000000 --- a/src/page/meal/constants/meal.constant.ts +++ /dev/null @@ -1,24 +0,0 @@ -const meal = { - prev: { - name: "이전", - type: "prev", - }, - first: { - name: "첫번째", - type: "first", - }, - second: { - name: "두번째", - type: "second", - }, - third: { - name: "세번째", - type: "third", - }, - next: { - name: "다음", - type: "next", - }, -}; - -export default meal; diff --git a/src/page/meal/index.tsx b/src/page/meal/index.tsx index 802a502b..2de3a7b2 100644 --- a/src/page/meal/index.tsx +++ b/src/page/meal/index.tsx @@ -1,6 +1,5 @@ -import Aside from "@/components/common/Aside"; -import React from "react"; import styled from "styled-components"; +import { Aside } from "@/components/common"; import Meal from "./layouts/Meal"; const MealPage = () => { diff --git a/src/page/meal/layouts/ListSlider.tsx b/src/page/meal/layouts/ListSlider.tsx index ddb240d4..bcb88a83 100644 --- a/src/page/meal/layouts/ListSlider.tsx +++ b/src/page/meal/layouts/ListSlider.tsx @@ -1,12 +1,12 @@ import React from "react"; import styled from "styled-components"; +import { IMealList } from "@/interfaces"; import Slider from "react-slick"; import "slick-carousel/slick/slick.css"; import MealListItem from "./MealListItem"; import SwipeArea from "./SwipeArea"; -import MealListType from "../types/mealList.type"; -const ListSlider = ({ mealList }: MealListType) => { +const ListSlider = ({ mealList }: IMealList) => { const [currentSlideIndex, setCurrentSlideIndex] = React.useState(0); const [slideSpeed, setSlideSpeed] = React.useState(300); diff --git a/src/page/meal/layouts/Meal.tsx b/src/page/meal/layouts/Meal.tsx index b5f94e70..2cfa6e9a 100644 --- a/src/page/meal/layouts/Meal.tsx +++ b/src/page/meal/layouts/Meal.tsx @@ -1,4 +1,3 @@ -import React from "react"; import styled from "styled-components"; import ListSlider from "./ListSlider"; diff --git a/src/page/meal/layouts/MealListItem.tsx b/src/page/meal/layouts/MealListItem.tsx index 26acc531..bbdcaeea 100644 --- a/src/page/meal/layouts/MealListItem.tsx +++ b/src/page/meal/layouts/MealListItem.tsx @@ -1,20 +1,19 @@ -import React from "react"; import styled, { css } from "styled-components"; -import slideState from "@/page/meal/constants/meal.constant"; -import color from "@/styles/color"; -import MealListItemsType from "../types/mealListItem.type"; +import { MEAL } from "@/constants"; +import { IMealListItem } from "@/interfaces"; +import { color } from "@/styles"; -const MealListItem = ({ date, menu, currentSlideIndex }: MealListItemsType) => { +const MealListItem = ({ date, menu, currentSlideIndex }: IMealListItem) => { const mealSlideTypeGenerator = (dateProps: number) => { const isPrevSlide = dateProps === currentSlideIndex - 1; const isFirstSlide = dateProps === currentSlideIndex; const isThirdSlide = dateProps === currentSlideIndex + 2; const isNextSlide = dateProps === currentSlideIndex + 3; - if (isPrevSlide) return slideState.prev.type; - if (isThirdSlide) return slideState.third.type; - if (isFirstSlide) return slideState.first.type; - if (isNextSlide) return slideState.next.type; - return slideState.second.type; + if (isPrevSlide) return MEAL.PREV.TYPE; + if (isThirdSlide) return MEAL.THIRD.TYPE; + if (isFirstSlide) return MEAL.FIRST.TYPE; + if (isNextSlide) return MEAL.NEXT.TYPE; + return MEAL.SECOND.TYPE; }; const isCurrentSlide = @@ -52,14 +51,14 @@ const MealList = styled.div<{ current: boolean; state: string }>` visibility: ${(props) => (props.current ? "visible" : "hidden")}; ${(props) => { - if (props.state === slideState.third.type) { + if (props.state === MEAL.THIRD.TYPE) { return css` transition: all 0.5s linear; top: 6vh; `; } - if (props.state === slideState.first.type) { + if (props.state === MEAL.FIRST.TYPE) { return css` transition: all 0.5s linear; transform: scaleX(0.9); @@ -67,7 +66,7 @@ const MealList = styled.div<{ current: boolean; state: string }>` `; } - if (props.state === slideState.second.type) { + if (props.state === MEAL.SECOND.TYPE) { return css` transform: scaleX(0.95); transition: all 0.5s linear; @@ -75,7 +74,7 @@ const MealList = styled.div<{ current: boolean; state: string }>` `; } - if (props.state === slideState.prev.type) { + if (props.state === MEAL.PREV.TYPE) { return css` transform: scaleX(0.85); transition: all 0.5s linear; diff --git a/src/page/meal/layouts/SwipeArea.tsx b/src/page/meal/layouts/SwipeArea.tsx index 9258899b..afc3f2e5 100644 --- a/src/page/meal/layouts/SwipeArea.tsx +++ b/src/page/meal/layouts/SwipeArea.tsx @@ -1,4 +1,3 @@ -import React from "react"; import styled from "styled-components"; const SwipeArea = ({ next, prev }: { next: () => void; prev: () => void }) => { diff --git a/src/page/meal/types/mealList.type.ts b/src/page/meal/types/mealList.type.ts deleted file mode 100644 index 0bab109c..00000000 --- a/src/page/meal/types/mealList.type.ts +++ /dev/null @@ -1,5 +0,0 @@ -interface MealListType { - mealList: Array; -} - -export default MealListType; diff --git a/src/page/oauth/index.tsx b/src/page/oauth/index.tsx index 782d2f10..dd0dfd9e 100644 --- a/src/page/oauth/index.tsx +++ b/src/page/oauth/index.tsx @@ -1,11 +1,10 @@ +import React from "react"; import Image from "next/image"; import { useSearchParams } from "next/navigation"; -import React from "react"; -import Loading from "@/global/assets/icons/loading.gif"; +import { loading } from "@/assets/images"; import styled from "styled-components"; -import { font } from "@/styles/font"; -import Column from "@/components/Flex/Column"; -import color from "@/styles/color"; +import { color, font } from "@/styles"; +import { Column } from "@/components/Flex"; import { useLoginMutation } from "./services/mutations.service"; const OAuthPage = () => { @@ -19,7 +18,7 @@ const OAuthPage = () => { return ( - + 로그인 처리중... diff --git a/src/page/oauth/services/mutations.service.ts b/src/page/oauth/services/mutations.service.ts index 2d29611f..b622b728 100644 --- a/src/page/oauth/services/mutations.service.ts +++ b/src/page/oauth/services/mutations.service.ts @@ -1,20 +1,14 @@ import throwAxiosError from "@/apis/error/throwAxiosError"; -import Storage from "@/apis/storage"; -import ROUTER from "@/global/constants/router.constant"; -import TOKEN from "@/global/constants/token.constant"; import { useRouter } from "next/navigation"; import { useMutation } from "react-query"; +import { ROUTER } from "@/constants"; import { ILoginParams, login } from "./api.service"; export const useLoginMutation = ({ authCode }: ILoginParams) => { const router = useRouter(); return useMutation(() => login({ authCode }), { - onSuccess: ({ data }) => { - const { accessToken, refreshToken } = data; - - Storage.setItem(TOKEN.ACCESS, accessToken); - Storage.setItem(TOKEN.REFRESH, refreshToken); + onSuccess: () => { router.push(ROUTER.HOME); }, onError: (err) => { diff --git a/src/page/timetable/index.tsx b/src/page/timetable/index.tsx index e69cbb8a..98bf488d 100644 --- a/src/page/timetable/index.tsx +++ b/src/page/timetable/index.tsx @@ -1,5 +1,4 @@ -import Aside from "@/components/common/Aside"; -import React from "react"; +import { Aside } from "@/components/common"; import styled from "styled-components"; import TimeTableBox from "./layouts/TimeTableBox"; diff --git a/src/page/timetable/layouts/TimeTableBar.tsx b/src/page/timetable/layouts/TimeTableBar.tsx index bb63f739..e455bb69 100644 --- a/src/page/timetable/layouts/TimeTableBar.tsx +++ b/src/page/timetable/layouts/TimeTableBar.tsx @@ -1,8 +1,6 @@ -import color from "@/styles/color"; -import { font } from "@/styles/font"; -import React from "react"; +import { color, font } from "@/styles"; import styled from "styled-components"; -import ITimetable from "@/global/types/timetable.type"; +import { ITimetable } from "@/interfaces"; import useTimetableBar from "@/hooks/useTimetableBar"; interface ITimeTableBarProps { diff --git a/src/page/timetable/layouts/TimeTableBox.tsx b/src/page/timetable/layouts/TimeTableBox.tsx index d58bef87..7312b972 100644 --- a/src/page/timetable/layouts/TimeTableBox.tsx +++ b/src/page/timetable/layouts/TimeTableBox.tsx @@ -2,12 +2,11 @@ import React from "react"; import styled from "styled-components"; import useDate from "@/hooks/useDate"; import { useQueryClient } from "react-query"; -import KEY from "@/global/constants/key.constant"; +import { KEY } from "@/constants"; +import { emptyTimetable, emptyClassLevel } from "@/assets/data"; import TimeTableBar from "./TimeTableBar"; import { useTimetableListQuery } from "../services/queries.service"; import TimeTableCategory from "./TimeTableCategory"; -import emptyTimetable from "../data/emptyTimetable"; -import emptyClassLevel from "../data/emptyClassLevel"; const TimeTableBox = () => { const queryClient = useQueryClient(); diff --git a/src/page/timetable/layouts/TimeTableCategory.tsx b/src/page/timetable/layouts/TimeTableCategory.tsx index 3a083fb0..21d25c97 100644 --- a/src/page/timetable/layouts/TimeTableCategory.tsx +++ b/src/page/timetable/layouts/TimeTableCategory.tsx @@ -1,11 +1,8 @@ -import Column from "@/components/Flex/Column"; -import Row from "@/components/Flex/Row"; -import Category from "@/components/atoms/Category"; -import Select from "@/components/atoms/Select"; -import IClassLevel from "@/global/types/classLevel.type"; -import { font } from "@/styles/font"; -import React from "react"; import styled from "styled-components"; +import { Column, Row } from "@/components/Flex"; +import { Category, Select } from "@/components/atoms"; +import { IClassLevel } from "@/interfaces"; +import { font } from "@/styles"; interface ITimeTableCategoryProps { weekdays: Array; diff --git a/src/page/timetable/services/api.service.ts b/src/page/timetable/services/api.service.ts index 930d57cc..80fa9b81 100644 --- a/src/page/timetable/services/api.service.ts +++ b/src/page/timetable/services/api.service.ts @@ -1,5 +1,5 @@ import httpClient from "@/apis/httpClient"; -import IClassLevel from "@/global/types/classLevel.type"; +import { IClassLevel } from "@/interfaces"; export const getTimetable = async (classLevel: IClassLevel) => { const { data } = await httpClient.timetable.getTimetable({ diff --git a/src/page/timetable/services/queries.service.ts b/src/page/timetable/services/queries.service.ts index 5d53f104..e362ad63 100644 --- a/src/page/timetable/services/queries.service.ts +++ b/src/page/timetable/services/queries.service.ts @@ -1,7 +1,6 @@ -import KEY from "@/global/constants/key.constant"; -import ITimetable from "@/global/types/timetable.type"; +import { KEY } from "@/constants"; import { useQuery } from "react-query"; -import IClassLevel from "@/global/types/classLevel.type"; +import { ITimetable, IClassLevel } from "@/interfaces"; import { getTimetable } from "./api.service"; export const useTimetableListQuery = (classLevel: IClassLevel) => { diff --git a/src/store/categories.store.ts b/src/store/categories.store.ts index aace29e2..13a50749 100644 --- a/src/store/categories.store.ts +++ b/src/store/categories.store.ts @@ -1,8 +1,8 @@ -import forum from "@/global/constants/forum.constant"; -import PostCategoryType from "@/global/types/postCategory.type"; +import { FORUM } from "@/constants"; +import { PostCategoryType } from "@/types"; import { atom } from "recoil"; export const categoriesStore = atom({ key: "categoriesStore", - default: forum.category.all.type, + default: FORUM.CATEGORY.ALL.TYPE, }); diff --git a/src/store/emoji.store.ts b/src/store/emoji.store.ts index 4d6a53d7..9793684f 100644 --- a/src/store/emoji.store.ts +++ b/src/store/emoji.store.ts @@ -1,4 +1,4 @@ -import IEmojiState from "@/global/types/emoji.type"; +import { IEmojiState } from "@/interfaces"; import { atom } from "recoil"; const emojiStore = atom({ diff --git a/src/store/forumType.store.ts b/src/store/forumType.store.ts index 21733ef7..afef2753 100644 --- a/src/store/forumType.store.ts +++ b/src/store/forumType.store.ts @@ -1,7 +1,7 @@ -import forum from "@/global/constants/forum.constant"; +import { FORUM } from "@/constants"; import { atom } from "recoil"; export const forumFilterStore = atom({ key: "forumFilterStore", - default: forum.free.type, + default: FORUM.FREE.TYPE, }); diff --git a/src/store/modal.store.ts b/src/store/modal.store.ts index 00763fe7..b2488ef0 100644 --- a/src/store/modal.store.ts +++ b/src/store/modal.store.ts @@ -1,4 +1,4 @@ -import { IModalState } from "@/global/types/modal.type"; +import { IModalState } from "@/interfaces"; import { atom } from "recoil"; const modalStore = atom({ diff --git a/src/store/user.store.ts b/src/store/user.store.ts index eab8222f..89919254 100644 --- a/src/store/user.store.ts +++ b/src/store/user.store.ts @@ -1,8 +1,8 @@ -import USER from "@/global/constants/user.constant"; -import { Student } from "@/global/types/user.type"; +import { USER } from "@/constants"; +import { IUser } from "@/interfaces"; import { atom } from "recoil"; -export const emptyUser: Student = { +export const emptyUser: IUser = { isLogin: true, code: 0, nickname: "", @@ -19,7 +19,7 @@ export const emptyUser: Student = { }, }; -export const userStore = atom({ +export const userStore = atom({ key: "userStore", default: emptyUser, }); diff --git a/src/styles/GlobalStyle.ts b/src/styles/GlobalStyle.ts new file mode 100644 index 00000000..b616e35e --- /dev/null +++ b/src/styles/GlobalStyle.ts @@ -0,0 +1,59 @@ +import { createGlobalStyle } from "styled-components"; + +const GlobalStyle = createGlobalStyle` + @import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css"); + + * { + margin: 0; + padding: 0; + box-sizing: border-box; + } + + body { + background-color: #f9faff; + } + + ul, + li { + list-style: none; + } + + p { + display: inline-block; + } + + a { + display: inline-block; + text-decoration: none; + color: inherit; + } + + label { + cursor: pointer; + } + + input, + textarea { + -moz-user-select: auto; + -webkit-user-select: auto; + -ms-user-select: auto; + user-select: auto; + border: none; + outline: none; + resize: none; + } + + input:focus { + outline: none; + } + + button { + outline: none; + border: none; + background: none; + padding: 0; + cursor: pointer; + } +`; + +export default GlobalStyle; diff --git a/src/styles/font.ts b/src/styles/font.ts index 5b4a457d..edf7fba5 100644 --- a/src/styles/font.ts +++ b/src/styles/font.ts @@ -11,7 +11,7 @@ const fontGenerator = ( letter-spacing: ${letterSpacing}px; `; -export const font = { +const font = { D1: fontGenerator(700, 4.5, 130, -1.5), D2: fontGenerator(700, 3.75, 130, -0.5), D3: fontGenerator(700, 3, 130, 0), @@ -36,3 +36,5 @@ export const font = { context: fontGenerator(500, 1, 130, 0), code: fontGenerator(400, 1, 130, 0), }; + +export default font; diff --git a/src/styles/index.ts b/src/styles/index.ts new file mode 100644 index 00000000..e5d5a4ae --- /dev/null +++ b/src/styles/index.ts @@ -0,0 +1,2 @@ +export { default as color } from "./color"; +export { default as font } from "./font"; diff --git a/src/styles/style.ts b/src/styles/style.ts deleted file mode 100644 index 2d884122..00000000 --- a/src/styles/style.ts +++ /dev/null @@ -1,5 +0,0 @@ -const style = { - boxShadow: `0 0 20px 0 rgba(80, 80, 80, 0.1)`, -}; - -export default style; diff --git a/src/types/index.ts b/src/types/index.ts new file mode 100644 index 00000000..6379686d --- /dev/null +++ b/src/types/index.ts @@ -0,0 +1,2 @@ +export type { default as StorageSettingKey } from "./storageSettingKey.type"; +export type { default as PostCategoryType } from "./postCategory.type"; diff --git a/src/global/types/postCategory.type.ts b/src/types/postCategory.type.ts similarity index 100% rename from src/global/types/postCategory.type.ts rename to src/types/postCategory.type.ts diff --git a/src/types/storageSettingKey.type.ts b/src/types/storageSettingKey.type.ts new file mode 100644 index 00000000..e3458a38 --- /dev/null +++ b/src/types/storageSettingKey.type.ts @@ -0,0 +1,3 @@ +type StorageSettingKey = "postLimit" | "theme" | "viewAllChildComments"; + +export default StorageSettingKey; From b986fe8911d24d2d264fa73ef5b0bd57230fa1c7 Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Tue, 1 Aug 2023 20:50:50 +0900 Subject: [PATCH 17/18] =?UTF-8?q?fix(style):=20GlobalStyle=20client=20comp?= =?UTF-8?q?onent=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/layout.tsx | 2 -- src/app/lostfound/{[postType] => [state]}/[id]/page.tsx | 0 src/helpers/provider.helper.tsx | 2 ++ src/styles/GlobalStyle.ts | 2 ++ 4 files changed, 4 insertions(+), 2 deletions(-) rename src/app/lostfound/{[postType] => [state]}/[id]/page.tsx (100%) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index a2e974a1..3dbc2693 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,5 +1,4 @@ import Provider from "@/helpers/provider.helper"; -import GlobalStyle from "@/styles/GlobalStyle"; export const metadata = { title: "BSM", @@ -14,7 +13,6 @@ export default function RootLayout({ return ( - {children} diff --git a/src/app/lostfound/[postType]/[id]/page.tsx b/src/app/lostfound/[state]/[id]/page.tsx similarity index 100% rename from src/app/lostfound/[postType]/[id]/page.tsx rename to src/app/lostfound/[state]/[id]/page.tsx diff --git a/src/helpers/provider.helper.tsx b/src/helpers/provider.helper.tsx index e635ff61..63136c43 100644 --- a/src/helpers/provider.helper.tsx +++ b/src/helpers/provider.helper.tsx @@ -5,6 +5,7 @@ import { ToastContainer, toast } from "react-toastify"; import { RecoilRoot } from "recoil"; import { Header, Footer, Modal } from "@/components/common"; import Column from "@/components/Flex/Column"; +import GlobalStyle from "@/styles/GlobalStyle"; import ReactQueryProvider from "./reactQueryProvider.helper"; const Provider = ({ children }: React.PropsWithChildren) => { @@ -12,6 +13,7 @@ const Provider = ({ children }: React.PropsWithChildren) => { +
{children} diff --git a/src/styles/GlobalStyle.ts b/src/styles/GlobalStyle.ts index b616e35e..f3f8c025 100644 --- a/src/styles/GlobalStyle.ts +++ b/src/styles/GlobalStyle.ts @@ -1,3 +1,5 @@ +"use client"; + import { createGlobalStyle } from "styled-components"; const GlobalStyle = createGlobalStyle` From f23f9b13b1dd1d63b75c0cefe21f37d1bc2576a4 Mon Sep 17 00:00:00 2001 From: Ubinquitous Date: Tue, 1 Aug 2023 20:55:10 +0900 Subject: [PATCH 18/18] =?UTF-8?q?chore(config):=20discord=20domain=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index 745e6349..686cb84d 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,7 @@ /** @type {import('next').NextConfig} */ const nextConfig = { images: { - domains: ["bssm.kro.kr", "discord.com"], + domains: ["bssm.kro.kr"], }, };