You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
PadelClub/PadelClub/Views/Team/PaymentRequestButton.swift

51 lines
1.3 KiB

//
// PaymentRequestButton.swift
// PadelClub
//
// Created by Razmig Sarkissian on 01/10/2025.
//
import SwiftUI
import PadelClubData
struct PaymentRequestButton: View {
let teamRegistration: TeamRegistration
@State private var isLoading = false
@State private var showAlert = false
@State private var alertMessage = ""
var body: some View {
Button("Renvoyer email de paiement") {
resendEmail()
}
.disabled(isLoading)
.alert("Résultat", isPresented: $showAlert) {
Button("OK") { }
} message: {
Text(alertMessage)
}
}
private func resendEmail() {
isLoading = true
Task {
do {
let response = try await PaymentService.resendPaymentEmail(
teamRegistrationId: teamRegistration.id
)
await MainActor.run {
isLoading = false
alertMessage = response.message
showAlert = true
}
} catch {
await MainActor.run {
isLoading = false
alertMessage = "Erreur lors de l'envoi"
showAlert = true
}
}
}
}
}