Fix HUD business name - get from listPending API

The previous approach called getBusiness which requires auth.
Now listPending returns BUSINESS_NAME and HUD uses that.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-01-19 20:33:09 -08:00
parent 30570c3772
commit 3df846a31b
2 changed files with 16 additions and 25 deletions

View file

@ -35,6 +35,13 @@
</cfif>
<cftry>
<!--- Get business name --->
<cfset qBusiness = queryExecute("
SELECT BusinessName FROM Businesses WHERE BusinessID = ?
", [ { value = BusinessID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
<cfset businessName = qBusiness.recordCount GT 0 ? qBusiness.BusinessName : "">
<!--- Build WHERE clause - unclaimed tasks only --->
<cfset whereClauses = ["t.TaskBusinessID = ?", "t.TaskClaimedByUserID = 0"]>
<cfset params = [ { value = BusinessID, cfsqltype = "cf_sql_integer" } ]>
@ -101,7 +108,8 @@
"OK": true,
"ERROR": "",
"TASKS": tasks,
"COUNT": arrayLen(tasks)
"COUNT": arrayLen(tasks),
"BUSINESS_NAME": businessName
})>
<cfcatch>

View file

@ -39,10 +39,7 @@ const HUD = {
setInterval(() => this.updateBars(), 1000);
setInterval(() => this.fetchTasks(), 3000);
// Fetch business name
this.fetchBusinessName();
// Initial fetch
// Initial fetch (also gets business name)
this.fetchTasks();
// Close overlay on background tap
@ -64,26 +61,6 @@ const HUD = {
document.getElementById('clock').textContent = `${hours}:${minutes}:${seconds}`;
},
// Fetch business name from API
async fetchBusinessName() {
try {
const response = await fetch('/api/setup/getBusiness.cfm', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ BusinessID: this.config.businessId })
});
const data = await response.json();
if (data.OK && data.BUSINESS && data.BUSINESS.BusinessName) {
this.businessName = data.BUSINESS.BusinessName;
document.getElementById('businessName').textContent = ' - ' + this.businessName;
}
} catch (err) {
console.error('[HUD] Error fetching business name:', err);
}
},
// Fetch tasks from API
async fetchTasks() {
try {
@ -99,6 +76,12 @@ const HUD = {
this.tasks = data.TASKS || [];
this.renderTasks();
this.setConnected(true);
// Update business name from response
if (data.BUSINESS_NAME && !this.businessName) {
this.businessName = data.BUSINESS_NAME;
document.getElementById('businessName').textContent = ' - ' + this.businessName;
}
} else {
console.error('[HUD] API error:', data.ERROR);
this.setConnected(false);