Pregunta antes de enviar la encuesta de calidad al finalizar un servicio
This commit is contained in:
@@ -1147,12 +1147,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const selectedSt = systemStatuses.find(st => String(st.id) === String(statusMap));
|
const selectedSt = systemStatuses.find(st => String(st.id) === String(statusMap));
|
||||||
|
|
||||||
// 🛑 SOLO avisamos si intenta poner "Citado" sin fecha
|
// 🛑 SOLO avisamos si intenta poner "Citado" sin fecha
|
||||||
if (selectedSt && selectedSt.name.toLowerCase().includes('citado') && !date) {
|
if (selectedSt && selectedSt.name.toLowerCase().includes('citado') && !date) {
|
||||||
if(!confirm("⚠️ Estás marcando el servicio como CITADO pero no has puesto la fecha. ¿Deseas continuar?")) return;
|
if(!confirm("⚠️ Estás marcando el servicio como CITADO pero no has puesto la fecha. ¿Deseas continuar?")) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🆕 Si el estado elegido es "Finalizado"/"Terminado", preguntamos si se envía la encuesta de calidad.
|
||||||
|
// Responda lo que responda el usuario, el servicio se guarda igual como Finalizado.
|
||||||
|
let skipSurvey = false;
|
||||||
|
const stNameCheck = (selectedSt?.name || "").toLowerCase();
|
||||||
|
if (stNameCheck.includes('finalizado') || stNameCheck.includes('terminado')) {
|
||||||
|
skipSurvey = !confirm("¿Enviar la encuesta de calidad al cliente por WhatsApp?");
|
||||||
|
}
|
||||||
|
|
||||||
const btn = document.getElementById('btnSaveAppt');
|
const btn = document.getElementById('btnSaveAppt');
|
||||||
const originalContent = btn.innerHTML;
|
const originalContent = btn.innerHTML;
|
||||||
btn.innerHTML = `<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Guardando...`;
|
btn.innerHTML = `<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Guardando...`;
|
||||||
@@ -1162,7 +1170,7 @@
|
|||||||
const res = await fetch(`${API_URL}/services/set-appointment/${id}`, {
|
const res = await fetch(`${API_URL}/services/set-appointment/${id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
||||||
body: JSON.stringify({ date, time, status_operativo: statusMap })
|
body: JSON.stringify({ date, time, status_operativo: statusMap, skip_survey: skipSurvey })
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
|
|||||||
Reference in New Issue
Block a user