From 3429ee92fea7054352db54de1b1fa881eea5d218 Mon Sep 17 00:00:00 2001 From: Pen Anderson Date: Thu, 5 Mar 2026 20:09:58 -0600 Subject: [PATCH] Update manual Volunteer entry. --- frontend/src/pages/Volunteers.svelte | 12 +++++++++--- handle_volunteers.go | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/Volunteers.svelte b/frontend/src/pages/Volunteers.svelte index 5f5f3c8..06f6aac 100644 --- a/frontend/src/pages/Volunteers.svelte +++ b/frontend/src/pages/Volunteers.svelte @@ -13,6 +13,7 @@ let showAdd = $state(false) let adding = $state(false) let newName = $state('') + let newTicketName = $state('') let newEmail = $state('') let newDeptID = $state('') let newIsLead = $state(false) @@ -89,6 +90,7 @@ try { const data = { name: newName, + ticket_name: newTicketName, email: newEmail, is_lead: newIsLead, note: newNote, @@ -97,7 +99,7 @@ const v = await api.volunteers.create(data) await db.volunteers.put(v) showAdd = false - newName = newEmail = newNote = '' + newName = newEmail = newTicketName = newNote = '' newDeptID = '' newIsLead = false } catch (err) { @@ -180,8 +182,12 @@
- - + + +
+
+ +
diff --git a/handle_volunteers.go b/handle_volunteers.go index 845bddd..6832995 100644 --- a/handle_volunteers.go +++ b/handle_volunteers.go @@ -33,11 +33,15 @@ func (app *App) handleListVolunteers(w http.ResponseWriter, r *http.Request) { } func (app *App) handleCreateVolunteer(w http.ResponseWriter, r *http.Request) { - var v Volunteer - if err := json.NewDecoder(r.Body).Decode(&v); err != nil { + var body struct { + Volunteer + TicketName string `json:"ticket_name"` + } + if err := json.NewDecoder(r.Body).Decode(&body); err != nil { writeError(w, "invalid request", http.StatusBadRequest) return } + v := body.Volunteer if v.Name == "" { writeError(w, "name is required", http.StatusBadRequest) return @@ -52,7 +56,9 @@ func (app *App) handleCreateVolunteer(w http.ResponseWriter, r *http.Request) { if v.Email != "" && v.ParticipantID == nil { p, _ := app.getParticipantByEmail(v.Email) if p == nil { - p, _ = app.createParticipant(Participant{PreferredName: v.Name, Email: v.Email}) + p, _ = app.createParticipant(Participant{PreferredName: v.Name, Email: v.Email, TicketName: body.TicketName}) + } else if body.TicketName != "" && p.TicketName == "" { + app.db.Exec(`UPDATE participants SET ticket_name = ?, updated_at = ? WHERE id = ?`, body.TicketName, now(), p.ID) } if p != nil { v.ParticipantID = &p.ID