Skip to content
Merged
5 changes: 4 additions & 1 deletion src/api/menuCategory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { MENU_CAGEGORY_API } from '@/constants/_apiPath';

const { MENU_CATEGORIES, SEARCH_SCHOOL } = MENU_CAGEGORY_API;

/**
* @description 소분류 조회
*/
const getMinorCategories = async (param: MajorCategory) => {
const response = await get<Result<string[] | null>>(MENU_CATEGORIES, {
params: {
Expand All @@ -16,7 +19,7 @@ const getMinorCategories = async (param: MajorCategory) => {
};

/**
* @description 학교명 검색 api
* @description 학교명 검색
*/
const getSearchSchool = async ({ keyword }: GetSearchSchoolRequest) => {
const response = await get<Result<string[] | []>>(SEARCH_SCHOOL, {
Expand Down
35 changes: 18 additions & 17 deletions src/components/feature/AutoPlan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
} from '@/components/common/Typography';
import MealCalendar from '@/components/shared/Meal/MealCalender';
import { MealHeaderFormData } from '@/components/shared/Meal/MealHeader';
import { ORGANIZATION_LIST } from '@/constants/_category';
import { ORGANIZATION_LIST, SCHOOL_LEVEL_LIST } from '@/constants/_category';
import { AUTO_PLAN_BETA_MESSAGE, MAJOR_CATEGORIES } from '@/constants/_meal';
import {
MEAL_FORM_LEGEND,
Expand All @@ -46,7 +46,7 @@ import { PAGE_TITLE } from '@/constants/_pageTitle';
import { MEAL_HEADER_ERROR } from '@/constants/_schema';
import { usePostMonthMenusAuto } from '@/hooks/menu/usePostMonthMenusAuto';
import { usePostMonthMenusSave } from '@/hooks/menu/usePostMonthMenusSave';
import { useFetchMinorCategories } from '@/hooks/menuCategory/useFetchMinorCategories';
// import { useFetchMinorCategories } from '@/hooks/menuCategory/useFetchMinorCategories';
import { useGetSearchSchool } from '@/hooks/menuCategory/useGetSearchSchool';
import { usePrefetchMinorCategories } from '@/hooks/menuCategory/usePrefetchMinorCategories';
import useNavigate from '@/hooks/useNavigate';
Expand All @@ -71,9 +71,10 @@ const AutoPlan = () => {
const { navigate } = useNavigate();

const queryClient = useQueryClient();
const { minorCategories } = useFetchMinorCategories(
selectedCategory.majorCategory,
);
// 현재는 대분류 '학교' 선택 시 소분류 옵션에 '초/중/고'만 보여주므로 주석처리
// const { minorCategories } = useFetchMinorCategories(
// selectedCategory.majorCategory,
// );
const { mutate: postAutoMutate } = usePostMonthMenusAuto();
const { mutate: postSaveMutate } = usePostMonthMenusSave();
const { prefetchMinorCategories, hasCategories } =
Expand Down Expand Up @@ -278,8 +279,8 @@ const AutoPlan = () => {
selectedValue={selectedCategory.majorCategory}
isError={isCategoryError}
/>
<div className='relative'>
{selectedCategory.majorCategory === MAJOR_CATEGORIES[1] && (
{selectedCategory.majorCategory === MAJOR_CATEGORIES[1] && (
<div className='relative'>
<div className='flex gap-4'>
<Input
variant='white'
Expand All @@ -298,23 +299,23 @@ const AutoPlan = () => {
<Subtitle2White>검색</Subtitle2White>
</Button>
</div>
)}
<Dropdown isOpen={isOpen} className='top-12'>
<OptionList
options={options}
onSelect={handleSchoolNameSelect}
size='basic'
/>
</Dropdown>
</div>
<Dropdown isOpen={isOpen} className='top-12'>
<OptionList
options={options}
onSelect={handleSchoolNameSelect}
size='basic'
/>
</Dropdown>
</div>
)}

{ORGANIZATION_LIST.map(
(organization) =>
selectedCategory.majorCategory === organization.value &&
selectedCategory.majorCategory !== MAJOR_CATEGORIES[1] && (
<Selectbox
key={organization.value}
options={minorCategories}
options={SCHOOL_LEVEL_LIST}
buttonSize='sm'
className='min-w-[194px] justify-start'
onChange={(minorCategory) =>
Expand Down
34 changes: 17 additions & 17 deletions src/components/feature/MealPlanEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
} from '@/components/common/Typography';
import MealCalendar from '@/components/shared/Meal/MealCalender';
import { MealHeaderFormData } from '@/components/shared/Meal/MealHeader';
import { ORGANIZATION_LIST } from '@/constants/_category';
import { ORGANIZATION_LIST, SCHOOL_LEVEL_LIST } from '@/constants/_category';
import { MAJOR_CATEGORIES } from '@/constants/_meal';
import {
MEAL_FORM_LEGEND,
Expand All @@ -45,7 +45,7 @@ import { ROUTES } from '@/constants/_navbar';
import { PAGE_TITLE } from '@/constants/_pageTitle';
import { MEAL_HEADER_ERROR } from '@/constants/_schema';
import { usePutMonthMenus } from '@/hooks/menu/usePutMonthMenus';
import { useFetchMinorCategories } from '@/hooks/menuCategory/useFetchMinorCategories';
// import { useFetchMinorCategories } from '@/hooks/menuCategory/useFetchMinorCategories';
import { useGetSearchSchool } from '@/hooks/menuCategory/useGetSearchSchool';
import useNavigate from '@/hooks/useNavigate';
import { useToastStore } from '@/stores/useToastStore';
Expand Down Expand Up @@ -77,9 +77,9 @@ const MealPlanEdit = ({ id: monthMenuId }: MealPlanEditProps) => {
const { navigate, handleBack } = useNavigate();

const queryClient = useQueryClient();
const { minorCategories } = useFetchMinorCategories(
selectedCategory.majorCategory,
);
// const { minorCategories } = useFetchMinorCategories(
// selectedCategory.majorCategory,
// );
const { mutate: putMutate } = usePutMonthMenus();

const {
Expand Down Expand Up @@ -321,8 +321,8 @@ const MealPlanEdit = ({ id: monthMenuId }: MealPlanEditProps) => {
selectedValue={selectedCategory.majorCategory}
isError={isCategoryError}
/>
<div className='relative'>
{selectedCategory.majorCategory === MAJOR_CATEGORIES[1] && (
{selectedCategory.majorCategory === MAJOR_CATEGORIES[1] && (
<div className='relative'>
<div className='flex gap-4'>
<Input
variant='white'
Expand All @@ -341,22 +341,22 @@ const MealPlanEdit = ({ id: monthMenuId }: MealPlanEditProps) => {
<Subtitle2White>검색</Subtitle2White>
</Button>
</div>
)}
<Dropdown isOpen={isOpen} className='top-12'>
<OptionList
options={options}
onSelect={handleSchoolNameSelect}
size='basic'
/>
</Dropdown>
</div>
<Dropdown isOpen={isOpen} className='top-12'>
<OptionList
options={options}
onSelect={handleSchoolNameSelect}
size='basic'
/>
</Dropdown>
</div>
)}
{ORGANIZATION_LIST.map(
(organization) =>
selectedCategory.majorCategory === organization.value &&
selectedCategory.majorCategory !== MAJOR_CATEGORIES[1] && (
<Selectbox
key={organization.value}
options={minorCategories}
options={SCHOOL_LEVEL_LIST}
buttonSize='sm'
className='min-w-[194px] justify-start'
onChange={(minorCategory) =>
Expand Down
37 changes: 20 additions & 17 deletions src/components/feature/MenualPlan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Option, Selectbox } from '@/components/common/Selectbox';
import { H2BlackH2, Subtitle2White } from '@/components/common/Typography';
import MealCalendar from '@/components/shared/Meal/MealCalender';
import { MealHeaderFormData } from '@/components/shared/Meal/MealHeader';
import { ORGANIZATION_LIST } from '@/constants/_category';
import { ORGANIZATION_LIST, SCHOOL_LEVEL_LIST } from '@/constants/_category';
import { MAJOR_CATEGORIES } from '@/constants/_meal';
import {
MEAL_FORM_LEGEND,
Expand All @@ -35,13 +35,16 @@ import { ROUTES } from '@/constants/_navbar';
import { PAGE_TITLE } from '@/constants/_pageTitle';
import { MEAL_HEADER_ERROR } from '@/constants/_schema';
import { MEAL_CREATE_MESSAGE } from '@/constants/_toastMessage';
import { useFetchMinorCategories } from '@/hooks/menuCategory/useFetchMinorCategories';
// import { useFetchMinorCategories } from '@/hooks/menuCategory/useFetchMinorCategories';
import { useGetSearchSchool } from '@/hooks/menuCategory/useGetSearchSchool';
import { usePrefetchMinorCategories } from '@/hooks/menuCategory/usePrefetchMinorCategories';
import useNavigate from '@/hooks/useNavigate';
import { useMenualPlanStore } from '@/stores/useMenualPlanStore';
import { useToastStore } from '@/stores/useToastStore';

/**
* @description 수동 식단 작성 페이지
*/
const MenualPlan = () => {
const [calendarData, setCalendarData] = useState<CalendarInfo>({});
const [selectedDate, setSelectedDate] = useState<string>('');
Expand All @@ -64,9 +67,9 @@ const MenualPlan = () => {
}),
);

const { minorCategories } = useFetchMinorCategories(
selectedCategory.majorCategory,
);
// const { minorCategories } = useFetchMinorCategories(
// selectedCategory.majorCategory,
// );
const { prefetchMinorCategories, hasCategories } =
usePrefetchMinorCategories();

Expand Down Expand Up @@ -240,8 +243,8 @@ const MenualPlan = () => {
isError={isCategoryError}
/>

<div className='relative'>
{selectedCategory.majorCategory === MAJOR_CATEGORIES[1] && (
{selectedCategory.majorCategory === MAJOR_CATEGORIES[1] && (
<div className='relative'>
<div className='flex gap-4'>
<Input
variant='white'
Expand All @@ -260,23 +263,23 @@ const MenualPlan = () => {
<Subtitle2White>검색</Subtitle2White>
</Button>
</div>
)}
<Dropdown isOpen={isOpen} className='top-12'>
<OptionList
options={options}
onSelect={handleSchoolNameSelect}
size='basic'
/>
</Dropdown>
</div>
<Dropdown isOpen={isOpen} className='top-12'>
<OptionList
options={options}
onSelect={handleSchoolNameSelect}
size='basic'
/>
</Dropdown>
</div>
)}

{ORGANIZATION_LIST.map(
(item) =>
selectedCategory.majorCategory === item.value &&
selectedCategory.majorCategory !== MAJOR_CATEGORIES[1] && (
<Selectbox
key={item.value}
options={minorCategories}
options={SCHOOL_LEVEL_LIST}
buttonSize='sm'
className='min-w-[194px] justify-start'
onChange={(minorCategory) =>
Expand Down
37 changes: 20 additions & 17 deletions src/components/feature/MenualPlanEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { Option, Selectbox } from '@/components/common/Selectbox';
import { H2BlackH2, Subtitle2White } from '@/components/common/Typography';
import MealCalendar from '@/components/shared/Meal/MealCalender';
import { MealHeaderFormData } from '@/components/shared/Meal/MealHeader';
import { ORGANIZATION_LIST } from '@/constants/_category';
import { ORGANIZATION_LIST, SCHOOL_LEVEL_LIST } from '@/constants/_category';
import { MAJOR_CATEGORIES } from '@/constants/_meal';
import {
MEAL_FORM_LEGEND,
Expand All @@ -38,12 +38,15 @@ import { ROUTES } from '@/constants/_navbar';
import { PAGE_TITLE } from '@/constants/_pageTitle';
import { MEAL_HEADER_ERROR } from '@/constants/_schema';
import { usePostMonthMenusSave } from '@/hooks/menu/usePostMonthMenusSave';
import { useFetchMinorCategories } from '@/hooks/menuCategory/useFetchMinorCategories';
// import { useFetchMinorCategories } from '@/hooks/menuCategory/useFetchMinorCategories';
import { useGetSearchSchool } from '@/hooks/menuCategory/useGetSearchSchool';
import useNavigate from '@/hooks/useNavigate';
import { useMenualPlanStore } from '@/stores/useMenualPlanStore';
import { useToastStore } from '@/stores/useToastStore';

/**
* @description 수동 식단 수정 페이지
*/
const MenualPlanEdit = () => {
const { monthMenuName, category, calendar } = useMenualPlanStore((state) => ({
monthMenuName: state.monthMenuName,
Expand All @@ -65,9 +68,9 @@ const MenualPlanEdit = () => {
const isBothSelected =
selectedCategory.majorCategory && selectedCategory.minorCategory;

const { minorCategories } = useFetchMinorCategories(
selectedCategory.majorCategory,
);
// const { minorCategories } = useFetchMinorCategories(
// selectedCategory.majorCategory,
// );
const { mutate: postSaveMutate } = usePostMonthMenusSave();

const {
Expand Down Expand Up @@ -250,8 +253,8 @@ const MenualPlanEdit = () => {
selectedValue={selectedCategory.majorCategory}
isError={isCategoryError}
/>
<div className='relative'>
{selectedCategory.majorCategory === MAJOR_CATEGORIES[1] && (
{selectedCategory.majorCategory === MAJOR_CATEGORIES[1] && (
<div className='relative'>
<div className='flex gap-4'>
<Input
variant='white'
Expand All @@ -270,23 +273,23 @@ const MenualPlanEdit = () => {
<Subtitle2White>검색</Subtitle2White>
</Button>
</div>
)}
<Dropdown isOpen={isOpen} className='top-12'>
<OptionList
options={options}
onSelect={handleSchoolNameSelect}
size='basic'
/>
</Dropdown>
</div>
<Dropdown isOpen={isOpen} className='top-12'>
<OptionList
options={options}
onSelect={handleSchoolNameSelect}
size='basic'
/>
</Dropdown>
</div>
)}

{ORGANIZATION_LIST.map(
(organization) =>
selectedCategory.majorCategory === organization.value &&
selectedCategory.majorCategory !== MAJOR_CATEGORIES[1] && (
<Selectbox
key={organization.value}
options={minorCategories}
options={SCHOOL_LEVEL_LIST}
buttonSize='sm'
className='min-w-[194px] justify-start'
onChange={(minorCategory) =>
Expand Down
13 changes: 0 additions & 13 deletions src/constants/_category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@ export const ORGANIZATION_LIST = [
{ value: MAJOR_CATEGORIES[2], label: MAJOR_CATEGORIES[2] },
];

export const MOCK_CATEGORY_LIST = [
SCHOOL_LEVEL_LIST,
ORGANIZATION_LIST,
[
{ value: '1', label: '세번쨰' },
{ value: '2', label: MAJOR_CATEGORIES[1] },
{ value: '3', label: MAJOR_CATEGORIES[2] },
{ value: '4', label: '세번쨰' },
{ value: '5', label: MAJOR_CATEGORIES[1] },
{ value: '6', label: MAJOR_CATEGORIES[2] },
],
];

export const CATEGORY_MAPPINGS = [
{ category: MAJOR_CATEGORIES[0], queryKey: 'getSchoolMinorCategories' },
// { category: MAJOR_CATEGORIES[1], queryKey: 'getSchoolNameMinorCategories' },
Expand Down