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 { 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 }),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user