fix: user tag edit photo upload — standalone form (was nested inside main form, invalid HTML), thumbnail on success; restore sms_enabled on tag 6; admin upload accepts HEIC (no image() rule)
This commit is contained in:
@@ -228,7 +228,7 @@ func (a *App) UploadPhoto(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
fmt.Fprintf(w, `<p class="mt-2 text-xs text-green-700">Photo uploaded ✓ — refresh to see it on the tag page.</p>`)
|
||||
fmt.Fprintf(w, `<div><img src="%s" alt="Uploaded photo" class="mb-2 h-32 w-32 rounded-lg object-cover"><p class="text-xs text-green-700">Photo uploaded ✓</p></div>`, photoURL)
|
||||
}
|
||||
|
||||
// CloseTag lets an owner close (retire) their tag. Data is kept; the tag page
|
||||
|
||||
@@ -25,15 +25,8 @@
|
||||
<textarea name="description" rows="3" class="mt-1 w-full rounded border border-stone-300 px-3 py-2">{{if .Data.Description.Valid}}{{.Data.Description.String}}{{end}}</textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium">Photo</label>
|
||||
{{if .Data.PhotoUrl.Valid}}<img src="{{.Data.PhotoUrl.String}}" alt="Current photo" class="mb-2 h-32 w-32 rounded-lg object-cover">{{end}}
|
||||
<input name="photo_url" type="url" value="{{if .Data.PhotoUrl.Valid}}{{.Data.PhotoUrl.String}}{{end}}" class="mt-1 w-full rounded border border-stone-300 px-3 py-2" placeholder="https://… or upload below">
|
||||
<form hx-encoding="multipart/form-data" hx-post="/account/tags/{{.Data.ID}}/photo" hx-target="#upload-area" hx-swap="innerHTML" class="mt-2 flex gap-2" id="upload-area">
|
||||
<input type="file" name="photo" accept="image/*" class="text-sm">
|
||||
<button type="submit" class="rounded bg-stone-200 px-3 py-1 text-xs font-medium hover:bg-stone-300">Upload</button>
|
||||
<span class="htmx-indicator self-center text-xs text-stone-400">Uploading…</span>
|
||||
</form>
|
||||
<p class="mt-1 text-xs text-stone-500">Upload a photo, or paste a URL above.</p>
|
||||
<label class="block text-sm font-medium">Photo URL</label>
|
||||
<input name="photo_url" type="url" value="{{if .Data.PhotoUrl.Valid}}{{.Data.PhotoUrl.String}}{{end}}" class="mt-1 w-full rounded border border-stone-300 px-3 py-2" placeholder="https://…">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium">Phone number (shown to finders)</label>
|
||||
@@ -56,5 +49,19 @@
|
||||
<a href="/account" class="rounded border border-stone-300 px-4 py-2 text-sm font-medium hover:bg-stone-50">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Standalone photo upload (outside the main form — nested forms are invalid HTML) -->
|
||||
<div class="mt-4 rounded-xl border border-stone-200 bg-white p-4 shadow-sm">
|
||||
<h2 class="text-sm font-bold">Photo</h2>
|
||||
<div id="photo-area" class="mt-2">
|
||||
{{if .Data.PhotoUrl.Valid}}<img src="{{.Data.PhotoUrl.String}}" alt="Current photo" class="mb-2 h-32 w-32 rounded-lg object-cover">{{end}}
|
||||
<form hx-encoding="multipart/form-data" hx-post="/account/tags/{{.Data.ID}}/photo" hx-target="#photo-area" hx-swap="innerHTML" class="flex gap-2">
|
||||
<input type="file" name="photo" accept="image/*" class="text-sm">
|
||||
<button type="submit" class="rounded bg-stone-900 px-3 py-1.5 text-xs font-semibold text-white hover:bg-stone-700">Upload photo</button>
|
||||
<span class="htmx-indicator self-center text-xs text-stone-400">Uploading…</span>
|
||||
</form>
|
||||
<p class="mt-1 text-xs text-stone-500">Upload a photo — it shows on your public tag page and in the admin.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user