Real-time SMS consent status update on customer record

When kiosk consent is completed, the staff-facing customer Details page
now updates the SMS badge instantly via SignalR — no page refresh needed.
Added customerId to the NewInAppNotification SignalR payload so the
KioskConsent handler can match the current URL and swap the badge in place.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 23:40:47 -04:00
parent 0af31c39b3
commit a73f14fa7f
4 changed files with 21 additions and 1 deletions
@@ -72,6 +72,7 @@ public class InAppNotificationService : IInAppNotificationService
message = notification.Message,
link = notification.Link,
notificationType = notification.NotificationType,
customerId = notification.CustomerId,
createdAt = now.ToString("o")
});
}
@@ -173,6 +173,7 @@
<i class="bi bi-envelope-slash me-1"></i>Email off
</span>
}
<span id="sms-status-section">
@if (Model.NotifyBySms)
{
<span class="badge bg-success bg-opacity-10 text-success border border-success border-opacity-25"
@@ -200,6 +201,7 @@
<i class="bi bi-x-circle me-1"></i>Cancel Consent
</button>
}
</span>
</div>
</div>
</div>
@@ -1914,7 +1914,8 @@
const icons = {
QuoteApproved: { icon: 'bi-check-circle-fill', cls: 'success', title: 'Quote Approved' },
QuoteDeclined: { icon: 'bi-x-circle-fill', cls: 'danger', title: 'Quote Declined' },
InvoicePaid: { icon: 'bi-cash-coin', cls: 'primary', title: 'Payment Received' }
InvoicePaid: { icon: 'bi-cash-coin', cls: 'primary', title: 'Payment Received' },
KioskConsent: { icon: 'bi-chat-fill', cls: 'success', title: 'SMS Consent' }
};
const t = icons[data.notificationType] || { icon: 'bi-bell', cls: 'info', title: 'Notification' };
toastr[t.cls === 'danger' ? 'warning' : t.cls === 'primary' ? 'info' : 'success'](
@@ -1922,6 +1923,12 @@
`<i class="bi ${t.icon} me-1"></i>${t.title}`,
{ timeOut: 10000, extendedTimeOut: 3000, closeButton: true, enableHtml: true }
);
if (data.notificationType === 'KioskConsent' && data.customerId) {
const path = window.location.pathname.toLowerCase();
if (path === `/customers/details/${data.customerId}`) {
window.updateCustomerSmsStatus?.();
}
}
});
connection.start().catch(err => console.warn('SignalR connection failed:', err));
@@ -37,3 +37,13 @@ async function cancelSmsConsent() {
toastr.error('An error occurred. Please try again.');
}
}
window.updateCustomerSmsStatus = function () {
const section = document.getElementById('sms-status-section');
if (!section) return;
const today = new Date().toLocaleDateString('en-US', { month: '2-digit', day: '2-digit', year: 'numeric' });
section.innerHTML = `<span class="badge bg-success bg-opacity-10 text-success border border-success border-opacity-25"
title="Consented ${today}">
<i class="bi bi-chat-fill me-1"></i>SMS on
</span>`;
};