import AppIntents
import WidgetKit

struct NewWordIntent: AppIntent {
    static let title: LocalizedStringResource = "New Word"
    static let description: IntentDescription = "Show a different word of the day"

    func perform() async throws -> some IntentResult {
        let shared = UserDefaults(suiteName: "group.com.conjuga.app")
        let current = shared?.integer(forKey: "wordOffset") ?? 0
        shared?.set(current + 1, forKey: "wordOffset")
        WidgetCenter.shared.reloadAllTimelines()
        return .result()
    }
}
