-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmarkResolved.js
More file actions
38 lines (36 loc) · 1.26 KB
/
markResolved.js
File metadata and controls
38 lines (36 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function markResolved(incidentId) {
if (!confirm('Are you sure you want to mark this incident as resolved?')) return;
fetch('/Women_safety_project/k23ndwebsite/resolve-incident.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({id: incidentId})
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log('Response data:', data);
if (data.success) {
const incidentElement = document.getElementById(`incident-${incidentId}`);
if (incidentElement) {
incidentElement.remove();
}
} else {
console.error('Error from server:', data.error || 'Unknown error');
alert('Failed to mark incident as resolved. See console for details.');
}
})
.catch(error => {
console.error('Error:', error);
alert('Failed to mark incident as resolved. Please try again later.');
});
// Refresh the incident list after successful resolution
if (typeof refreshIncidents === 'function') {
refreshIncidents();
}
}