From c98ac9ae544d3eadc9f7b963d649e88a2ba9d736 Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 30 May 2026 15:31:15 -0500 Subject: [PATCH] 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) --- .../intake/steps/DOTIntakeStep.astro | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/site/src/components/intake/steps/DOTIntakeStep.astro b/site/src/components/intake/steps/DOTIntakeStep.astro index 8a13cbe..a3366ef 100644 --- a/site/src/components/intake/steps/DOTIntakeStep.astro +++ b/site/src/components/intake/steps/DOTIntakeStep.astro @@ -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"; });