diff --git a/src/components/user/auth-form/ProfileImageContainer.tsx b/src/components/user/auth-form/ProfileImageContainer.tsx index b65e6e5d..b599ff73 100644 --- a/src/components/user/auth-form/ProfileImageContainer.tsx +++ b/src/components/user/auth-form/ProfileImageContainer.tsx @@ -4,7 +4,7 @@ import { useFormContext } from 'react-hook-form'; import { convertBytesToString } from '@utils/converter'; import { USER_SETTINGS } from '@constants/settings'; import useToast from '@hooks/useToast'; -import { useEffect, useRef } from 'react'; +import { useEffect } from 'react'; type ProfileImageContainerProps = { imageUrl: string; @@ -14,14 +14,12 @@ type ProfileImageContainerProps = { export default function ProfileImageContainer({ imageUrl, setImageUrl }: ProfileImageContainerProps) { const { setValue } = useFormContext(); const { toastWarn } = useToast(); - const imageRef = useRef(null); - // 컴포넌트 언마운트 시 이미지 URL 해제 useEffect(() => { return () => { - if (imageRef.current) URL.revokeObjectURL(imageRef.current); + if (imageUrl) URL.revokeObjectURL(imageUrl); }; - }, []); + }, [imageUrl]); const handleChangeImg = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; @@ -37,13 +35,11 @@ export default function ProfileImageContainer({ imageUrl, setImageUrl }: Profile const image = URL.createObjectURL(file); setImageUrl(image); setValue('profileUrl', image); - imageRef.current = image; }; const handleRemoveImg = () => { - if (imageRef.current) { - URL.revokeObjectURL(imageRef.current); - imageRef.current = null; + if (imageUrl) { + URL.revokeObjectURL(imageUrl); } setImageUrl(''); diff --git a/src/constants/settings.ts b/src/constants/settings.ts index e74320f1..75573579 100644 --- a/src/constants/settings.ts +++ b/src/constants/settings.ts @@ -1,9 +1,9 @@ -import { MB } from '@constants/units'; +import { DAY, MB, MINUTE, SECOND } from '@constants/units'; export const AUTH_SETTINGS = Object.freeze({ - // ACCESS_TOKEN_EXPIRATION: 3000, // 테스트용 3초 - ACCESS_TOKEN_EXPIRATION: 15 * 60 * 1000, // 15분 - REFRESH_TOKEN_EXPIRATION: 7 * 24 * 60 * 60 * 1000, // 7일 + // ACCESS_TOKEN_EXPIRATION: 5 * SECOND, // 테스트용 5초 + ACCESS_TOKEN_EXPIRATION: 15 * MINUTE, // 15분 + REFRESH_TOKEN_EXPIRATION: 7 * DAY, // 7일 }); export const USER_SETTINGS = Object.freeze({ diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts index a9884e73..1aae7d61 100644 --- a/src/mocks/handlers.ts +++ b/src/mocks/handlers.ts @@ -2,7 +2,7 @@ import userServiceHandler from '@mocks/services/userServiceHandler'; import teamServiceHandler from '@mocks/services/teamServiceHandler'; import projectServiceHandler from '@mocks/services/projectServiceHandler'; import taskServiceHandler from '@mocks/services/taskServiceHandler'; -import authServiceHandler from './services/authServiceHandler'; +import authServiceHandler from '@mocks/services/authServiceHandler'; const handlers = [ ...userServiceHandler, diff --git a/src/services/axiosProvider.ts b/src/services/axiosProvider.ts index 87f5e0f6..bcd7ea19 100644 --- a/src/services/axiosProvider.ts +++ b/src/services/axiosProvider.ts @@ -2,9 +2,9 @@ import axios from 'axios'; import { SECOND } from '@constants/units'; import { JWT_TOKEN_DUMMY } from '@mocks/mockData'; import type { AxiosInstance, AxiosRequestConfig } from 'axios'; +import useToast from '@hooks/useToast'; +import { getAccessToken } from '@services/authService'; import { useAuthStore } from '@/stores/useAuthStore'; -import useToast from '@/hooks/useToast'; -import { getAccessToken } from './authService'; const BASE_URL = import.meta.env.VITE_BASE_URL; const defaultConfigOptions: AxiosRequestConfig = {