140 lines
6.5 KiB
HTML
140 lines
6.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; connect-src https://autoatend.linco.work">
|
|
<title>Aguardando atendimento</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
<script src="js/jquery/jquery.js"></script>
|
|
<style>
|
|
body {
|
|
margin: 10px;
|
|
padding: 0;
|
|
font-family: Arial, sans-serif;
|
|
background-color: #f4f4f4;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="list-view">
|
|
<h1>Fila</h1>
|
|
<ul id="item-list">
|
|
<!-- Itens serão carregados aqui -->
|
|
</ul>
|
|
<button id="next-button" disabled>Iniciar atendimento</button>
|
|
<button id="sendto-button" disabled>Encaminhar</button>
|
|
<button id="sair-button">Sair do app</button>
|
|
</div>
|
|
|
|
<div id="obs-view" style="display: none;">
|
|
<h1>Observações</h1>
|
|
<p>Item selecionado: <span id="selected-item-name"></span></p>
|
|
<textarea id="observation-text" rows="10" cols="50" placeholder="Digite suas observações..."></textarea>
|
|
<button id="save-button">Salvar</button>
|
|
</div>
|
|
|
|
<div id="encaminhar-view" style="display: none;">
|
|
<h1>Observações</h1>
|
|
<p>Item selecionado: <span id="selected-item-name"></span></p>
|
|
<textarea id="observation-text" rows="10" cols="50" placeholder="Digite suas observações..."></textarea>
|
|
<button id="save-button">Salvar</button>
|
|
</div>
|
|
|
|
<script src="renderer.js"></script>
|
|
<script>
|
|
$(function(){
|
|
|
|
let apiUrl = 'https://autoatend.linco.work/api/v1/';
|
|
let token = localStorage.getItem('authToken');
|
|
let colabId = localStorage.getItem('idOperator');
|
|
|
|
function obtemProximosLocalStorage(){
|
|
let datastorage = localStorage.getItem('proximos');
|
|
|
|
// Adiciona os outros itens apenas para visualização (opcional)
|
|
const proximos = JSON.parse(datastorage);
|
|
|
|
itemList.innerHTML = ''; // Limpa a lista anterior
|
|
if (!proximos || proximos.length === 0) {
|
|
itemList.innerHTML = '<li>Nenhum item encontrado.</li>';
|
|
nextButton.disabled = true;
|
|
return;
|
|
}
|
|
|
|
// Seleciona o primeiro item por padrão (ou o próximo disponível)
|
|
// Aqui, vamos apenas pegar o primeiro da lista atual
|
|
const itemToProcess = proximos[0]; // Pega o primeiro item
|
|
if (itemToProcess) {
|
|
selectedItemId = itemToProcess.id;
|
|
selectedItemName = itemToProcess.clientName;
|
|
const li = document.createElement('li');
|
|
li.textContent = `${itemToProcess.senhaGen}: ${itemToProcess.clientName.toUpperCase()} - ${itemToProcess.attendanceType.toUpperCase()} - ${itemToProcess.descricaoServico.toUpperCase()}`;
|
|
li.dataset.id = itemToProcess.id; // Armazena o ID no elemento
|
|
li.classList.add('selected'); // Marca como selecionado visualmente (precisa de CSS)
|
|
itemList.appendChild(li);
|
|
nextButton.disabled = false;
|
|
} else {
|
|
itemList.innerHTML = '<li>Nenhum item para processar.</li>';
|
|
nextButton.disabled = true;
|
|
selectedItemId = null;
|
|
selectedItemName = '';
|
|
}
|
|
|
|
//[{"id":57,"userToken":"1feb970af7708cb","colabId":null,"colabObs":null,"serviceId":2,"attendanceType":"Normal","clientName":"Augusto teles","whatsappNumber":null,"notificationType":"audio","Favorito":false,"Status":"Fila","inicioAtendimento":null,"fimAtendimento":null,"duracaoAtendimento":null,"obsAtendimento":null,"subServiceId":0,"senhaGen":"AWTT","descricaoServico":"ENTREGA DE DOCUMENTO"}]
|
|
|
|
// Adiciona os outros itens apenas para visualização (opcional)
|
|
proximos.slice(1).forEach(item => {
|
|
const li = document.createElement('li');
|
|
li.textContent = `${item.senhaGen}: ${item.clientName.toUpperCase()} - ${item.attendanceType.toUpperCase()} - ${item.descricaoServico.toUpperCase()}`;
|
|
itemList.appendChild(li);
|
|
});
|
|
|
|
}
|
|
|
|
//não vai ser usado timer pois é usado no floatbuttom, ele atualiza com timer
|
|
//essa função vai ser chamada apenas quando algum registro já estiver sido atendido
|
|
function updRemoteList() {
|
|
if (!token && !colabId) {
|
|
console.warn("Token or colabId not found in localStorage. API requests will not be made.");
|
|
return; // Stop the function if token or colabId is missing
|
|
}
|
|
|
|
$.ajax(apiUrl + 'get-proximos/'+colabId, {
|
|
method: 'GET',
|
|
headers: { 'Authorization': 'Bearer '+token },
|
|
processData: false,
|
|
contentType: false,
|
|
dataType: 'JSON',
|
|
success: function(response) {
|
|
console.log('Resposta:', response);
|
|
// Ensure the response is valid JSON before parsing
|
|
try {
|
|
localStorage.setItem('proximos', JSON.stringify(response));
|
|
} catch (e) {
|
|
console.error("Error parsing JSON response:", e);
|
|
console.error("Response text:", response); // Log the raw response for debugging
|
|
}
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error('Erro na requisição:', status, error);
|
|
console.error('Response Text:', xhr.responseText); // Log the response text for debugging
|
|
// Optionally, handle different error codes:
|
|
if (xhr.status === 401) {
|
|
console.warn("Unauthorized. Token might be invalid.");
|
|
// You could redirect the user to a login page here.
|
|
} else if (xhr.status === 404) {
|
|
console.warn("Resource not found. Check the API endpoint.");
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
setTimeout(()=>{
|
|
obtemProximosLocalStorage();
|
|
},5000);
|
|
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |