WIP: bulkbalk boven de lijst, definitief verwijderen en prullenbak legen, uitsnede direct zonder opslaan, teller per batch
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { api } from '@/lib/api-client';
|
||||
import type { HeroAdminDto, HeroImageDto, HeroSaveRequest, HeroUploadLimits } from './types';
|
||||
import type { HeroAdminDto, HeroFocusRequest, HeroImageDto, HeroSaveRequest, HeroUploadLimits } from './types';
|
||||
|
||||
export const HERO_KEY = ['hero'];
|
||||
|
||||
@@ -68,3 +68,18 @@ export const heroImageQuery = (imageId: string) => ({
|
||||
refetchInterval: (query: { state: { data?: HeroImageDto } }) => (query.state.data?.processing ? 5000 : false),
|
||||
refetchIntervalInBackground: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* A new crop for an image, applied at once without saving the hero (Bryan, 2026-11-17): the server cuts the new variants
|
||||
* in the background and the image switches to them when they are complete. The answer is the image, now processing.
|
||||
*/
|
||||
export function useSetHeroImageFocus() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<HeroImageDto, Error, { imageId: string; request: HeroFocusRequest }>({
|
||||
mutationFn: ({ imageId, request }) => api.put<HeroImageDto>(`/api/v1/hero/images/${imageId}/focus`, request),
|
||||
onSuccess: (image) => {
|
||||
queryClient.setQueryData(['hero', 'image', image.id], image);
|
||||
return queryClient.invalidateQueries({ queryKey: HERO_KEY });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user