fixing rolodex and search

This commit is contained in:
HotSwapp
2025-08-11 21:58:25 -05:00
parent 278eb7c5d4
commit c76b68d009
25 changed files with 1651 additions and 915 deletions

View File

@@ -235,13 +235,7 @@
let availableFiles = {};
let importInProgress = false;
// Helper function for authenticated API calls
function getAuthHeaders() {
const token = localStorage.getItem('auth_token');
return {
'Authorization': `Bearer ${token}`
};
}
// Authorization is injected by window.http.wrappedFetch
// Initialize on page load
document.addEventListener('DOMContentLoaded', function() {
@@ -288,9 +282,7 @@ function setupEventListeners() {
async function loadAvailableFiles() {
try {
const response = await fetch('/api/import/available-files', {
headers: getAuthHeaders()
});
const response = await window.http.wrappedFetch('/api/import/available-files');
if (response.status === 401 || response.status === 403) {
console.error('Authentication error - redirecting to login');
@@ -335,9 +327,7 @@ async function loadAvailableFiles() {
async function loadImportStatus() {
try {
const response = await fetch('/api/import/status', {
headers: getAuthHeaders()
});
const response = await window.http.wrappedFetch('/api/import/status');
if (response.status === 401 || response.status === 403) {
console.error('Authentication error - redirecting to login');
@@ -422,9 +412,8 @@ async function validateFile() {
try {
showProgress(true, 'Validating file...');
const response = await fetch(`/api/import/validate/${fileType}`, {
const response = await window.http.wrappedFetch(`/api/import/validate/${fileType}`, {
method: 'POST',
headers: getAuthHeaders(),
body: formData
});
@@ -540,9 +529,8 @@ async function handleImport(event) {
try {
showProgress(true, 'Importing data...');
const response = await fetch(`/api/import/upload/${fileType}`, {
const response = await window.http.wrappedFetch(`/api/import/upload/${fileType}`, {
method: 'POST',
headers: getAuthHeaders(),
body: formData
});
@@ -629,10 +617,9 @@ async function clearTable() {
}
try {
const response = await fetch(`/api/import/clear/${fileType}`, {
method: 'DELETE',
headers: getAuthHeaders()
});
const response = await window.http.wrappedFetch(`/api/import/clear/${fileType}`, {
method: 'DELETE'
});
if (!response.ok) {
const error = await response.json();
@@ -769,11 +756,10 @@ async function handleBatchImport(event) {
try {
showProgress(true, 'Processing batch import...');
const response = await fetch('/api/import/batch-upload', {
method: 'POST',
headers: getAuthHeaders(),
body: formData
});
const response = await window.http.wrappedFetch('/api/import/batch-upload', {
method: 'POST',
body: formData
});
if (!response.ok) {
const error = await response.json();