diff --git a/src/apis/user.ts b/src/apis/user.ts index f25cb2e..5e7a853 100644 --- a/src/apis/user.ts +++ b/src/apis/user.ts @@ -1,6 +1,6 @@ import { API_URL, getToken, IApiResponse } from '.'; -interface IGetUserInfoResponse extends IApiResponse {} +export interface IGetUserInfoResponse extends IApiResponse {} interface IUpdateUserInfoResponse extends IApiResponse {} interface ISupplementaryUpdateInfoResponse extends IApiResponse {} @@ -21,6 +21,10 @@ export interface IUserInfo { userUsePurpose: any; // 임시 타입 } +export interface IUserName { + userName: string; +} + export interface IUserUpdateInfo { userName: string; userPassword?: string; diff --git a/src/components/molecules/RecordTagDropDown/RecordTagDropDown.tsx b/src/components/molecules/RecordTagDropDown/RecordTagDropDown.tsx index 1d6a078..a86fa92 100644 --- a/src/components/molecules/RecordTagDropDown/RecordTagDropDown.tsx +++ b/src/components/molecules/RecordTagDropDown/RecordTagDropDown.tsx @@ -4,16 +4,16 @@ import useRecordModalStore, { ITagItem, } from '../../../store/useRecordModalStore'; import { getSchedule } from '../../../apis/schedule'; -import { useUserInfoStore } from '../../../store/useUserInfoStore'; +import { useNameStore } from '../../../store/useUserNameStore'; import { useUnauthorizedRedirect } from '../../../hooks/useUnauthorizedRedirect'; import useServerErrorToast from '../../../hooks/useServerErrorToast'; import styles from './RecordTagDropDown.module.scss'; const RecordTagDropDown = () => { - const { userInfo } = useUserInfoStore(); + const { userName } = useNameStore(); const { data, isError } = useQuery({ - queryKey: ['schedule', userInfo?.userName], - queryFn: () => getSchedule(userInfo?.userName), + queryKey: ['schedule', userName?.userName], + queryFn: () => getSchedule(userName?.userName), }); useUnauthorizedRedirect(data); diff --git a/src/components/molecules/ScriptToolTip/ScriptToolTip.tsx b/src/components/molecules/ScriptToolTip/ScriptToolTip.tsx index 5cdc4a0..5d2b87e 100644 --- a/src/components/molecules/ScriptToolTip/ScriptToolTip.tsx +++ b/src/components/molecules/ScriptToolTip/ScriptToolTip.tsx @@ -8,7 +8,7 @@ import { import { useAlertStore } from '../../../store/useAlertStore'; import ScriptIcon from '../../../assets/images/nav/my-script-inactive.svg?react'; import TrashCan from '../../../assets/images/orange-trash-can.svg?react'; -import { useUserInfoStore } from '../../../store/useUserInfoStore'; +import { useNameStore } from '../../../store/useUserNameStore'; import { useUnauthorizedRedirect } from '../../../hooks/useUnauthorizedRedirect'; import useServerErrorToast from '../../../hooks/useServerErrorToast'; import styles from './ScriptToolTip.module.scss'; @@ -23,7 +23,7 @@ const ScriptToolTip = ({ id, scheduleName }: IProps) => { const queryClient = useQueryClient(); const addAlert = useAlertStore((state) => state.addAlert); const showConfirm = useAlertStore((state) => state.showConfirm); - const { userInfo } = useUserInfoStore(); + const { userName } = useNameStore(); const { data, isError } = useQuery({ queryKey: ['tooltip', id], @@ -34,10 +34,10 @@ const ScriptToolTip = ({ id, scheduleName }: IProps) => { useServerErrorToast(isError); const deleteMutation = useMutation({ - mutationFn: (id: number) => deleteScheduleElement(id, userInfo.userName), + mutationFn: (id: number) => deleteScheduleElement(id, userName.userName), onSuccess: () => { queryClient.invalidateQueries({ - queryKey: ['schedule', userInfo.userName], + queryKey: ['schedule', userName.userName], }); addAlert(`'${scheduleName}' 수업이 삭제되었습니다.`, 'success'); }, diff --git a/src/components/organisms/AddScheduleForm/AddScheduleForm.tsx b/src/components/organisms/AddScheduleForm/AddScheduleForm.tsx index 0d57f85..55542ae 100644 --- a/src/components/organisms/AddScheduleForm/AddScheduleForm.tsx +++ b/src/components/organisms/AddScheduleForm/AddScheduleForm.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useRef } from 'react'; import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { useUserInfoStore } from '../../../store/useUserInfoStore'; +import { useNameStore } from '../../../store/useUserNameStore'; import { useAlertStore } from '../../../store/useAlertStore'; import Warning from '../../../assets/images/warning.svg?react'; import { @@ -40,7 +40,7 @@ const AddScheduleForm = ({ onClose }: IProps) => { const endMinuteRef = useRef(null); const addAlert = useAlertStore((state) => state.addAlert); - const { userInfo } = useUserInfoStore(); + const { userName } = useNameStore(); useEffect(() => { const isFormValid = getIsAddScheduleFormValid(lectureInfo); @@ -102,13 +102,13 @@ const AddScheduleForm = ({ onClose }: IProps) => { const postMutation = useMutation({ mutationFn: (data: IScheduleElementDTO) => - addScheduleElement(data, userInfo.userName), + addScheduleElement(data, userName.userName), onSuccess: (res) => { if (res.success) { addAlert('강의 추가에 성공했습니다.', 'success'); onClose(); queryClient.invalidateQueries({ - queryKey: ['schedule', userInfo.userName], + queryKey: ['schedule', userName.userName], }); } else { if (res.msg === 'Duplicate ScheduleElement Name') { @@ -125,7 +125,7 @@ const AddScheduleForm = ({ onClose }: IProps) => { if (isFormValid) { const existingSchedule = queryClient.getQueryData([ 'schedule', - userInfo.userName, + userName.userName, ]); const formattedData = transformToScheduleElementDTO(lectureInfo); if (existingSchedule?.object?.scheduleElements) { diff --git a/src/components/organisms/navigators/MainNav/MainNav.tsx b/src/components/organisms/navigators/MainNav/MainNav.tsx index ffadd14..6417454 100644 --- a/src/components/organisms/navigators/MainNav/MainNav.tsx +++ b/src/components/organisms/navigators/MainNav/MainNav.tsx @@ -7,18 +7,18 @@ import TestMakeActive from '../../../../assets/images/nav/test-make-active.svg?r import TestMakeInactive from '../../../../assets/images/nav/test-make-inactive.svg?react'; import MyPageActive from '../../../../assets/images/nav/my-page-active.svg?react'; import MyPageInactive from '../../../../assets/images/nav/my-page-inactive.svg?react'; -import { useUserInfoStore } from '../../../../store/useUserInfoStore'; +import { useNameStore } from '../../../../store/useUserNameStore'; import styles from './MainNav.module.scss'; const MainNav = () => { - const { userInfo } = useUserInfoStore(); - const firstLetter = userInfo?.userName.charAt(0); + const { userName } = useNameStore(); + const firstLetter = userName?.userName.charAt(0); return (