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:
@@ -58,6 +58,7 @@ export const resetMockHero = (): void => {
|
||||
uploadFailure = null;
|
||||
retried = [];
|
||||
focusRequests = [];
|
||||
resetSlideRequests = [];
|
||||
recutting = new Set();
|
||||
};
|
||||
|
||||
@@ -80,9 +81,11 @@ export const getRetriedImages = (): string[] => retried;
|
||||
|
||||
export const getSavedHeroRequests = (): HeroSaveRequest[] => saved;
|
||||
|
||||
let focusRequests: { imageId: string; body: HeroFocusRequest }[] = [];
|
||||
let focusRequests: { imageId: string; slideId?: string; body: HeroFocusRequest }[] = [];
|
||||
let resetSlideRequests: string[] = [];
|
||||
export const getResetSlideRequests = (): string[] => resetSlideRequests;
|
||||
/** 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 getFocusRequests = (): { imageId: string; slideId?: string; body: HeroFocusRequest }[] => focusRequests;
|
||||
|
||||
export const failNextUpload = (failure: { status: number; error: string; message: string } | null): void => {
|
||||
uploadFailure = failure;
|
||||
@@ -123,6 +126,29 @@ export const heroHandlers = [
|
||||
return HttpResponse.json(hero);
|
||||
}),
|
||||
|
||||
// A crop for one slide (crop per use): the slide gets its own crop and shows the photo as processing.
|
||||
http.put(`${API_BASE}/api/v1/hero/slides/:id/focus`, async ({ params, request }) => {
|
||||
const slideId = String(params.id);
|
||||
const body = (await request.json()) as HeroFocusRequest;
|
||||
const slide = hero.slides.find((s) => s.id === slideId);
|
||||
if (!slide) return new HttpResponse(null, { status: 404 });
|
||||
focusRequests.push({ imageId: slide.imageId, slideId, body });
|
||||
const updated = { ...slide, ownCrop: true, image: { ...slide.image, focus: body.focus, wideFocus: body.wide ?? null, tallFocus: body.tall ?? null, processing: true } };
|
||||
recutting.add(slide.imageId);
|
||||
hero = { ...hero, slides: hero.slides.map((s) => (s.id === slideId ? updated : s)) };
|
||||
return HttpResponse.json(updated);
|
||||
}),
|
||||
|
||||
http.delete(`${API_BASE}/api/v1/hero/slides/:id/focus`, ({ params }) => {
|
||||
const slideId = String(params.id);
|
||||
const slide = hero.slides.find((s) => s.id === slideId);
|
||||
if (!slide) return new HttpResponse(null, { status: 404 });
|
||||
resetSlideRequests.push(slideId);
|
||||
const updated = { ...slide, ownCrop: false, image: { ...slide.image, processing: false } };
|
||||
hero = { ...hero, slides: hero.slides.map((s) => (s.id === slideId ? updated : s)) };
|
||||
return HttpResponse.json(updated);
|
||||
}),
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user