diff --git a/src/apis/dto/auth/accept-terms.ts b/src/apis/dto/auth/accept-terms.ts index f306cfe6..8c9448fb 100644 --- a/src/apis/dto/auth/accept-terms.ts +++ b/src/apis/dto/auth/accept-terms.ts @@ -2,7 +2,6 @@ export interface AcceptTermsRequest { userId: number; privacyAcceptedStatus: number; termsOfUseAcceptedStatus: number; - marketingAcceptedStatus: number; } export interface AcceptTermsResponse { diff --git a/src/apis/hooks/users/useEditProfile.tsx b/src/apis/hooks/users/useEditProfile.tsx index c03fa3c7..f7306e32 100644 --- a/src/apis/hooks/users/useEditProfile.tsx +++ b/src/apis/hooks/users/useEditProfile.tsx @@ -16,7 +16,7 @@ export default function useEditProfile() { }, onSuccess: () => { queryClient.refetchQueries({ - queryKey: ['user'], + queryKey: ['userType'], }); queryClient.refetchQueries({ queryKey: ['posts'], diff --git a/src/apis/hooks/users/useUser.tsx b/src/apis/hooks/users/useUser.tsx index 84e7b4b9..eb9d8a79 100644 --- a/src/apis/hooks/users/useUser.tsx +++ b/src/apis/hooks/users/useUser.tsx @@ -1,38 +1,46 @@ -import { useQuery } from '@tanstack/react-query'; +import { useQuery, useQueryClient } from '@tanstack/react-query'; import { GetUserResponse } from '@/apis/dto/users/get-user'; import { GetUserTypeResponse } from '@/apis/dto/users/get-user-type'; import { axiosInstance } from '@/libs/axios'; import { User } from '@/types/user'; +import { useEffect } from 'react'; export default function useUser( { enabled }: { enabled: boolean } = { enabled: true }, ) { - const { data, error: userTypeError } = useQuery({ - queryKey: ['user'], + const queryClient = useQueryClient(); + + const { + data, + error: userTypeError, + isSuccess, + } = useQuery({ + queryKey: ['userType'], queryFn: async () => { const res = await axiosInstance.get('/user/type'); return res.data; }, retry: false, enabled, - refetchInterval: 60 * 1000, }); + const userId = data?.userId; + const { data: userData, isLoading, error, } = useQuery({ - queryKey: ['user', data?.userId], + queryKey: ['user', userId], queryFn: async () => { const res = await axiosInstance.get( - `/user/${data?.userId}`, + `/user/${userId || 'fuck'}`, ); return res.data; }, retry: 5, - enabled: !!data, + enabled: !!userId, }); if (userTypeError) { @@ -70,6 +78,14 @@ export default function useUser( } : null; + useEffect(() => { + if (isSuccess) { + queryClient.refetchQueries({ + queryKey: ['user', data.userId], + }); + } + }, [isSuccess]); + return { user, isLoading, diff --git a/src/components/ImageFullScreen.tsx b/src/components/ImageFullScreen.tsx index 0d516df5..7fc9f570 100644 --- a/src/components/ImageFullScreen.tsx +++ b/src/components/ImageFullScreen.tsx @@ -31,7 +31,7 @@ export default function ImageFullScreen({ }, []); return ( -
+
투표 항목
- {formData.voteOptions.map((_, i) => ( - - ))} + {formData.voteOptions + .filter((option) => option.label !== null) + .map((_, i) => ( + + ))} - {String(age)[0] + '0'} + {String(age).slice(0, -1) + '0'} )} {nickname} diff --git a/src/components/post/form/PostTitleInput/PostTitleInput.tsx b/src/components/post/form/PostTitleInput/PostTitleInput.tsx index 7ec57172..1b464e82 100644 --- a/src/components/post/form/PostTitleInput/PostTitleInput.tsx +++ b/src/components/post/form/PostTitleInput/PostTitleInput.tsx @@ -82,7 +82,7 @@ export default function PostTitleInput({ />
{showReset && ( -
{showReset && ( -
diff --git a/src/states/registerData.ts b/src/states/registerData.ts index 7283045a..9f4d68bd 100644 --- a/src/states/registerData.ts +++ b/src/states/registerData.ts @@ -12,8 +12,6 @@ interface RegisterData { accept: { gochamTerm: boolean; personalInformation: boolean; - olderThan14: boolean; - marketing: boolean; allCheck: boolean; }; } @@ -28,8 +26,6 @@ export const registerDataAtom = atom({ accept: { gochamTerm: false, personalInformation: false, - olderThan14: false, - marketing: false, allCheck: false, }, }); diff --git a/src/utils/validations/postForm.ts b/src/utils/validations/postForm.ts index 9c4ab581..cf6c78e1 100644 --- a/src/utils/validations/postForm.ts +++ b/src/utils/validations/postForm.ts @@ -22,8 +22,9 @@ export function validatePostForm( if (typeof deadline !== 'number') { errorMessage.deadline = '투표 마감 시간을 선택해주세요.'; } - for (let i = 0; i < voteOptions.length; i++) { - const option = voteOptions[i]; + const options = voteOptions.filter((option) => option.label); + for (let i = 0; i < options.length; i++) { + const option = options[i]; if (!option.label.trim() || (option.image && !option.label.trim())) { errorMessage.voteOptions = '투표 항목은 텍스트를 포함해야 합니다.'; voteOptionErrorIndex = i; @@ -31,15 +32,15 @@ export function validatePostForm( } } let count = 0; - for (const option of voteOptions) { + for (const option of options) { if (option.label.trim()) { count += 1; } } if (count < 2) { errorMessage.voteOptions = '투표 항목을 2개 이상 입력해주세요.'; - for (let i = 0; i < voteOptions.length; i++) { - const option = voteOptions[i]; + for (let i = 0; i < options.length; i++) { + const option = options[i]; if (!option.label) { voteOptionErrorIndex = i; break; @@ -48,8 +49,8 @@ export function validatePostForm( } const labels: string[] = []; - for (let i = 0; i < voteOptions.length; i++) { - const option = voteOptions[i]; + for (let i = 0; i < options.length; i++) { + const option = options[i]; if (labels.includes(option.label)) { errorMessage.voteOptions = '동일한 투표 항목을 중복으로 작성하실 수 없습니다.';