Skip to content

Commit

Permalink
refactor: 불필요한 키 삭제 및 파일 합침
Browse files Browse the repository at this point in the history
  • Loading branch information
hyejun0228 committed Apr 7, 2024
1 parent 3d85dce commit 877297f
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/page/ShopRegistration/component/Modal/Category/index.tsx
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/page/ShopRegistration/view/Mobile/ShopCategory/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions src/query/KeyFactory/allShopKeys.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/query/KeyFactory/registerKeys.ts
Original file line number Diff line number Diff line change
@@ -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,
};
3 changes: 0 additions & 3 deletions src/query/KeyFactory/shopCategoryKeys.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/query/KeyFactory/shopKeys.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
8 changes: 7 additions & 1 deletion src/query/shop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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') {
Expand All @@ -46,7 +52,7 @@ const useMyShop = () => {
});

return {
shopData, menusData, addMenuMutation, addMenuError, refetchShopData, isLoading,
shopData, menusData, addMenuMutation, addMenuError, refetchShopData, isLoading, categoryList,
};
};

Expand Down
13 changes: 0 additions & 13 deletions src/query/shopCategory.ts

This file was deleted.

0 comments on commit 877297f

Please sign in to comment.