import Foundation

@MainActor @Observable
final class GoalsViewModel {
    var goal: DailyGoal = .defaultGoal
    var isLoading = true
    var errorMessage: String?

    private let repo = FitnessRepository.shared

    func load() async {
        isLoading = true
        errorMessage = nil

        do {
            goal = try await repo.goals(for: Date().apiDateString, forceRefresh: true)
        } catch {
            errorMessage = error.localizedDescription
        }

        isLoading = false
    }
}
