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:
parent
30570c3772
commit
3df846a31b
2 changed files with 16 additions and 25 deletions
|
|
@ -35,6 +35,13 @@
|
||||||
</cfif>
|
</cfif>
|
||||||
|
|
||||||
<cftry>
|
<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 --->
|
<!--- Build WHERE clause - unclaimed tasks only --->
|
||||||
<cfset whereClauses = ["t.TaskBusinessID = ?", "t.TaskClaimedByUserID = 0"]>
|
<cfset whereClauses = ["t.TaskBusinessID = ?", "t.TaskClaimedByUserID = 0"]>
|
||||||
<cfset params = [ { value = BusinessID, cfsqltype = "cf_sql_integer" } ]>
|
<cfset params = [ { value = BusinessID, cfsqltype = "cf_sql_integer" } ]>
|
||||||
|
|
@ -101,7 +108,8 @@
|
||||||
"OK": true,
|
"OK": true,
|
||||||
"ERROR": "",
|
"ERROR": "",
|
||||||
"TASKS": tasks,
|
"TASKS": tasks,
|
||||||
"COUNT": arrayLen(tasks)
|
"COUNT": arrayLen(tasks),
|
||||||
|
"BUSINESS_NAME": businessName
|
||||||
})>
|
})>
|
||||||
|
|
||||||
<cfcatch>
|
<cfcatch>
|
||||||
|
|
|
||||||
31
hud/hud.js
31
hud/hud.js
|
|
@ -39,10 +39,7 @@ const HUD = {
|
||||||
setInterval(() => this.updateBars(), 1000);
|
setInterval(() => this.updateBars(), 1000);
|
||||||
setInterval(() => this.fetchTasks(), 3000);
|
setInterval(() => this.fetchTasks(), 3000);
|
||||||
|
|
||||||
// Fetch business name
|
// Initial fetch (also gets business name)
|
||||||
this.fetchBusinessName();
|
|
||||||
|
|
||||||
// Initial fetch
|
|
||||||
this.fetchTasks();
|
this.fetchTasks();
|
||||||
|
|
||||||
// Close overlay on background tap
|
// Close overlay on background tap
|
||||||
|
|
@ -64,26 +61,6 @@ const HUD = {
|
||||||
document.getElementById('clock').textContent = `${hours}:${minutes}:${seconds}`;
|
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
|
// Fetch tasks from API
|
||||||
async fetchTasks() {
|
async fetchTasks() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -99,6 +76,12 @@ const HUD = {
|
||||||
this.tasks = data.TASKS || [];
|
this.tasks = data.TASKS || [];
|
||||||
this.renderTasks();
|
this.renderTasks();
|
||||||
this.setConnected(true);
|
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 {
|
} else {
|
||||||
console.error('[HUD] API error:', data.ERROR);
|
console.error('[HUD] API error:', data.ERROR);
|
||||||
this.setConnected(false);
|
this.setConnected(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue