Files
muzick/frontend/src/services/historyService.ts
T

37 lines
1.1 KiB
TypeScript

import api from './api';
import type { FeedbackAction, HistoryEntry } from '../types';
export const historyService = {
// POST /api/history { trackId, completed?, batchId? } -> { historyId }
async recordPlay(
trackId: string,
completed?: boolean,
batchId?: string
): Promise<{ historyId: string }> {
const res = await api.post<{ historyId: string }>('/history', {
trackId,
completed,
batchId,
});
return res.data;
},
// POST /api/history/skip { trackId } -> { status }
async skip(trackId: string): Promise<{ status: string }> {
const res = await api.post<{ status: string }>('/history/skip', { trackId });
return res.data;
},
// GET /api/history -> recent play history (Track + playback metadata)
async list(): Promise<HistoryEntry[]> {
const res = await api.get<HistoryEntry[]>('/history');
return res.data;
},
// POST /api/feedback { trackId, action } -> { status }
async feedback(trackId: string, action: FeedbackAction): Promise<{ status: string }> {
const res = await api.post<{ status: string }>('/feedback', { trackId, action });
return res.data;
},
};