import { postData, verifyLogin } from "./client.js"; import { formatSalary } from "./utils.js"; const searchForm = document.getElementById("searchForm"); const token = window.localStorage.getItem("token"); const tableHeader = document.getElementById("header"); const tableBody = document.getElementById("results"); const table = document.getElementById("table"); const nomatch = document.getElementById("nomatch"); updateTableVisibility(); if (searchForm)searchForm.onsubmit = async e => { e.preventDefault(); if (!verifyLogin()) return; let resultObject = await postData("/getPlayers", { player: document.getElementById("query").value }, token); if (resultObject.matches.length === 0) { nomatch.style.display = ""; table.style.display = "none"; return; } nomatch.style.display = "none" table.style.display = ""; tableHeader.innerHTML = ""; const headerRow = document.createElement("tr") //Object.keys(resultObject.matches[0]).forEach(attribute => { // headerRow.innerHTML += `