Skip to content

Commit

Permalink
피드 작성 spec 변경, 이미지 업로드 필수로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
YOOJS1205 committed Mar 31, 2024
1 parent 56ddcfb commit 898b22e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
8 changes: 5 additions & 3 deletions src/app/review/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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'],
Expand Down Expand Up @@ -137,7 +137,9 @@ export default function Page() {
/>
</div>
<FixedBottomCTAButton
disabled={!rating || !description || description.length < 10}
disabled={
!rating || !description || description.length < 10 || !imageUrl
}
onClick={handleClickSubmitButton}
>
작성완료
Expand Down
2 changes: 1 addition & 1 deletion src/components/review/ImageUploader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function ImageUploader({
</div>
) : (
<>
<p className="body-16-bold">사진을 추가해주세요(선택)</p>
<p className="body-16-bold">사진을 추가해주세요</p>
<p className="body-14-regular">*기록당 최대 1개 업로드가 가능해요.</p>
<PlusIcon />
<input
Expand Down
24 changes: 15 additions & 9 deletions src/hooks/api/usePostLog.ts → src/hooks/api/usePostFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface NewStore {
}

// TODO: api spec 확정되면 변경
interface Log {
interface Feed {
storeId: string | null;
newStore: NewStore | null;
rating: number;
Expand All @@ -29,25 +29,31 @@ interface Log {
description: string;
}

interface LogWriteResponse {
interface FeedWriteResponse {
reviewId: number;
storeId: number;
}

const postLog = ({ ...props }: Log): Promise<ApiResponse<LogWriteResponse>> => {
const postFeed = ({
...props
}: Feed): Promise<ApiResponse<FeedWriteResponse>> => {
const body = {
...props,
};
return axiosRequest('post', `/api/v1/stores/reviews`, body);
return axiosRequest('post', `/api/v1/feeds`, body);
};

export const usePostLog = (
options?: UseMutationOptions<ApiResponse<LogWriteResponse>, AxiosError, Log>,
): UseMutationResult<ApiResponse<LogWriteResponse>, AxiosError, Log> => {
export const usePostFeed = (
options?: UseMutationOptions<
ApiResponse<FeedWriteResponse>,
AxiosError,
Feed
>,
): UseMutationResult<ApiResponse<FeedWriteResponse>, 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'] });
},
Expand Down

0 comments on commit 898b22e

Please sign in to comment.