Обновить templates/modal.html

This commit is contained in:
Alex55 2025-04-23 14:29:13 +03:00
parent a0335727b7
commit cf669b25a1
1 changed files with 17 additions and 27 deletions

View File

@ -114,7 +114,7 @@
<div class="border border-gray-200 rounded-md p-5 mt-5">
<div id="knows-container"></div>
</div>
</div>
@ -225,30 +225,20 @@ document.addEventListener("DOMContentLoaded", () => {
modal.classList.remove("hidden");
// Потом работаем с getKnows
const token = data.token;
console.log("Токен:", token);
if (token) {
fetch("https://devnet.turboapply.ai/api/getKnows", {
method: "GET",
headers: {
"token": token
}
})
.then(response => {
if (!response.ok) throw new Error("Network error");
return response.json();
})
.then(result => {
console.log("Результат запроса getKnows:", result);
// Тут можно вставить в DOM
})
.catch(error => {
console.error("Ошибка запроса getKnows:", error);
// Отображаем знания (knows)
const knows = data.knows?.result || [];
const knowsContainer = document.getElementById("knows-container");
knowsContainer.innerHTML = ""; // Очистка контейнера перед добавлением новых данных
knows.forEach(item => {
const block = document.createElement("div");
block.className = "intro-y box p-4";
block.innerHTML = `
<div class="font-medium text-lg">${item.title}</div>
<span>${item.text}</span>
`;
knowsContainer.appendChild(block);
});
} else {
console.warn("Токен отсутствует, getKnows не запрашивается");
}