Mark notifications read when clicked on

This commit is contained in:
Kevin McConnell
2025-01-10 14:26:00 +00:00
parent 58ce85ce36
commit fd1789ed58
6 changed files with 46 additions and 3 deletions
@@ -0,0 +1,18 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
record({ target, params: { url } }) {
navigator.sendBeacon(url, this.#csrfPayload())
target.remove()
}
#csrfPayload() {
const data = new FormData()
data.append("authenticity_token", this.#csrfToken())
return data
}
#csrfToken() {
return document.querySelector('meta[name="csrf-token"]').content
}
}