Fase 2 stap B (frontend): uitsnede per slide in het scherm, herstelpunt in het plan

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 21:51:21 +01:00
co-authored by Claude Sonnet 5.5
parent e30d885d64
commit e44ca80d1d
11 changed files with 195 additions and 54 deletions
+18 -1
View File
@@ -1,6 +1,6 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { api } from '@/lib/api-client';
import type { HeroAdminDto, HeroFocusRequest, HeroImageDto, HeroSaveRequest, HeroUploadLimits } from './types';
import type { HeroAdminDto, HeroFocusRequest, HeroImageDto, HeroSaveRequest, HeroSlideAdminDto, HeroUploadLimits } from './types';
export const HERO_KEY = ['hero'];
@@ -73,6 +73,23 @@ export const heroImageQuery = (imageId: string) => ({
* 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 useSetSlideFocus() {
const queryClient = useQueryClient();
return useMutation<HeroSlideAdminDto, Error, { slideId: string; request: HeroFocusRequest }>({
mutationFn: ({ slideId, request }) => api.put<HeroSlideAdminDto>(`/api/v1/hero/slides/${slideId}/focus`, request),
onSuccess: () => queryClient.invalidateQueries({ queryKey: HERO_KEY }),
});
}
/** Takes the slide's own crop away: it uses the crop of its photo again. */
export function useResetSlideFocus() {
const queryClient = useQueryClient();
return useMutation<HeroSlideAdminDto, Error, string>({
mutationFn: (slideId) => api.delete<HeroSlideAdminDto>(`/api/v1/hero/slides/${slideId}/focus`),
onSuccess: () => queryClient.invalidateQueries({ queryKey: HERO_KEY }),
});
}
export function useSetHeroImageFocus() {
const queryClient = useQueryClient();
return useMutation<HeroImageDto, Error, { imageId: string; request: HeroFocusRequest }>({