From 8ff1a4175a736082ca44ede6a6980a2ecdbc1470 Mon Sep 17 00:00:00 2001 From: cclohmar Date: Mon, 1 Jun 2026 23:16:35 +0000 Subject: [PATCH] feat: view receipt image from expense list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added 🖼️ button on each expense — opens full-screen lightbox - Click anywhere on the overlay to close - Images served via /storage/{filename} (auth-protected) - Fixed ImagePath to store only filename (was storage/storage/...) - Both expense_list.html fragment and event_expenses.html page updated --- internal/handlers/expenses.go | 7 +++++-- templates/event_expenses.html | 23 ++++++++++++++++++----- templates/expense_list.html | 17 +++++++++++++++-- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/internal/handlers/expenses.go b/internal/handlers/expenses.go index e0c9746..d4d5d6c 100644 --- a/internal/handlers/expenses.go +++ b/internal/handlers/expenses.go @@ -136,8 +136,11 @@ func (h *ExpenseHandler) UploadReceipt(w http.ResponseWriter, r *http.Request) { exchangeRate = 1.0 } - // 9. Call the Gemini Vision API for AI extraction. - receipt, aiErr := ai.ExtractReceipt(storagePath) + // 9. Call the Gemini Vision API for AI extraction (uses full disk path). + receipt, aiErr := ai.ExtractReceipt(filepath.Join("storage", filename)) + + // Strip the storage/ prefix so the template can build a proper URL: /storage/{file} + storagePath = filename // 10. Render the receipt_form.html fragment. tmpl := getTemplate("receipt_form.html") diff --git a/templates/event_expenses.html b/templates/event_expenses.html index f35f03d..6f616b5 100644 --- a/templates/event_expenses.html +++ b/templates/event_expenses.html @@ -43,12 +43,25 @@
{{printf "%.2f" .ConvertedAmount}} {{.BaseCurrency}}
{{end}} - +
+ {{if .ImagePath}} + + {{end}} + +
+ {{if .ImagePath}} + + {{end}} {{end}} {{else}} diff --git a/templates/expense_list.html b/templates/expense_list.html index 5df4dbd..6716d27 100644 --- a/templates/expense_list.html +++ b/templates/expense_list.html @@ -28,8 +28,15 @@ {{end}} -
- + {{end}} +
+ {{if .ImagePath}} + + {{end}} {{end}}