From b888bc0dc084156dc81b1e8be7012937d8405c6f Mon Sep 17 00:00:00 2001 From: mgYang53 Date: Sun, 22 Feb 2026 23:20:17 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EC=95=BD=EC=86=8D=20=ED=9A=8C?= =?UTF-8?q?=EA=B3=A0=20API=20=EB=A0=88=EC=9D=B4=EC=96=B4=20=EA=B5=AC?= =?UTF-8?q?=EC=B6=95=20(#94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit STT Job 생성, 요약 조회/수정/발행 API 함수 및 React Query 훅 구현. AbortController 기반 STT 요청 취소 지원, setQueryData 캐시 전략 적용. --- src/features/retrospectives/hooks/index.ts | 5 + .../hooks/retrospectiveQueryKeys.ts | 6 ++ .../retrospectives/hooks/useCreateSttJob.ts | 46 ++++++++++ .../retrospectives/hooks/usePublishSummary.ts | 26 ++++++ .../retrospectives/hooks/useSummary.ts | 17 ++++ .../retrospectives/hooks/useUpdateSummary.ts | 26 ++++++ src/features/retrospectives/index.ts | 21 +++++ .../retrospectives/retrospectives.api.ts | 91 +++++++++++++++++++ .../retrospectives.endpoints.ts | 15 +++ .../retrospectives/retrospectives.types.ts | 87 ++++++++++++++++++ 10 files changed, 340 insertions(+) create mode 100644 src/features/retrospectives/hooks/index.ts create mode 100644 src/features/retrospectives/hooks/retrospectiveQueryKeys.ts create mode 100644 src/features/retrospectives/hooks/useCreateSttJob.ts create mode 100644 src/features/retrospectives/hooks/usePublishSummary.ts create mode 100644 src/features/retrospectives/hooks/useSummary.ts create mode 100644 src/features/retrospectives/hooks/useUpdateSummary.ts create mode 100644 src/features/retrospectives/retrospectives.api.ts create mode 100644 src/features/retrospectives/retrospectives.endpoints.ts create mode 100644 src/features/retrospectives/retrospectives.types.ts diff --git a/src/features/retrospectives/hooks/index.ts b/src/features/retrospectives/hooks/index.ts new file mode 100644 index 0000000..ceb6492 --- /dev/null +++ b/src/features/retrospectives/hooks/index.ts @@ -0,0 +1,5 @@ +export * from './retrospectiveQueryKeys' +export * from './useCreateSttJob' +export * from './usePublishSummary' +export * from './useSummary' +export * from './useUpdateSummary' diff --git a/src/features/retrospectives/hooks/retrospectiveQueryKeys.ts b/src/features/retrospectives/hooks/retrospectiveQueryKeys.ts new file mode 100644 index 0000000..de28939 --- /dev/null +++ b/src/features/retrospectives/hooks/retrospectiveQueryKeys.ts @@ -0,0 +1,6 @@ +export const retrospectiveQueryKeys = { + all: ['retrospectives'] as const, + + summaries: () => [...retrospectiveQueryKeys.all, 'summary'] as const, + summary: (meetingId: number) => [...retrospectiveQueryKeys.summaries(), meetingId] as const, +} diff --git a/src/features/retrospectives/hooks/useCreateSttJob.ts b/src/features/retrospectives/hooks/useCreateSttJob.ts new file mode 100644 index 0000000..c020729 --- /dev/null +++ b/src/features/retrospectives/hooks/useCreateSttJob.ts @@ -0,0 +1,46 @@ +import { useMutation } from '@tanstack/react-query' +import { useCallback, useRef } from 'react' + +import type { ApiError } from '@/api' +import type { ApiResponse } from '@/api/types' + +import { createSttJob } from '../retrospectives.api' +import type { CreateSttJobParams, SttJobResponse } from '../retrospectives.types' + +/** + * STT Job 생성 (AI 요약 트리거) mutation 훅 + * + * - 동기 API이므로 mutation pending 동안 로딩 오버레이 표시 + * - cancel() 호출 시 진행 중인 HTTP 요청 중단 + */ +export const useCreateSttJob = () => { + const abortControllerRef = useRef(null) + + const mutation = useMutation< + ApiResponse, + ApiError, + CreateSttJobParams + >({ + mutationFn: (params: CreateSttJobParams) => { + abortControllerRef.current?.abort() + + const controller = new AbortController() + abortControllerRef.current = controller + + return createSttJob(params, controller.signal) + }, + onSettled: () => { + abortControllerRef.current = null + }, + }) + + const { reset } = mutation + + const cancel = useCallback(() => { + abortControllerRef.current?.abort() + abortControllerRef.current = null + reset() + }, [reset]) + + return { ...mutation, cancel } +} diff --git a/src/features/retrospectives/hooks/usePublishSummary.ts b/src/features/retrospectives/hooks/usePublishSummary.ts new file mode 100644 index 0000000..1d57b6f --- /dev/null +++ b/src/features/retrospectives/hooks/usePublishSummary.ts @@ -0,0 +1,26 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query' + +import type { ApiError } from '@/api' +import type { ApiResponse } from '@/api/types' + +import { publishSummary } from '../retrospectives.api' +import type { PublishSummaryParams, RetrospectiveSummaryResponse } from '../retrospectives.types' +import { retrospectiveQueryKeys } from './retrospectiveQueryKeys' + +export const usePublishSummary = () => { + const queryClient = useQueryClient() + + return useMutation< + ApiResponse, + ApiError, + PublishSummaryParams + >({ + mutationFn: (params: PublishSummaryParams) => publishSummary(params), + onSuccess: (response, variables) => { + queryClient.setQueryData( + retrospectiveQueryKeys.summary(variables.meetingId), + response.data + ) + }, + }) +} diff --git a/src/features/retrospectives/hooks/useSummary.ts b/src/features/retrospectives/hooks/useSummary.ts new file mode 100644 index 0000000..1a9abfe --- /dev/null +++ b/src/features/retrospectives/hooks/useSummary.ts @@ -0,0 +1,17 @@ +import { useQuery } from '@tanstack/react-query' + +import type { ApiError } from '@/api' + +import { getSummary } from '../retrospectives.api' +import type { RetrospectiveSummaryResponse } from '../retrospectives.types' +import { retrospectiveQueryKeys } from './retrospectiveQueryKeys' + +export const useSummary = (meetingId: number) => { + const isValid = !Number.isNaN(meetingId) && meetingId > 0 + + return useQuery({ + queryKey: retrospectiveQueryKeys.summary(meetingId), + queryFn: () => getSummary(meetingId), + enabled: isValid, + }) +} diff --git a/src/features/retrospectives/hooks/useUpdateSummary.ts b/src/features/retrospectives/hooks/useUpdateSummary.ts new file mode 100644 index 0000000..46be7be --- /dev/null +++ b/src/features/retrospectives/hooks/useUpdateSummary.ts @@ -0,0 +1,26 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query' + +import type { ApiError } from '@/api' +import type { ApiResponse } from '@/api/types' + +import { updateSummary } from '../retrospectives.api' +import type { RetrospectiveSummaryResponse, UpdateSummaryParams } from '../retrospectives.types' +import { retrospectiveQueryKeys } from './retrospectiveQueryKeys' + +export const useUpdateSummary = () => { + const queryClient = useQueryClient() + + return useMutation< + ApiResponse, + ApiError, + UpdateSummaryParams + >({ + mutationFn: (params: UpdateSummaryParams) => updateSummary(params), + onSuccess: (response, variables) => { + queryClient.setQueryData( + retrospectiveQueryKeys.summary(variables.meetingId), + response.data + ) + }, + }) +} diff --git a/src/features/retrospectives/index.ts b/src/features/retrospectives/index.ts index 4ffb8fb..7a3aafd 100644 --- a/src/features/retrospectives/index.ts +++ b/src/features/retrospectives/index.ts @@ -1,2 +1,23 @@ // Components export * from './components' + +// Hooks +export * from './hooks' + +// API +export { createSttJob, getSummary, publishSummary, updateSummary } from './retrospectives.api' + +// Types +export type { + CreateSttJobParams, + KeyPoint, + KeyPointUpdateRequest, + PublishSummaryParams, + RetrospectiveSummaryResponse, + SttJobResponse, + SttJobStatus, + SummaryTopic, + UpdateSummaryParams, + UpdateSummaryRequest, + UpdateSummaryTopicRequest, +} from './retrospectives.types' diff --git a/src/features/retrospectives/retrospectives.api.ts b/src/features/retrospectives/retrospectives.api.ts new file mode 100644 index 0000000..9dd709e --- /dev/null +++ b/src/features/retrospectives/retrospectives.api.ts @@ -0,0 +1,91 @@ +/** + * @file retrospectives.api.ts + * @description 약속 회고 AI 요약 API 요청 함수 + */ + +import { api, apiClient } from '@/api/client' +import type { ApiResponse } from '@/api/types' + +import { RETROSPECTIVES_ENDPOINTS } from './retrospectives.endpoints' +import type { + CreateSttJobParams, + PublishSummaryParams, + RetrospectiveSummaryResponse, + SttJobResponse, + UpdateSummaryParams, +} from './retrospectives.types' + +/** STT 요청 타임아웃: 5분 (동기 API이므로 충분히 길게) */ +const STT_TIMEOUT = 5 * 60 * 1000 + +/** + * STT Job 생성 (AI 요약 트리거) + * + * @description + * 녹음 파일을 업로드하거나 사전 의견만으로 STT + AI 요약을 실행합니다. + * 동기 API이므로 완료될 때까지 블로킹됩니다. + * + * @param params - 생성 파라미터 + * @param signal - AbortSignal (취소 지원) + */ +export const createSttJob = async ( + params: CreateSttJobParams, + signal?: AbortSignal +) => { + const { gatheringId, meetingId, file } = params + + const formData = new FormData() + if (file) { + formData.append('file', file) + } + + const response = await apiClient.post>( + RETROSPECTIVES_ENDPOINTS.STT_JOBS(gatheringId, meetingId), + formData, + { + headers: { 'Content-Type': undefined }, + timeout: STT_TIMEOUT, + signal, + } + ) + return response.data +} + +/** + * 회고 요약 조회 + * + * @param meetingId - 약속 식별자 + */ +export const getSummary = async ( + meetingId: number +): Promise => { + return api.get( + RETROSPECTIVES_ENDPOINTS.SUMMARY(meetingId) + ) +} + +/** + * 회고 요약 수정 + * + * @param params - 수정 파라미터 (meetingId + topics 데이터) + */ +export const updateSummary = async (params: UpdateSummaryParams) => { + const { meetingId, data } = params + const response = await apiClient.patch>( + RETROSPECTIVES_ENDPOINTS.SUMMARY(meetingId), + data + ) + return response.data +} + +/** + * 회고 요약 발행 (약속 회고 생성) + * + * @param params - 발행 파라미터 (meetingId) + */ +export const publishSummary = async (params: PublishSummaryParams) => { + const response = await apiClient.post>( + RETROSPECTIVES_ENDPOINTS.PUBLISH(params.meetingId) + ) + return response.data +} diff --git a/src/features/retrospectives/retrospectives.endpoints.ts b/src/features/retrospectives/retrospectives.endpoints.ts new file mode 100644 index 0000000..9bfe948 --- /dev/null +++ b/src/features/retrospectives/retrospectives.endpoints.ts @@ -0,0 +1,15 @@ +import { API_PATHS } from '@/api' + +export const RETROSPECTIVES_ENDPOINTS = { + /** STT Job 생성 (POST) */ + STT_JOBS: (gatheringId: number, meetingId: number) => + `${API_PATHS.GATHERINGS}/${gatheringId}/meetings/${meetingId}/stt/jobs`, + + /** 회고 요약 조회/수정 (GET/PATCH) */ + SUMMARY: (meetingId: number) => + `${API_PATHS.MEETINGS}/${meetingId}/retrospectives/summary`, + + /** 회고 요약 발행 (POST) */ + PUBLISH: (meetingId: number) => + `${API_PATHS.MEETINGS}/${meetingId}/retrospectives/summary/publish`, +} as const diff --git a/src/features/retrospectives/retrospectives.types.ts b/src/features/retrospectives/retrospectives.types.ts new file mode 100644 index 0000000..53c10d5 --- /dev/null +++ b/src/features/retrospectives/retrospectives.types.ts @@ -0,0 +1,87 @@ +/** + * @file retrospectives.types.ts + * @description 약속 회고 AI 요약 관련 타입 정의 + */ + +// ─── STT Job ─── + +/** STT Job 상태 */ +export type SttJobStatus = 'PENDING' | 'PROCESSING' | 'DONE' | 'FAILED' + +/** STT Job 생성 요청 파라미터 */ +export type CreateSttJobParams = { + gatheringId: number + meetingId: number + file?: File +} + +/** STT Job 응답 */ +export interface SttJobResponse { + jobId: number + meetingId: number + userId: number + status: SttJobStatus + summary: string | null + highlights: string[] | null + errorMessage: string | null + createdAt: string +} + +// ─── Retrospective Summary ─── + +/** 주요 포인트 항목 */ +export interface KeyPoint { + title: string + details: string[] +} + +/** 토픽별 요약 */ +export interface SummaryTopic { + topicId: number + confirmOrder: number + topicTitle: string + topicDescription: string + summary: string + keyPoints: KeyPoint[] +} + +/** 회고 요약 응답 (GET, PATCH, POST publish 공통) */ +export interface RetrospectiveSummaryResponse { + meetingId: number + isPublished: boolean + publishedAt: string | null + topics: SummaryTopic[] +} + +// ─── Request Types ─── + +/** 주요 포인트 수정 요청 */ +export type KeyPointUpdateRequest = { + title: string + details: string[] +} + +/** 토픽 요약 수정 요청 */ +export type UpdateSummaryTopicRequest = { + topicId: number + summary: string + keyPoints: KeyPointUpdateRequest[] +} + +/** 회고 요약 수정 요청 바디 */ +export type UpdateSummaryRequest = { + topics: UpdateSummaryTopicRequest[] +} + +// ─── Hook Params ─── + +/** 요약 수정 훅 파라미터 */ +export type UpdateSummaryParams = { + meetingId: number + data: UpdateSummaryRequest +} + +/** 요약 발행 훅 파라미터 */ +export type PublishSummaryParams = { + meetingId: number +} From dee365aa5826fde787903146befc1bed4d7a9222 Mon Sep 17 00:00:00 2001 From: mgYang53 Date: Sun, 22 Feb 2026 23:24:56 +0900 Subject: [PATCH 2/3] =?UTF-8?q?style:=20prettier=20=ED=8F=AC=EB=A7=B7=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../retrospectives/hooks/useCreateSttJob.ts | 6 +----- .../retrospectives/hooks/usePublishSummary.ts | 11 ++--------- .../retrospectives/hooks/useUpdateSummary.ts | 11 ++--------- src/features/retrospectives/retrospectives.api.ts | 13 +++---------- .../retrospectives/retrospectives.endpoints.ts | 3 +-- 5 files changed, 9 insertions(+), 35 deletions(-) diff --git a/src/features/retrospectives/hooks/useCreateSttJob.ts b/src/features/retrospectives/hooks/useCreateSttJob.ts index c020729..0fad044 100644 --- a/src/features/retrospectives/hooks/useCreateSttJob.ts +++ b/src/features/retrospectives/hooks/useCreateSttJob.ts @@ -16,11 +16,7 @@ import type { CreateSttJobParams, SttJobResponse } from '../retrospectives.types export const useCreateSttJob = () => { const abortControllerRef = useRef(null) - const mutation = useMutation< - ApiResponse, - ApiError, - CreateSttJobParams - >({ + const mutation = useMutation, ApiError, CreateSttJobParams>({ mutationFn: (params: CreateSttJobParams) => { abortControllerRef.current?.abort() diff --git a/src/features/retrospectives/hooks/usePublishSummary.ts b/src/features/retrospectives/hooks/usePublishSummary.ts index 1d57b6f..c063649 100644 --- a/src/features/retrospectives/hooks/usePublishSummary.ts +++ b/src/features/retrospectives/hooks/usePublishSummary.ts @@ -10,17 +10,10 @@ import { retrospectiveQueryKeys } from './retrospectiveQueryKeys' export const usePublishSummary = () => { const queryClient = useQueryClient() - return useMutation< - ApiResponse, - ApiError, - PublishSummaryParams - >({ + return useMutation, ApiError, PublishSummaryParams>({ mutationFn: (params: PublishSummaryParams) => publishSummary(params), onSuccess: (response, variables) => { - queryClient.setQueryData( - retrospectiveQueryKeys.summary(variables.meetingId), - response.data - ) + queryClient.setQueryData(retrospectiveQueryKeys.summary(variables.meetingId), response.data) }, }) } diff --git a/src/features/retrospectives/hooks/useUpdateSummary.ts b/src/features/retrospectives/hooks/useUpdateSummary.ts index 46be7be..f259fcf 100644 --- a/src/features/retrospectives/hooks/useUpdateSummary.ts +++ b/src/features/retrospectives/hooks/useUpdateSummary.ts @@ -10,17 +10,10 @@ import { retrospectiveQueryKeys } from './retrospectiveQueryKeys' export const useUpdateSummary = () => { const queryClient = useQueryClient() - return useMutation< - ApiResponse, - ApiError, - UpdateSummaryParams - >({ + return useMutation, ApiError, UpdateSummaryParams>({ mutationFn: (params: UpdateSummaryParams) => updateSummary(params), onSuccess: (response, variables) => { - queryClient.setQueryData( - retrospectiveQueryKeys.summary(variables.meetingId), - response.data - ) + queryClient.setQueryData(retrospectiveQueryKeys.summary(variables.meetingId), response.data) }, }) } diff --git a/src/features/retrospectives/retrospectives.api.ts b/src/features/retrospectives/retrospectives.api.ts index 9dd709e..3254cc2 100644 --- a/src/features/retrospectives/retrospectives.api.ts +++ b/src/features/retrospectives/retrospectives.api.ts @@ -28,10 +28,7 @@ const STT_TIMEOUT = 5 * 60 * 1000 * @param params - 생성 파라미터 * @param signal - AbortSignal (취소 지원) */ -export const createSttJob = async ( - params: CreateSttJobParams, - signal?: AbortSignal -) => { +export const createSttJob = async (params: CreateSttJobParams, signal?: AbortSignal) => { const { gatheringId, meetingId, file } = params const formData = new FormData() @@ -56,12 +53,8 @@ export const createSttJob = async ( * * @param meetingId - 약속 식별자 */ -export const getSummary = async ( - meetingId: number -): Promise => { - return api.get( - RETROSPECTIVES_ENDPOINTS.SUMMARY(meetingId) - ) +export const getSummary = async (meetingId: number): Promise => { + return api.get(RETROSPECTIVES_ENDPOINTS.SUMMARY(meetingId)) } /** diff --git a/src/features/retrospectives/retrospectives.endpoints.ts b/src/features/retrospectives/retrospectives.endpoints.ts index 9bfe948..9567887 100644 --- a/src/features/retrospectives/retrospectives.endpoints.ts +++ b/src/features/retrospectives/retrospectives.endpoints.ts @@ -6,8 +6,7 @@ export const RETROSPECTIVES_ENDPOINTS = { `${API_PATHS.GATHERINGS}/${gatheringId}/meetings/${meetingId}/stt/jobs`, /** 회고 요약 조회/수정 (GET/PATCH) */ - SUMMARY: (meetingId: number) => - `${API_PATHS.MEETINGS}/${meetingId}/retrospectives/summary`, + SUMMARY: (meetingId: number) => `${API_PATHS.MEETINGS}/${meetingId}/retrospectives/summary`, /** 회고 요약 발행 (POST) */ PUBLISH: (meetingId: number) => From b6c209cd105d606e9d654a01a569689a02dd25f2 Mon Sep 17 00:00:00 2001 From: mgYang53 Date: Sun, 22 Feb 2026 23:39:11 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81=20(#94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - api 함수 api.* 헬퍼로 통일 - useCreateSttJob race condition 수정 - useCreateSttJob 언마운트 시 자동 취소 - KeyPointUpdateRequest 타입 alias로 변경 --- .../retrospectives/hooks/useCreateSttJob.ts | 22 +++++++++----- .../retrospectives/hooks/usePublishSummary.ts | 7 ++--- .../retrospectives/hooks/useUpdateSummary.ts | 7 ++--- .../retrospectives/retrospectives.api.ts | 30 +++++++++---------- .../retrospectives/retrospectives.types.ts | 7 ++--- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/features/retrospectives/hooks/useCreateSttJob.ts b/src/features/retrospectives/hooks/useCreateSttJob.ts index 0fad044..f87ada9 100644 --- a/src/features/retrospectives/hooks/useCreateSttJob.ts +++ b/src/features/retrospectives/hooks/useCreateSttJob.ts @@ -1,8 +1,7 @@ import { useMutation } from '@tanstack/react-query' -import { useCallback, useRef } from 'react' +import { useCallback, useEffect, useRef } from 'react' import type { ApiError } from '@/api' -import type { ApiResponse } from '@/api/types' import { createSttJob } from '../retrospectives.api' import type { CreateSttJobParams, SttJobResponse } from '../retrospectives.types' @@ -12,21 +11,30 @@ import type { CreateSttJobParams, SttJobResponse } from '../retrospectives.types * * - 동기 API이므로 mutation pending 동안 로딩 오버레이 표시 * - cancel() 호출 시 진행 중인 HTTP 요청 중단 + * - 컴포넌트 언마운트 시 자동 취소 */ export const useCreateSttJob = () => { const abortControllerRef = useRef(null) - const mutation = useMutation, ApiError, CreateSttJobParams>({ + useEffect(() => { + return () => { + abortControllerRef.current?.abort() + abortControllerRef.current = null + } + }, []) + + const mutation = useMutation({ mutationFn: (params: CreateSttJobParams) => { abortControllerRef.current?.abort() const controller = new AbortController() abortControllerRef.current = controller - return createSttJob(params, controller.signal) - }, - onSettled: () => { - abortControllerRef.current = null + return createSttJob(params, controller.signal).finally(() => { + if (abortControllerRef.current === controller) { + abortControllerRef.current = null + } + }) }, }) diff --git a/src/features/retrospectives/hooks/usePublishSummary.ts b/src/features/retrospectives/hooks/usePublishSummary.ts index c063649..1636fd6 100644 --- a/src/features/retrospectives/hooks/usePublishSummary.ts +++ b/src/features/retrospectives/hooks/usePublishSummary.ts @@ -1,7 +1,6 @@ import { useMutation, useQueryClient } from '@tanstack/react-query' import type { ApiError } from '@/api' -import type { ApiResponse } from '@/api/types' import { publishSummary } from '../retrospectives.api' import type { PublishSummaryParams, RetrospectiveSummaryResponse } from '../retrospectives.types' @@ -10,10 +9,10 @@ import { retrospectiveQueryKeys } from './retrospectiveQueryKeys' export const usePublishSummary = () => { const queryClient = useQueryClient() - return useMutation, ApiError, PublishSummaryParams>({ + return useMutation({ mutationFn: (params: PublishSummaryParams) => publishSummary(params), - onSuccess: (response, variables) => { - queryClient.setQueryData(retrospectiveQueryKeys.summary(variables.meetingId), response.data) + onSuccess: (data, variables) => { + queryClient.setQueryData(retrospectiveQueryKeys.summary(variables.meetingId), data) }, }) } diff --git a/src/features/retrospectives/hooks/useUpdateSummary.ts b/src/features/retrospectives/hooks/useUpdateSummary.ts index f259fcf..c2ecdac 100644 --- a/src/features/retrospectives/hooks/useUpdateSummary.ts +++ b/src/features/retrospectives/hooks/useUpdateSummary.ts @@ -1,7 +1,6 @@ import { useMutation, useQueryClient } from '@tanstack/react-query' import type { ApiError } from '@/api' -import type { ApiResponse } from '@/api/types' import { updateSummary } from '../retrospectives.api' import type { RetrospectiveSummaryResponse, UpdateSummaryParams } from '../retrospectives.types' @@ -10,10 +9,10 @@ import { retrospectiveQueryKeys } from './retrospectiveQueryKeys' export const useUpdateSummary = () => { const queryClient = useQueryClient() - return useMutation, ApiError, UpdateSummaryParams>({ + return useMutation({ mutationFn: (params: UpdateSummaryParams) => updateSummary(params), - onSuccess: (response, variables) => { - queryClient.setQueryData(retrospectiveQueryKeys.summary(variables.meetingId), response.data) + onSuccess: (data, variables) => { + queryClient.setQueryData(retrospectiveQueryKeys.summary(variables.meetingId), data) }, }) } diff --git a/src/features/retrospectives/retrospectives.api.ts b/src/features/retrospectives/retrospectives.api.ts index 3254cc2..1564b59 100644 --- a/src/features/retrospectives/retrospectives.api.ts +++ b/src/features/retrospectives/retrospectives.api.ts @@ -3,8 +3,7 @@ * @description 약속 회고 AI 요약 API 요청 함수 */ -import { api, apiClient } from '@/api/client' -import type { ApiResponse } from '@/api/types' +import { api } from '@/api/client' import { RETROSPECTIVES_ENDPOINTS } from './retrospectives.endpoints' import type { @@ -28,7 +27,10 @@ const STT_TIMEOUT = 5 * 60 * 1000 * @param params - 생성 파라미터 * @param signal - AbortSignal (취소 지원) */ -export const createSttJob = async (params: CreateSttJobParams, signal?: AbortSignal) => { +export const createSttJob = async ( + params: CreateSttJobParams, + signal?: AbortSignal +): Promise => { const { gatheringId, meetingId, file } = params const formData = new FormData() @@ -36,7 +38,7 @@ export const createSttJob = async (params: CreateSttJobParams, signal?: AbortSig formData.append('file', file) } - const response = await apiClient.post>( + return api.post( RETROSPECTIVES_ENDPOINTS.STT_JOBS(gatheringId, meetingId), formData, { @@ -45,7 +47,6 @@ export const createSttJob = async (params: CreateSttJobParams, signal?: AbortSig signal, } ) - return response.data } /** @@ -62,13 +63,11 @@ export const getSummary = async (meetingId: number): Promise { +export const updateSummary = async ( + params: UpdateSummaryParams +): Promise => { const { meetingId, data } = params - const response = await apiClient.patch>( - RETROSPECTIVES_ENDPOINTS.SUMMARY(meetingId), - data - ) - return response.data + return api.patch(RETROSPECTIVES_ENDPOINTS.SUMMARY(meetingId), data) } /** @@ -76,9 +75,8 @@ export const updateSummary = async (params: UpdateSummaryParams) => { * * @param params - 발행 파라미터 (meetingId) */ -export const publishSummary = async (params: PublishSummaryParams) => { - const response = await apiClient.post>( - RETROSPECTIVES_ENDPOINTS.PUBLISH(params.meetingId) - ) - return response.data +export const publishSummary = async ( + params: PublishSummaryParams +): Promise => { + return api.post(RETROSPECTIVES_ENDPOINTS.PUBLISH(params.meetingId)) } diff --git a/src/features/retrospectives/retrospectives.types.ts b/src/features/retrospectives/retrospectives.types.ts index 53c10d5..b03891c 100644 --- a/src/features/retrospectives/retrospectives.types.ts +++ b/src/features/retrospectives/retrospectives.types.ts @@ -55,11 +55,8 @@ export interface RetrospectiveSummaryResponse { // ─── Request Types ─── -/** 주요 포인트 수정 요청 */ -export type KeyPointUpdateRequest = { - title: string - details: string[] -} +/** 주요 포인트 수정 요청 (KeyPoint와 동일 형태) */ +export type KeyPointUpdateRequest = KeyPoint /** 토픽 요약 수정 요청 */ export type UpdateSummaryTopicRequest = {