diff --git a/src/hooks/use-auto-complete.hooks.ts b/src/hooks/use-auto-complete.hooks.ts index 4ff9d48..bd7de0b 100644 --- a/src/hooks/use-auto-complete.hooks.ts +++ b/src/hooks/use-auto-complete.hooks.ts @@ -1,6 +1,7 @@ import { useEffect, useState } from 'react'; import useDebouce from './use-debounce.hooks'; import { searchAutoComplete } from '../api/search-auto-complete'; +import useTypeStore from '../store/type-category-store'; interface UseAutoCompleteProps { content: string; @@ -15,6 +16,7 @@ export interface AutoCompleteResult { export const useAutoComplete = ({ content, delay = 300 }: UseAutoCompleteProps) => { const [results, setResults] = useState([]); const [error, setError] = useState(null); + const { type, category } = useTypeStore(); const debouncedContent = useDebouce(content, delay); @@ -24,7 +26,7 @@ export const useAutoComplete = ({ content, delay = 300 }: UseAutoCompleteProps) setError(null); try { - const response = await searchAutoComplete(debouncedContent); + const response = await searchAutoComplete(debouncedContent, type, category); setResults(response.data); } catch (err) { setError('자동완성 api 호출 실패'); diff --git a/src/store/type-category-store.ts b/src/store/type-category-store.ts index cff5ff0..5a9ebef 100644 --- a/src/store/type-category-store.ts +++ b/src/store/type-category-store.ts @@ -1,15 +1,15 @@ import { create } from 'zustand'; interface TypeCategoryState { - type: null | 'SUSI' | 'PYEONIP' | 'JEONGSI'; - category: null | 'ADMISSION_GUIDELINE' | 'PASSING_RESULT' | 'PAST_QUESTIONS' | 'INTERVIEW_PRACTICAL_TEST'; + type: undefined | 'SUSI' | 'PYEONIP' | 'JEONGSI'; + category: undefined | 'ADMISSION_GUIDELINE' | 'PASSING_RESULT' | 'PAST_QUESTIONS' | 'INTERVIEW_PRACTICAL_TEST'; setSelectedType: (button: TypeCategoryState['type']) => void; setSelectedCategory: (button: TypeCategoryState['category']) => void; } const useTypeStore = create()((set) => ({ - type: null, - category: null, + type: undefined, + category: undefined, setSelectedType: (button) => set({ type: button }), setSelectedCategory: (button) => set({ category: button }), })); diff --git a/src/ui/components/molecule/header/header.tsx b/src/ui/components/molecule/header/header.tsx index 5f719f0..21d1c2c 100644 --- a/src/ui/components/molecule/header/header.tsx +++ b/src/ui/components/molecule/header/header.tsx @@ -6,7 +6,7 @@ import IconButton from '../../atom/icon/icon-button'; import MenuDrawer from '../menu-drawer/menu-drawer'; interface HeaderProps { - type: null | 'SUSI' | 'PYEONIP' | 'JEONGSI'; + type: undefined | 'SUSI' | 'PYEONIP' | 'JEONGSI'; } const Header = ({ type }: HeaderProps) => { diff --git a/src/ui/components/molecule/menu-drawer/menu-drawer.tsx b/src/ui/components/molecule/menu-drawer/menu-drawer.tsx index f3f81ac..c80ea66 100644 --- a/src/ui/components/molecule/menu-drawer/menu-drawer.tsx +++ b/src/ui/components/molecule/menu-drawer/menu-drawer.tsx @@ -11,7 +11,7 @@ interface MenuDrawerProps { } const MenuDrawer = ({ open, onClose }: MenuDrawerProps) => { - const [selectedButton, setSelectedButton] = React.useState<'SUSI' | 'PYEONIP' | 'JEONGSI' | null>(null); + const [selectedButton, setSelectedButton] = React.useState<'SUSI' | 'PYEONIP' | 'JEONGSI' | undefined>(undefined); const { type } = useTypeStore(); useEffect(() => { diff --git a/src/ui/pages/maru-egg.tsx b/src/ui/pages/maru-egg.tsx index 120180a..b4694dc 100644 --- a/src/ui/pages/maru-egg.tsx +++ b/src/ui/pages/maru-egg.tsx @@ -9,10 +9,12 @@ import PresetButton from '../components/atom/preset/preset-button'; const MaruEgg: React.FC = () => { const { setSelectedType, type, setSelectedCategory, category } = useTypeStore(); const { messages } = useChatStore(); - const [selectedTypeButton, setSelectedTypeButton] = React.useState<'SUSI' | 'PYEONIP' | 'JEONGSI' | null>(null); + const [selectedTypeButton, setSelectedTypeButton] = React.useState<'SUSI' | 'PYEONIP' | 'JEONGSI' | undefined>( + undefined, + ); const [selectedCategoryButton, setSelectedCategoryButton] = React.useState< - null | 'ADMISSION_GUIDELINE' | 'PASSING_RESULT' | 'PAST_QUESTIONS' | 'INTERVIEW_PRACTICAL_TEST' - >(null); + undefined | 'ADMISSION_GUIDELINE' | 'PASSING_RESULT' | 'PAST_QUESTIONS' | 'INTERVIEW_PRACTICAL_TEST' + >(undefined); const handleTypeButtonClick = (selectedType: 'SUSI' | 'PYEONIP' | 'JEONGSI') => { setSelectedType(selectedType); @@ -53,10 +55,10 @@ const MaruEgg: React.FC = () => { 정시 - {type !== null && ( + {type !== undefined && ( )} - {type !== null && ( + {type !== undefined && ( <>
@@ -78,11 +80,17 @@ const MaruEgg: React.FC = () => { > 면접등 기출문제 + handleCategoryButtonClick('INTERVIEW_PRACTICAL_TEST')} + isSelected={selectedCategoryButton === 'INTERVIEW_PRACTICAL_TEST'} + > + 실기관련 +
)} - {category !== null && ( + {category !== undefined && ( { } /> )} - {type !== null && category !== null && ( + {type !== undefined && category !== undefined && ( { return ; })} - {type !== null && category !== null && ( + {type !== undefined && category !== undefined && (