support code emailing

This commit is contained in:
soukainna 2022-10-31 10:39:43 +01:00
parent 6abeb1bed4
commit d557ffe6b3
4 changed files with 92 additions and 0 deletions

View File

@ -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)
}

19
renderer/support.go Normal file
View File

@ -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)
}

View File

@ -0,0 +1,4 @@
{{define "content"}}
<p>Vous avez reçu un commentaire sur PARCOURSMOB de la part de <b>{{.user}}</b></p>
<p>{{.key}}</p>
{{end}}

View File

@ -0,0 +1,24 @@
{{define "content"}}
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 space-y-6">
<h1 class="text-2xl font-semibold text-gray-900">Contact</h1>
<div class="bg-white py-2 px-4 shadow sm:rounded-lg sm:px-10">
<form action="" method="POST">
<div class="mb-4 w-full bg-gray-50 rounded-lg border border-gray-200 dark:bg-gray-700 dark:border-gray-600">
<div class="py-2 px-4 bg-white rounded-t-lg dark:bg-gray-800">
<label class="sr-only">Votre message</label>
<textarea name="comment" rows="4" class="block w-full resize-none border-0 border-b border-transparent p-0 pb-2 focus:border-indigo-600 focus:ring-0 sm:text-sm" placeholder="Votre message..." required></textarea>
</div>
<div class="flex justify-center items-center py-2 px-3 border-t dark:border-gray-600">
<button type="submit" value="send message" class="px-2 py-2 border border-transparent text-sm font-medium rounded-2xl shadow-sm text-white bg-co-blue hover:bg-co-blue focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-co-blue">
Envoyer
</button>
</div>
</div>
</form>
</div>
</div>
{{end}}