Hero: Slide toevoegen via de bibliotheek of een upload, geen foto wijzigen per slide
Continuous Integration / config-sls (pull_request) Successful in 9s
Continuous Integration / config-asf (pull_request) Successful in 8s
Continuous Integration / changes (pull_request) Successful in 15s
Continuous Integration / compile-sites (pull_request) Successful in 1m19s
Continuous Integration / backend-build (pull_request) Successful in 1m53s
Continuous Integration / vulnerability-scan (pull_request) Successful in 2m0s
Continuous Integration / frontend-prepare (pull_request) Successful in 2m25s
Continuous Integration / frontend-build (pull_request) Canceled after 0s
Continuous Integration / frontend-test (pull_request) Canceled after 0s
Continuous Integration / publish-sls-test (pull_request) Canceled after 0s
Continuous Integration / publish-sls-production (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-test (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-production (pull_request) Canceled after 0s
Continuous Integration / publish-asf-test (pull_request) Canceled after 0s
Continuous Integration / deploy-asf-test (pull_request) Canceled after 0s
Continuous Integration / smoke-sls-test (pull_request) Canceled after 0s
Continuous Integration / smoke-asf-test (pull_request) Canceled after 0s
Continuous Integration / frontend-lint (pull_request) Canceled after 32s
Continuous Integration / backend-test (pull_request) Canceled after 3m42s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 19:55:22 +01:00
co-authored by Claude Sonnet 5.5
parent a045e93105
commit e7443e6e82
6 changed files with 1841 additions and 1841 deletions
+10 -17
View File
@@ -155,7 +155,7 @@ function HeroEditor({ hero }: { hero: HeroAdminDto }) {
const [batch, setBatch] = useState<string[]>([]);
const [recutIds, setRecutIds] = useState<string[]>([]);
// The slide (by position) whose photo is being chosen from the library.
const [libraryFor, setLibraryFor] = useState<number | null>(null);
const [adding, setAdding] = useState(false);
const fileInput = useRef<HTMLInputElement>(null);
const {
@@ -271,18 +271,16 @@ function HeroEditor({ hero }: { hero: HeroAdminDto }) {
return () => window.removeEventListener('beforeunload', warn);
}, [hasUnsaved]);
// A photo chosen from the library (or uploaded in the picker) becomes the photo of that slide: only the image id of the
// slide changes (no new data model). The photo is the same photo wherever it is used, so its crop is shared.
// "Add slide": a photo chosen from the library, or uploaded in the picker (it then also lands in the library), becomes a NEW
// slide with exactly that one photo. A slide's photo is never changed afterwards: remove the slide and add another.
const queryClient = useQueryClient();
const chooseForSlide = async (index: number, imageId: string, uploaded?: HeroImageDto) => {
const current = watchedSlides[index];
if (!current) return;
const addSlideWithPhoto = async (imageId: string, uploaded?: HeroImageDto) => {
try {
const image: HeroImageDto = uploaded ?? ((await queryClient.fetchQuery(heroImageQuery(imageId))) as HeroImageDto);
setLocalImages((cur) => ({ ...cur, [image.id]: image }));
if (uploaded && image.processing) setBatch((cur) => (cur.some((id) => images[id]?.processing) ? [...cur, image.id] : [image.id]));
if (image.id !== current.imageId) slides.update(index, { ...current, imageId: image.id });
setLibraryFor(null);
slides.append({ id: null, imageId: image.id, alt: '', decorative: false, isActive: true }, { shouldFocus: false });
setAdding(false);
} catch (error) {
setServerError(serverMessage(error, t('errors.generic'), t('errors.network')));
}
@@ -530,7 +528,7 @@ function HeroEditor({ hero }: { hero: HeroAdminDto }) {
data-testid="hero-upload"
onChange={(event) => void onFiles(event.target.files)}
/>
<Button type="button" variant="outline" disabled={uploading} onClick={() => fileInput.current?.click()} data-testid="hero-upload-button">
<Button type="button" variant="outline" disabled={uploading} onClick={() => setAdding(true)} data-testid="hero-upload-button">
<ImagePlus className="mr-2 size-4" aria-hidden="true" />
{uploading ? t('hero.slides.uploading') : t('hero.slides.add')}
</Button>
@@ -574,9 +572,6 @@ function HeroEditor({ hero }: { hero: HeroAdminDto }) {
<div className="flex h-20 w-28 items-center justify-center rounded bg-muted text-xs">?</div>
)}
<DoneStatus done={Boolean(image && justDone[image.id] && !image.processing)} slideNumber={index + 1} testId={`hero-slide-${index}-done`} />
<Button type="button" variant="outline" size="sm" onClick={() => setLibraryFor(index)} data-testid={`hero-slide-${index}-library`}>
{t('hero.library.choose')}
</Button>
{watchedSlides.some((other, otherIndex) => otherIndex !== index && other?.imageId === field.imageId) && (
<p className="max-w-28 text-xs text-muted-foreground" data-testid={`hero-slide-${index}-shared-crop`}>
{t('hero.library.sharedCrop')}
@@ -664,13 +659,11 @@ function HeroEditor({ hero }: { hero: HeroAdminDto }) {
</div>
<LibraryPickerDialog
open={libraryFor !== null}
onOpenChange={(open) => !open && setLibraryFor(null)}
currentImageId={libraryFor !== null ? (watchedSlides[libraryFor]?.imageId ?? null) : null}
onChoose={(imageId, uploaded) => libraryFor !== null && void chooseForSlide(libraryFor, imageId, uploaded)}
open={adding}
onOpenChange={setAdding}
onChoose={(imageId, uploaded) => void addSlideWithPhoto(imageId, uploaded)}
maxUploadBytes={limits?.maxUploadBytes ?? MAX_UPLOAD_BYTES}
limitsText={limits ? t('hero.slides.limits', { formats: limits.formats.join(', '), size: Math.round(limits.maxUploadBytes / (1024 * 1024)), megapixels: limits.maxMegapixels }) : undefined}
slideNumber={(libraryFor ?? 0) + 1}
/>
<FocusDialog
image={focusImageId ? images[focusImageId] ?? null : null}