Fix DOT intake crash: null-safe photo ID element refs
Script crashed on 'Cannot read properties of null' because photo ID elements are inside a hidden section. All element refs now use optional chaining instead of non-null assertions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d55384975e
commit
c98ac9ae54
1 changed files with 11 additions and 11 deletions
|
|
@ -391,12 +391,12 @@
|
|||
}});
|
||||
});
|
||||
|
||||
// Photo ID upload
|
||||
const idBtn = document.getElementById("dot-id-btn")!;
|
||||
const idInput = document.getElementById("dot-photo-id") as HTMLInputElement;
|
||||
const idPreview = document.getElementById("dot-id-preview")!;
|
||||
const idImg = document.getElementById("dot-id-img") as HTMLImageElement;
|
||||
const idRemove = document.getElementById("dot-id-remove")!;
|
||||
// Photo ID upload (elements may not exist if section is hidden)
|
||||
const idBtn = document.getElementById("dot-id-btn");
|
||||
const idInput = document.getElementById("dot-photo-id") as HTMLInputElement | null;
|
||||
const idPreview = document.getElementById("dot-id-preview");
|
||||
const idImg = document.getElementById("dot-id-img") as HTMLImageElement | null;
|
||||
const idRemove = document.getElementById("dot-id-remove");
|
||||
idBtn?.addEventListener("click", () => idInput?.click());
|
||||
idInput?.addEventListener("change", () => {
|
||||
const file = idInput.files?.[0];
|
||||
|
|
@ -407,13 +407,13 @@
|
|||
reader.onload = (e) => { idImg.src = e.target?.result as string; };
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
idPreview.hidden = false;
|
||||
idBtn.style.display = "none";
|
||||
if (idPreview) idPreview.hidden = false;
|
||||
if (idBtn) idBtn.style.display = "none";
|
||||
});
|
||||
idRemove?.addEventListener("click", () => {
|
||||
(window as any).__dotPhotoId = null;
|
||||
idInput.value = "";
|
||||
idPreview.hidden = true;
|
||||
idBtn.style.display = "flex";
|
||||
if (idInput) idInput.value = "";
|
||||
if (idPreview) idPreview.hidden = true;
|
||||
if (idBtn) idBtn.style.display = "flex";
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue