- Replace 5-tab layout with 4 tabs: Dashboard, Timer, Entries, Settings - Dashboard: add Work Time Balance section using /client-targets API, showing per-client weekly progress bar, overtime/undertime label and expandable week breakdown - Time Entries: replace flat list with UICalendarView month grid; tap a day to see that day's entries; add filter sheet (date range, project, client); new TimeEntryDetailSheet for creating and editing entries; duration shown as Xh Ymin - Settings tab: user info header, navigation to Clients and Projects, logout button - ClientsListView: list with NavigationLink to ClientDetailView - ClientDetailView: inline client editing + full work time target CRUD (create, edit, delete target; add/delete balance corrections with date, hours, description) - ProjectsListView: grouped by client, NavigationLink to ProjectDetailView - ProjectDetailView: edit name, description, colour, client assignment - Add ClientTarget, WeekBalance, BalanceCorrection models and APIEndpoints for /client-targets routes - Update TimeInterval formatter: add formattedShortDuration (Xh Ymin / Xmin / <1min) used throughout app; keep formattedDuration for live timer display
63 lines
1.5 KiB
Swift
63 lines
1.5 KiB
Swift
import Foundation
|
|
|
|
// MARK: - Client Target
|
|
|
|
struct ClientTarget: Codable, Identifiable, Equatable {
|
|
let id: String
|
|
let clientId: String
|
|
let clientName: String
|
|
let userId: String
|
|
let weeklyHours: Double
|
|
let startDate: String // "YYYY-MM-DD"
|
|
let createdAt: String
|
|
let updatedAt: String
|
|
let corrections: [BalanceCorrection]
|
|
|
|
// Computed balance fields returned by the API
|
|
let totalBalanceSeconds: Int
|
|
let currentWeekTrackedSeconds: Int
|
|
let currentWeekTargetSeconds: Int
|
|
let weeks: [WeekBalance]
|
|
}
|
|
|
|
// MARK: - Week Balance
|
|
|
|
struct WeekBalance: Codable, Identifiable, Equatable {
|
|
var id: String { weekStart }
|
|
let weekStart: String // "YYYY-MM-DD"
|
|
let weekEnd: String
|
|
let trackedSeconds: Int
|
|
let targetSeconds: Int
|
|
let correctionHours: Double
|
|
let balanceSeconds: Int
|
|
}
|
|
|
|
// MARK: - Balance Correction
|
|
|
|
struct BalanceCorrection: Codable, Identifiable, Equatable {
|
|
let id: String
|
|
let date: String // "YYYY-MM-DD"
|
|
let hours: Double
|
|
let description: String?
|
|
let createdAt: String
|
|
}
|
|
|
|
// MARK: - Input Types
|
|
|
|
struct CreateClientTargetInput: Codable {
|
|
let clientId: String
|
|
let weeklyHours: Double
|
|
let startDate: String // "YYYY-MM-DD", must be a Monday
|
|
}
|
|
|
|
struct UpdateClientTargetInput: Codable {
|
|
let weeklyHours: Double?
|
|
let startDate: String?
|
|
}
|
|
|
|
struct CreateBalanceCorrectionInput: Codable {
|
|
let date: String // "YYYY-MM-DD"
|
|
let hours: Double
|
|
let description: String?
|
|
}
|