go-crm initial
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"go-crm/internal/db"
|
||||
"go-crm/internal/handlers"
|
||||
@@ -31,7 +32,15 @@ func main() {
|
||||
templates.Init()
|
||||
|
||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
templates.Layout("Home", "home.html").Render(r.Context(), w)
|
||||
homeTmpl := templates.Get("home.html")
|
||||
layoutTmpl := templates.Layout("Home", "")
|
||||
if homeTmpl != nil && layoutTmpl != nil {
|
||||
buf := &strings.Builder{}
|
||||
homeTmpl.Execute(buf, map[string]string{"Title": "Home"})
|
||||
layoutTmpl.Execute(w, map[string]string{"Title": "Home", "Content": buf.String()})
|
||||
} else {
|
||||
w.Write([]byte(`<!DOCTYPE html><html><head><title>Home</title></head><body><h1>Welcome to CRM</h1><nav><a href="/clients">Clients</a> | <a href="/customers">Customers</a> | <a href="/services">Services</a> | <a href="/questions">Questions</a> | <a href="/answers">Answers</a></nav></body></html>`))
|
||||
}
|
||||
})
|
||||
|
||||
r.Route("/auth", func(r chi.Router) {
|
||||
@@ -74,7 +83,7 @@ func main() {
|
||||
r.Delete("/{id}", handlers.DeleteSchedule)
|
||||
})
|
||||
|
||||
r.Route("/payments", func(r chi.Router) {
|
||||
r.Route("/payments", func(r chi.Router) {
|
||||
r.Get("/", handlers.ListPayments)
|
||||
r.Post("/", handlers.CreatePayment)
|
||||
r.Get("/{id}", handlers.ViewPayment)
|
||||
|
||||
Reference in New Issue
Block a user