first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import {BackendResponse} from '@common/http/backend-response/backend-response';
import {useMutation} from '@tanstack/react-query';
import {apiClient, queryClient} from '@common/http/query-client';
import {showHttpErrorToast} from '@common/utils/http/show-http-error-toast';
import {toast} from '@common/ui/toast/toast';
import {message} from '@common/i18n/message';
import {Episode} from '@app/titles/models/episode';
import {seasonQueryKey} from '@app/seasons/requests/use-season';
interface Response extends BackendResponse {}
export function useDeleteEpisode(episode: Episode) {
return useMutation({
mutationFn: () => deleteEpisode(episode.id),
onSuccess: async () => {
await queryClient.invalidateQueries({
queryKey: seasonQueryKey(episode.title_id, episode.season_number),
});
toast(message('Episode deleted'));
},
onError: r => showHttpErrorToast(r),
});
}
function deleteEpisode(seasonId: number | string): Promise<Response> {
return apiClient.delete(`episodes/${seasonId}`).then(r => r.data);
}