Files
dognation_PT/src/api/matches.ts
T
sb cc3a0fa836
CI / build (push) Failing after 14m12s
feat: 매칭 플로우 프론트 (진행중·알림·수락/거절·1:1 채팅)
- 매칭 버튼: 신청 후 "진행중" 표시, 무료 소진(429) 안내
- 헤더 알림 벨: 받은 매칭 신청 목록 + 수락/거절
- 실시간 알림: STOMP /topic/users/{id} 구독(신청/수락/거절/만료 토스트)
- 수락 시 1:1 매칭 채팅(MatchChatDialog, /topic/matches/{id})

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-11 15:04:21 +09:00

39 lines
1.1 KiB
TypeScript

import { http } from './http'
export interface Match {
id: number
requesterDogId: number
targetDogId: number
status: string
createdAt: string
expiresAt: string | null
respondedAt: string | null
}
/** 받은 매칭 신청 (신청 견 정보 포함) — 수락/거절 UI용. */
export interface ReceivedMatch {
id: number
requesterDogId: number
requesterDogName: string
requesterDogBreed: string | null
createdAt: string
expiresAt: string | null
}
/** STOMP /topic/users/{userId} 로 오는 매칭 알림. */
export interface MatchNotification {
type: 'NEW_REQUEST' | 'ACCEPTED' | 'REJECTED' | 'EXPIRED'
matchId: number
title: string
message: string
}
export const matchesApi = {
create: (requesterDogId: number, targetDogId: number) =>
http.post<Match>('/api/matches', { requesterDogId, targetDogId }),
accept: (id: number) => http.post<Match>(`/api/matches/${id}/accept`),
reject: (id: number) => http.post<Match>(`/api/matches/${id}/reject`),
received: (dogId: number) => http.get<ReceivedMatch[]>(`/api/matches/received/${dogId}`),
sent: (dogId: number) => http.get<Match[]>(`/api/matches/sent/${dogId}`),
}