diff --git a/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategoryDropdown/CategoryDropdown.tsx b/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategoryDropdown/CategoryDropdown.tsx index 45e6070..f6cae9f 100644 --- a/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategoryDropdown/CategoryDropdown.tsx +++ b/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategoryDropdown/CategoryDropdown.tsx @@ -7,15 +7,13 @@ import React from 'react'; import { ISelectedCategoryProps } from 'types/category'; interface ICategoryDropdownProp { - setSelectedCategory: React.Dispatch< - React.SetStateAction - >; setIsOpen: React.Dispatch>; + handleSelectCategory: ({ name, categoryId }: ISelectedCategoryProps) => void; } const CategoryDropdown = ({ - setSelectedCategory, setIsOpen, + handleSelectCategory, }: ICategoryDropdownProp) => { const categories = useRecoilValue(categoryState); return ( @@ -25,8 +23,8 @@ const CategoryDropdown = ({ ))} diff --git a/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategoryDropdown/DropdownItem.tsx b/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategoryDropdown/DropdownItem.tsx index 9bd120b..7fcfb91 100644 --- a/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategoryDropdown/DropdownItem.tsx +++ b/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategoryDropdown/DropdownItem.tsx @@ -6,10 +6,8 @@ import { DropdownTopCategoryName } from '@/styles/SummaryPage'; interface ICategoryDropdownProp { category: IFolderProps; - setSelectedCategory: React.Dispatch< - React.SetStateAction - >; setIsOpen: React.Dispatch>; + handleSelectCategory: ({ name, categoryId }: ISelectedCategoryProps) => void; } interface IItemClickProps { @@ -19,8 +17,8 @@ interface IItemClickProps { const DropdownItem = ({ category, - setSelectedCategory, setIsOpen, + handleSelectCategory, }: ICategoryDropdownProp) => { const [isShow, setIsShow] = useState(false); @@ -34,12 +32,7 @@ const DropdownItem = ({ }; const handleItemClick = async ({ name, categoryId }: IItemClickProps) => { - setSelectedCategory({ - name, - categoryId, - }); - // API 요청 - console.log('API 요청'); + handleSelectCategory({ name, categoryId }); setIsOpen(false); }; diff --git a/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategorySelectBox.tsx b/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategorySelectBox.tsx index 459575e..670d491 100644 --- a/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategorySelectBox.tsx +++ b/src/components/SummaryPage/SummaryDetailBox/CategorySelectBox/CategorySelectBox.tsx @@ -8,11 +8,17 @@ import useOutsideClick from '@/hooks/useOutsideClick'; import { CategoryDropdown } from './CategoryDropdown'; import { ISelectedCategoryProps } from 'types/category'; -const CategorySelectBox = () => { +interface ICategorySelectBoxProps { + selectedCategory: ISelectedCategoryProps; + handleSelectCategory: ({ name, categoryId }: ISelectedCategoryProps) => void; +} + +const CategorySelectBox = ({ + selectedCategory, + handleSelectCategory, +}: ICategorySelectBoxProps) => { const [isLogin] = useState(true); const [isOpen, setIsOpen] = useState(false); - const [selectedCategory, setSelectedCategory] = - useState({ name: '', categoryId: 0 }); // 다른 영역 클릭 시 dropdown 안보여지게 하기 const [ref] = useOutsideClick(() => { @@ -41,8 +47,8 @@ const CategorySelectBox = () => { {isOpen && ( )} diff --git a/src/components/SummaryPage/SummaryDetailBox/SummaryDetailBox.tsx b/src/components/SummaryPage/SummaryDetailBox/SummaryDetailBox.tsx index be84652..b5dfd07 100644 --- a/src/components/SummaryPage/SummaryDetailBox/SummaryDetailBox.tsx +++ b/src/components/SummaryPage/SummaryDetailBox/SummaryDetailBox.tsx @@ -6,10 +6,26 @@ import { DetailBox } from '@/styles/SummaryPage'; import { CategorySelectBox } from './CategorySelectBox'; import { NoteBox } from './NoteBox'; +import { useState } from 'react'; +import { ISelectedCategoryProps } from 'types/category'; const SummaryDetailBox = () => { const summaryVideo = useRecoilValue(summaryVideoState); + const [selectedCategory, setSelectedCategory] = + useState({ name: '', categoryId: 0 }); + + const handleSelectCategory = ({ + name, + categoryId, + }: ISelectedCategoryProps) => { + setSelectedCategory({ + name, + categoryId, + }); + console.log('name, categoryId를 이용한 API 요청'); + }; + return (
{ }} /> - + {summaryVideo?.description}