(null)
+ const deleteMutation = useMutation({
+ mutationFn: ({ id, withMedia }: { id: string; withMedia: boolean }) =>
+ deleteShow(id, withMedia),
+ onSuccess: () => {
+ setToDelete(null)
+ invalidate()
+ },
+ onError,
+ })
return (
@@ -309,11 +321,7 @@ export function ShowsPanel() {
{show.seasonCount} |
{show.episodeCount} |
- |
@@ -324,6 +332,15 @@ export function ShowsPanel() {
+
+ {toDelete && (
+ deleteMutation.mutate({ id: toDelete.id, withMedia })}
+ onClose={() => setToDelete(null)}
+ />
+ )}
)
}
diff --git a/frontend/src/features/admin/shows/api.ts b/frontend/src/features/admin/shows/api.ts
index d5131cc..abac2be 100644
--- a/frontend/src/features/admin/shows/api.ts
+++ b/frontend/src/features/admin/shows/api.ts
@@ -79,8 +79,10 @@ export function getShowUsage(id: string) {
return apiRequest(`/admin/shows/${id}/usage`)
}
-export function deleteShow(id: string) {
- return apiRequest(`/admin/shows/${id}`, { method: 'DELETE' })
+/** `withMedia` — снести заодно файлы шоу: иначе они переживут его осиротевшими. */
+export function deleteShow(id: string, withMedia = false) {
+ const query = withMedia ? '?withMedia=true' : ''
+ return apiRequest(`/admin/shows/${id}${query}`, { method: 'DELETE' })
}
export function addEpisode(showId: string, mediaAssetId: string) {
diff --git a/frontend/src/shared/lib/locales/en.ts b/frontend/src/shared/lib/locales/en.ts
index e10ba9d..14cec80 100644
--- a/frontend/src/shared/lib/locales/en.ts
+++ b/frontend/src/shared/lib/locales/en.ts
@@ -412,6 +412,11 @@ export const en = {
genre: 'Genre',
allGenres: 'All genres',
allKinds: 'All kinds',
+ deleteTitle: 'Delete the show?',
+ deleteHint: '“{{name}}” will be removed from the library. This cannot be undone.',
+ deleteWithMedia: 'Delete its media too: {{count}} file(s)',
+ deleteWithMediaHint:
+ 'Otherwise the files stay in the media list with no owner and keep taking space.',
otherGenres: 'Other genres',
bulk: {
selected: 'Selected: {{count}}',
diff --git a/frontend/src/shared/lib/locales/ru.ts b/frontend/src/shared/lib/locales/ru.ts
index 1540276..5d1028a 100644
--- a/frontend/src/shared/lib/locales/ru.ts
+++ b/frontend/src/shared/lib/locales/ru.ts
@@ -409,6 +409,11 @@ export const ru = {
genre: 'Жанр',
allGenres: 'Все жанры',
allKinds: 'Все типы',
+ deleteTitle: 'Удалить шоу?',
+ deleteHint: '«{{name}}» будет удалено из библиотеки. Отменить это нельзя.',
+ deleteWithMedia: 'Также удалить медиа: файлов {{count}}',
+ deleteWithMediaHint:
+ 'Иначе файлы останутся в списке медиа ничьими и продолжат занимать место.',
otherGenres: 'Остальные жанры',
bulk: {
selected: 'Отмечено: {{count}}',