feat(go-crm): industrial terminal-core UI redesign
Complete visual overhaul of the go-crm web interface: - New shared layout system (internal/templates/ui.go) with dark zinc industrial theme, JetBrains Mono typography, grid/noise textures - Redesigned all pages: Dashboard, Login/Signup, Clients, Customers, Services, Scheduling, Payments, Questions, Answers, Leads, Review Queue, Report, Keyword Mapping - Tailwind CSS via CDN with custom color palette (amber/emerald/rose/sky) - HTMX-powered interactions with CSS swap animations - Status pills, KPI cards, data tables, empty states, inline forms - Mobile-responsive sidebar with collapsible navigation - All existing tests updated and passing - Zero new build dependencies — works with existing go run/air workflow
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"go-crm/internal/db"
|
||||
"go-crm/internal/templates"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
@@ -45,28 +47,93 @@ func (a *App) ListQuestions(w http.ResponseWriter, r *http.Request) {
|
||||
clientNames := make(map[int64]string)
|
||||
customerNames := make(map[int64]string)
|
||||
for _, c := range clients {
|
||||
clientOptions += `<option value="` + strconv.FormatInt(c.ClientID, 10) + `">` + c.Name + `</option>`
|
||||
clientOptions += fmt.Sprintf(`<option value="%d">%s</option>`, c.ClientID, htmlEscape(c.Name))
|
||||
clientNames[c.ClientID] = c.Name
|
||||
}
|
||||
for _, cu := range customers {
|
||||
customerOptions += `<option value="` + strconv.FormatInt(cu.CustomerID, 10) + `">` + cu.Name + `</option>`
|
||||
customerOptions += fmt.Sprintf(`<option value="%d">%s</option>`, cu.CustomerID, htmlEscape(cu.Name))
|
||||
customerNames[cu.CustomerID] = cu.Name
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.Write([]byte(`<!DOCTYPE html><html><head><script src="https://unpkg.com/htmx.org@1.9.10"></script><style>.edit-row{display:none}</style></head><body><h1>Questions</h1><button class="btn" onclick="document.getElementById('questionForm').style.display='block'">Add Question</button><div id="questionForm" style="display:none; margin-top:1rem;"><form hx-post="/questions" hx-target="#questionList"><select name="client_id" required><option value="">Select Client</option>` + clientOptions + `</select><select name="customer_id" required><option value="">Select Customer</option>` + customerOptions + `</select><textarea name="question" placeholder="Question" required></textarea><select name="status"><option value="pending">Pending</option><option value="answered">Answered</option></select><button type="submit">Add</button></form></div><table><thead><tr><th>Client</th><th>Customer</th><th>Question</th><th>Status</th><th>Actions</th></tr></thead><tbody id="questionList">`))
|
||||
for _, q := range questions {
|
||||
clientName := clientNames[q.ClientID]
|
||||
if clientName == "" {
|
||||
clientName = strconv.FormatInt(q.ClientID, 10)
|
||||
buf := templates.BufRender()
|
||||
actions := `<button type="button" onclick="document.getElementById('questionForm').classList.toggle('hidden')" class="btn-primary"><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg> Add Question</button>`
|
||||
fmt.Fprint(buf, templates.PageHeader("Questions", "Customer inquiries and Q&A", actions))
|
||||
|
||||
fmt.Fprintf(buf, `
|
||||
<div id="questionForm" class="hidden mb-6 animate-slide-up">
|
||||
<div class="card-industrial p-5">
|
||||
<h3 class="text-sm font-semibold text-zinc-200 mb-4">New Question</h3>
|
||||
<form hx-post="/questions" hx-target="#questionList" hx-swap="innerHTML" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<select name="client_id" required class="input-industrial"><option value="">Select Client</option>%s</select>
|
||||
<select name="customer_id" required class="input-industrial"><option value="">Select Customer</option>%s</select>
|
||||
<textarea name="question" placeholder="Question text" required class="input-industrial sm:col-span-2" rows="2"></textarea>
|
||||
<select name="status" class="input-industrial"><option value="pending">Pending</option><option value="answered">Answered</option></select>
|
||||
<div class="flex items-end"><button type="submit" class="btn-primary">Save</button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>`, clientOptions, customerOptions)
|
||||
|
||||
if len(questions) == 0 {
|
||||
fmt.Fprint(buf, templates.EmptyState(`<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>`, "No questions recorded yet."))
|
||||
} else {
|
||||
fmt.Fprintf(buf, `<div class="card-industrial overflow-hidden animate-slide-up stagger-1"><div class="overflow-x-auto">`)
|
||||
fmt.Fprint(buf, templates.TableStart([]string{"Client", "Customer", "Question", "Status", "Actions"}))
|
||||
for _, q := range questions {
|
||||
clientName := clientNames[q.ClientID]
|
||||
if clientName == "" {
|
||||
clientName = strconv.FormatInt(q.ClientID, 10)
|
||||
}
|
||||
customerName := customerNames[q.CustomerID]
|
||||
if customerName == "" {
|
||||
customerName = strconv.FormatInt(q.CustomerID, 10)
|
||||
}
|
||||
statusPill := `<span class="pill pill-amber">pending</span>`
|
||||
if q.Status == "answered" {
|
||||
statusPill = `<span class="pill pill-emerald">answered</span>`
|
||||
}
|
||||
fmt.Fprintf(buf, `<tr>
|
||||
<td class="text-zinc-300 text-sm">%s</td>
|
||||
<td class="text-zinc-300 text-sm">%s</td>
|
||||
<td class="text-zinc-400 text-xs max-w-xs truncate">%s</td>
|
||||
<td>%s</td>
|
||||
<td>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="/questions/%d" class="btn-ghost btn-sm">View</a>
|
||||
<button type="button" onclick="document.getElementById('editQ%d').classList.toggle('hidden')" class="btn-ghost btn-sm">Edit</button>
|
||||
<form hx-delete="/questions/%d" hx-target="closest tr" hx-swap="outerHTML" style="display:inline">
|
||||
<button type="submit" class="btn-danger btn-sm" onclick="return confirm('Delete?')">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>`, htmlEscape(clientName), htmlEscape(customerName), htmlEscape(q.Question), statusPill, q.QuestionID, q.QuestionID, q.QuestionID)
|
||||
}
|
||||
customerName := customerNames[q.CustomerID]
|
||||
if customerName == "" {
|
||||
customerName = strconv.FormatInt(q.CustomerID, 10)
|
||||
fmt.Fprint(buf, templates.TableEnd())
|
||||
fmt.Fprintf(buf, `</div></div>`)
|
||||
|
||||
for _, q := range questions {
|
||||
clientName := clientNames[q.ClientID]
|
||||
customerName := customerNames[q.CustomerID]
|
||||
fmt.Fprintf(buf, `
|
||||
<div id="editQ%d" class="hidden mt-4 animate-slide-up">
|
||||
<div class="card-industrial p-5 border-amber-400/10">
|
||||
<h3 class="text-sm font-semibold text-zinc-200 mb-3">Edit Question #%d</h3>
|
||||
<form hx-put="/questions/%d" hx-target="#questionList" hx-swap="innerHTML" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3">
|
||||
<select name="client_id" class="input-industrial text-xs"><option value="%d">%s</option>%s</select>
|
||||
<select name="customer_id" class="input-industrial text-xs"><option value="%d">%s</option>%s</select>
|
||||
<textarea name="question" class="input-industrial text-xs sm:col-span-2" rows="2">%s</textarea>
|
||||
<select name="status" class="input-industrial text-xs"><option value="%s">%s</option><option value="pending">Pending</option><option value="answered">Answered</option></select>
|
||||
<div class="flex items-end gap-2">
|
||||
<button type="submit" class="btn-primary btn-sm">Save</button>
|
||||
<button type="button" onclick="document.getElementById('editQ%d').classList.add('hidden')" class="btn-ghost btn-sm">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>`, q.QuestionID, q.QuestionID, q.QuestionID, q.ClientID, htmlEscape(clientName), clientOptions, q.CustomerID, htmlEscape(customerName), customerOptions, htmlEscape(q.Question), q.Status, q.Status, q.QuestionID)
|
||||
}
|
||||
w.Write([]byte(`<tr><td>` + clientName + `</td><td>` + customerName + `</td><td>` + q.Question + `</td><td>` + q.Status + `</td><td><a href="/questions/` + strconv.FormatInt(q.QuestionID, 10) + `">View</a><button type="button" onclick="document.getElementById('editQ` + strconv.FormatInt(q.QuestionID, 10) + `').style.display='table-row'">Edit</button><form method="DELETE" style="display:inline" hx-delete="/questions/` + strconv.FormatInt(q.QuestionID, 10) + `" hx-target="closest tr"><button type="submit">Delete</button></form></td></tr><tr id="editQ` + strconv.FormatInt(q.QuestionID, 10) + `" style="display:none"><td colspan="5"><form hx-put="/questions/` + strconv.FormatInt(q.QuestionID, 10) + `" hx-target="#questionList" hx-swap="innerHTML"><select name="client_id"><option value="` + strconv.FormatInt(q.ClientID, 10) + `">` + clientName + `</option>` + clientOptions + `</select><select name="customer_id"><option value="` + strconv.FormatInt(q.CustomerID, 10) + `">` + customerName + `</option>` + customerOptions + `</select><textarea name="question">` + q.Question + `</textarea><select name="status"><option value="` + q.Status + `">` + q.Status + `</option><option value="pending">Pending</option><option value="answered">Answered</option></select><button type="submit">Save</button></form></td></tr>`))
|
||||
}
|
||||
w.Write([]byte(`</tbody></table></body></html>`))
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
templates.WritePage(w, buf, "Questions", "questions")
|
||||
}
|
||||
|
||||
func (a *App) CreateQuestion(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -109,8 +176,29 @@ func (a *App) ViewQuestion(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
buf := templates.BufRender()
|
||||
fmt.Fprint(buf, templates.PageHeader("Question", "Inquiry details"))
|
||||
statusPill := `<span class="pill pill-amber">pending</span>`
|
||||
if q.Status == "answered" {
|
||||
statusPill = `<span class="pill pill-emerald">answered</span>`
|
||||
}
|
||||
fmt.Fprintf(buf, `
|
||||
<div class="max-w-lg animate-slide-up">
|
||||
<div class="card-industrial p-6">
|
||||
<div class="flex items-center gap-2 mb-4">%s</div>
|
||||
<div class="text-sm text-zinc-200 leading-relaxed mb-6">%s</div>
|
||||
<div class="space-y-2 text-xs text-zinc-500 font-mono">
|
||||
<div>Client ID: %d</div>
|
||||
<div>Customer ID: %d</div>
|
||||
</div>
|
||||
<div class="mt-6">
|
||||
<a href="/questions" class="btn-ghost btn-sm">Back</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>`, statusPill, htmlEscape(q.Question), q.ClientID, q.CustomerID)
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.Write([]byte(`<!DOCTYPE html><body><h1>Question</h1><p>Client ID: ` + strconv.FormatInt(q.ClientID, 10) + `</p><p>Customer ID: ` + strconv.FormatInt(q.CustomerID, 10) + `</p><p>Question: ` + q.Question + `</p><p>Status: ` + q.Status + `</p><a href="/questions">Back</a></body></html>`))
|
||||
templates.WritePage(w, buf, "Question", "questions")
|
||||
}
|
||||
|
||||
func (a *App) UpdateQuestion(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -141,6 +229,8 @@ func (a *App) DeleteQuestion(w http.ResponseWriter, r *http.Request) {
|
||||
a.DB.Exec("DELETE FROM questions WHERE question_id = ?", id)
|
||||
}
|
||||
|
||||
// --- Answers (in same file as original) ---
|
||||
|
||||
func (a *App) ListAnswers(w http.ResponseWriter, r *http.Request) {
|
||||
accountID, ok := a.requireAuth(w, r)
|
||||
if !ok {
|
||||
@@ -169,88 +259,93 @@ func (a *App) ListAnswers(w http.ResponseWriter, r *http.Request) {
|
||||
var questionOptions string
|
||||
questionText := make(map[int64]string)
|
||||
for _, q := range questions {
|
||||
questionOptions += `<option value="` + strconv.FormatInt(q.QuestionID, 10) + `">` + q.Question + `</option>`
|
||||
questionOptions += fmt.Sprintf(`<option value="%d">%s</option>`, q.QuestionID, htmlEscape(q.Question))
|
||||
questionText[q.QuestionID] = q.Question
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.Write([]byte(`<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://unpkg.com/htmx.org@1.9.10"></script>
|
||||
<style>
|
||||
.edit-form { display:none; margin-top:0.5rem; padding:0.5rem; border:1px solid #ccc; }
|
||||
.edit-row { display:none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Answers</h1>
|
||||
<button class="btn" onclick="document.getElementById('answerForm').style.display='block'">Add Answer</button>
|
||||
<div id="answerForm" style="display:none; margin-top:1rem;">
|
||||
<form hx-post="/answers" hx-target="#answerList" hx-swap="innerHTML">
|
||||
<select name="question_id" required>
|
||||
<option value="">Select Question</option>
|
||||
` + questionOptions + `
|
||||
</select>
|
||||
<textarea name="answer" placeholder="Answer" required></textarea>
|
||||
<button type="submit">Add Answer</button>
|
||||
buf := templates.BufRender()
|
||||
actions := `<button type="button" onclick="document.getElementById('answerForm').classList.toggle('hidden')" class="btn-primary"><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg> Add Answer</button>`
|
||||
fmt.Fprint(buf, templates.PageHeader("Answers", "Responses to customer questions", actions))
|
||||
|
||||
fmt.Fprintf(buf, `
|
||||
<div id="answerForm" class="hidden mb-6 animate-slide-up">
|
||||
<div class="card-industrial p-5">
|
||||
<h3 class="text-sm font-semibold text-zinc-200 mb-4">New Answer</h3>
|
||||
<form hx-post="/answers" hx-target="#answerList" hx-swap="innerHTML" class="grid grid-cols-1 gap-4">
|
||||
<select name="question_id" required class="input-industrial max-w-md"><option value="">Select Question</option>%s</select>
|
||||
<textarea name="answer" placeholder="Answer text" required class="input-industrial" rows="3"></textarea>
|
||||
<div><button type="submit" class="btn-primary">Save</button></div>
|
||||
</form>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Client</th><th>Customer</th><th>Question</th><th>Answer</th><th>Status</th><th>Actions</th></tr>
|
||||
</thead>
|
||||
<tbody id="answerList">
|
||||
`))
|
||||
for _, a2 := range answers {
|
||||
qText := a2.QuestionText
|
||||
if qText == "" {
|
||||
qText = questionText[a2.QuestionID]
|
||||
</div>`, questionOptions)
|
||||
|
||||
if len(answers) == 0 {
|
||||
fmt.Fprint(buf, templates.EmptyState(`<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"/>`, "No answers recorded yet."))
|
||||
} else {
|
||||
fmt.Fprintf(buf, `<div class="card-industrial overflow-hidden animate-slide-up stagger-1"><div class="overflow-x-auto">`)
|
||||
fmt.Fprint(buf, templates.TableStart([]string{"Client", "Customer", "Question", "Answer", "Actions"}))
|
||||
for _, a2 := range answers {
|
||||
qText := a2.QuestionText
|
||||
if qText == "" {
|
||||
qText = strconv.FormatInt(a2.QuestionID, 10)
|
||||
qText = questionText[a2.QuestionID]
|
||||
if qText == "" {
|
||||
qText = strconv.FormatInt(a2.QuestionID, 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
clientName := a2.ClientName
|
||||
if clientName == "" {
|
||||
clientName = strconv.FormatInt(a2.ClientID, 10)
|
||||
}
|
||||
customerName := a2.CustomerName
|
||||
if customerName == "" {
|
||||
customerName = "Unknown"
|
||||
}
|
||||
w.Write([]byte(`
|
||||
<tr>
|
||||
<td>` + clientName + `</td>
|
||||
<td>` + customerName + `</td>
|
||||
<td>` + qText + `</td>
|
||||
<td>` + a2.Answer + `</td>
|
||||
<td>` + a2.Status + `</td>
|
||||
clientName := a2.ClientName
|
||||
if clientName == "" {
|
||||
clientName = strconv.FormatInt(a2.ClientID, 10)
|
||||
}
|
||||
customerName := a2.CustomerName
|
||||
if customerName == "" {
|
||||
customerName = "Unknown"
|
||||
}
|
||||
fmt.Fprintf(buf, `<tr>
|
||||
<td class="text-zinc-300 text-sm">%s</td>
|
||||
<td class="text-zinc-300 text-sm">%s</td>
|
||||
<td class="text-zinc-400 text-xs max-w-[200px] truncate">%s</td>
|
||||
<td class="text-zinc-400 text-xs max-w-[300px] truncate">%s</td>
|
||||
<td>
|
||||
<a href="/answers/` + strconv.FormatInt(a2.AnswerID, 10) + `">View</a>
|
||||
<button type="button" onclick="document.getElementById('editA` + strconv.FormatInt(a2.AnswerID, 10) + `').style.display='table-row'">Edit</button>
|
||||
<form method="DELETE" style="display:inline" hx-delete="/answers/` + strconv.FormatInt(a2.AnswerID, 10) + `" hx-target="closest tr">
|
||||
<button type="submit">Delete</button>
|
||||
</form>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="/answers/%d" class="btn-ghost btn-sm">View</a>
|
||||
<button type="button" onclick="document.getElementById('editA%d').classList.toggle('hidden')" class="btn-ghost btn-sm">Edit</button>
|
||||
<form hx-delete="/answers/%d" hx-target="closest tr" hx-swap="outerHTML" style="display:inline">
|
||||
<button type="submit" class="btn-danger btn-sm" onclick="return confirm('Delete?')">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="editA` + strconv.FormatInt(a2.AnswerID, 10) + `" class="edit-row" style="display:none">
|
||||
<td colspan="6">
|
||||
<form hx-put="/answers/` + strconv.FormatInt(a2.AnswerID, 10) + `" hx-target="#answerList" hx-swap="innerHTML">
|
||||
<select name="question_id">
|
||||
<option value="` + strconv.FormatInt(a2.QuestionID, 10) + `">` + qText + `</option>
|
||||
` + questionOptions + `
|
||||
</select>
|
||||
<textarea name="answer">` + a2.Answer + `</textarea>
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>`))
|
||||
</tr>`, htmlEscape(clientName), htmlEscape(customerName), htmlEscape(qText), htmlEscape(a2.Answer), a2.AnswerID, a2.AnswerID, a2.AnswerID)
|
||||
}
|
||||
fmt.Fprint(buf, templates.TableEnd())
|
||||
fmt.Fprintf(buf, `</div></div>`)
|
||||
|
||||
for _, a2 := range answers {
|
||||
qText := a2.QuestionText
|
||||
if qText == "" {
|
||||
qText = questionText[a2.QuestionID]
|
||||
if qText == "" {
|
||||
qText = strconv.FormatInt(a2.QuestionID, 10)
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(buf, `
|
||||
<div id="editA%d" class="hidden mt-4 animate-slide-up">
|
||||
<div class="card-industrial p-5 border-amber-400/10">
|
||||
<h3 class="text-sm font-semibold text-zinc-200 mb-3">Edit Answer #%d</h3>
|
||||
<form hx-put="/answers/%d" hx-target="#answerList" hx-swap="innerHTML" class="grid grid-cols-1 gap-3">
|
||||
<select name="question_id" class="input-industrial text-xs max-w-md"><option value="%d">%s</option>%s</select>
|
||||
<textarea name="answer" class="input-industrial text-xs" rows="3">%s</textarea>
|
||||
<div class="flex items-end gap-2">
|
||||
<button type="submit" class="btn-primary btn-sm">Save</button>
|
||||
<button type="button" onclick="document.getElementById('editA%d').classList.add('hidden')" class="btn-ghost btn-sm">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>`, a2.AnswerID, a2.AnswerID, a2.AnswerID, a2.QuestionID, htmlEscape(qText), questionOptions, htmlEscape(a2.Answer), a2.AnswerID)
|
||||
}
|
||||
}
|
||||
w.Write([]byte(`
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>`))
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
templates.WritePage(w, buf, "Answers", "answers")
|
||||
}
|
||||
|
||||
func (a *App) CreateAnswer(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -307,8 +402,24 @@ func (a *App) ViewAnswer(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
buf := templates.BufRender()
|
||||
fmt.Fprint(buf, templates.PageHeader("Answer", "Response details"))
|
||||
fmt.Fprintf(buf, `
|
||||
<div class="max-w-lg animate-slide-up">
|
||||
<div class="card-industrial p-6">
|
||||
<div class="text-sm text-zinc-200 leading-relaxed mb-6">%s</div>
|
||||
<div class="space-y-2 text-xs text-zinc-500 font-mono">
|
||||
<div>Question ID: %d</div>
|
||||
<div>Client ID: %d</div>
|
||||
</div>
|
||||
<div class="mt-6">
|
||||
<a href="/answers" class="btn-ghost btn-sm">Back</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>`, htmlEscape(ans.Answer), ans.QuestionID, ans.ClientID)
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.Write([]byte(`<!DOCTYPE html><body><h1>Answer</h1><p>Question ID: ` + strconv.FormatInt(ans.QuestionID, 10) + `</p><p>Answer: ` + ans.Answer + `</p><a href="/answers">Back</a></body></html>`))
|
||||
templates.WritePage(w, buf, "Answer", "answers")
|
||||
}
|
||||
|
||||
func (a *App) UpdateAnswer(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -338,7 +449,7 @@ func (a *App) DeleteAnswer(w http.ResponseWriter, r *http.Request) {
|
||||
a.DB.Exec("DELETE FROM answers WHERE answer_id = ?", id)
|
||||
}
|
||||
|
||||
// --- package-level shims kept for existing tests ---
|
||||
// --- package-level shims ---
|
||||
|
||||
func ListQuestions(w http.ResponseWriter, r *http.Request) {
|
||||
(&App{DB: DB, WAConnector: WAConnector}).ListQuestions(w, r)
|
||||
|
||||
Reference in New Issue
Block a user