WIP: bulkbalk boven de lijst, definitief verwijderen en prullenbak legen, uitsnede direct zonder opslaan, teller per batch

This commit is contained in:
2026-11-17 16:58:23 +01:00
parent 8ad071da1c
commit 1384cafa7b
28 changed files with 816 additions and 134 deletions
+17 -1
View File
@@ -1,6 +1,6 @@
import { http, HttpResponse } from 'msw';
import { API_BASE } from '@/features/auth/mocks/fixtures';
import type { HeroAdminDto, HeroImageDto, HeroSaveRequest, HeroSlideAdminDto } from '@/features/hero/services/types';
import type { HeroAdminDto, HeroFocusRequest, HeroImageDto, HeroSaveRequest, HeroSlideAdminDto } from '@/features/hero/services/types';
const seedImage = (id: string, width = 1600, height = 1067): HeroImageDto => ({
id,
@@ -57,6 +57,7 @@ export const resetMockHero = (): void => {
uploads = 0;
uploadFailure = null;
retried = [];
focusRequests = [];
recutting = new Set();
};
@@ -79,6 +80,10 @@ export const getRetriedImages = (): string[] => retried;
export const getSavedHeroRequests = (): HeroSaveRequest[] => saved;
let focusRequests: { imageId: string; body: HeroFocusRequest }[] = [];
/** The crops sent at once with PUT hero/images/{id}/focus (no save of the hero involved). */
export const getFocusRequests = (): { imageId: string; body: HeroFocusRequest }[] => focusRequests;
export const failNextUpload = (failure: { status: number; error: string; message: string } | null): void => {
uploadFailure = failure;
};
@@ -118,6 +123,17 @@ export const heroHandlers = [
return HttpResponse.json(hero);
}),
http.put(`${API_BASE}/api/v1/hero/images/:id/focus`, async ({ params, request }) => {
const id = String(params.id);
const body = (await request.json()) as HeroFocusRequest;
focusRequests.push({ imageId: id, body });
const current = images[id] ?? hero.slides.find((s) => s.imageId === id)?.image ?? seedImage(id);
images[id] = { ...current, focus: body.focus, wideFocus: body.wide ?? null, tallFocus: body.tall ?? null, processing: true };
recutting.add(id);
hero = { ...hero, slides: hero.slides.map((s) => (s.imageId === id ? { ...s, image: images[id] } : s)) };
return HttpResponse.json(images[id]);
}),
http.get(`${API_BASE}/api/v1/hero/images/limits`, () =>
HttpResponse.json({ formats: ['JPEG', 'PNG', 'GIF', 'BMP', 'TIFF', 'WebP', 'AVIF'], maxUploadBytes: 10 * 1024 * 1024, maxMegapixels: 64 }),
),