From 7665fc75a086740c2f5afe8d0c07f819fd27cbe5 Mon Sep 17 00:00:00 2001 From: Nicolas CARON Date: Wed, 4 Dec 2024 18:21:29 +0100 Subject: [PATCH] Edit diags handlers --- handlers/application/diags.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/handlers/application/diags.go b/handlers/application/diags.go index cf192ff..cbe75b3 100644 --- a/handlers/application/diags.go +++ b/handlers/application/diags.go @@ -91,14 +91,12 @@ func (h *ApplicationHandler) BeneficiariesCreateDiag(w http.ResponseWriter, r *h if r.Method == http.MethodPost { - // Récupérer le groupe courant g := r.Context().Value(identification.GroupKey) if g == nil { http.Error(w, "Missing group information", http.StatusBadRequest) return } - // Parse le formulaire diagForm, err := parseDiagsForm(r) if err != nil { log.Error().Err(err).Msg("Invalid form data") @@ -108,7 +106,6 @@ func (h *ApplicationHandler) BeneficiariesCreateDiag(w http.ResponseWriter, r *h log.Debug().Interface("diagForm", diagForm).Msg("Form data parsed") - // Préparation des données supplémentaires data, err := structpb.NewStruct(map[string]any{ "beneficiary": beneficiaryID, }) @@ -118,7 +115,6 @@ func (h *ApplicationHandler) BeneficiariesCreateDiag(w http.ResponseWriter, r *h return } - // Crée la requête gRPC pour créer le diagnostic request := &diags.CreateDiagRequest{ Diag: &diags.Diag{ Name: diagForm.Name, @@ -130,7 +126,6 @@ func (h *ApplicationHandler) BeneficiariesCreateDiag(w http.ResponseWriter, r *h }, } - // Appelle le service gRPC resp, err := h.services.GRPC.Diags.CreateDiag(context.TODO(), request) if err != nil { log.Error().Err(err).Msg("Failed to create diagnostic") @@ -138,8 +133,7 @@ func (h *ApplicationHandler) BeneficiariesCreateDiag(w http.ResponseWriter, r *h return } - // Redirection après succès - http.Redirect(w, r, fmt.Sprintf("/app/benefeciaries/%s", resp.Diag), http.StatusFound) + http.Redirect(w, r, fmt.Sprintf("/app/diags/%s", resp.Diag.Id), http.StatusFound) return }