diff --git a/db/schema.sql b/db/schema.sql index b58bcd9..4b440a5 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -97,3 +97,6 @@ ALTER TABLE orders ADD COLUMN IF NOT EXISTS renews_at TIMESTAMPTZ; -- Tag lifecycle: closed state (owner close / moved-from). Idempotent. ALTER TABLE tags DROP CONSTRAINT IF EXISTS tags_status_check; ALTER TABLE tags ADD CONSTRAINT tags_status_check CHECK (status IN ('unset','active','suspended','closed')); + +-- Product photos (admin). +ALTER TABLE products ADD COLUMN IF NOT EXISTS photo_url TEXT; diff --git a/frontend/internal/handlers/location.go b/frontend/internal/handlers/location.go index e3cc4fd..e675274 100644 --- a/frontend/internal/handlers/location.go +++ b/frontend/internal/handlers/location.go @@ -1,11 +1,8 @@ package handlers import ( - "errors" "net/http" - "github.com/jackc/pgx/v5" - "wherewoof/frontend/internal/db" ) @@ -16,10 +13,16 @@ type locationData struct { FinderPhone string TagCode string ScannedAt string + ItemType string + Name string + PhotoURL string + Phone string + Address string } // ServeShort resolves a short code to its scan and renders the owner's -// location page (map embed + finder details). +// location page: "your item was found here" — map embed + finder details + +// the tag's return details. func (a *App) ServeShort(w http.ResponseWriter, r *http.Request) { code := r.PathValue("code") sc, err := a.Queries.GetShortCode(r.Context(), code) @@ -36,11 +39,7 @@ func (a *App) ServeShort(w http.ResponseWriter, r *http.Request) { tag, err := a.Queries.GetTagByID(r.Context(), scan.TagID) if err != nil { - if errors.Is(err, pgx.ErrNoRows) { - http.NotFound(w, r) - return - } - http.Error(w, "internal error", http.StatusInternalServerError) + http.NotFound(w, r) return } @@ -50,8 +49,15 @@ func (a *App) ServeShort(w http.ResponseWriter, r *http.Request) { FinderPhone: scan.ScannerPhone.String, TagCode: tag.TagCode, ScannedAt: scan.ScannedAt.Time.Local().Format("Mon 2 Jan, 3:04 pm"), + Name: tag.Description.String, + PhotoURL: tag.PhotoUrl.String, + Phone: tag.Phone.String, + Address: tag.Address.String, } - a.render(w, r, "location", "Location found", data, "") + if tag.ItemType.Valid { + data.ItemType = titleCase(tag.ItemType.String) + } + a.render(w, r, "location", "Found", data, "") } // keep the db import referenced (Tag lookup above uses a.Queries only; this diff --git a/frontend/templates/location.html b/frontend/templates/location.html index 141cffc..1521b20 100644 --- a/frontend/templates/location.html +++ b/frontend/templates/location.html @@ -2,8 +2,8 @@
Your Where Woof tag was scanned at {{.Data.ScannedAt}}. This is where it was reported:
+It was reported at {{.Data.ScannedAt}}. Here's where it was seen:
{{.Data.Name}}
{{end}} + {{if .Data.Address}}{{.Data.Address}}
{{end}} + {{if .Data.Phone}}Contact: {{.Data.Phone}}
{{end}} +The owner has disabled this tag. Please try another way to return the item.
This tag is no longer active. If you found this item, please try to return it another way.
+This Where Woof tag is no longer active — its owner has retired it (maybe a broken tag, a new tag, or the item was found and the tag removed).
+If you found this item, please try to return it another way (ask around, check lost & found, or contact local authorities).
+Help the owner find it: sharing your location sends them a map link. No location? No problem — the page still works.
+