update pricing i guess

This commit is contained in:
2025-06-09 12:28:15 -04:00
parent 77d6fd6e29
commit 82fd1cb2da
6 changed files with 268 additions and 61 deletions

View File

@ -4,6 +4,8 @@ document.addEventListener('DOMContentLoaded', function() {
showTransactionModal();
});
document.getElementById('downloadTcgplayerUpdateBtn').addEventListener('click', downloadTcgplayerUpdateFile);
document.getElementById('addVendorBtn').addEventListener('click', () => {
const vendorName = prompt('Enter vendor name:');
if (vendorName) {
@ -1074,4 +1076,38 @@ async function saveTransaction() {
console.error('Error saving transaction:', error);
alert('Failed to save transaction. Please try again.');
}
}
// TCGPlayer Update File Functions
async function downloadTcgplayerUpdateFile() {
try {
const response = await fetch('/api/inventory/tcgplayer/update-file');
if (!response.ok) {
throw new Error('Failed to download TCGPlayer update file');
}
// Get the filename from the Content-Disposition header
const contentDisposition = response.headers.get('Content-Disposition');
let filename = 'tcgplayer_update_file.csv';
if (contentDisposition) {
const filenameMatch = contentDisposition.match(/filename=(.+)/);
if (filenameMatch) {
filename = filenameMatch[1];
}
}
// Create a blob from the response and download it
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
} catch (error) {
console.error('Error downloading TCGPlayer update file:', error);
alert('Failed to download TCGPlayer update file. Please try again.');
}
}