Fix kiosk intake routing, view names, and SignalR diagnostics

Three bugs identified:
1. Routing: /Kiosk/Intake/{token}/{action} had no matching route — 4-segment
   URL fell through the default 3-segment {controller}/{action}/{id?} route.
   Added explicit kiosk_intake route in Program.cs.

2. View names: Contact/Job/Terms/Confirmation actions returned View(model)
   which resolved to Views/Kiosk/{Action}.cshtml — those files don't exist.
   Views live in Views/Kiosk/Intake/. Fixed all six return statements.

3. Diagnostics: conn dot now starts gray ("Connecting...") and turns green
   only when SignalR actually connects. Red + message if no company ID or
   connection fails. Makes it easy to confirm the hub connection is live.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 18:28:16 -04:00
parent 350f2d7658
commit 0b24c320cd
4 changed files with 40 additions and 24 deletions
@@ -5,44 +5,54 @@
if (!el) return;
const companyId = el.dataset.companyId;
if (!companyId) return;
const dot = document.getElementById("kiosk-conn-dot");
const label = document.getElementById("kiosk-conn-label");
function setStatus(color, text) {
if (dot) dot.style.background = color;
if (label) label.textContent = text;
}
if (!companyId) {
setStatus("#ef4444", "Not configured (no company ID)");
console.error("KioskHub: data-company-id is empty — kiosk activation may be invalid.");
return;
}
setStatus("#94a3b8", "Connecting…");
const connection = new signalR.HubConnectionBuilder()
.withUrl(`/hubs/kiosk?companyId=${companyId}`)
.withAutomaticReconnect([2000, 5000, 10000, 30000])
.configureLogging(signalR.LogLevel.Warning)
.configureLogging(signalR.LogLevel.Information)
.build();
connection.on("StartIntake", function (sessionToken) {
setStatus("#2563eb", "Starting…");
window.location.href = `/Kiosk/Intake/${sessionToken}/Contact`;
});
async function startConnection() {
try {
await connection.start();
setStatus("#16a34a", "Ready");
console.info("KioskHub connected, group kiosk-" + companyId);
} catch (err) {
console.warn("Kiosk SignalR connect failed, retrying in 10s...", err);
setStatus("#ef4444", "Connection failed retrying…");
console.warn("KioskHub connect failed, retrying in 10s…", err);
setTimeout(startConnection, 10000);
}
}
startConnection();
// Show connection status indicator
connection.onreconnecting(() => {
const dot = document.getElementById("kiosk-conn-dot");
if (dot) dot.style.background = "#f59e0b";
});
connection.onreconnecting(() => setStatus("#f59e0b", "Reconnecting…"));
connection.onreconnected(() => {
const dot = document.getElementById("kiosk-conn-dot");
if (dot) dot.style.background = "#16a34a";
setStatus("#16a34a", "Ready");
console.info("KioskHub reconnected");
});
connection.onclose(() => {
const dot = document.getElementById("kiosk-conn-dot");
if (dot) dot.style.background = "#ef4444";
// Keep retrying
setStatus("#ef4444", "Disconnected — retrying…");
setTimeout(startConnection, 10000);
});
})();