import SwiftUI struct DepotstandAdd: View { @StateObject private var DATA = DataService() @Binding var isPresented: Bool @Binding var depot_id: Int @Binding var date: Date @Binding var amount: Double var body: some View { VStack { VStack { Text("Neuer Depostand") .font(.system(size: 20, weight: .bold)) .padding() } Form { Section { VStack(alignment: .leading) { Text("Datum") .font(.callout) .bold() .padding(.top) HStack { Spacer() DatePicker("Datum", selection: $date, in: ...Date(), displayedComponents: .date) .datePickerStyle(.wheel) .labelsHidden() Spacer() } } } Section { VStack(alignment: .leading) { Text("Betrag in CHF") .font(.callout) .bold() .padding(.top) TextField("Bitte Betrag eingeben", value: $amount, format: .number) .keyboardType(.decimalPad) .textFieldStyle(.roundedBorder) .padding(.bottom) } } } Spacer() Button { Task { let parameters: [String: Any] = [ "depot_id": depot_id, "date": DateFormat(datum: date, format: "yyyy-MM-dd").description, "amount": amount ] //print(DATA.sortedDatapoints.first!.amount) await DATA.createDepotStand(parameters: parameters) await DATA.readDepot(id: depot_id) print(DATA.sortedDatapoints[0].amount) isPresented = false } } label: { HStack { Image(systemName: "plus") Text("Depotstand hinzufügen") .bold() } } .padding(.vertical) Button { isPresented = false } label: { Text("Abbrechen") } .padding(.bottom) } } }