Skip to content

fix: Dashboard Widget Data Display Fixes#8

Merged
christag merged 1 commit intomainfrom
feature/dashboard-widget-fixes
Oct 28, 2025
Merged

fix: Dashboard Widget Data Display Fixes#8
christag merged 1 commit intomainfrom
feature/dashboard-widget-fixes

Conversation

@christag
Copy link
Copy Markdown
Owner

Summary

Fixes dashboard widget APIs to return complete data with proper column names expected by the frontend. This resolves the "Dashboard Widget Fixes - 500 errors" item from the TODO list (though the issue was actually incomplete data, not 500 errors).

Problem

The three expiring items widgets on the dashboard were displaying incomplete/empty data because of column name mismatches between the frontend components and the API responses:

  • Expiring Warranties: Frontend expected device_name, but API only returned hostname
  • Expiring Licenses: Frontend expected license_name and vendor, but API didn't JOIN with software or companies tables
  • Expiring Contracts: Frontend expected contract_title and vendor, but API only returned contract_name without vendor JOIN

Changes

1. Expiring Warranties API (src/app/api/dashboard/expiring-warranties/route.ts)

  • Added column alias: d.hostname as device_name
  • Frontend now receives the expected device_name field

2. Expiring Licenses API (src/app/api/dashboard/expiring-licenses/route.ts)

  • Added JOIN with software table: LEFT JOIN software s ON sl.software_id = s.id
  • Added JOIN with companies table: LEFT JOIN companies c ON sl.purchased_from_id = c.id
  • Added column aliases:
    • s.product_name as license_name
    • c.company_name as vendor
  • Frontend now receives complete license information

3. Expiring Contracts API (src/app/api/dashboard/expiring-contracts/route.ts)

  • Added JOIN with companies table: LEFT JOIN companies co ON c.company_id = co.id
  • Added column aliases:
    • c.contract_name as contract_title
    • co.company_name as vendor
  • Frontend now receives complete contract information

Testing

  • ✅ Build passes with 0 errors
  • ✅ Lint passes (2 warnings, max 20 allowed)
  • ✅ Manual testing via Playwright: All three widgets load without errors
  • ✅ Verified proper empty state messages when no data exists
  • ✅ No console errors related to dashboard widgets
  • ✅ TypeScript interfaces already support all returned fields (no updates needed)

Screenshots

Dashboard showing all three widgets with proper empty states:
Dashboard Widgets

Impact

  • User Experience: Widgets will now display complete information including device names, license names, contract titles, and vendor information
  • API Consistency: All dashboard APIs now return complete data sets with proper column naming
  • Performance: LEFT JOINs are efficient and don't impact query performance significantly

Files Modified

  • src/app/api/dashboard/expiring-warranties/route.ts - Added column alias
  • src/app/api/dashboard/expiring-licenses/route.ts - Added JOINs and aliases
  • src/app/api/dashboard/expiring-contracts/route.ts - Added JOIN and aliases

Verification Steps

  1. Navigate to dashboard (/)
  2. Check "Expiring Warranties" widget - should show device names when data exists
  3. Check "Expiring Licenses" widget - should show license names and vendors when data exists
  4. Check "Expiring Contracts" widget - should show contract titles and vendors when data exists
  5. Verify no console errors

🤖 Generated with Claude Code

**Problem**: Dashboard widgets (Expiring Warranties, Licenses, Contracts) were
displaying incomplete data due to column name mismatches between frontend and API.

**Changes**:
- Expiring Warranties API: Added `hostname as device_name` alias
- Expiring Licenses API: Added JOIN with `software` table for `product_name as license_name`
  and `companies` table for vendor name
- Expiring Contracts API: Added `contract_name as contract_title` alias and
  JOIN with `companies` table for vendor name

**Testing**: Verified all three widgets load without errors and display proper
empty states when no data exists. Build passing with 0 errors.

**Files Modified**:
- src/app/api/dashboard/expiring-warranties/route.ts
- src/app/api/dashboard/expiring-licenses/route.ts
- src/app/api/dashboard/expiring-contracts/route.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@christag christag merged commit 055d27f into main Oct 28, 2025
0 of 2 checks passed
@christag christag deleted the feature/dashboard-widget-fixes branch October 28, 2025 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant