From 877297f40d2fd5e4a2d0447176a12f10a1ba8d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=9C=EC=A4=80?= Date: Sun, 7 Apr 2024 20:23:55 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=82=A4=20=EC=82=AD=EC=A0=9C=20=EB=B0=8F=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=ED=95=A9=EC=B9=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/Modal/Category/index.tsx | 4 ++-- .../view/Mobile/ShopCategory/index.tsx | 4 ++-- src/query/KeyFactory/allShopKeys.ts | 3 --- src/query/KeyFactory/registerKeys.ts | 4 ++-- src/query/KeyFactory/shopCategoryKeys.ts | 3 --- src/query/KeyFactory/shopKeys.ts | 1 + src/query/shop.ts | 8 +++++++- src/query/shopCategory.ts | 13 ------------- 8 files changed, 14 insertions(+), 26 deletions(-) delete mode 100644 src/query/KeyFactory/allShopKeys.ts delete mode 100644 src/query/KeyFactory/shopCategoryKeys.ts delete mode 100644 src/query/shopCategory.ts diff --git a/src/page/ShopRegistration/component/Modal/Category/index.tsx b/src/page/ShopRegistration/component/Modal/Category/index.tsx index 15d363b0..0ca60c69 100644 --- a/src/page/ShopRegistration/component/Modal/Category/index.tsx +++ b/src/page/ShopRegistration/component/Modal/Category/index.tsx @@ -1,11 +1,11 @@ -import useShopCategory from 'query/shopCategory'; +import useMyShop from 'query/shop'; import cn from 'utils/ts/className'; import { Category as CategoryProps } from 'model/category/storeCategory'; import useShopRegistrationStore from 'store/shopRegistration'; import styles from './Category.module.scss'; export default function Category() { - const { categoryList } = useShopCategory(); + const { categoryList } = useMyShop(); const { category, setCategory, setCategoryId } = useShopRegistrationStore(); const handleCategoryClick = (categoryInfo: CategoryProps) => { diff --git a/src/page/ShopRegistration/view/Mobile/ShopCategory/index.tsx b/src/page/ShopRegistration/view/Mobile/ShopCategory/index.tsx index 46491899..b6f2f827 100644 --- a/src/page/ShopRegistration/view/Mobile/ShopCategory/index.tsx +++ b/src/page/ShopRegistration/view/Mobile/ShopCategory/index.tsx @@ -1,5 +1,5 @@ import useStepStore from 'store/useStepStore'; -import useShopCategory from 'query/shopCategory'; +import useMyShop from 'query/shop'; import cn from 'utils/ts/className'; import { Category as CategoryProps } from 'model/category/storeCategory'; import useShopRegistrationStore from 'store/shopRegistration'; @@ -10,7 +10,7 @@ import styles from './ShopCategory.module.scss'; export default function ShopCategory() { const [isError, setIsError] = useState(false); - const { categoryList } = useShopCategory(); + const { categoryList } = useMyShop(); const { increaseStep } = useStepStore(); const { category, setCategory, setCategoryId, diff --git a/src/query/KeyFactory/allShopKeys.ts b/src/query/KeyFactory/allShopKeys.ts deleted file mode 100644 index 18f057e6..00000000 --- a/src/query/KeyFactory/allShopKeys.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const allShopKeys = { - all: ['shop'] as const, -}; diff --git a/src/query/KeyFactory/registerKeys.ts b/src/query/KeyFactory/registerKeys.ts index a70c73c0..8788e95d 100644 --- a/src/query/KeyFactory/registerKeys.ts +++ b/src/query/KeyFactory/registerKeys.ts @@ -1,8 +1,8 @@ export const registerKeys = { all: ['register'] as const, + fileUrlList: ['fileUrlList'] as const, + registerUser: ['registerUser'] as const, emailCheck: (email: string) => [...registerKeys.all, 'emailDuplicateCheck', email] as const, authCode: (email: string) => [...registerKeys.all, 'generateEmailAuthCode', email] as const, verificationCode: (code: string, email: string) => [...registerKeys.all, 'verificationCode', code, email] as const, - registerUser: ['registerUser'] as const, - fileUrlList: ['fileUrlList'] as const, }; diff --git a/src/query/KeyFactory/shopCategoryKeys.ts b/src/query/KeyFactory/shopCategoryKeys.ts deleted file mode 100644 index cba5bdbb..00000000 --- a/src/query/KeyFactory/shopCategoryKeys.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const shopCategoryKeys = { - shopCategory: ['shopCategory'] as const, -}; diff --git a/src/query/KeyFactory/shopKeys.ts b/src/query/KeyFactory/shopKeys.ts index f085afbe..76599bca 100644 --- a/src/query/KeyFactory/shopKeys.ts +++ b/src/query/KeyFactory/shopKeys.ts @@ -1,5 +1,6 @@ export const shopKeys = { all: ['shop'] as const, + shopCategoryInfo: ['shopCategory'] as const, myShopList: (myShopQueryKey: string | undefined) => [...shopKeys.all, 'myShop', myShopQueryKey] as const, myShopInfo: (shopId: number) => [...shopKeys.all, 'myShopInfo', shopId] as const, myMenuInfo: (shopId: number) => [...shopKeys.all, 'myMenuInfo', shopId] as const, diff --git a/src/query/shop.ts b/src/query/shop.ts index 396bdae7..504477e4 100644 --- a/src/query/shop.ts +++ b/src/query/shop.ts @@ -7,6 +7,7 @@ import { import useUserStore from 'store/user'; import useAddMenuStore from 'store/addMenu'; import { NewMenu } from 'model/shopInfo/newMenu'; +import getShopCategory from 'api/category'; import { shopKeys } from './KeyFactory/shopKeys'; const useMyShop = () => { @@ -32,6 +33,11 @@ const useMyShop = () => { enabled: !!shopId, }); + const { data: categoryList } = useQuery({ + queryKey: shopKeys.shopCategoryInfo, + queryFn: () => getShopCategory(), + }); + const { mutate: addMenuMutation, isError: addMenuError } = useMutation({ mutationFn: (param: NewMenu) => { if (typeof shopId === 'number') { @@ -46,7 +52,7 @@ const useMyShop = () => { }); return { - shopData, menusData, addMenuMutation, addMenuError, refetchShopData, isLoading, + shopData, menusData, addMenuMutation, addMenuError, refetchShopData, isLoading, categoryList, }; }; diff --git a/src/query/shopCategory.ts b/src/query/shopCategory.ts deleted file mode 100644 index b18c6be8..00000000 --- a/src/query/shopCategory.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { useQuery } from '@tanstack/react-query'; -import getShopCategory from 'api/category'; -import { shopCategoryKeys } from './KeyFactory/shopCategoryKeys'; - -const useShopCategory = () => { - const { data: categoryList } = useQuery({ - queryKey: shopCategoryKeys.shopCategory, - queryFn: () => getShopCategory(), - }); - return { categoryList }; -}; - -export default useShopCategory;