Spaces:
Runtime error
Runtime error
File size: 4,459 Bytes
b9a69cb |
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
<form
action="/candidatos/vaga={{ vaga.id }}"
method="POST"
enctype="multipart/form-data"
id="uploadForm"
style="display: none"
>
<input
type="file"
name="file"
accept="application/pdf"
id="file"
style="display: none"
/>
<button type="submit">Enviar PDF</button>
</form>
<div id="toastBoxInetum"></div>
<style>
#toastBoxInetum {
position: absolute;
bottom: 0;
right: 1px;
display: flex;
align-items: flex-end;
flex-direction: column;
overflow: hidden;
padding: 20px;
z-index: 9999;
user-select: none;
}
.toastInetum {
display: flex;
align-items: center;
position: relative;
width: 400px;
height: 80px;
background: #fff;
font-weight: 500;
margin: 15px 0;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
transform: translateX(100%);
animation: moveleft 0.4s linear forwards;
}
.toastInetum i {
margin: 0 20px;
font-size: 35px;
color: var(--mineral-green);
}
.toastInetum.error-proccess i {
color: var(--primary-red);
}
.toastInetum.warning-proccess i {
color: #cca123;
}
.toastInetum::after {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 5px;
background: var(--mineral-green);
animation: anim 6s linear forwards;
}
@keyframes moveleft {
100% {
transform: translateX(0);
}
}
@keyframes anim {
100% {
width: 0;
}
}
.toastInetum.error-proccess::after {
background: var(--primary-red);
}
.toastInetum.warning-proccess::after {
background: #cca123;
}
</style>
<script>
$(document).ready(function () {
function showToast(msg) {
let toastBox = document.getElementById("toastBoxInetum");
let toast = document.createElement("div");
toast.classList.add("toastInetum");
toast.innerHTML = msg;
toastBox.appendChild(toast);
if (msg.includes("Erro")) {
toast.classList.add("error-proccess");
setTimeout(() => {
toast.style.transition = "opacity 0.5s ease";
toast.style.opacity = 0;
setTimeout(() => {
toast.remove();
}, 500);
}, 6000);
}
if (msg.includes("Iniciando")) {
toast.classList.add("warning-proccess");
setTimeout(() => {
toast.style.transition = "opacity 0.5s ease";
toast.style.opacity = 0;
toast.style.zIndex = 10000;
setTimeout(() => {
toast.remove();
}, 500);
}, 6000);
}
if (msg.includes("cadastrado")) {
toast.classList.add("success-proccess");
setTimeout(() => {
toast.style.transition = "opacity 0.4s ease";
toast.style.opacity = 0;
setTimeout(() => {
toast.remove();
}, 500);
}, 6000);
}
}
$("#new-candidate").click(function () {
$("#file").click();
});
$("#file").change(function () {
$("#uploadForm").submit();
});
$("#uploadForm").submit(function (event) {
event.preventDefault(); // Evita que o formulário seja submetido diretamente
// Exibe a mensagem de "Iniciando..."
showToast('<i class="bi bi-hourglass-split"></i> Iniciando...');
var vagaId = $("#select-vaga").val();
if (vagaId) {
// Se o vagaId existe, atualiza o action do formulário com a URL correta
$("#uploadForm").attr("action", "/candidatos/vaga=" + vagaId);
$(".page-content").fadeOut(300);
}
// Envia a solicitação POST usando jQuery AJAX
$.ajax({
url: $(this).attr("action"),
type: "POST",
data: new FormData(this),
processData: false,
contentType: false,
success: function (response, textStatus, xhr) {
// Recupera o cabeçalho 'X-Message' da resposta
var mensagem = xhr.getResponseHeader("X-Message");
// Exibe a mensagem se estiver disponível
if (mensagem) {
showToast('<i class="bi bi-check-circle-fill"></i> ' + mensagem);
}
},
error: function (xhr, textStatus, errorThrown) {
console.error("Erro:", errorThrown);
},
});
});
});
</script>
|