diff --git a/handlers/application/support.go b/handlers/application/support.go new file mode 100644 index 0000000..e842b72 --- /dev/null +++ b/handlers/application/support.go @@ -0,0 +1,45 @@ +package application + +import ( + "fmt" + "net/http" + + "git.coopgo.io/coopgo-apps/parcoursmob/utils/identification" +) + +type Message struct { + Content string +} + +func (h *ApplicationHandler) SupportSend(w http.ResponseWriter, r *http.Request) { + + c := r.Context().Value(identification.ClaimsKey) + if c == nil { + fmt.Println("no current user claims") + w.WriteHeader(http.StatusInternalServerError) + return + } + current_user_claims := c.(map[string]any) + + comment := r.PostFormValue(("comment")) + + if r.Method == "POST" { + data := map[string]any{ + "key": comment, + "user": current_user_claims["email"], + } + + if err := h.emailing.Send("onboarding.Support_email", "support@parcoursmob.fr", data); err != nil { + fmt.Println(err) + fmt.Println("error") + } + fmt.Println("success") + http.Redirect(w, r, "/app/", http.StatusFound) + return + } + + fmt.Println("comment page!") + fmt.Println(comment) + fmt.Print(current_user_claims["email"]) + h.Renderer.SupportSend(w, r, comment, current_user_claims) +} diff --git a/renderer/support.go b/renderer/support.go new file mode 100644 index 0000000..e4dd151 --- /dev/null +++ b/renderer/support.go @@ -0,0 +1,19 @@ +package renderer + +import ( + "net/http" +) + +const commentMenu = "comment" +const commentsend = "sendComment" + +func (renderer *Renderer) SupportSend(w http.ResponseWriter, r *http.Request, comment any, admins any) { + + files := renderer.ThemeConfig.GetStringSlice("views.support.search.files") + state := NewState(r, renderer.ThemeConfig, commentMenu) + state.ViewState = map[string]any{ + "comment": comment, + "admins": admins, + } + renderer.Render("comment", w, r, files, state) +} diff --git a/themes/default/emails/onboarding/support_emailing.html b/themes/default/emails/onboarding/support_emailing.html new file mode 100644 index 0000000..40ea8c7 --- /dev/null +++ b/themes/default/emails/onboarding/support_emailing.html @@ -0,0 +1,4 @@ +{{define "content"}} +
Vous avez reçu un commentaire sur PARCOURSMOB de la part de {{.user}}
+{{.key}}
+{{end}} \ No newline at end of file diff --git a/themes/default/web/layouts/support/support.html b/themes/default/web/layouts/support/support.html new file mode 100644 index 0000000..0eae295 --- /dev/null +++ b/themes/default/web/layouts/support/support.html @@ -0,0 +1,24 @@ +{{define "content"}} + +