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.
51 lines
1.5 KiB
51 lines
1.5 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 {
|
|
FooterButtonView("Renvoyer l'email de paiement", role: .destructive, confirmationMessage: "Cette action permet de renvoyer le mail de confirmation de sélection de l'équipe incluant la demande du 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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|