diff --git a/src/page/archiving/index/ArchivingPage.tsx b/src/page/archiving/index/ArchivingPage.tsx index d7c7d4726..dc545fa2e 100644 --- a/src/page/archiving/index/ArchivingPage.tsx +++ b/src/page/archiving/index/ArchivingPage.tsx @@ -12,9 +12,9 @@ import { useInteractTimeline } from '@/page/archiving/index/hook/common/useInter import { Block } from '@/page/archiving/index/type/blockType'; import ContentBox from '@/shared/component/ContentBox/ContentBox'; -import TeamProvider, { useTeamContext } from '@/shared/hook/common/useTeamContext'; import { useDrawerAction } from '@/shared/store/drawer'; import { useOpenModal } from '@/shared/store/modal'; +import { useTeamId } from '@/shared/store/team'; const ArchivingPage = () => { const { selectedBlock, handleBlockClick } = useInteractTimeline(); @@ -43,30 +43,28 @@ const ArchivingPage = () => { openModal('create-block'); }; return ( - - - - - 타임블록 추가 - - }> -
- - - - {/** fallback UI 디자인 나올 시에 TimeLine 크기만큼 채워서 Layout 안움직이도록 */} - - - -
-
-
-
-
+ + + + 타임블록 추가 + + }> +
+ + + + {/** fallback UI 디자인 나올 시에 TimeLine 크기만큼 채워서 Layout 안움직이도록 */} + + + +
+
+
+
); }; diff --git a/src/page/archiving/index/component/TimeBlockModal/component/Upload/UploadModal.tsx b/src/page/archiving/index/component/TimeBlockModal/component/Upload/UploadModal.tsx index f32c9ee06..f82bcec73 100644 --- a/src/page/archiving/index/component/TimeBlockModal/component/Upload/UploadModal.tsx +++ b/src/page/archiving/index/component/TimeBlockModal/component/Upload/UploadModal.tsx @@ -17,8 +17,8 @@ import { formatDatePost } from '@/page/archiving/index/component/TimeBlockModal/ import { Files } from '@/shared/api/time-blocks/team/time-block/type'; import WorkSapceInfo from '@/shared/component/WorkSpaceModal/info/WorkSpaceInfo'; import { useBlockContext } from '@/shared/hook/common/useBlockContext'; -import { useTeamContext } from '@/shared/hook/common/useTeamContext'; import { useCloseModal } from '@/shared/store/modal'; +import { useTeamId } from '@/shared/store/team'; import { useToastAction } from '@/shared/store/toast'; interface UploadModalProps { @@ -26,7 +26,7 @@ interface UploadModalProps { } const UploadModal = ({ isVisible }: UploadModalProps) => { - const teamId = useTeamContext(); + const teamId = useTeamId(); const { formData, reset } = useBlockContext(); const closeModal = useCloseModal(); diff --git a/src/page/archiving/index/component/TimeLine/index.tsx b/src/page/archiving/index/component/TimeLine/index.tsx index 8a6a99ce1..193167a24 100644 --- a/src/page/archiving/index/component/TimeLine/index.tsx +++ b/src/page/archiving/index/component/TimeLine/index.tsx @@ -13,8 +13,8 @@ import { useGetTimeBlockQuery } from '@/page/archiving/index/hook/api/useGetTime import { Block } from '@/page/archiving/index/type/blockType'; import { alignBlocks, createTimeBlock } from '@/page/archiving/index/util/block'; -import { useTeamContext } from '@/shared/hook/common/useTeamContext'; import { useDrawerIsOpen } from '@/shared/store/drawer'; +import { useTeamId } from '@/shared/store/team'; interface TimeLineProps { selectedBlock?: Block; @@ -22,10 +22,10 @@ interface TimeLineProps { } const TimeLine = ({ selectedBlock, onBlockClick }: TimeLineProps) => { - const teamId = useTeamContext(); + const teamId = useTeamId(); const { currentYear, currentMonth, endDay } = useDateContext(); - const { data } = useGetTimeBlockQuery(teamId, 'executive', currentYear, currentMonth); + const { data } = useGetTimeBlockQuery(+teamId, 'executive', currentYear, currentMonth); const timeBlocks: Block[] = data.timeBlocks; const blockFloors = alignBlocks(timeBlocks, endDay, currentMonth, currentYear); diff --git a/src/page/dashboard/component/Timeline/TimelineSection.tsx b/src/page/dashboard/component/Timeline/TimelineSection.tsx index b7b39c832..c7d11bcf7 100644 --- a/src/page/dashboard/component/Timeline/TimelineSection.tsx +++ b/src/page/dashboard/component/Timeline/TimelineSection.tsx @@ -12,12 +12,12 @@ import { alignBlocks, createTimeBlock } from '@/page/archiving/index/util/block' import { timelineContentStyle } from '@/page/dashboard/component/Timeline/TimelineSection.style'; import { PATH } from '@/shared/constant/path'; -import { useTeamContext } from '@/shared/hook/common/useTeamContext'; +import { useTeamId } from '@/shared/store/team'; const TimelineSection = () => { const navigate = useNavigate(); - const teamId = useTeamContext(); + const teamId = useTeamId(); const { currentYear, currentMonth, endDay } = useDate(+teamId); const { data } = useGetTimeBlockQuery(+teamId, 'executive', currentYear, currentMonth); diff --git a/src/shared/hook/common/useTeamContext.tsx b/src/shared/hook/common/useTeamContext.tsx deleted file mode 100644 index 941435e71..000000000 --- a/src/shared/hook/common/useTeamContext.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { ReactNode, createContext, useContext } from 'react'; - -import { useClubInfoQuery } from '@/shared/hook/api/useClubInfoQuery'; - -interface TeamProviderProp { - children?: ReactNode; -} - -const TeamContext = createContext(Number(localStorage.getItem('teamId'))); - -export const useTeamContext = () => { - const context = useContext(TeamContext); - - if (context === undefined) { - throw new Error('useTeamContext must be used within a TeamProvider'); - } - - return context; -}; - -const TeamProvider = ({ children }: TeamProviderProp) => { - const { data } = useClubInfoQuery(); - const teamId = Number(localStorage.getItem('teamId')) || data?.belongTeamGetResponses?.[0]?.id; - - if (!teamId) { - console.error('teamId undefined'); - return; - } - - return {children}; -}; - -export default TeamProvider;