1import { Controller } from "@hotwired/stimulus" 2 3export default class extends Controller { 4 async deleteNeighbor(event) { 5 const button = event.currentTarget 6 const neighborId = button.dataset.neighborId 7 8 if (!confirm('Are you sure you want to remove this neighbor?')) { 9 return 10 } 11 12 try { 13 const response = await fetch(`/neighbors/${neighborId}`, { 14 method: 'DELETE', 15 headers: { 16 'Accept': 'application/json', 17 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content 18 } 19 }) 20 21 if (response.ok) { 22 // Find and remove the neighbor card 23 const neighborCard = button.closest(`[data-neighbor-id="${neighborId}"]`) 24 neighborCard.remove() 25 26 // Optionally refresh the page to update the count 27 window.location.reload() 28 } else { 29 console.error('Failed to delete neighbor') 30 alert('Failed to remove neighbor. Please try again.') 31 } 32 } catch (error) { 33 console.error('Error:', error) 34 alert('An error occurred while removing the neighbor.') 35 } 36 } 37}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.