From 898b22e0ff695fca93fb8119797c7bdf1169790a Mon Sep 17 00:00:00 2001 From: YOOJS1205 Date: Sun, 31 Mar 2024 23:15:48 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=BC=EB=93=9C=20=EC=9E=91=EC=84=B1=20spec?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD,=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=ED=95=84=EC=88=98=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/review/page.tsx | 8 ++++--- src/components/review/ImageUploader/index.tsx | 2 +- .../api/{usePostLog.ts => usePostFeed.ts} | 24 ++++++++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) rename src/hooks/api/{usePostLog.ts => usePostFeed.ts} (64%) diff --git a/src/app/review/page.tsx b/src/app/review/page.tsx index edbfd4b9..428d6874 100644 --- a/src/app/review/page.tsx +++ b/src/app/review/page.tsx @@ -4,7 +4,7 @@ import { useState, useCallback, ChangeEvent, useEffect } from 'react'; import { useSearchParams, useRouter } from 'next/navigation'; import { useQueryClient } from '@tanstack/react-query'; -import { NewStore, usePostLog } from '@hooks/api/usePostLog'; +import { NewStore, usePostFeed } from '@hooks/api/usePostFeed'; import { useGetPresignedUrl } from '@hooks/api/useGetPresignedUrl'; import ImageUploader from '@components/review/ImageUploader'; import StarRating from '@components/review/StarRating'; @@ -20,7 +20,7 @@ export default function Page() { const searchParams = useSearchParams(); const storeName = searchParams.get('storeName'); const myRevisitedCount = searchParams.get('myRevisitedCount') ?? 0; - const { mutate: postLog } = usePostLog({ + const { mutate: postLog } = usePostFeed({ onSuccess: () => { queryClient.refetchQueries({ queryKey: ['get-myLog'], @@ -137,7 +137,9 @@ export default function Page() { /> 작성완료 diff --git a/src/components/review/ImageUploader/index.tsx b/src/components/review/ImageUploader/index.tsx index f5d1709f..a17ba798 100644 --- a/src/components/review/ImageUploader/index.tsx +++ b/src/components/review/ImageUploader/index.tsx @@ -43,7 +43,7 @@ export default function ImageUploader({ ) : ( <> -

사진을 추가해주세요(선택)

+

사진을 추가해주세요

*기록당 최대 1개 업로드가 가능해요.

> => { +const postFeed = ({ + ...props +}: Feed): Promise> => { const body = { ...props, }; - return axiosRequest('post', `/api/v1/stores/reviews`, body); + return axiosRequest('post', `/api/v1/feeds`, body); }; -export const usePostLog = ( - options?: UseMutationOptions, AxiosError, Log>, -): UseMutationResult, AxiosError, Log> => { +export const usePostFeed = ( + options?: UseMutationOptions< + ApiResponse, + AxiosError, + Feed + >, +): UseMutationResult, AxiosError, Feed> => { const queryClient = useQueryClient(); return useMutation({ - mutationKey: ['post-log'], - mutationFn: ({ ...props }) => postLog({ ...props }), + mutationKey: ['post-feed'], + mutationFn: ({ ...props }) => postFeed({ ...props }), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['get-review'] }); },