//
//  DateMenuView.swift
//  PadelClub
//
//  Created by razmig on 22/11/2024.
//


import SwiftUI

struct DateMenuView: View {
    @Binding var date: Date
    
    private func adjustDate(byDays days: Int) {
        let calendar = Calendar.current
        if let newDate = calendar.date(byAdding: .day, value: days, to: date) {
            date = newDate.truncateMinutesAndSeconds()
        }
    }
    
    var body: some View {
        Menu {
            Button("24h avant") { adjustDate(byDays: -1) }
            Button("48h avant") { adjustDate(byDays: -2) }
            Divider()
            Button("24h après") { adjustDate(byDays: 1) }
            Button("48h après") { adjustDate(byDays: 2) }
        } label: {
            Text("Ajuster")
                .underline()
        }
    }
}
