From f2a2053b96c91e3743809874c574797109484d24 Mon Sep 17 00:00:00 2001 From: MinseoLee <mmmm@ajou.ac.kr> Date: Thu, 30 Nov 2023 17:55:56 +0900 Subject: [PATCH] refactor: directory structure --- public/index.html | 2 +- src/{app => _app}/App.module.css | 0 src/{app => _app}/App.tsx | 2 +- src/{app => _app}/config/route.ts | 0 src/{app => _app}/modules/wrapper/Wrapper.module.css | 0 src/{app => _app}/modules/wrapper/Wrapper.tsx | 0 src/{ => common}/instances/Connector.ts | 2 +- src/common/utils/api.ts | 2 +- src/components/header/Header.tsx | 2 +- src/components/navigator/config.ts | 2 +- src/index.tsx | 4 ++-- src/pages/cart-page/CartPage.tsx | 4 ++-- src/pages/history-page/HistoryPage.tsx | 2 +- src/pages/login-page/LoginPage.tsx | 4 ++-- src/pages/main-page/MainPage.tsx | 2 +- src/pages/menu-page/MenuPage.tsx | 2 +- 16 files changed, 15 insertions(+), 15 deletions(-) rename src/{app => _app}/App.module.css (100%) rename src/{app => _app}/App.tsx (98%) rename src/{app => _app}/config/route.ts (100%) rename src/{app => _app}/modules/wrapper/Wrapper.module.css (100%) rename src/{app => _app}/modules/wrapper/Wrapper.tsx (100%) rename src/{ => common}/instances/Connector.ts (93%) diff --git a/public/index.html b/public/index.html index e153c98..8c89ef6 100644 --- a/public/index.html +++ b/public/index.html @@ -11,7 +11,7 @@ /> <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> <!-- - manifest.json provides metadata used when your web app is installed on a + manifest.json provides metadata used when your web _app is installed on a user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ --> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> diff --git a/src/app/App.module.css b/src/_app/App.module.css similarity index 100% rename from src/app/App.module.css rename to src/_app/App.module.css diff --git a/src/app/App.tsx b/src/_app/App.tsx similarity index 98% rename from src/app/App.tsx rename to src/_app/App.tsx index b48df98..69b9892 100644 --- a/src/app/App.tsx +++ b/src/_app/App.tsx @@ -3,13 +3,13 @@ import '../common/css/common.css'; import '../common/css/reset.css'; import { Routes, Route, useNavigate } from "react-router-dom"; +import Connector from "../common/instances/Connector"; import BottomSheet from "../components/bottom-sheet/BottomSheet"; import Header from "../components/header/Header"; import Toast from "../components/toast/Toast"; import { BSProvider } from "../contexts/bottom-sheet"; import { CartProvider } from "../contexts/cart"; import { ToastProvider } from "../contexts/toast"; -import Connector from "../instances/Connector"; import CartPage from "../pages/cart-page/CartPage"; import HistoryPage from "../pages/history-page/HistoryPage"; import LoginPage from "../pages/login-page/LoginPage"; diff --git a/src/app/config/route.ts b/src/_app/config/route.ts similarity index 100% rename from src/app/config/route.ts rename to src/_app/config/route.ts diff --git a/src/app/modules/wrapper/Wrapper.module.css b/src/_app/modules/wrapper/Wrapper.module.css similarity index 100% rename from src/app/modules/wrapper/Wrapper.module.css rename to src/_app/modules/wrapper/Wrapper.module.css diff --git a/src/app/modules/wrapper/Wrapper.tsx b/src/_app/modules/wrapper/Wrapper.tsx similarity index 100% rename from src/app/modules/wrapper/Wrapper.tsx rename to src/_app/modules/wrapper/Wrapper.tsx diff --git a/src/instances/Connector.ts b/src/common/instances/Connector.ts similarity index 93% rename from src/instances/Connector.ts rename to src/common/instances/Connector.ts index c8ef5a7..51aa0d5 100644 --- a/src/instances/Connector.ts +++ b/src/common/instances/Connector.ts @@ -1,4 +1,4 @@ -import { FETCH_METHOD, fetchData, RESPONSE_STATUS } from "../common/utils/api"; +import { FETCH_METHOD, fetchData, RESPONSE_STATUS } from "../utils/api"; import type { Dispatch, SetStateAction } from "react"; diff --git a/src/common/utils/api.ts b/src/common/utils/api.ts index 59d0fec..9f0198e 100644 --- a/src/common/utils/api.ts +++ b/src/common/utils/api.ts @@ -51,7 +51,7 @@ async function fetchData<T> ( throw e; } - return {status, response}; + return { status, response }; } export { fetchData, FETCH_METHOD, RESPONSE_STATUS }; diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index f911b3c..4f50cbb 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -1,7 +1,7 @@ import { useContext, useEffect, useState } from "react"; import { Link, useLocation } from "react-router-dom"; -import APP_ROUTE from "../../app/config/route"; +import APP_ROUTE from "../../_app/config/route"; import { CartContext } from "../../contexts/cart"; import S from './Header.module.css'; diff --git a/src/components/navigator/config.ts b/src/components/navigator/config.ts index 070e14d..5318061 100644 --- a/src/components/navigator/config.ts +++ b/src/components/navigator/config.ts @@ -1,4 +1,4 @@ -import APP_ROUTE from "../../app/config/route"; +import APP_ROUTE from "../../_app/config/route"; interface NavRoute { icon: string; diff --git a/src/index.tsx b/src/index.tsx index f732e5e..65b8bb0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,9 +1,9 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import {BrowserRouter} from "react-router-dom"; +import { BrowserRouter } from "react-router-dom"; -import App from './app/App'; +import App from './_app/App'; const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement diff --git a/src/pages/cart-page/CartPage.tsx b/src/pages/cart-page/CartPage.tsx index 3a0a9de..791fc24 100644 --- a/src/pages/cart-page/CartPage.tsx +++ b/src/pages/cart-page/CartPage.tsx @@ -11,7 +11,7 @@ import { CartContext } from "../../contexts/cart"; import S from './CartPage.module.css'; import type { CartItemData, OrderPostModel } from "./config/type"; -import type Connector from "../../instances/Connector"; +import type Connector from "../../common/instances/Connector"; import type { FC } from "react"; @@ -23,7 +23,7 @@ const CartPage: FC<Props> = ({ connector }) => { const [quantities, setQuantities] = useState<number[]>([]); const [totalPrice, setTotalPrice] = useState(0); - const a=1; + const a = 1; const b = 1; diff --git a/src/pages/history-page/HistoryPage.tsx b/src/pages/history-page/HistoryPage.tsx index 20ea714..156a15a 100644 --- a/src/pages/history-page/HistoryPage.tsx +++ b/src/pages/history-page/HistoryPage.tsx @@ -5,7 +5,7 @@ import { HISTORY_PAGE_DUMMY } from "./config/dummy"; import OrderBox from "./modules/order-box/OrderBox"; import type { HistoryPageModel } from "./config/type"; -import type Connector from "../../instances/Connector"; +import type Connector from "../../common/instances/Connector"; import type { FC } from "react"; diff --git a/src/pages/login-page/LoginPage.tsx b/src/pages/login-page/LoginPage.tsx index 88fde64..3e2c17d 100644 --- a/src/pages/login-page/LoginPage.tsx +++ b/src/pages/login-page/LoginPage.tsx @@ -1,11 +1,11 @@ import { useState } from "react"; import { useNavigate } from "react-router-dom"; -import APP_ROUTE from "../../app/config/route"; +import APP_ROUTE from "../../_app/config/route"; import S from './LoginPage.module.css'; -import type Connector from "../../instances/Connector"; +import type Connector from "../../common/instances/Connector"; import type { FC } from "react"; diff --git a/src/pages/main-page/MainPage.tsx b/src/pages/main-page/MainPage.tsx index 256112e..77f70eb 100644 --- a/src/pages/main-page/MainPage.tsx +++ b/src/pages/main-page/MainPage.tsx @@ -8,7 +8,7 @@ import ShopBox from "./modules/shop-box/ShopBox"; import type { MainPageModel } from "./config/type"; -import type Connector from "../../instances/Connector"; +import type Connector from "../../common/instances/Connector"; import type { FC } from "react"; diff --git a/src/pages/menu-page/MenuPage.tsx b/src/pages/menu-page/MenuPage.tsx index 4af885e..024d64c 100644 --- a/src/pages/menu-page/MenuPage.tsx +++ b/src/pages/menu-page/MenuPage.tsx @@ -6,7 +6,7 @@ import { ALERT } from "../../common/constants"; import MenuBox from "./modules/menu-box/MenuBox"; import type { MenuPageModel } from "./config/type"; -import type Connector from "../../instances/Connector"; +import type Connector from "../../common/instances/Connector"; import type { Dispatch, FC, SetStateAction } from "react"; -- GitLab