Refactor: Eliminate duplicate types - Use handler types directly

- Deleted templates.CollectionDetailData - using templates.CollectionData everywhere
- Deleted templates.BookData - using handlers.BookInfo everywhere
- Deleted templates.DeviceData - using handlers.DeviceInfo everywhere
- Deleted templates.ProgressItemData - using handlers.ProgressWithMedia everywhere
- Deleted templates.convertDevices() helper - Use handlers types directly in templates
- Enhanced handlers.ProgressWithMedia with device metadata fields
- Added handlers.getDeviceIcon() helper
- Updated all templates to import handlers package
- Cleaned up unused imports

This aligns codebase with templ's design philosophy (use Go types directly, no parallel type system)
This commit is contained in:
2026-02-12 19:48:07 -05:00
parent b5745e1554
commit 2a64ca423f
15 changed files with 639 additions and 168 deletions
-25
View File
@@ -2,9 +2,7 @@ package router
import (
"context"
"time"
"bookhoard/internal/handlers"
"bookhoard/templates"
"github.com/google/uuid"
@@ -43,29 +41,6 @@ func getTemplateUserWithTheme(c echo.Context, cfg *Config) (templates.User, erro
}, nil
}
func convertDevices(deviceInfos []handlers.DeviceInfo) []templates.DeviceData {
result := make([]templates.DeviceData, len(deviceInfos))
for i, d := range deviceInfos {
lastSync := ""
if d.LastSync != nil {
lastSync = d.LastSync.Format(time.RFC3339)
}
lastSeen := ""
if d.LastSeen != nil {
lastSeen = d.LastSeen.Format(time.RFC3339)
}
result[i] = templates.DeviceData{
ID: d.ID.String(),
DeviceName: d.DeviceName,
DeviceType: d.DeviceType,
SyncEnabled: d.SyncEnabled,
LastSync: lastSync,
LastSeen: lastSeen,
}
}
return result
}
func convertPending(pending []map[string]interface{}) []templates.PendingRegistrationData {
result := make([]templates.PendingRegistrationData, len(pending))
for i, p := range pending {