Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 리뷰 등록 step 1,2,3 페이지 구현 #162

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/apis/review/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface ICreateReviewPayload {
flavorIds: number[];
}

export const postReview = async (payload: ICreateReviewPayload) => {
export const createReview = async (payload: ICreateReviewPayload) => {
const res = await request<ICreateReviewResponseData>({
method: 'post',
url: '/api/v1/reviews',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/reviews/create/[beerId].page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NextPage, GetServerSideProps } from 'next';
import { RecoilRoot } from 'recoil';

import { getBeer } from '@/apis/beers/getBeer';
import { getReview, postReview } from '@/apis/review';
import { getReview, createReview } from '@/apis/review';
import Header, { HEADER_HEIGHT } from '@/components/Header';
import { BackButton } from '@/components/Header/extras';
import SwiperLayout from '@/components/layouts/SwiperLayout';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useMutation } from 'react-query';
import { useRecoilValue } from 'recoil';

import { useGetFlavors } from '@/apis/flavors';
import { ICreateReviewPayload, postReview } from '@/apis/review';
import { ICreateReviewPayload, createReview } from '@/apis/review';
import { uploadImage } from '@/apis/upload/uploadImage';
import BottomFloatingButtonArea from '@/components/BottomFloatingButtonArea';
import { BOTTOM_FLOATING_BUTTON_AREA_HEIGHT } from '@/components/BottomFloatingButtonArea/BottomFloatingButtonArea';
Expand Down Expand Up @@ -40,7 +40,7 @@ const ReviewDetailContainer: React.FC<RecordThirdStepContainerProps> = ({
const reviewForm = useRecoilValue($reviewForm);
const { data: flavors } = useGetFlavors();
const { mutateAsync: uploadImageMutation } = useMutation(uploadImage);
const { mutateAsync: createReviewMutation } = useMutation(postReview);
const { mutateAsync: createReviewMutation } = useMutation(createReview);
Copy link
Contributor

@hoo00nn hoo00nn Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hy57in

mutation도 한 번 래핑해서 사용하는건 어떠신가요?

export const useCreateReviewMutation = () => {
  const cache = useQueryClient();

  const { mutateAsync: createReviewMutation, ...rest } = useMutation(createReview, {
    onSuccess: async () => {
      await cache.invalidateQueries(queryKeyFactory.GET_REVIEW);
    },
  });

  return {
    createReview: createReviewMutation,
    ...rest,
  };
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hy57in

useGetReviewsByBeer 도 queryKey를 queryKeyFactory에서 가져오는 방식으로 변경하는거 어떨까요!?

ref

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bf34ee2

만들어두신 queryKeyFactory 를 잊고 있었네요. 해당부분 수정했습니다!

mutaion도 래핑해서 수정했습니다!

// const { mutateAsync: updateRecordMutation } = useMutation(updateRecord, {
// onSuccess: () => {
// router.back();
Expand Down