From b3e1c5465e4775f04e760b57bcc800899c68426d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=B5=E1=84=8C=E1=85=A2=E1=84=92=E1=85=A1?= Date: Fri, 20 Oct 2023 05:15:21 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A0=84=EC=B2=B4=20=EB=8F=84=EC=9E=A5?= =?UTF-8?q?=20=EA=B0=AF=EC=88=98=EB=A5=BC=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=83=88=20api=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/app/stamp/components/DrinkStampContainer.tsx | 6 ++---- .../app/stamp/components/MyEnjoiedDrinkInfoSection.tsx | 6 +++--- .../src/app/stamp/service/useDrinkStampListService.ts | 9 +++++---- .../src/app/vote/[id]/update/hook/useUpdataVoteForm.ts | 10 ++++++---- apps/jurumarble/src/lib/apis/drink.ts | 7 ++++++- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/apps/jurumarble/src/app/stamp/components/DrinkStampContainer.tsx b/apps/jurumarble/src/app/stamp/components/DrinkStampContainer.tsx index 2c8f47d3..6d81cc39 100644 --- a/apps/jurumarble/src/app/stamp/components/DrinkStampContainer.tsx +++ b/apps/jurumarble/src/app/stamp/components/DrinkStampContainer.tsx @@ -15,7 +15,7 @@ function DrinkStampContainer() { setRegionOption(value); }; - const { drinkList, subscribe, numberOfStampedDrinks } = useDrinkStampService({ + const { drinkList, subscribe, enjoyedDrinkCount } = useDrinkStampService({ page: 0, size: 10, region: regionOption, @@ -23,9 +23,7 @@ function DrinkStampContainer() { return ( <> - +

우리술 도장을
- {numberOfStampedDrinks}개 모았어요. + {enjoyedDrinkCount}개 모았어요.

diff --git a/apps/jurumarble/src/app/stamp/service/useDrinkStampListService.ts b/apps/jurumarble/src/app/stamp/service/useDrinkStampListService.ts index 11018a63..972c107f 100644 --- a/apps/jurumarble/src/app/stamp/service/useDrinkStampListService.ts +++ b/apps/jurumarble/src/app/stamp/service/useDrinkStampListService.ts @@ -22,7 +22,8 @@ export default function useDrinkStampListService(params: DrinkStampListProps) { page: pageParam?.page || params.page, }), { - getNextPageParam: ({ last, number }) => { + getNextPageParam: ({ drinkData }) => { + const { last, number } = drinkData; if (last) { return undefined; } @@ -34,11 +35,11 @@ export default function useDrinkStampListService(params: DrinkStampListProps) { }, ); - const numberOfStampedDrinks = data?.pages[0].numberOfElements ?? 0; + const enjoyedDrinkCount = data?.pages[0].enjoyedDrinkCount ?? 0; - const drinkList = data?.pages.flatMap((page) => page.content) ?? []; + const drinkList = data?.pages.flatMap((page) => page.drinkData.content) ?? []; const [subscribe] = useInfiniteScroll(fetchNextPage); - return { drinkList, fetchNextPage, subscribe, numberOfStampedDrinks }; + return { drinkList, fetchNextPage, subscribe, enjoyedDrinkCount }; } diff --git a/apps/jurumarble/src/app/vote/[id]/update/hook/useUpdataVoteForm.ts b/apps/jurumarble/src/app/vote/[id]/update/hook/useUpdataVoteForm.ts index 9b83caab..ea01c055 100644 --- a/apps/jurumarble/src/app/vote/[id]/update/hook/useUpdataVoteForm.ts +++ b/apps/jurumarble/src/app/vote/[id]/update/hook/useUpdataVoteForm.ts @@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import Path from 'lib/Path'; import { modifyDrinkVoteAPI, modifyNormalVoteAPI } from 'lib/apis/vote'; -import { queryKeys } from 'lib/queryKeys'; +import { queryKeys, reactQueryKeys } from 'lib/queryKeys'; import { useParams, useRouter } from 'next/navigation'; import { DrinkInfoType } from 'src/types/drink'; import { PostVoteType } from 'src/types/vote'; @@ -27,7 +27,8 @@ export default function useUpdateVoteForm() { const queryClient = useQueryClient(); const params = useParams(); - const { data } = useVoteLoadService(Number(params.id)); + const voteId = Number(params.id); + const { data } = useVoteLoadService(voteId); const [postVoteInfo, setPostVoteInfo] = useState({ detail: '', @@ -89,6 +90,7 @@ export default function useUpdateVoteForm() { onSuccess: () => { queryClient.invalidateQueries([queryKeys.VOTE_LIST]); queryClient.invalidateQueries(getMyCreatedVoteQueryKey); + queryClient.invalidateQueries(reactQueryKeys.voteDetail(voteId)); router.push(Path.VOTE_HOME); }, }, @@ -111,14 +113,14 @@ export default function useUpdateVoteForm() { title, titleA, titleB, - voteId: Number(params.id), + voteId: voteId, }) : mutateDrinkVote({ title, detail, drinkAId, drinkBId, - voteId: Number(params.id), + voteId: voteId, }); }; diff --git a/apps/jurumarble/src/lib/apis/drink.ts b/apps/jurumarble/src/lib/apis/drink.ts index 328c6af1..45b751e8 100644 --- a/apps/jurumarble/src/lib/apis/drink.ts +++ b/apps/jurumarble/src/lib/apis/drink.ts @@ -42,7 +42,12 @@ interface GetEnjoyedDrinkListRequest { region?: string; } -export interface GetEnjoyedDrinkListResponse extends DrinkListResponse {} +interface DrinkData extends DrinkListResponse {} + +interface GetEnjoyedDrinkListResponse { + drinkData: DrinkData; + enjoyedDrinkCount: number; +} export const getEnjoyedDrinkList = async ( params: GetEnjoyedDrinkListRequest,