diff --git a/frontend/src/api/endpoint.ts b/frontend/src/api/endpoint.ts index c667926..782653d 100644 --- a/frontend/src/api/endpoint.ts +++ b/frontend/src/api/endpoint.ts @@ -7,5 +7,6 @@ export const API_ENDPOINT = { TIME: buildApiUrl("/v1/time"), DANIME: buildApiUrl("/v1/danime"), OAUTH_FIREBASE: buildApiUrl("/v1/oauth/firebase"), + ARCHIVE: buildApiUrl("/v1/archive"), }, } as const; diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index d0610ce..b8c26cc 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -35,3 +35,12 @@ export type FirebaseAuthResponse = { issuer?: string; expires?: number; }; + +export type ArchiveResult = { + moved_ids: number[]; + deleted_ids: number[]; + skipped_ids: number[]; + inserted: number; + deleted: number; + skipped: number; +}; diff --git a/frontend/src/api/watchparty.ts b/frontend/src/api/watchparty.ts index 94f9fde..1011bdf 100644 --- a/frontend/src/api/watchparty.ts +++ b/frontend/src/api/watchparty.ts @@ -1,6 +1,6 @@ import { API_ENDPOINT } from "./endpoint"; import { ApiError, apiFetch } from "./client"; -import type { DanimeEpisode, ScheduleResponse, ShowItem, TimeResponse } from "./types"; +import type { ArchiveResult, DanimeEpisode, ScheduleResponse, ShowItem, TimeResponse } from "./types"; export type { DanimeEpisode, ScheduleResponse, ShowItem, TimeResponse } from "./types"; @@ -137,18 +137,19 @@ export async function createShow(payload: { }); } -export async function deleteShow(id: number, idToken: string) { +export async function archiveShow(id: number, idToken: string) { if (!idToken) { - throw new ApiError("Missing auth token for delete"); + throw new ApiError("Missing auth token for archive"); } - const url = `${API_ENDPOINT.v1.SHOWS}?id=${encodeURIComponent(id)}`; - await apiFetch(url, { - method: "DELETE", + await apiFetch(API_ENDPOINT.v1.ARCHIVE, { + method: "POST", headers: { "Authorization": `Bearer ${idToken}`, + "Content-Type": "application/json", }, + body: JSON.stringify({ ids: [id] }), timeoutMs: 10_000, - expect: "void", - logLabel: "delete show", + expect: "json", + logLabel: "archive show", }); } diff --git a/frontend/src/pages/ShowsPage.tsx b/frontend/src/pages/ShowsPage.tsx index 750719f..2a13f04 100644 --- a/frontend/src/pages/ShowsPage.tsx +++ b/frontend/src/pages/ShowsPage.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState, useRef } from "react"; import { useNavigate } from "react-router-dom"; import { logApiError } from "../utils/logger"; import { toastError, toastInfo } from "../utils/toastBus"; -import { createShow, deleteShow, fetchDanimeEpisode, fetchShows, postCurrentEpisode } from "../api/watchparty"; +import { archiveShow, createShow, fetchDanimeEpisode, fetchShows, postCurrentEpisode } from "../api/watchparty"; import type { DanimeEpisode, ShowItem } from "../api/watchparty"; import { useAuth } from "../auth/AuthProvider"; @@ -235,7 +235,7 @@ export default function ShowsPage() { } try { setDeletingId(showId); - await deleteShow(showId, idToken); + await archiveShow(showId, idToken); toastInfo("エピソードを削除しました"); if (selectedId === showId) { setSelectedId(null);