Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 4 additions & 16 deletions src/apis/verify/queries.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
import { useInfiniteQuery } from '@tanstack/react-query'
import { http } from '#/shared/apis/http'
import { getVerify } from './mock'
import type { VerifyResponse } from '#/types/verify'

export const verifyKeys = {
bySector: (sector: string) => ['verify', sector] as const,
}

/** GET /api/verify가 쓰는 sector/cursor 쿼리스트링. */
function pageSearchParams(sector: string, cursor?: string) {
const searchParams: Record<string, string> = {}
if (sector && sector !== '전체') searchParams.sector = sector
if (cursor) searchParams.cursor = cursor
return searchParams
}

async function fetchVerify(
sector: string,
cursor?: string,
): Promise<VerifyResponse> {
const searchParams = pageSearchParams(sector, cursor)
return http.get('verify', { searchParams }).json<VerifyResponse>()
/** 예측 검증 탭 — 실 백엔드에 해당 API가 없어 verify.json 더미 데이터를
* API를 거치지 않고 클라이언트에서 직접 페이징한다. */
function fetchVerify(sector: string, cursor?: string) {
return getVerify({ sector, cursor })
}

/** 검증 목록 — 무한 스크롤용 커서 기반 페이징. `data.pages.flatMap(p => p.news)`로 펼쳐 쓴다. */
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/analysis/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpResponse, delay, http } from 'msw'
import { getNewsImpact } from '#/apis/analysis/mock'

export const analysisHandlers = [
http.get('/api/news/:id/impact', async ({ params }) => {
http.get('/api/v1/news/:id/impact', async ({ params }) => {
await delay(350)
const impact = getNewsImpact(Number(params.id))
if (!impact) {
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/graph/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpResponse, delay, http } from 'msw'
import { getGraph } from '#/apis/graph/mock'

export const graphHandlers = [
http.get('/api/graph', async () => {
http.get('/api/v1/graph', async () => {
await delay(250)
return HttpResponse.json(getGraph({ mode: 'full' }))
}),
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/news/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getNews } from '#/apis/news/mock'
*/

export const newsHandlers = [
http.get('/api/news', async ({ request }) => {
http.get('/api/v1/news', async ({ request }) => {
await delay(300)
const searchParams = new URL(request.url).searchParams
const cursorId = searchParams.get('cursorId')
Expand Down
Loading