fix: mobile dashboard priority labels now join priorities table
- API: replaced hardcoded wrong map (1=Critical etc) with JOIN on priorities table - API: sorted by count DESC instead of priority value - Frontend: PRIORITY_COLOR/TEXT maps updated to cover all 10 actual Autotask values (1-11) - Middleware: added /api/mobile to publicRoutes (was getting auth-redirected)
This commit is contained in:
parent
5be7b22953
commit
5719daa84b
3 changed files with 26 additions and 6 deletions
|
|
@ -17,10 +17,11 @@ export async function GET() {
|
|||
GROUP BY t.queue_id, q.label ORDER BY count DESC LIMIT 8
|
||||
`),
|
||||
postgresClient.query(`
|
||||
SELECT t.priority, COUNT(*) as count
|
||||
SELECT t.priority, p.label, COUNT(*) as count
|
||||
FROM tickets t
|
||||
LEFT JOIN priorities p ON p.value = t.priority
|
||||
WHERE t.status != 5 AND t.is_deleted = false
|
||||
GROUP BY t.priority ORDER BY t.priority
|
||||
GROUP BY t.priority, p.label ORDER BY count DESC
|
||||
`),
|
||||
postgresClient.query(`
|
||||
SELECT t.id, t.ticket_number, t.title, t.status, t.priority,
|
||||
|
|
@ -55,7 +56,6 @@ export async function GET() {
|
|||
56: 'Waiting Vendor', 58: 'Waiting Parts', 59: 'Pending Approval',
|
||||
60: 'In Deployment', 66: 'Closed', 68: 'Resolved', 70: 'Customer Follow-Up', 71: 'Archived',
|
||||
};
|
||||
const priorityLabels: Record<number, string> = { 1: 'Critical', 2: 'High', 3: 'Medium', 4: 'Low' };
|
||||
|
||||
const slaRow = sla.rows[0];
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ export async function GET() {
|
|||
})),
|
||||
by_priority: byPriority.rows.map(r => ({
|
||||
priority: parseInt(r.priority),
|
||||
label: priorityLabels[r.priority] ?? `P${r.priority}`,
|
||||
label: r.label ?? `P${r.priority}`,
|
||||
count: parseInt(r.count),
|
||||
})),
|
||||
recent: recentActivity.rows,
|
||||
|
|
|
|||
|
|
@ -17,10 +17,28 @@ interface DashboardData {
|
|||
}
|
||||
|
||||
const PRIORITY_COLOR: Record<number, string> = {
|
||||
1: 'bg-red-500', 2: 'bg-orange-400', 3: 'bg-yellow-400', 4: 'bg-slate-300',
|
||||
1: 'bg-slate-300', // Standard
|
||||
2: 'bg-slate-300', // Medium
|
||||
3: 'bg-slate-300', // Standard
|
||||
4: 'bg-red-500', // Critical
|
||||
6: 'bg-orange-400', // High
|
||||
7: 'bg-purple-500', // Security Event
|
||||
8: 'bg-yellow-400', // Minor Service
|
||||
9: 'bg-orange-500', // Major Service
|
||||
10: 'bg-blue-400', // Installation
|
||||
11: 'bg-pink-400', // Fast Track
|
||||
};
|
||||
const PRIORITY_TEXT: Record<number, string> = {
|
||||
1: 'text-red-600', 2: 'text-orange-500', 3: 'text-yellow-600', 4: 'text-slate-500',
|
||||
1: 'text-slate-500', // Standard
|
||||
2: 'text-slate-500', // Medium
|
||||
3: 'text-slate-500', // Standard
|
||||
4: 'text-red-600', // Critical
|
||||
6: 'text-orange-500', // High
|
||||
7: 'text-purple-600', // Security Event
|
||||
8: 'text-yellow-600', // Minor Service
|
||||
9: 'text-orange-600', // Major Service
|
||||
10: 'text-blue-600', // Installation
|
||||
11: 'text-pink-600', // Fast Track
|
||||
};
|
||||
|
||||
function pct(n: number, d: number) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ const publicRoutes = [
|
|||
"/api/integrations/status",
|
||||
// Legal pages required by Intuit
|
||||
"/legal",
|
||||
// Mobile app API endpoints
|
||||
"/api/mobile",
|
||||
// OpenClaw external agent API (auth via x-openclaw-key header)
|
||||
"/api/openclaw",
|
||||
// Sync endpoints called by scheduler
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue