cmtracker/assets/js/app/message.js

32 lines
956 B
JavaScript
Raw Permalink Normal View History

2025-01-10 07:34:49 -05:00
export function messageSupervisor() {
let btn = document.getElementById('message-supervisor');
btn.setAttribute('data-bs-toggle', 'modal');
btn.setAttribute('data-bs-target', '#message-modal');
btn.click();
}
export function openMessage() {
let btn = document.getElementById('open-message');
btn.setAttribute('data-bs-toggle', 'modal');
btn.setAttribute('data-bs-target', '#message-modal');
btn.click();
}
export function sendMessage() {
fetch('/api/send-message', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
case: document.getElementById('my-cases').value,
message: document.getElementById('message').value
})
})
.then(response => response.json())
.then(data => {
if (data.success === true) {
$('#close-modal').click();
}
});
}