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,33 @@
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 {titleSeasonsQueryKey} from '@app/titles/requests/use-title-seasons';
import {toast} from '@common/ui/toast/toast';
import {message} from '@common/i18n/message';
import {Season} from '@app/titles/models/season';
interface Response extends BackendResponse {
season: Season;
}
export function useCreateSeason(titleId: number) {
return useMutation({
mutationFn: () => createSeason(titleId),
onSuccess: async response => {
await queryClient.invalidateQueries({
queryKey: titleSeasonsQueryKey(response.season.title_id),
});
toast(
message('Season :number created', {
values: {number: response.season.number},
}),
);
},
onError: r => showHttpErrorToast(r),
});
}
function createSeason(titleId: number): Promise<Response> {
return apiClient.post(`titles/${titleId}/seasons`).then(r => r.data);
}