|
|
|
|
@ -33,24 +33,7 @@ struct CourtAvailabilitySettingsView: View { |
|
|
|
|
if let dates = courtsUnavailability[key] { |
|
|
|
|
Section { |
|
|
|
|
ForEach(dates) { dateInterval in |
|
|
|
|
HStack { |
|
|
|
|
VStack(alignment: .leading, spacing: 0) { |
|
|
|
|
Text(dateInterval.startDate.localizedTime()).font(.largeTitle) |
|
|
|
|
Text(dateInterval.startDate.localizedDay()).font(.caption) |
|
|
|
|
} |
|
|
|
|
Spacer() |
|
|
|
|
VStack { |
|
|
|
|
Image(systemName: "arrowshape.forward.fill") |
|
|
|
|
.tint(.master) |
|
|
|
|
Text("indisponible").foregroundStyle(.red).font(.caption) |
|
|
|
|
} |
|
|
|
|
Spacer() |
|
|
|
|
VStack(alignment: .trailing, spacing: 0) { |
|
|
|
|
Text(dateInterval.endDate.localizedTime()).font(.largeTitle) |
|
|
|
|
Text(dateInterval.endDate.localizedDay()).font(.caption) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.contextMenu(menuItems: { |
|
|
|
|
Menu { |
|
|
|
|
Button("dupliquer") { |
|
|
|
|
let duplicatedDateInterval = DateInterval(event: event.id, courtIndex: (courtIndex+1)%tournament.courtCount, startDate: dateInterval.startDate, endDate: dateInterval.endDate) |
|
|
|
|
try? dataStore.dateIntervals.addOrUpdate(instance: duplicatedDateInterval) |
|
|
|
|
@ -65,7 +48,25 @@ struct CourtAvailabilitySettingsView: View { |
|
|
|
|
Button("effacer", role: .destructive) { |
|
|
|
|
try? dataStore.dateIntervals.delete(instance: dateInterval) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} label: { |
|
|
|
|
HStack { |
|
|
|
|
VStack(alignment: .leading, spacing: 0) { |
|
|
|
|
Text(dateInterval.startDate.localizedTime()).font(.largeTitle) |
|
|
|
|
Text(dateInterval.startDate.localizedDay()).font(.caption) |
|
|
|
|
} |
|
|
|
|
Spacer() |
|
|
|
|
VStack { |
|
|
|
|
Image(systemName: "arrowshape.forward.fill") |
|
|
|
|
.tint(.master) |
|
|
|
|
Text("indisponible").foregroundStyle(.red).font(.caption) |
|
|
|
|
} |
|
|
|
|
Spacer() |
|
|
|
|
VStack(alignment: .trailing, spacing: 0) { |
|
|
|
|
Text(dateInterval.endDate.localizedTime()).font(.largeTitle) |
|
|
|
|
Text(dateInterval.endDate.localizedDay()).font(.caption) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.swipeActions { |
|
|
|
|
Button(role: .destructive) { |
|
|
|
|
try? dataStore.dateIntervals.delete(instance: dateInterval) |
|
|
|
|
@ -95,6 +96,8 @@ struct CourtAvailabilitySettingsView: View { |
|
|
|
|
Text("Vous pouvez précisez l'indisponibilité d'une ou plusieurs terrains, que ce soit pour une journée entière ou un créneau précis.") |
|
|
|
|
} actions: { |
|
|
|
|
RowButtonView("Ajouter une indisponibilité", systemImage: "plus.circle.fill") { |
|
|
|
|
startDate = tournament.startDate |
|
|
|
|
endDate = tournament.startDate.addingTimeInterval(5400) |
|
|
|
|
showingPopover = true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|